git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git-daemon regression: 650c449250d7 common-main: call git_extract_argv0_path()

From
Jeff King <peff@peff.net>
Date
Nov 26, 2016, 17:09 UTC
Message-ID
<20161126170933.6tge6j5etuchqy33@sigill.intra.peff.net>
In-Reply-To
<1480169028.3830.24.camel@gmail.com>
On Sat, Nov 26, 2016 at 03:03:48PM +0100, Mike Galbraith wrote:
> git-daemon went broke on me post v2.9.3 due to binaries being installed
> in /usr/lib/git, which is not in PATH.  Reverting 650c449250d7 fixes it
> up, as does ln -s /usr/lib/git/git-daemon /usr/bin/git-daemon 'course,
> but thought I should report it, since it used to work without that.

Generally /usr/lib/git _should_ be in your PATH, as it is added by the git wrapper when you run "git daemon".

The only behavior difference caused by 650c449250d7 is that we replace argv[0] with the output of git_extract_argv0_path(argv[0]), which will give the basename, not a full path. So presumably you are running:

  /usr/lib/git/git-daemon

directly. I'm not sure that's even supposed to work these days, and it was not just a happy accident that it did.

On the other hand, I am sympathetic that something used to work and now doesn't. It probably wouldn't be that hard to work around it.

The reason for the behavior change is that one of the cmd_main() functions was relying on the basename side-effect of the extract_argv0_path function, so 650c449250d7 just feeds the munged argv[0] to all of the programs. The cleanest fix would probably be something like:

diff --git a/common-main.c b/common-main.c
index 44a29e8b1..c654f9555 100644
--- a/common-main.c
+++ b/common-main.c
@@ -33,7 +33,7 @@ int main(int argc, const char **argv)
 
 	git_setup_gettext();
 
-	argv[0] = git_extract_argv0_path(argv[0]);
+	git_extract_argv0_path(argv[0]);
 
 	restore_sigpipe_to_default();
 
diff --git a/git.c b/git.c
index bd66a2e0a..05986680c 100644
--- a/git.c
+++ b/git.c
@@ -730,6 +730,11 @@ int cmd_main(int argc, const char **argv)
 	cmd = argv[0];
 	if (!cmd)
 		cmd = "git-help";
+	else {
+		const char *base = find_last_dir_sep(cmd);
+		if (base)
+			cmd = base + 1;
+	}
 
 	trace_command_performance(argv);
 	trace_stdin();

-Peff
Previous: Dennis KaarsemakerNext: Mike Galbraith
Message 3 of 5 in “git-daemon regression: 650c449250d7 common-main: call git_extract_argv0_path()”
  1. Mike GalbraithNov 26, 2016
  2. Dennis KaarsemakerNov 26, 2016
  3. Jeff KingNov 26, 2016
  4. Mike GalbraithNov 26, 2016
  5. common-main: stop munging argv[0] pathJeff King, Nov 27, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.