diff options
| author | Elijah Newren <newren@gmail.com> | 2019-08-17 11:41:40 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2019-08-19 10:08:04 -0700 |
| commit | e95e481f9e6e4dfe62380ccc8a47acf446403a94 (patch) | |
| tree | 9194fcc0afaee920b3a521837946de0f4ec4edc6 /builtin/commit-graph.c | |
| parent | merge-recursive: comment and reorder the merge_options fields (diff) | |
| download | git-e95e481f9e6e4dfe62380ccc8a47acf446403a94.tar.gz git-e95e481f9e6e4dfe62380ccc8a47acf446403a94.zip | |
merge-recursive: avoid losing output and leaking memory holding that output
If opt->buffer_output is less than 2, then merge_trees(),
merge_recursive(), and merge_recursive_generic() are all supposed to
flush the opt->obuf output buffer to stdout and release any memory it
holds. merge_trees() did not do this. Move the logic that handles this
for merge_recursive_internal() to merge_finalize() so that all three
methods handle this requirement.
Note that this bug didn't cause any problems currently, because there
are only two callers of merge_trees() right now (a git grep for
'merge_trees(' is misleading because builtin/merge-tree.c also defines a
'merge_tree' function that is unrelated), and only one of those is
called with buffer_output less than 2 (builtin/checkout.c), but it set
opt->verbosity to 0, for which there is only currently one non-error
message that would be shown: "Already up to date!". However, that one
message can only occur when the merge is utterly trivial (the merge base
tree exactly matches the merge tree), and builtin/checkout.c already
attempts a trivial merge via unpack_trees() before falling back to
merge_trees().
Also, if opt->buffer_output is 2, then the caller is responsible to
handle showing any output in opt->obuf and for free'ing it. This
requirement might be easy to overlook, so add a comment to
merge-recursive.h pointing it out. (There are currently two callers
that set buffer_output to 2, both in sequencer.c, and both of which
handle this correctly.)
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit-graph.c')
0 files changed, 0 insertions, 0 deletions
