aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/describe.c2
-rw-r--r--builtin/pack-objects.c1
-rw-r--r--builtin/show-ref.c23
-rw-r--r--refs.c2
4 files changed, 6 insertions, 22 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 9f63067f5..94b06069a 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -144,7 +144,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
if (!all && !might_be_tag)
return 0;
- if (!peel_ref(path, peeled) && !is_null_sha1(peeled)) {
+ if (!peel_ref(path, peeled)) {
is_tag = !!hashcmp(sha1, peeled);
} else {
hashcpy(peeled, sha1);
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 782e7d0c3..035ed3b2d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2033,7 +2033,6 @@ static int add_ref_tag(const char *path, const unsigned char *sha1, int flag, vo
if (!prefixcmp(path, "refs/tags/") && /* is a tag? */
!peel_ref(path, peeled) && /* peelable? */
- !is_null_sha1(peeled) && /* annotated tag? */
locate_object_entry(peeled)) /* object packed? */
add_object_entry(sha1, OBJ_TAG, NULL, 0);
return 0;
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 391166190..aaac2b22f 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -28,7 +28,6 @@ static void show_one(const char *refname, const unsigned char *sha1)
static int show_ref(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
{
- struct object *obj;
const char *hex;
unsigned char peeled[20];
@@ -79,25 +78,9 @@ match:
if (!deref_tags)
return 0;
- if ((flag & REF_ISPACKED) && !peel_ref(refname, peeled)) {
- if (!is_null_sha1(peeled)) {
- hex = find_unique_abbrev(peeled, abbrev);
- printf("%s %s^{}\n", hex, refname);
- }
- }
- else {
- obj = parse_object(sha1);
- if (!obj)
- die("git show-ref: bad ref %s (%s)", refname,
- 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);
- }
+ if (!peel_ref(refname, peeled)) {
+ hex = find_unique_abbrev(peeled, abbrev);
+ printf("%s %s^{}\n", hex, refname);
}
return 0;
}
diff --git a/refs.c b/refs.c
index 0a916a0c2..f672ad93a 100644
--- a/refs.c
+++ b/refs.c
@@ -1202,6 +1202,8 @@ int peel_ref(const char *refname, unsigned char *sha1)
if (current_ref && (current_ref->name == refname
|| !strcmp(current_ref->name, refname))) {
if (current_ref->flag & REF_KNOWS_PEELED) {
+ if (is_null_sha1(current_ref->u.value.peeled))
+ return -1;
hashcpy(sha1, current_ref->u.value.peeled);
return 0;
}