Skip to content

Commit a1c6d7c

Browse files
jonathantanmygitster
authored andcommitted
fetch-pack: restore save_commit_buffer after use
In fetch-pack, the global variable save_commit_buffer is set to 0, but not restored to its original value after use. In particular, if show_log() (in log-tree.c) is invoked after fetch_pack() in the same process, show_log() will return before printing out the commit message (because the invocation to get_cached_commit_buffer() returns NULL, because the commit buffer was not saved). I discovered this when attempting to run "git log -S" in a partial clone, triggering the case where revision walking lazily loads missing objects. Therefore, restore save_commit_buffer to its original value after use. An alternative to solve the problem I had is to replace get_cached_commit_buffer() with get_commit_buffer(). That invocation was introduced in commit a97934d ("use get_cached_commit_buffer where appropriate", 2014-06-13) to replace "commit->buffer" introduced in commit 3131b71 ("Add "--show-all" revision walker flag for debugging", 2008-02-13). In the latter commit, the commit author seems to be deciding between not showing an unparsed commit at all and showing an unparsed commit without the message (which is what the commit does), and did not mention parsing the unparsed commit, so I prefer to preserve the existing behavior. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c0c578b commit a1c6d7c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fetch-pack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ static int everything_local(struct fetch_pack_args *args,
717717
{
718718
struct ref *ref;
719719
int retval;
720+
int old_save_commit_buffer = save_commit_buffer;
720721
timestamp_t cutoff = 0;
721722

722723
save_commit_buffer = 0;
@@ -786,6 +787,9 @@ static int everything_local(struct fetch_pack_args *args,
786787
print_verbose(args, _("already have %s (%s)"), oid_to_hex(remote),
787788
ref->name);
788789
}
790+
791+
save_commit_buffer = old_save_commit_buffer;
792+
789793
return retval;
790794
}
791795

0 commit comments

Comments
 (0)