summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-01-02 18:39:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-01-02 18:39:37 (GMT)
commit229096a591cb1cd9b309feca0b786be0a0adbe04 (patch)
treebe912c43113e4840b6e1b4d86b066870c0729257 /refs.c
parent77a5efb4eb71d01d010dbcb859516aa232971d28 (diff)
parentb3f1280ec740d8012d18e870a50a5ff76c4e3c42 (diff)
downloadgit-229096a591cb1cd9b309feca0b786be0a0adbe04.zip
git-229096a591cb1cd9b309feca0b786be0a0adbe04.tar.gz
git-229096a591cb1cd9b309feca0b786be0a0adbe04.tar.bz2
Merge branch 'jk/repack-ref-racefix'
"git pack-refs" that ran in parallel to another process that created new refs had a nasty race. * jk/repack-ref-racefix: refs: do not use cached refs in repack_without_ref
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index 6cec1c8..541fec2 100644
--- a/refs.c
+++ b/refs.c
@@ -1744,7 +1744,8 @@ static struct lock_file packlock;
static int repack_without_ref(const char *refname)
{
struct repack_without_ref_sb data;
- struct ref_dir *packed = get_packed_refs(get_ref_cache(NULL));
+ struct ref_cache *refs = get_ref_cache(NULL);
+ struct ref_dir *packed = get_packed_refs(refs);
if (find_ref(packed, refname) == NULL)
return 0;
data.refname = refname;
@@ -1753,6 +1754,8 @@ static int repack_without_ref(const char *refname)
unable_to_lock_error(git_path("packed-refs"), errno);
return error("cannot delete '%s' from packed refs", refname);
}
+ clear_packed_ref_cache(refs);
+ packed = get_packed_refs(refs);
do_for_each_ref_in_dir(packed, 0, "", repack_without_ref_fn, 0, 0, &data);
return commit_lock_file(&packlock);
}