8000 Ensure that commits don't fail if committing content that already exists · libgit2/libgit2@1db9d2c · GitHub
[go: up one dir, main page]

Skip to content

Commit 1db9d2c

Browse files
committed
Ensure that commits don't fail if committing content that already exists
Making a commit that results in a blob that already exists in the ODB (i.e. committing something, then making a revert commit) will result in us trying to p_rename -> MoveFileExW a temp file into the existing ODB entry. Despite the MOVEFILE_REPLACE_EXISTING flag is passed in, Win32 does not care and fails it with STATUS_ACCESS_DENIED. To fix this, we p_unlink the ODB entry before attempting to rename it. This call will typically fail, but we don't care, we'll let the p_rename fail if the file actually does exist and we couldn't delete it for some reason (ACLs, etc).
1 parent 34ab819 commit 1db9d2c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/filebuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ int git_filebuf_commit(git_filebuf *file, mode_t mode)
291291
goto cleanup;
292292
}
293293

294+
p_unlink(file->path_original);
295+
294296
error = p_rename(file->path_lock, file->path_original);
295297

296298
cleanup:

0 commit comments

Comments
 (0)
0