Merge branch 'jk/git-no-more-argv0-path-munging'
authorJunio C Hamano <gitster@pobox.com>
Tue, 19 May 2015 20:17:52 +0000 (13:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 May 2015 20:17:52 +0000 (13:17 -0700)
We have prepended $GIT_EXEC_PATH and the path "git" is installed in
(typically "/usr/bin") to $PATH when invoking subprograms and hooks
for almost eternity, but the original use case the latter tried to
support was semi-bogus (i.e. install git to /opt/foo/git and run it
without having /opt/foo on $PATH), and more importantly it has
become less and less relevant as Git grew more mainstream (i.e. the
users would _want_ to have it on their $PATH). Stop prepending the
path in which "git" is installed to users' $PATH, as that would
interfere the command search order people depend on (e.g. they may
not like versions of programs that are unrelated to Git in /usr/bin
and want to override them by having different ones in /usr/local/bin
and have the latter directory earlier in their $PATH).

* jk/git-no-more-argv0-path-munging:
stop putting argv[0] dirname at front of PATH

1  2 
exec_cmd.c
diff --combined exec_cmd.c
index 8ab37b5f74f360abf8ff4d689b4ff4f3d29cf785,855749dc92f21d6d8232c5930186bb2ddbeb6c4a..e85f0fd8d897f4823a7c765d6b6ef929a15ca679
@@@ -6,7 -6,7 +6,7 @@@
  static const char *argv_exec_path;
  static const char *argv0_path;
  
 -const char *system_path(const char *path)
 +char *system_path(const char *path)
  {
  #ifdef RUNTIME_PREFIX
        static const char *prefix;
@@@ -16,7 -16,7 +16,7 @@@
        struct strbuf d = STRBUF_INIT;
  
        if (is_absolute_path(path))
 -              return path;
 +              return xstrdup(path);
  
  #ifdef RUNTIME_PREFIX
        assert(argv0_path);
@@@ -34,7 -34,8 +34,7 @@@
  #endif
  
        strbuf_addf(&d, "%s/%s", prefix, path);
 -      path = strbuf_detach(&d, NULL);
 -      return path;
 +      return strbuf_detach(&d, NULL);
  }
  
  const char *git_extract_argv0_path(const char *argv0)
@@@ -96,7 -97,6 +96,6 @@@ void setup_path(void
        struct strbuf new_path = STRBUF_INIT;
  
        add_path(&new_path, git_exec_path());
-       add_path(&new_path, argv0_path);
  
        if (old_path)
                strbuf_addstr(&new_path, old_path);