threads / discuss / 2601

git --exec-path conversion

Subject: git --exec-path conversion

## tl;dr

4 messages between Nov 19, 2005 and Nov 19, 2005.

replies: 3people: 3as markdown or json

Marco Costalba· Nov 19, 2005, 11:14 UTC · lore
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

Junio C Hamano· Nov 19, 2005, 12:04 UTC · re: Marco Costalba · lore

Re: git --exec-path conversion

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.

← back to recent threads