From: Junio C Hamano Date: Tue, 20 Oct 2015 22:22:41 +0000 (-0700) Subject: Merge branch 'js/gc-with-stale-symref' into maint X-Git-Tag: v2.6.3~31 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b05c2f9ed48adfd9670b28ecdd5c55a4e4698704 Merge branch 'js/gc-with-stale-symref' into maint "git gc" used to barf when a symbolic ref has gone dangling (e.g. the branch that used to be your upstream's default when you cloned from it is now gone, and you did "fetch --prune"). * js/gc-with-stale-symref: pack-objects: do not get distracted by broken symrefs gc: demonstrate failure with stale remote HEAD --- b05c2f9ed48adfd9670b28ecdd5c55a4e4698704 diff --cc reachable.c index 9cff25b490,4cfd0dec70..43616d49c7 --- a/reachable.c +++ b/reachable.c @@@ -22,12 -22,17 +22,18 @@@ static void update_progress(struct conn display_progress(cp->progress, cp->count); } -static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int add_one_ref(const char *path, const struct object_id *oid, + int flag, void *cb_data) { - struct object *object = parse_object_or_die(oid->hash, path); struct rev_info *revs = (struct rev_info *)cb_data; + struct object *object; + if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) { + warning("symbolic ref is dangling: %s", path); + return 0; + } + - object = parse_object_or_die(sha1, path); ++ object = parse_object_or_die(oid->hash, path); add_pending_object(revs, object, ""); return 0;