summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Koegler <mkoegler@auto.tuwien.ac.at>2008-02-18 08:31:54 +0100
committerJunio C Hamano <gitster@pobox.com>2008-02-17 23:46:55 -0800
commitaffeef12fb2d10317fbcc7a866fbc3603cf16119 (patch)
tree61ce1a23d8259dc7f90778c7a0fd1b8898a7aa50
parent9886ea417b7da9722c95630b5980ac174e04c71c (diff)
downloadgit-affeef12fb2d10317fbcc7a866fbc3603cf16119.tar.gz
deref_tag: handle return value NULL
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin-show-ref.c3
-rw-r--r--merge-recursive.c2
-rw-r--r--sha1_name.c5
-rw-r--r--shallow.c2
-rw-r--r--upload-pack.c3
5 files changed, 12 insertions, 3 deletions
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 65051d14fd..a323633e29 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -86,6 +86,9 @@ match:
sha1_to_hex(sha1));
if (obj->type == OBJ_TAG) {
obj = deref_tag(obj, refname, 0);
+ if (!obj)
+ die("git-show-ref: bad tag at ref %s (%s)", refname,
+ sha1_to_hex(sha1));
hex = find_unique_abbrev(obj->sha1, abbrev);
printf("%s %s^{}\n", hex, refname);
}
diff --git a/merge-recursive.c b/merge-recursive.c
index dd52342539..55ef76f5a5 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1673,6 +1673,8 @@ static struct commit *get_ref(const char *ref)
if (get_sha1(ref, sha1))
die("Could not resolve ref '%s'", ref);
object = deref_tag(parse_object(sha1), ref, strlen(ref));
+ if (!object)
+ return NULL;
if (object->type == OBJ_TREE)
return make_virtual_commit((struct tree*)object,
better_branch_name(ref));
diff --git a/sha1_name.c b/sha1_name.c
index be8489e4e5..ed3c867d6a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -578,8 +578,11 @@ static int handle_one_ref(const char *path,
struct object *object = parse_object(sha1);
if (!object)
return 0;
- if (object->type == OBJ_TAG)
+ if (object->type == OBJ_TAG) {
object = deref_tag(object, path, strlen(path));
+ if (!object)
+ return 0;
+ }
if (object->type != OBJ_COMMIT)
return 0;
insert_by_date((struct commit *)object, list);
diff --git a/shallow.c b/shallow.c
index dbd9f5ad0a..212e62b77c 100644
--- a/shallow.c
+++ b/shallow.c
@@ -56,7 +56,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
if (i < heads->nr) {
commit = (struct commit *)
deref_tag(heads->objects[i++].item, NULL, 0);
- if (commit->object.type != OBJ_COMMIT) {
+ if (!commit || commit->object.type != OBJ_COMMIT) {
commit = NULL;
continue;
}
diff --git a/upload-pack.c b/upload-pack.c
index 51e3ec49d1..eaea9990e9 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -575,7 +575,8 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
}
if (o->type == OBJ_TAG) {
o = deref_tag(o, refname, 0);
- packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
+ if (o)
+ packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
}
return 0;
}