Skip to content

Commit 4ecbc17

Browse files
peffgitster
authored andcommitted
Makefile: install 'git' in execdir
When a git command executes a subcommand, it uses the "git foo" form, which relies on finding "git" in the PATH. Normally this should not be a problem, since the same "git" that was used to invoke git in the first place will be found. And if somebody invokes a "git" outside of the PATH (e.g., by giving its absolute path), this case is already covered: we put that absolute path onto the front of PATH. However, if one is using "sudo", then sudo will execute the "git" from the PATH, but pass along a restricted PATH that may not contain the original "git" directory. In this case, executing a subcommand will fail. To solve this, we put the "git" wrapper itself into the execdir; this directory is prepended to the PATH when git starts, so the wrapper will always be found. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3125be1 commit 4ecbc17

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,15 +1641,15 @@ ifneq (,$X)
16411641
endif
16421642
bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
16431643
execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
1644-
{ $(RM) "$$execdir/git-add$X" && \
1644+
{ $(RM) "$$execdir/git$X" && \
16451645
test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
1646-
ln "$$bindir/git$X" "$$execdir/git-add$X" 2>/dev/null || \
1647-
cp "$$bindir/git$X" "$$execdir/git-add$X"; } && \
1648-
{ for p in $(filter-out git-add$X,$(BUILT_INS)); do \
1646+
ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
1647+
cp "$$bindir/git$X" "$$execdir/git$X"; } && \
1648+
{ for p in $(BUILT_INS); do \
16491649
$(RM) "$$execdir/$$p" && \
1650-
ln "$$execdir/git-add$X" "$$execdir/$$p" 2>/dev/null || \
1651-
ln -s "git-add$X" "$$execdir/$$p" 2>/dev/null || \
1652-
cp "$$execdir/git-add$X" "$$execdir/$$p" || exit; \
1650+
ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
1651+
ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \
1652+
cp "$$execdir/git$X" "$$execdir/$$p" || exit; \
16531653
done; } && \
16541654
./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
16551655

0 commit comments

Comments
 (0)