From 295dd2ad201c0ebb281563750a13d904bd466e01 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 9 Nov 2007 06:06:10 -0500 Subject: [PATCH 1/4] Fix memory leak in traverse_commit_list If we were listing objects too then the objects were buffered in an array only reachable from a stack allocated structure. When this function returns that array would be leaked as nobody would have a reference to it anymore. Historically this hasn't been a problem as the primary user of traverse_commit_list() (the noble git-rev-list) would terminate as soon as the function was finished, thus allowing the operating system to cleanup memory. However we have been leaking this data in git-pack-objects ever since that program learned how to run the revision listing internally, rather than relying on reading object names from git-rev-list. To better facilitate reuse of traverse_commit_list during other builtin tools (such as git-fetch) we shouldn't leak temporary memory like this and instead we need to clean up properly after ourselves. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- list-objects.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/list-objects.c b/list-objects.c index e5c88c278..4ef58e7ec 100644 --- a/list-objects.c +++ b/list-objects.c @@ -170,4 +170,11 @@ void traverse_commit_list(struct rev_info *revs, } for (i = 0; i < objects.nr; i++) show_object(&objects.objects[i]); + free(objects.objects); + if (revs->pending.nr) { + free(revs->pending.objects); + revs->pending.nr = 0; + revs->pending.alloc = 0; + revs->pending.objects = NULL; + } } From c8cfa3e4a5b1d1d4c870c82d2dbf162f570f0561 Mon Sep 17 00:00:00 2001 From: Benoit Sigoure Date: Sun, 11 Nov 2007 19:41:41 +0100 Subject: [PATCH 2/4] git-svn: prevent dcommitting if the index is dirty. dcommit uses rebase to sync the history with what has just been pushed to SVN. Trying to dcommit with a dirty index is troublesome for rebase, so now the user will get an error message if he attempts to dcommit with a dirty index. Signed-off-by: Benoit Sigoure Acked-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 3 +++ t/t9106-git-svn-dcommit-clobber-series.sh | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/git-svn.perl b/git-svn.perl index ec25ea423..4c779b6c6 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -374,6 +374,9 @@ sub cmd_set_tree { sub cmd_dcommit { my $head = shift; + git_cmd_try { command_oneline(qw/diff-index --quiet HEAD/) } + 'Cannot dcommit with a dirty index. Commit your changes first' + . "or stash them with `git stash'.\n"; $head ||= 'HEAD'; my @refs; my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs); diff --git a/t/t9106-git-svn-dcommit-clobber-series.sh b/t/t9106-git-svn-dcommit-clobber-series.sh index 7eff4cdc0..d59acc8d1 100755 --- a/t/t9106-git-svn-dcommit-clobber-series.sh +++ b/t/t9106-git-svn-dcommit-clobber-series.sh @@ -53,4 +53,10 @@ test_expect_success 'change file but in unrelated area' " test x\"\`sed -n -e 61p < file\`\" = x6611 " +test_expect_failure 'attempt to dcommit with a dirty index' ' + echo foo >>file && + git add file && + git svn dcommit +' + test_done From 53e780c8f662bb937dc66a698c34fa2407cff31b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 11 Nov 2007 23:07:05 -0500 Subject: [PATCH 3/4] git-branch: remove mention of non-existent '-b' option This looks like a cut and paste error from the git-checkout explanation of --no-track. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- Documentation/git-branch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index b7285bcdb..37cb8b83b 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -105,7 +105,7 @@ OPTIONS '--track' were given. --no-track:: - When -b is given and a branch is created off a remote branch, + When a branch is created off a remote branch, set up configuration so that git-pull will not retrieve data from the remote branch, ignoring the branch.autosetupmerge configuration variable. From a74fa1106dd29390077025e7f176cf6b53eada62 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 12 Nov 2007 05:37:25 +0100 Subject: [PATCH 4/4] for-each-ref: fix off by one read. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- builtin-for-each-ref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c index 29f70aabc..0327f4030 100644 --- a/builtin-for-each-ref.c +++ b/builtin-for-each-ref.c @@ -297,7 +297,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un if (!eol) return ""; eol++; - if (eol[1] == '\n') + if (*eol == '\n') return ""; /* end of header */ buf = eol; }