git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] shrink git-shell by avoiding redundant dependencies

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Jul 18, 2008, 05:59 UTC
Message-ID
<20080718055902.GI2925@dpotapov.dyndns.org>
In-Reply-To
<20080718002620.GE8421@leksak.fem-net>
On Fri, Jul 18, 2008 at 02:26:20AM +0200, Stephan Beyer wrote:
Show 31 quoted lines
> 
> Dmitry Potapov wrote:
> > diff --git a/shell.c b/shell.c
> > index b27d01c..91ca7de 100644
> > --- a/shell.c
> > +++ b/shell.c
> > @@ -3,6 +3,14 @@
> >  #include "exec_cmd.h"
> >  #include "strbuf.h"
> >  
> > +/* Stubs for functions that make no sense for git-shell. These stubs
> > + * are provided here to avoid linking in external redundant modules.
> > + */
> > +void release_pack_memory(size_t need, int fd){}
> > +void trace_argv_printf(const char **argv, const char *fmt, ...){}
> > +void trace_printf(const char *fmt, ...){}
> > +
> > +
> 
> I don't really understand why this works.
> You redefine libgit.a functions here
> 
> So the linker should complain like that:
> 	libgit.a(sha1_file.o): In function `release_pack_memory':
> 	/home/sbeyer/src/git/sha1_file.c:624: multiple definition of `release_pack_memory'
> 	shell.o:/home/sbeyer/src/git/shell.c:9: first defined here
> 	collect2: ld returned 1 exit status
> 
> And, in fact, it does when I move a function from a builtin to a lib
> source file, for example launch_editor() from builtin-tag.c to strbuf.c,
> like the following one:

It works because these functions are defined in object files, so the linker should not search for them in libraries. However, if the linker is forced to link sha1_file.c for some other reason, you will get the conflict.

Dmitry
Previous: Dmitry PotapovNext: Johannes Schindelin
Message 13 of 16 in “shrink git-shell by avoiding redundant dependencies”
  1. shrink git-shell by avoiding redundant dependenciesDmitry Potapov, Jun 27, 2008
  2. Junio C HamanoJun 27, 2008
  3. Dmitry PotapovJun 27, 2008
  4. Junio C HamanoJun 27, 2008
  5. Stephan BeyerJul 18, 2008
  6. Shawn O. PearceJul 18, 2008
  7. Link git-shell only to a subset of libgit.aStephan Beyer, Jul 18, 2008
  8. Shawn O. PearceJul 18, 2008
  9. Dmitry PotapovJul 18, 2008
  10. Johannes SchindelinJul 18, 2008
  11. Remove function stubs in shell.cStephan Beyer, Jul 18, 2008
  12. Dmitry PotapovJul 18, 2008
  13. Dmitry PotapovJul 18, 2008
  14. Johannes SchindelinJun 28, 2008
  15. Dmitry PotapovJun 28, 2008
  16. Johannes SchindelinJun 28, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.