Skip to content

Commit b37a562

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
Add support for negative refs
You can remove a ref that is packed two different ways: either simply repack all the refs without that one, or create a loose ref that has the magic all-zero SHA1. This also adds back the test that a ref actually has the object it points to. Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e1e22e3 commit b37a562

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

refs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ static int do_for_each_ref(const char *base, int (*fn)(const char *path, const u
280280
}
281281
if (strncmp(base, entry->name, trim))
282282
continue;
283+
if (is_null_sha1(entry->sha1))
284+
continue;
285+
if (!has_sha1_file(entry->sha1)) {
286+
error("%s does not point to a valid object!", entry->name);
287+
continue;
288+
}
283289
retval = fn(entry->name + trim, entry->sha1);
284290
if (retval)
285291
return retval;

0 commit comments

Comments
 (0)