Re: [PATCH] git_progname

From: Andreas Ericsson <ae@op5.se>
Date: 2005-10-25 21:12:07
Petr Baudis wrote:
> Could you please also trim the mails you are replying to a bit?
> 

Aye.

> Dear diary, on Tue, Oct 25, 2005 at 11:11:54AM CEST, I got a letter
> where Andreas Ericsson <ae@op5.se> told me that...
> 
>>grep -l "int main" *.c | xargs -- sed -i '/^#include/i#include "main.h"'
> 
> 
> Urgh. Now this is ugly. What about making it a bit more intrusive while
> quite more saner?
> 

I'm not sure what you're referring to. The one-liner is a one-liner. 
It's sort of supposed to be ugly.

Including main.h is a fairly sane option for common initialization code.

> 
> Also, when you already solve this for non-__GLIBC__ systems, I doubt
> that there is any win in keeping the __GLIBC__-specific hack, except
> that most developers won't see any bugs in the generic solution since
> they are using glibc.
> 

True. I'll rework it if someone thinks it's worth it.

> 
> Someone said that converting main()s to git_main()s would help the
> libification effort,


I had some thoughts along those lines as well, especially for reading 
configuration files.

> but I suspect that you actually want to set the
> progname to whatever you call when you call its git_main().
> 

This I don't understand. Do you mean "set the progname to whatever you 
call" as in "set the progname to whatever the program author calls the 
program" or as in "set the progname to whatever it's called as from the 
command-line"?

> We can make it go into the init section, but that won't be too portable
> either.
> 
> So I'd say just add setup_progname("foo") at the start of your main().
> 

Set the progname to whatever the author calls it then.

If so, I'd put
const char *git_progname = GIT_PROGNAME;
anywhere in the main() file and expanding the %.o: rule to include 
-DGIT_PROGNAME=\"git-$*\"

This would bark if there's a program that doesn't have it that's linked 
against something that uses it, which the setup_progname() approach 
wouldn't do.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Tue Oct 25 21:13:15 2005

This archive was generated by hypermail 2.1.8 : 2005-10-25 21:13:20 EST