bugfix, rfc alias.foo = --git-dir /path/to/repo ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I found this while playing with alias.foo = --git-dir /path/to/repo
(looking for other problems):

    $ git foo
    *** glibc detected *** realloc(): invalid pointer: 0x0811d14c ***
    [1]    24815 abort      git foo

Patch for this problem is below.  Now that this is fixed the more
interesting thing is

    alias.foo = --git-dir /tmp/foo.git log
    alias.bar = --git-dir /tmp/foo.git status

The first one will use the current repository and the second one will
use /tmp/foo.git (because status is no built-in command).

Possible solutions:
(1) allow changing the repository path after reading the config
(2) deny the use of --git-dir in aliases
(3) reexec git for the alias instead of handling commands internally
    if --git-dir is used
I'm in favour of (3).

---
fix bug in handle_options

handle_options did not count the number of used arguments
correctly.  When --git-dir was used the extra argument was
not added to the number of handled arguments.

Signed-off-by: Matthias Lederhofer <matled@xxxxxxx>
---
 git.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/git.c b/git.c
index 33dd4d3..7def319 100644
--- a/git.c
+++ b/git.c
@@ -66,6 +66,7 @@ static int handle_options(const char*** argv, int* argc)
 			setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
 			(*argv)++;
 			(*argc)--;
+			handled++;
 		} else if (!prefixcmp(cmd, "--git-dir=")) {
 			setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
 		} else if (!strcmp(cmd, "--bare")) {
-- 
1.5.1.1.81.g6aead-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]