mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-04 01:41:43 +00:00
Don't overwrite existing objects
It's redundant to do this (git doesn't) and Windows doesn't allow us to overwrite a read-only file (which objects are). Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
This commit is contained in:
parent
2cbca8b06c
commit
472d4d858b
@ -670,6 +670,17 @@ static int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
|
||||
return git__rethrow(error, "Failed to write loose backend");
|
||||
|
||||
stream->finished = 1;
|
||||
|
||||
/*
|
||||
* Don't try to add an existing object to the repository. This
|
||||
* is what git does and allows us to sidestep the fact that
|
||||
* we're not allowed to overwrite a read-only file on Windows.
|
||||
*/
|
||||
if (git_futils_exists(final_path) == GIT_SUCCESS) {
|
||||
git_filebuf_cleanup(&stream->fbuf);
|
||||
return GIT_SUCCESS;
|
||||
}
|
||||
|
||||
return git_filebuf_commit_at(&stream->fbuf, final_path, GIT_OBJECT_FILE_MODE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user