{"thread":{"id":"7628","subject":"bugfix, rfc alias.foo = --git-dir /path/to/repo ...","startedAt":"2007-04-12T18:52:03Z","lastAt":"2007-04-12T18:52:03Z","messageCount":1,"participants":["Matthias Lederhofer"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"39225","messageId":"20070412185203.GA28255@moooo.ath.cx","threadId":"7628","inReplyTo":null,"subject":"bugfix, rfc alias.foo = --git-dir /path/to/repo ...","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-04-12T18:52:03Z","receivedAt":"2007-04-12T18:52:03Z","isPatch":false,"sender":{"key":"matled@gmx.net","avatar":null},"body":"I found this while playing with alias.foo = --git-dir /path/to/repo\n(looking for other problems):\n\n    $ git foo\n    *** glibc detected *** realloc(): invalid pointer: 0x0811d14c ***\n    [1]    24815 abort      git foo\n\nPatch for this problem is below.  Now that this is fixed the more\ninteresting thing is\n\n    alias.foo = --git-dir /tmp/foo.git log\n    alias.bar = --git-dir /tmp/foo.git status\n\nThe first one will use the current repository and the second one will\nuse /tmp/foo.git (because status is no built-in command).\n\nPossible solutions:\n(1) allow changing the repository path after reading the config\n(2) deny the use of --git-dir in aliases\n(3) reexec git for the alias instead of handling commands internally\n    if --git-dir is used\nI'm in favour of (3).\n\n---\nfix bug in handle_options\n\nhandle_options did not count the number of used arguments\ncorrectly.  When --git-dir was used the extra argument was\nnot added to the number of handled arguments.\n\nSigned-off-by: Matthias Lederhofer <matled@gmx.net>\n---\n git.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 33dd4d3..7def319 100644\n--- a/git.c\n+++ b/git.c\n@@ -66,6 +66,7 @@ static int handle_options(const char*** argv, int* argc)\n \t\t\tsetenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);\n \t\t\t(*argv)++;\n \t\t\t(*argc)--;\n+\t\t\thandled++;\n \t\t} else if (!prefixcmp(cmd, \"--git-dir=\")) {\n \t\t\tsetenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);\n \t\t} else if (!strcmp(cmd, \"--bare\")) {\n-- \n1.5.1.1.81.g6aead-dirty\n"}]}