summaryrefslogtreecommitdiff
path: root/bisect.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-05-25 11:08:23 +0200
committerJunio C Hamano <gitster@pobox.com>2013-06-02 15:28:47 -0700
commitbf42772e38db8e758aa28a045e8cba88096a9fcc (patch)
treed6ba4088263ca0811ffbf1c9762afc4cb9023e52 /bisect.c
parent66ce0366285f73c340f04a21b3d8be898d7bf5a7 (diff)
downloadgit-bf42772e38db8e758aa28a045e8cba88096a9fcc.tar.gz
register_ref(): make a copy of the bad reference SHA-1
The lifetime of the sha1 parameter passed to an each_ref_fn callback is not guaranteed, so make a copy for later use. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bisect.c')
-rw-r--r--bisect.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bisect.c b/bisect.c
index 374d9e24bd..71c19581da 100644
--- a/bisect.c
+++ b/bisect.c
@@ -15,7 +15,7 @@
static struct sha1_array good_revs;
static struct sha1_array skipped_revs;
-static const unsigned char *current_bad_sha1;
+static unsigned char *current_bad_sha1;
static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
@@ -404,7 +404,8 @@ static int register_ref(const char *refname, const unsigned char *sha1,
int flags, void *cb_data)
{
if (!strcmp(refname, "bad")) {
- current_bad_sha1 = sha1;
+ current_bad_sha1 = xmalloc(20);
+ hashcpy(current_bad_sha1, sha1);
} else if (!prefixcmp(refname, "good-")) {
sha1_array_append(&good_revs, sha1);
} else if (!prefixcmp(refname, "skip-")) {