Skip to content

Commit

Permalink
ref-log: fix D/F conflict coming from deleted refs.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Oct 19, 2006
1 parent a9cb3c6 commit 3b463c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,18 @@ static int log_ref_write(struct ref_lock *lock,
if (logfd < 0) {
if (!(oflags & O_CREAT) && errno == ENOENT)
return 0;
return error("Unable to append to %s: %s",
lock->log_file, strerror(errno));

if ((oflags & O_CREAT) && errno == EISDIR) {
if (remove_empty_directories(lock->log_file)) {
return error("There are still logs under '%s'",
lock->log_file);
}
logfd = open(lock->log_file, oflags, 0666);
}

if (logfd < 0)
return error("Unable to append to %s: %s",
lock->log_file, strerror(errno));
}

committer = git_committer_info(1);
Expand Down
2 changes: 2 additions & 0 deletions t/t3210-pack-refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ semantic is still the same.
'
. ./test-lib.sh

echo '[core] logallrefupdates = true' >>.git/config

test_expect_success \
'prepare a trivial repository' \
'echo Hello > A &&
Expand Down

0 comments on commit 3b463c3

Please sign in to comment.