summaryrefslogtreecommitdiff
path: root/refs/files-backend.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-05-16 21:05:24 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-05-16 21:05:24 +0900
commit16f91451fae2f3b12cbbc372bd6a5104e8109076 (patch)
tree1f2f70f25c886f8bddcf923e65952bd57b15c21e /refs/files-backend.c
parentMerge branch 'lh/maintenance-leakfix' (diff)
parentrefs: cleanup directories when deleting packed ref (diff)
downloadtgif-16f91451fae2f3b12cbbc372bd6a5104e8109076.tar.xz
Merge branch 'wc/packed-ref-removal-cleanup'
When "git update-ref -d" removes a ref that is packed, it left empty directories under $GIT_DIR/refs/ for * wc/packed-ref-removal-cleanup: refs: cleanup directories when deleting packed ref
Diffstat (limited to 'refs/files-backend.c')
-rw-r--r--refs/files-backend.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 3f29f8c143..677b7e4cdd 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -45,10 +45,10 @@
#define REF_UPDATE_VIA_HEAD (1 << 8)
/*
- * Used as a flag in ref_update::flags when the loose reference has
- * been deleted.
+ * Used as a flag in ref_update::flags when a reference has been
+ * deleted and the ref's parent directories may need cleanup.
*/
-#define REF_DELETED_LOOSE (1 << 9)
+#define REF_DELETED_RMDIR (1 << 9)
struct ref_lock {
char *ref_name;
@@ -2852,6 +2852,7 @@ static int files_transaction_finish(struct ref_store *ref_store,
if (update->flags & REF_DELETING &&
!(update->flags & REF_LOG_ONLY)) {
+ update->flags |= REF_DELETED_RMDIR;
if (!(update->type & REF_ISPACKED) ||
update->type & REF_ISSYMREF) {
/* It is a loose reference. */
@@ -2861,7 +2862,6 @@ static int files_transaction_finish(struct ref_store *ref_store,
ret = TRANSACTION_GENERIC_ERROR;
goto cleanup;
}
- update->flags |= REF_DELETED_LOOSE;
}
}
}
@@ -2874,9 +2874,9 @@ cleanup:
for (i = 0; i < transaction->nr; i++) {
struct ref_update *update = transaction->updates[i];
- if (update->flags & REF_DELETED_LOOSE) {
+ if (update->flags & REF_DELETED_RMDIR) {
/*
- * The loose reference was deleted. Delete any
+ * The reference was deleted. Delete any
* empty parent directories. (Note that this
* can only work because we have already
* removed the lockfile.)