# git --exec-path conversion

4 messages from 2005-11-19 to 2005-11-19. Participants: Marco Costalba, Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/2601

## Marco Costalba, 2005-11-19 11:14

Subject: git --exec-path conversion
Message-ID: <20051119111444.82122.qmail@web26309.mail.ukl.yahoo.com>
URL: https://gitlist.dev/e/20051119111444.82122.qmail%40web26309.mail.ukl.yahoo.com

```
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 

```

## Johannes Schindelin, 2005-11-19 11:20

Subject: Re: git --exec-path conversion
Message-ID: <Pine.LNX.4.63.0511191218370.27986@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511191218370.27986%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <20051119111444.82122.qmail@web26309.mail.ukl.yahoo.com>

```
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

```

## Junio C Hamano, 2005-11-19 12:04

Subject: Re: git --exec-path conversion
Message-ID: <7vy83k6dyf.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy83k6dyf.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20051119111444.82122.qmail@web26309.mail.ukl.yahoo.com>

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

```

## Junio C Hamano, 2005-11-19 12:05

Subject: Re: git --exec-path conversion
Message-ID: <7vu0e86dxj.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vu0e86dxj.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0511191218370.27986@wbgn013.biozentrum.uni-wuerzburg.de>

```
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 ;-)?

```
