ref-log: fix D/F conflict coming from deleted refs.
After deleting a branch l/k, you should be able to create a branch l. Earlier we added remove_empty_directories() on the ref creation side to remove leftover .git/refs/l directory but we also need a matching code to remove .git/logs/refs/l directory. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Oct 19, 2006 at 01:28 UTC
3b463c3f02f83ef0bce2d5daa193459418e5258f
2 files changed
+14
-2
refs.c
+12
-2
@@ -733,8 +733,18 @@ static int log_ref_write(struct ref_lock *lock,
733
if (logfd < 0) {
734
if (!(oflags & O_CREAT) && errno == ENOENT)
735
return 0;
736
- return error("Unable to append to %s: %s",
737
- lock->log_file, strerror(errno));
736
+
737
+ if ((oflags & O_CREAT) && errno == EISDIR) {
738
+ if (remove_empty_directories(lock->log_file)) {
739
+ return error("There are still logs under '%s'",
740
+ lock->log_file);
741
+ }
742
+ logfd = open(lock->log_file, oflags, 0666);
743
+ }
744
+
745
+ if (logfd < 0)
746
+ return error("Unable to append to %s: %s",
747
+ lock->log_file, strerror(errno));
748
}
749
750
committer = git_committer_info(1);
t/t3210-pack-refs.sh
+2
@@ -11,6 +11,8 @@ semantic is still the same.
11
'
12
. ./test-lib.sh
13
14
+echo '[core] logallrefupdates = true' >>.git/config
15
+
16
test_expect_success \
17
'prepare a trivial repository' \
18
'echo Hello > A &&