git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: Jeff King <peff@peff.net>, Vincent van Ravesteijn <vfr@lyx.org>,
	John Keeping <john@keeping.me.uk>,
	Ramkumar Ramachandra <artagnon@gmail.com>,
	git@vger.kernel.org, Jonathan Nieder <jrnieder@gmail.com>,
	Duy Nguyen <pclouds@gmail.com>
Subject: Re: [PATCH] build: get rid of the notion of a git library
Date: Tue, 11 Jun 2013 10:33:34 -0700	[thread overview]
Message-ID: <7vtxl4blht.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <CAMP44s0r96ByEs3+N1Qo+O18rOmT72rHk4zAEFAyFdU_DsQ8wA@mail.gmail.com> (Felipe Contreras's message of "Mon, 10 Jun 2013 23:15:14 -0500")

Felipe Contreras <felipe.contreras@gmail.com> writes:

>>  - There may be pieces of usefully reusable code buried in
>>    builtin/*.o;
>>
>>  - By definition, any code (piece of data or function definition) in
>>    builtin/*.o cannot be used in standalone binaries, because all of
>>    builtin/*.o expect to link with git.o and expect their cmd_foo()
>>    getting called from main in it;
>>
>>  - By moving the useful reusable pieces ont of builtin/*.o and
>>    adding them to libgit.a, these pieces become usable from
>>    standalone binaries as well.
>
> What if these reusable pieces should not be used by standalone binaries?

I am not sure what you mean.  A piece is either reusable or not.
When would one piece _be_ reusable and should *not* be used in one
context but not in another?

There are distinctions between being "useful" and "usable", but I
think the zeroth order of approximation when thinking about this is
to think builtin/*.o as set of subroutines called by git.c::main().

These set of subroutines may call out to more generic helper
functions that are usable from anywhere both within builtins and
also from standalone.  They may also call to their own helper
functions that were originally designed to support only their use
by the original caller from somewhere in builtin/*.o (most commonly
in the same file, marked as static).

The general direction, if we want to have an improve libgit.a,
should be to see if the functions and their data that are private
to builtin/*.o can be used from standalone, either as they are or
with more generalization, and turn them from helpers specific to one
cmd_foo() into more generally useful library-ish functions.

There may be pieces in the callchain from that entry point to
cmd_foo() that are implementation details of git.c::main(); for
example the loop that does command dispatching to check with
builtins, external commands that begin with git-, and aliases, is
one of them, and would not be usable (nor it is useful) outside the
context of "git" aggregate binary.  But there are things that ought
to be usable that are currently in builtin/*.o, which prevents them
from being used by standalone binaries.  If a remote helper binary
that is standalone wants to call "create_note()", it is not
sufficient to make it non-static in builtin/notes.o, for example.

But if it is moved outside builtin/notes.o, it becomes usable.

I think the "git notes", being one of the most recent additions,
haven't gone through enough round of refactoring to come to the best
separation between library-ish part (i.e. could be in notes.o, even
though it is mostly about the underlying data structure manipulation
and contains no higher-level operations like actually creating and
copying, which might want to be in a separate source notes-lib.o)
and its CLI implementation "builtin/notes.o".

> But this doesn't answer the question; what about code that is shared
> between builtins, but cannot be used by standalone programs?

Again, I do not know what you mean by "cannot" here.  My tentative
answer to that question is "the eventual goal should be not to have
any code in that class, and that is a reasonable goal we can achieve
once we refactor what ought to be reusable out of builtin/*.o".

What are the examples you have in mind, code that we want to forbid
standalone from using?

  reply	other threads:[~2013-06-11 17:33 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-08 17:29 [PATCH] build: get rid of the notion of a git library Felipe Contreras
2013-06-08 18:02 ` Ramkumar Ramachandra
2013-06-08 18:22   ` Felipe Contreras
2013-06-09 14:56     ` Ramkumar Ramachandra
2013-06-09 15:12       ` John Keeping
2013-06-09 15:40         ` Felipe Contreras
2013-06-09 16:02           ` John Keeping
2013-06-09 16:22             ` Felipe Contreras
2013-06-09 16:42               ` John Keeping
2013-06-09 17:03                 ` Ramkumar Ramachandra
2013-06-09 17:12                   ` Ramkumar Ramachandra
2013-06-09 17:13                   ` Felipe Contreras
2013-06-09 17:32                     ` John Keeping
2013-06-09 17:45                       ` Felipe Contreras
2013-06-09 16:36             ` Ramkumar Ramachandra
2013-06-09 17:30           ` Vincent van Ravesteijn
2013-06-09 17:35             ` Felipe Contreras
2013-06-10 21:45             ` Jeff King
2013-06-10 21:52               ` Felipe Contreras
2013-06-10 22:06                 ` Jeff King
2013-06-10 22:22                   ` Felipe Contreras
2013-06-10 23:05                   ` Junio C Hamano
2013-06-10 23:41                     ` Junio C Hamano
2013-06-10 23:51                       ` Felipe Contreras
2013-06-11  0:04                         ` Junio C Hamano
2013-06-11  1:53                           ` Junio C Hamano
2013-06-11  4:15                             ` Felipe Contreras
2013-06-11 17:33                               ` Junio C Hamano [this message]
2013-06-11 17:41                                 ` Felipe Contreras
2013-06-11 17:58                                   ` Junio C Hamano
2013-06-11 18:06                                     ` Felipe Contreras
2013-06-11 18:14                                       ` Linus Torvalds
2013-06-11 19:15                                         ` Felipe Contreras
2013-06-11 19:59                                         ` Junio C Hamano
2013-06-11 20:12                                           ` Felipe Contreras
2013-06-12  0:12                                           ` [PATCH 0/3] Refactor useful notes functions into notes-utils.[ch] Johan Herland
2013-06-12  0:12                                             ` [PATCH 1/3] finish_copy_notes_for_rewrite(): Let caller provide commit message Johan Herland
2013-06-12 17:27                                               ` Junio C Hamano
2013-06-12  0:13                                             ` [PATCH 2/3] Move copy_note_for_rewrite + friends from builtin/notes.c to notes-utils.c Johan Herland
2013-06-12  0:32                                               ` Felipe Contreras
2013-06-12  7:10                                                 ` Johan Herland
2013-06-12 18:28                                                   ` Felipe Contreras
2013-06-12 19:14                                                     ` Johan Herland
2013-06-12 19:18                                                       ` Felipe Contreras
2013-06-13  6:45                                                     ` Andreas Krey
2013-06-13 13:13                                                       ` Felipe Contreras
2013-06-12 20:02                                               ` Junio C Hamano
2013-06-12  0:13                                             ` [PATCH 3/3] Move create_notes_commit() from notes-merge.c into notes-utils.c Johan Herland
2013-06-12 20:02                                             ` [PATCH 0/3] Refactor useful notes functions into notes-utils.[ch] Junio C Hamano
2013-06-12 20:11                                               ` Felipe Contreras
2013-06-13 17:24                                                 ` Junio C Hamano
2013-06-13 18:16                                                   ` Felipe Contreras
2013-06-13 18:50                                                     ` Felipe Contreras
2013-06-11 18:17                                       ` [PATCH] build: get rid of the notion of a git library Junio C Hamano
2013-06-11 19:01                                         ` Felipe Contreras
2013-06-11 19:24                                           ` Junio C Hamano
2013-06-11 19:49                                             ` Felipe Contreras
2013-06-11  4:04                           ` Felipe Contreras
2013-06-09 15:41       ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vtxl4blht.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=artagnon@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=john@keeping.me.uk \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=vfr@lyx.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).