@matheusbsbs / matheus-bagliano / commits / 4ecbc17870
Fork 0

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 9, 2009 at 02:37 UTC 4ecbc178704ca6c1027a38483e98f5fe493b1322
1 file changed +7 -7
Makefile
+7 -7
@@ -1641,15 +1641,15 @@ ifneq (,$X)
1641 endif
1642 bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
1643 execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
1644 - { $(RM) "$$execdir/git-add$X" && \
1644 + { $(RM) "$$execdir/git$X" && \
1645 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 \
1649 $(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; \
1653 done; } && \
1654 ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
1655