Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff-tree: fix crash when used with --remerge-diff
When using "git-diff-tree" to get the tree diff for merge commits with the diff format set to `remerge`, a bug is triggered as shown below: $ git diff-tree -r --remerge-diff 363337e 363337e BUG: log-tree.c:1006: did a remerge diff without remerge_objdir?!? This bug is reported by `log-tree.c:do_remerge_diff`, where a bug check added in commit 7b90ab4 (log: clean unneeded objects during log --remerge-diff, 2022-02-02) detects the absence of `remerge_objdir` when attempting to clean up temporary objects generated during the remerge process. After some further digging, I find that the remerge-related diff options were introduced in db757e8 (show, log: provide a --remerge-diff capability, 2022-02-02), which also affect the setup of `rev_info` for "git-diff-tree", but were not accounted for in the original implementation (inferred from the commit message). Elijah Newren (author of the remerge diff feature) also notes that other callers of `log-tree.c:log_tree_commit` (which is the only caller of above mentioned `log-tree.c:do_remerge_diff`) also exist, but: builtin/am.c: manually sets all flags; remerge_diff is not among them sequencer.c: manually sets all flags; remerge_diff is not among them so "builtin/diff-tree.c" really is the only caller that was overlooked when remerge-diff functionality was added. This commit fixes the bug by adding the setup logic for `remerge_objdir` in "builtin/diff-tree.c", mirroring the logic in `builtin/log.c:cmd_log_walk_no_free`. And a final cleanup for `remerge_objdir` is also included. Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
- Loading branch information