Skip to content

Commit 03b9533

Browse files
larsxschneidergitster
authored andcommitted
entry.c: update cache entry only for existing files
In 2841e8f ("convert: add "status=delayed" to filter process protocol", 2017-06-30) we taught the filter process protocol to delay responses. That means an external filter might answer in the first write_entry() call on a file that requires filtering "I got your request, but I can't answer right now. Ask again later!". As Git got no answer, we do not write anything to the filesystem. Consequently, the lstat() call in the finish block of the function writes garbage to the cache entry. The garbage is eventually overwritten when the filter answers with the final file content in a subsequent write_entry() call. Fix the brief time window of garbage in the cache entry by adding a special finish block that does nothing for delayed responses. The cache entry is written properly in a subsequent write_entry() call where the filter responds with the final file content. Reported-by: Jeff King <[email protected]> Signed-off-by: Lars Schneider <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2841e8f commit 03b9533

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

entry.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static int write_entry(struct cache_entry *ce,
290290
ce->name, new, size, &buf, dco);
291291
if (ret && string_list_has_string(&dco->paths, ce->name)) {
292292
free(new);
293-
goto finish;
293+
goto delayed;
294294
}
295295
} else
296296
ret = convert_to_working_tree(
@@ -346,6 +346,7 @@ static int write_entry(struct cache_entry *ce,
346346
ce->ce_flags |= CE_UPDATE_IN_BASE;
347347
state->istate->cache_changed |= CE_ENTRY_CHANGED;
348348
}
349+
delayed:
349350
return 0;
350351
}
351352

0 commit comments

Comments
 (0)