Skip to content

Commit

Permalink
Merge branch 'js/gc-with-stale-symref' into maint
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
gitster committed Oct 20, 2015
2 parents 3b7c49e + 14886b4 commit b05c2f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion reachable.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ static void update_progress(struct connectivity_progress *cp)
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(oid->hash, path);
add_pending_object(revs, object, "");

return 0;
Expand Down
13 changes: 13 additions & 0 deletions t/t6500-gc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,17 @@ test_expect_success 'gc -h with invalid configuration' '
test_i18ngrep "[Uu]sage" broken/usage
'

test_expect_success 'gc is not aborted due to a stale symref' '
git init remote &&
(
cd remote &&
test_commit initial &&
git clone . ../client &&
git branch -m develop &&
cd ../client &&
git fetch --prune &&
git gc
)
'

test_done

0 comments on commit b05c2f9

Please sign in to comment.