diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2011-12-12 06:38:58 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-12 09:08:57 -0800 |
commit | 84c14bbcacc53a318a65dc3c59e4aa319463184a (patch) | |
tree | 0a6fffe1bc8d4a2e5841bc70578997f350069e57 | |
parent | 6a871b0a34230a977534d341b2e10182a0565b19 (diff) | |
download | git-mh/ref-api-rest.tar.gz |
repack_without_ref(): call clear_packed_ref_cache()mh/ref-api-rest
Call clear_packed_ref_cache() from repack_without_ref(). This is a
more logical place to call it than from delete_ref(). Also,
repack_without_ref() is smart enough to know that it doesn't have to
invalidate the cache if the reference was not found among the packed
refs.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | refs.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1736,7 +1736,9 @@ static struct lock_file packlock; static int repack_without_ref(const char *refname) { struct repack_without_ref_sb data; - struct ref_entry *packed = get_packed_refs(get_ref_cache(NULL)); + struct ref_cache *refs = get_ref_cache(NULL); + struct ref_entry *packed = get_packed_refs(refs); + if (find_ref(packed, refname) == NULL) return 0; data.refname = refname; @@ -1746,6 +1748,7 @@ static int repack_without_ref(const char *refname) return error("cannot delete '%s' from packed refs", refname); } do_for_each_ref_in_dir(packed, 0, "", repack_without_ref_fn, 0, 0, &data); + clear_packed_ref_cache(refs); return commit_lock_file(&packlock); } @@ -1774,6 +1777,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt) if (!(delopt & REF_NODEREF)) lock->lk->filename[i] = '.'; + clear_loose_ref_cache(get_ref_cache(NULL)); } /* removing the loose one could have resurrected an earlier * packed one. Also, if it was not loose we need to repack @@ -1782,7 +1786,6 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt) ret |= repack_without_ref(refname); unlink_or_warn(git_path("logs/%s", lock->ref_name)); - invalidate_ref_cache(NULL); unlock_ref(lock); return ret; } |