git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: git --exec-path conversion
@ 2005-11-19 13:50 Marco Costalba
  0 siblings, 0 replies; 7+ messages in thread
From: Marco Costalba @ 2005-11-19 13:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano wrote:

>Marco Costalba <mcostalba@yahoo.it> writes:
>
>>if I understood correctly, git programs will be installed
>>somewhere in $PATH for at least next two months.
>
>
>I suspect things will stay in /usr/bin longer than that, but
>futureproofing is good in any case.
>
>Assuming you are writing things in C or C++:
>
> - run "git --exec-path" at the very beginning of main(),
> - read the output, prepend it to $PATH using setenv(3).
>
>and I think you are done. 

Yes. Thanks.




		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: git --exec-path conversion
  2005-11-19 11:32 Marco Costalba
@ 2005-11-19 13:51 ` Johannes Schindelin
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Schindelin @ 2005-11-19 13:51 UTC (permalink / raw)
  To: Marco Costalba; +Cc: junkio, git

Hi,

On Sat, 19 Nov 2005, Marco Costalba wrote:

> Incredible how many errors in only two lines of code :-)

If you want to know how to introduce 3 bugs in just 512 bytes of 
production code (i.e. not a development version), see

	http://www.xbox-linux.org/wiki/The_Hidden_Boot_Code_of_the_Xbox

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: git --exec-path conversion
  2005-11-19 11:20 ` Johannes Schindelin
@ 2005-11-19 12:05   ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2005-11-19 12:05 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Marco Costalba, junkio, git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Little nit: Test for "git-", because "git" and "gitk" will stay in the 
> PATH.

Heh, he is writing QGit; why should he run gitk ;-)?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: git --exec-path conversion
  2005-11-19 11:14 Marco Costalba
  2005-11-19 11:20 ` Johannes Schindelin
@ 2005-11-19 12:04 ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2005-11-19 12:04 UTC (permalink / raw)
  To: Marco Costalba; +Cc: git

Marco Costalba <mcostalba@yahoo.it> writes:

> if I understood correctly, git programs will be installed
> somewhere in $PATH for at least next two months.

I suspect things will stay in /usr/bin longer than that, but
futureproofing is good in any case.

Assuming you are writing things in C or C++:

 - run "git --exec-path" at the very beginning of main(),
 - read the output, prepend it to $PATH using setenv(3).

and I think you are done.  After this, your QGit::run("ls") and
QGit::run("git frotz") would not be affected (you still have
/usr/bin in your $PATH), and QGIT::run("git-frotz") would find
git-frotz installed somewhere outside /usr/bin.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: git --exec-path conversion
@ 2005-11-19 11:32 Marco Costalba
  2005-11-19 13:51 ` Johannes Schindelin
  0 siblings, 1 reply; 7+ messages in thread
From: Marco Costalba @ 2005-11-19 11:32 UTC (permalink / raw)
  To: Johannes.Schindelin; +Cc: junkio, git

Johannes Schindelin wrote:

>Hi,
>
>On Sat, 19 Nov 2005, Marco Costalba wrote:
>
>>    if (cmd.left(3) == "git") 
>>         cmd = cmd.prepend(exec-path);
>
>
>Little nit: Test for "git-", because "git" and "gitk" will stay in the 
>PATH.
>
You are rights. Thanks.

Also 'exec-path' is not a valid C++ identifier, it should be

    if (cmd.left(4) == "git-") 
         cmd = cmd.prepend(exec_path);


Incredible how many errors in only two lines of code :-)

Marco



		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: git --exec-path conversion
  2005-11-19 11:14 Marco Costalba
@ 2005-11-19 11:20 ` Johannes Schindelin
  2005-11-19 12:05   ` Junio C Hamano
  2005-11-19 12:04 ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2005-11-19 11:20 UTC (permalink / raw)
  To: Marco Costalba; +Cc: junkio, git

Hi,

On Sat, 19 Nov 2005, Marco Costalba wrote:

>     if (cmd.left(3) == "git") 
>          cmd = cmd.prepend(exec-path);

Little nit: Test for "git-", because "git" and "gitk" will stay in the 
PATH.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 7+ messages in thread

* git --exec-path conversion
@ 2005-11-19 11:14 Marco Costalba
  2005-11-19 11:20 ` Johannes Schindelin
  2005-11-19 12:04 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Marco Costalba @ 2005-11-19 11:14 UTC (permalink / raw)
  To: junkio; +Cc: git

Hi,

   if I understood correctly, git programs will be installed somewhere in $PATH for at least next
two months.

But I would like to update to what will be the future, i.e. prepending what 'git --exec-path' says
to any git command.

I don't call git programs directly but I use a function QGit::run(cmd) that does this plus other
things.

The problem is that I call QGit::run() also for other commands not related to git (ls, cat,
etc..).

How can I make the transition?

Now I have two ways, the brute force way and the easy (peraphs tricky) way.

The brute force is to create a new function QGit::runGitCmd() that deals only with git commands
_and_ replace all the occurences of run() with the latter.

The easy way is to prepend the exec-path *inside* run(), and to use to disambiguate bewteen git
and shell commands the testing of first three chars of the command to launch, something like:

    if (cmd.left(3) == "git") 
         cmd = cmd.prepend(exec-path);


I would like to go with the second one, I'm a bit lazy ;-) , but I would like to ask if this is a
good policy, i.e. if also inside git programs/scripts (like in git.c I guess) is used or is
foreseen to keep using something like this.


Thanks
Marco


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-11-19 13:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-19 13:50 git --exec-path conversion Marco Costalba
  -- strict thread matches above, loose matches on Subject: below --
2005-11-19 11:32 Marco Costalba
2005-11-19 13:51 ` Johannes Schindelin
2005-11-19 11:14 Marco Costalba
2005-11-19 11:20 ` Johannes Schindelin
2005-11-19 12:05   ` Junio C Hamano
2005-11-19 12:04 ` Junio C Hamano

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).