Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Invoke git-repo-config directly.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:21
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Linus Torvalds [off-list ref] writes:
On Wed, 15 Mar 2006, Junio C Hamano wrote:
quoted
If we do the dash-form for consistency's sake, we should do
PATH="`git --exec-path`:$PATH" in git-setup-sh when/before we do
so.
Yes. That would make sense too. Then git-setup-sh would look more like 
what the builtin git.c does.
I actually think what git.c does is _wrong_.

Believe it or not, there are people with bizarre configurations
just like Qingning's is bizarre in different sense [*1*].  They
have diff they do not like (either broken or inadequete)
installed under /usr/bin, and they install GNU diff under
/home/$u/bin, and have their PATH set so that /home/$u/bin/diff
is found before /usr/bin/diff (up to here, there is nothing
bizarre).  However, somehow they have the latest "git" installed
under /usr/bin (this _is_ the bizarre part).

Earlier, we prepended GIT_EXEC_PATH to user-supplied PATH when
C-level routines needed to exec git programs.  This breaks that
"bizarre" setup -- for such a setup, GIT_EXEC_PATH is currently
set to /usr/bin and when we try to exec "diff", we ended up
running /usr/bin/diff.  So in order to work this around, we
introduced exec[vl]_git_cmd() wrappers which use --exec-path
(if the command supports per invocation override), GIT_EXEC_PATH
environment, and then gitexecdir in Makefile when it was built,
in this order.  "git" wrapper should know about this, but the
older code was never removed when we introduced exec_cmd.c.

I think we need to do something like the attached patch.

[Footnote]

*1* I first wrote "configuration even more bizarre than
Qingning's", but before sending the message out I came to
senses.  We have to admit that that configuration is quite
unusual, and I would say it is the one more bizarre than the one
in question here.  When people have standard system executable
directories such as /usr/bin and /bin and private directories
like /home/$u/bin and /usr/local/bin on their PATH, private
directories always come before the system directories, so that
things in the system directories (often you do not have write
permission to) can be overriden by private directories (which is
under your control).

-- >8 --
diff --git a/git.c b/git.c
index 0b40e30..25e6a4e 100644
--- a/git.c
+++ b/git.c
@@ -219,25 +219,6 @@ static void cmd_usage(int show_all, cons
 	exit(1);
 }
 
-static void prepend_to_path(const char *dir, int len)
-{
-	char *path, *old_path = getenv("PATH");
-	int path_len = len;
-
-	if (!old_path)
-		old_path = "/usr/local/bin:/usr/bin:/bin";
-
-	path_len = len + strlen(old_path) + 1;
-
-	path = malloc(path_len + 1);
-
-	memcpy(path, dir, len);
-	path[len] = ':';
-	memcpy(path + len + 1, old_path, path_len - len);
-
-	setenv("PATH", path, 1);
-}
-
 static void show_man_page(const char *git_cmd)
 {
 	const char *page;
@@ -447,18 +428,6 @@ int main(int argc, const char **argv, ch
 	}
 	argv[0] = cmd;
 
-	/*
-	 * We search for git commands in the following order:
-	 *  - git_exec_path()
-	 *  - the path of the "git" command if we could find it
-	 *    in $0
-	 *  - the regular PATH.
-	 */
-	if (exec_path)
-		prepend_to_path(exec_path, strlen(exec_path));
-	exec_path = git_exec_path();
-	prepend_to_path(exec_path, strlen(exec_path));
-
 	/* See if it's an internal command */
 	handle_internal_command(argc, argv, envp);
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help