Skip to content

Commit dbf92c7

Browse files
derrickstoleedscho
authored andcommitted
gvfs-helper: skip collision check for loose objects
When we are installing a loose object, finalize_object_file() first checks to see if the contents match what already exists in a loose object file of the target name. However, this doesn't check if the target is valid, it assumes the target is valid. However, in the case of a power outage or something like that, the file may be corrupt (for example: all NUL bytes). That is a common occurrence when we are needing to install a loose object _again_: we don't think we have it already so any copy that exists is probably bogus. Use the flagged version with FOF_SKIP_COLLISION_CHECK to avoid these types of errors, as seen in GitHub issue microsoft#837. Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent ad6f04c commit dbf92c7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

gvfs-helper.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,16 @@ static void install_loose(struct gh__request_params *params,
24592459
goto cleanup;
24602460
}
24612461

2462-
if (finalize_object_file(the_repository, tmp_path.buf, loose_path.buf)) {
2462+
/*
2463+
* We skip collision check because the loose object in the target
2464+
* may be corrupt and we should override it with a better value
2465+
* instead of failing at this point.
2466+
*
2467+
* See https://github.com/microsoft/git/issues/837
2468+
*/
2469+
if (finalize_object_file_flags(the_repository,
2470+
tmp_path.buf, loose_path.buf,
2471+
FOF_SKIP_COLLISION_CHECK)) {
24632472
unlink(tmp_path.buf);
24642473
strbuf_addf(&status->error_message,
24652474
"could not install loose object '%s'",

0 commit comments

Comments
 (0)