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

Re: [PATCH] Allow an alias to start with "-p"

From
Jeff King <peff@peff.net>
Date
Jul 25, 2006, 05:03 UTC
Message-ID
<20060725050312.GA5618@coredump.intra.peff.net>
In-Reply-To
<Pine.LNX.4.63.0607241408170.29667@wbgn013.biozentrum.uni-wuerzburg.de>
On Mon, Jul 24, 2006 at 02:10:45PM +0200, Johannes Schindelin wrote:
Show 8 quoted lines
> @@ -264,6 +289,7 @@ int main(int argc, const char **argv, ch
>  	if (!strncmp(cmd, "git-", 4)) {
>  		cmd += 4;
>  		argv[0] = cmd;
> +		handle_alias(&argc, &argv);
>  		handle_internal_command(argc, argv, envp);
>  		die("cannot handle %s internally", cmd);
>  	}

I believe this change is the source of the breakage in tests. GIT_DIR=foo git-init-db no longer works because handle_alias unconditionally calls setup_git_directory_gently(), which thinks that if GIT_DIR is set, it must exist.

This can be fixed by giving precedence to the internal command over alias checking. This makes sense, anyway, since later in the function, we give precedence to internal commands in the "git init-db" form.

Patch is below (wow, that +++ is kind of ugly!).
-Peff

+++ git: choose internal commands over aliases for git-*

This is especially important because some commands (like init-db) don't require a working GIT_DIR, and alias expansion tries to look at it. It also matches the behavior of "git cmd".

Signed-off-by: Jeff King <peff@peff.net>
---
 git.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index 8d7c644..68ce826 100644
--- a/git.c
+++ b/git.c
@@ -289,8 +289,8 @@ int main(int argc, const char **argv, ch
 	if (!strncmp(cmd, "git-", 4)) {
 		cmd += 4;
 		argv[0] = cmd;
-		handle_alias(&argc, &argv);
 		handle_internal_command(argc, argv, envp);
+		handle_alias(&argc, &argv);
 		die("cannot handle %s internally", cmd);
 	}
 
-- 
1.4.2.rc1.gc470-dirty
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 6 of 8 in “Allow an alias to start with "-p"”
  1. Allow an alias to start with "-p"Johannes Schindelin, Jul 18, 2006
  2. Junio C HamanoJul 24, 2006
  3. Allow an alias to start with "-p"Johannes Schindelin, Jul 24, 2006
  4. Junio C HamanoJul 25, 2006
  5. Johannes SchindelinJul 25, 2006
  6. Jeff KingJul 25, 2006
  7. Johannes SchindelinJul 25, 2006
  8. Junio C HamanoJul 25, 2006

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.