Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Qingning Huo <qhuo@mayhq.co.uk>, git@vger.kernel.org
Subject: Re: [PATCH] Invoke git-repo-config directly.
Date: Wed, 15 Mar 2006 22:37:09 -0800	[thread overview]
Message-ID: <7voe06dhey.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0603151450070.3618@g5.osdl.org> (Linus Torvalds's message of "Wed, 15 Mar 2006 14:51:30 -0800 (PST)")

Linus Torvalds <torvalds@osdl.org> writes:

> On Wed, 15 Mar 2006, Junio C Hamano wrote:
>> 
>> 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);
 

      parent reply	other threads:[~2006-03-16  6:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-14 21:10 [PATCH] Invoke git-repo-config directly Qingning Huo
2006-03-14 21:20 ` Johannes Schindelin
2006-03-14 21:30   ` Qingning Huo
2006-03-14 21:58 ` Linus Torvalds
2006-03-14 22:40   ` Qingning Huo
2006-03-14 23:07     ` Linus Torvalds
2006-03-15 20:40       ` Qingning Huo
2006-03-15 21:33       ` Junio C Hamano
2006-03-15 21:35         ` Junio C Hamano
2006-03-15 22:11           ` Qingning Huo
2006-03-15 22:51         ` Linus Torvalds
2006-03-15 23:35           ` Junio C Hamano
2006-03-16  7:53             ` Qingning Huo
2006-03-16  7:57               ` Junio C Hamano
2006-03-16  8:26               ` Junio C Hamano
2006-03-16 12:53                 ` Mark Wooding
2006-03-16 13:53                   ` Andreas Ericsson
2006-03-17  2:10                     ` Junio C Hamano
2006-03-17 10:51                       ` Mark Wooding
2006-03-16 14:27                   ` Timo Hirvonen
2006-03-16 14:39                     ` Andreas Ericsson
2006-03-16 20:33                 ` Qingning Huo
2006-03-16 10:14               ` Junio C Hamano
2006-03-16 11:55                 ` Andreas Ericsson
2006-03-16 19:27                 ` Jon Loeliger
2006-03-16 19:32                   ` Jon Loeliger
2006-03-16  6:37           ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7voe06dhey.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=qhuo@mayhq.co.uk \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox