From e42251a221e44c0bd8438019da1c307def9a4ca8 Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Mon, 28 Apr 2008 23:09:55 +0200 Subject: Use "=" instead of "==" in condition as it is more portable At least the dash from Ubuntu's /bin/sh says: test: 233: ==: unexpected operator Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- git-clone.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-clone.sh b/git-clone.sh index 9e433c080..8c7fc7f63 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -219,7 +219,7 @@ fi if test -n "$2" then dir="$2" - test $# == 2 || die "excess parameter to git-clone" + test $# = 2 || die "excess parameter to git-clone" else # Derive one from the repository name # Try using "humanish" part of source repo if user didn't specify one -- cgit v1.2.1 From 72269ad9564b700e6aab30338e35b4e6ffea854d Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 28 Apr 2008 16:27:49 -0700 Subject: fetch-pack: do not stop traversing an already parsed commit f3ec549 (fetch-pack: check parse_commit/object results, 2008-03-03) broke common ancestor computation by stopping traversal when it sees an already parsed commit. This should fix it. Signed-off-by: Junio C Hamano --- builtin-fetch-pack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c index 65350ca52..fe8cfa0cb 100644 --- a/builtin-fetch-pack.c +++ b/builtin-fetch-pack.c @@ -117,15 +117,15 @@ static const unsigned char* get_rev(void) while (commit == NULL) { unsigned int mark; - struct commit_list *parents = NULL; + struct commit_list *parents; if (rev_list == NULL || non_common_revs == 0) return NULL; commit = rev_list->item; - if (!(commit->object.parsed)) - if (!parse_commit(commit)) - parents = commit->parents; + if (commit->object.parsed) + parse_commit(commit); + parents = commit->parents; commit->object.flags |= POPPED; if (!(commit->object.flags & COMMON)) -- cgit v1.2.1 From 7b7f39eae6ab0bbcc68d3c42a5b23595880e528f Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Mon, 28 Apr 2008 22:23:35 +0200 Subject: Fix use after free() in builtin-fetch As reported by Dave Jones: Since master.kernel.org updated to latest, I noticed that I could crash git-fetch by doing this.. export KERNEL=/pub/scm/linux/kernel/git/ git fetch $KERNEL/torvalds/linux-2.6 master:linus (gdb) bt 0 0x000000349fd6d44b in free () from /lib64/libc.so.6 1 0x000000000048f4eb in transport_unlock_pack (transport=0x7ce530) at transport.c:811 2 0x000000349fd31b25 in exit () from /lib64/libc.so.6 3 0x00000000004043d8 in handle_internal_command (argc=3, argv=0x7fffea4449f0) at git.c:379 4 0x0000000000404547 in main (argc=3, argv=0x7fffea4449f0) at git.c:443 5 0x000000349fd1c784 in __libc_start_main () from /lib64/libc.so.6 6 0x0000000000403ef9 in ?? () 7 0x00007fffea4449d8 in ?? () 8 0x0000000000000000 in ?? () I then remembered, my .bashrc has this.. export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) which is handy for showing up such bugs. More info on this glibc feature is at http://udrepper.livejournal.com/11429.html Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- builtin-fetch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/builtin-fetch.c b/builtin-fetch.c index 139a6b10c..167f94803 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -577,8 +577,6 @@ static int do_fetch(struct transport *transport, free_refs(ref_map); } - transport_disconnect(transport); - return 0; } @@ -599,6 +597,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) int i; static const char **refs = NULL; int ref_nr = 0; + int exit_code; /* Record the command line for the reflog */ strbuf_addstr(&default_rla, "fetch"); @@ -652,6 +651,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix) signal(SIGINT, unlock_pack_on_signal); atexit(unlock_pack); - return do_fetch(transport, + exit_code = do_fetch(transport, parse_fetch_refspec(ref_nr, refs), ref_nr); + transport_disconnect(transport); + transport = NULL; + return exit_code; } -- cgit v1.2.1 From 861f00e3496fd5cd866a73f11826dfc8822a5195 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Apr 2008 00:13:58 -0400 Subject: fix reflog approxidate parsing bug In get_sha1_basic, we parse a string like HEAD@{10 seconds ago}:path/to/file into its constituent ref, reflog date, and path components. We never actually munge the string itself, but instead keep offsets into the string with their associated lengths. When we call approxidate on the contents inside braces, however, we pass just a string without a length. This means that approxidate could sometimes look past the closing brace and (erroneously) interpret the rest of the string as part of the date. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- sha1_name.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 6c9c1c75a..6298c37ae 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -352,8 +352,11 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1) } if (0 <= nth) at_time = 0; - else - at_time = approxidate(str + at + 2); + else { + char *tmp = xstrndup(str + at + 2, reflog_len); + at_time = approxidate(tmp); + free(tmp); + } if (read_ref_at(real_ref, at_time, nth, sha1, NULL, &co_time, &co_tz, &co_cnt)) { if (at_time) -- cgit v1.2.1 From b3bb5f76e6193db102b063187be854ef3842d89b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Apr 2008 00:36:14 -0400 Subject: cvsimport: always pass user data to "system" as a list This avoids invoking the shell. Not only is it faster, but it prevents the possibility of interpreting our arguments in the shell. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-cvsimport.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 8093996e2..33777e278 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -767,7 +767,7 @@ sub commit { waitpid($pid,0); die "Error running git-commit-tree: $?\n" if $?; - system("git-update-ref $remote/$branch $cid") == 0 + system('git-update-ref', "$remote/$branch", $cid) == 0 or die "Cannot write branch $branch for update: $!\n"; if ($tag) { -- cgit v1.2.1