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

Re: [BUG] aliases not working outside of a working copy

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 1, 2008, 04:39 UTC
Message-ID
<7v1w5qkx2j.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<8aa486160803310819r3a905bbeg5f993a55aaf6efbf@mail.gmail.com>
"Santi Béjar" <sbejar@gmail.com> writes:
Show 12 quoted lines
>   I use the following alias:
>
> [alias]
>         wdiff = diff --color-words
>
> and it no longer works outside of a working copy since:
>
> af05d67 (Always set *nongit_ok in setup_git_directory_gently())
>
> The problem is with the alias system that detects if you are in a
> working copy, not with the command, as the
> command just works fine.

I was wondering if anybody was using git alias outside git repository, as I thought such a use would be somewhat unorthodox. The easter egg took 6 days to get discovered.

I'll commit this on 'master'.  Thanks for satisfying my curiosity ;-)

-- >8 -- [PATCH] Accept git aliases outside a git repository

af05d67 (Always set *nongit_ok in setup_git_directory_gently(), 2008-03-25) had a change from the patch originally submitted that resulted in disabling aliases outside a git repository.

It turns out that some people used "alias.fubar = diff --color-words" in $HOME/.gitconfig to use non-git command outside git repositories, and this change broke such a usage, so this resurrects the support.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index b7729d7..c4e4644 100644
--- a/git.c
+++ b/git.c
@@ -148,8 +148,9 @@ static int handle_alias(int *argcp, const char ***argv)
 	const char** new_argv;
 	const char *alias_command;
 	char *alias_string;
+	int unused_nongit;
 
-	subdir = setup_git_directory_gently(NULL);
+	subdir = setup_git_directory_gently(&unused_nongit);
 
 	alias_command = (*argv)[0];
 	alias_string = alias_lookup(alias_command);
-- 
1.5.5.rc2.155.gb0a67
Previous: Johannes SchindelinNext: Santi Béjar
Message 3 of 4 in “[BUG] aliases not working outside of a working copy”
  1. Santi BéjarMar 31, 2008
  2. Johannes SchindelinMar 31, 2008
  3. Junio C HamanoApr 1, 2008
  4. Santi BéjarApr 1, 2008

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.