What's cooking in git.git
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:16
Junio C Hamano [off-list ref] writes:
- Exec git programs without using PATH (Michal Ostrowski). This has been discussed for the last couple of days on the list. I think C side is ready to go in, but I'd like to decide what to do on the scripting side before merging it into the master branch.
I've done a minor fix in the Makefile (things were installed in
the wrong way around --- $bindir should hold git and gitk and
$gitexecdir should hold the rest), and ran a brief test after
installing things with gitexecdir set to /usr/lib/git-core/x.
gitk needs to be taught to use git --exec-path upfront to set
its own PATH, but other than that, everything looks peachy.
About prepending to/appending to/not touching PATH, my current
thinking is that prepending is the way to go. The best
rationale so far I have heard against mucking with PATH was
"/home/mo/bin/diff vs /usr/bin/diff" issue, but I do not find
this to be so convincing in practice. This "use my diff not
system diff" is done most often when system diff is not GNU
enough, but on such a machine git will not be installed under
/usr/bin anyway (after all git prefers GNU diff).
And this becomes truly a non-issue when you point $gitexecdir at
a separate location that holds *only* git stuff. Everybody will
find the matching version of git that way, and when looking for
"diff", it will be found from one of the directories in the rest
of the PATH, not from $gitexecdir.
So unless there is an objection, this will graduate into the
"master" branch over the weekend.
What happens if gitexecdir != bindir?
As long as the user invokes "git foo" from the command line, not
"git-foo", everything should work fine, and once gitk is
updated, binary distributions could ship git with only git and
gitk in /usr/bin and others in /usr/lib/git-core/tools, or
something like that.
I will _not_ change the default gitexecdir in my Makefile nor
change the spec file, so RPM binary from kernel.org will still
have everything in /usr/bin for now.
Somebody needs to audit how ready popular Porcelains are, for at
least Cogito, stgit, gitweb and qgit and feed patches to
respective authors as necessary. I haven't looked into any of
them about this issue. The rules are:
(1) you can assume "git" is available on PATH;
(2) you should be safe if you do not use "git-foo" form;
(3) you can run
PATH="$(git --exec-path):$PATH"; export PATH
once at the beginning of your program and use "git-foo"
form.
Volunteers?