Merge branch 'js/gc-with-stale-symref' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 20 Oct 2015 22:22:41 +0000 (15:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Oct 2015 22:22:42 +0000 (15:22 -0700)
"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

1  2 
reachable.c
diff --cc reachable.c
index 9cff25b490f7ec7c5535647afe017326a6984520,4cfd0dec70cf29233b7374f806b92c76fc4dc39e..43616d49c7f88166d2fa2f009ca5b926d751ab0b
@@@ -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;
  
 -      object = parse_object_or_die(sha1, path);
+       if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
+               warning("symbolic ref is dangling: %s", path);
+               return 0;
+       }
++      object = parse_object_or_die(oid->hash, path);
        add_pending_object(revs, object, "");
  
        return 0;