summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-03-03 19:55:48 +0200
committerVicent Marti <tanoku@gmail.com>2011-03-03 20:23:52 +0200
commit8f90ced5ed79b445509a5be190add4e76d5bae3f (patch)
treed2e2494a60a7f4938c51bd36c198f9028f3e2986
parent268bee3d4f54c2c2623a79cdc19151cda32c762f (diff)
downloadlibgit2-8f90ced5ed79b445509a5be190add4e76d5bae3f.tar.gz
Fix corner case in reference renaming
Renaming a packed reference should not pack another reference which happens to be in both loose and pack state.
-rw-r--r--src/refs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c
index 5bbc7770e..8e24ba80e 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -695,9 +695,18 @@ static int packed_remove_loose(git_repository *repo, git_vector *packing_list)
unsigned int i;
char full_path[GIT_PATH_MAX];
int error = GIT_SUCCESS;
+ git_reference *reference;
for (i = 0; i < packing_list->length; ++i) {
git_reference *ref = git_vector_get(packing_list, i);
+
+ /* Ensure the packed reference doesn't exist
+ * in a (more up-to-date?) state as a loose reference
+ */
+ reference = git_hashtable_lookup(ref->owner->references.loose_cache, ref->name);
+ if (reference != NULL)
+ continue;
+
git__joinpath(full_path, repo->path_repository, ref->name);
if (gitfo_exists(full_path) == GIT_SUCCESS &&