aboutsummaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-03-11 19:49:08 +0100
committerJunio C Hamano <junkio@cox.net>2007-03-11 13:28:13 -0700
commited8ad7e2e29d4adf342964f6cc15d6b84f62c700 (patch)
treefebc16922cc6e28f75cbd053f127e78d38abe5e0 /sha1_name.c
parent8a3fbdd9e6c37c74b12fd0e8bd7cde8372861288 (diff)
downloadgit-ed8ad7e2e29d4adf342964f6cc15d6b84f62c700.tar.gz
git-ed8ad7e2e29d4adf342964f6cc15d6b84f62c700.tar.xz
I like the idea of the new ':/<oneline prefix>' notation, and gave it
a try, but all I could get was a segfault. It was dereferencing a NULL commit list. Fix below. With it, this example now works: $ mkdir .j; cd .j; touch f $ git-init; git-add f; git-commit -mc f; echo x >f; git-commit -md f $ git-diff -p :/c :/d diff --git a/f b/f index e69de29..587be6b 100644 --- a/f +++ b/f @@ -0,0 +1 @@ +x Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 31812d3d2..6b8b67b4d 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -605,7 +605,7 @@ static int handle_one_ref(const char *path,
int get_sha1_oneline(const char *prefix, unsigned char *sha1)
{
struct commit_list *list = NULL, *backup = NULL, *l;
- struct commit *commit;
+ struct commit *commit = NULL;
if (prefix[0] == '!') {
if (prefix[1] != '!')
@@ -617,8 +617,12 @@ int get_sha1_oneline(const char *prefix, unsigned char *sha1)
for_each_ref(handle_one_ref, &list);
for (l = list; l; l = l->next)
commit_list_insert(l->item, &backup);
- while ((commit = pop_most_recent_commit(&list, ONELINE_SEEN))) {
+ while (list) {
char *p;
+
+ commit = pop_most_recent_commit(&list, ONELINE_SEEN);
+ if (!commit)
+ break;
parse_object(commit->object.sha1);
if (!commit->buffer || !(p = strstr(commit->buffer, "\n\n")))
continue;