Hi, I am working on a simple little feature which shows the "amended content" when running 'git-commit -v'. Currently, only the changes in the _entire_ commit are shown. In a large commit, it is difficult to spot a line or two that were amended. So, show just the amended content in a different section. I'm having trouble working with the internal diff API. 'rev' in the function here is used to diff against HEAD^1. I want to do the exact same thing, but against HEAD instead. The diff below works, but it is obviously an ugly hack that just resets 'rev' and duplicates all the initialization code. I added it here as a "proof of concept". What would be the cleaner way to do it? I tried a bunch of things, but they either end up in me hitting BUG("run_diff_index must be passed exactly one tree"); in 'run_diff_index', or just doing something completely unexpected/useless. Some help/pointers would be appreciated. Thanks. Regards, Pratyush Yadav -- 8< -- Signed-off-by: Pratyush Yadav <me@xxxxxxxxxxxxxxxxx> --- wt-status.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/wt-status.c b/wt-status.c index cc6f94504d..efa01c7ed6 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1086,6 +1086,27 @@ static void wt_longstatus_print_verbose(struct wt_status *s) rev.diffopt.b_prefix = "w/"; run_diff_files(&rev, 0); } + + if (s->amend) { + repo_init_revisions(s->repo, &rev, NULL); + rev.diffopt.flags.allow_textconv = 1; + rev.diffopt.ita_invisible_in_index = 1; + + memset(&opt, 0, sizeof(opt)); + opt.def = "HEAD"; + setup_revisions(0, NULL, &rev, &opt); + + rev.diffopt.output_format |= DIFF_FORMAT_PATCH; + rev.diffopt.detect_rename = s->detect_rename >= 0 ? s->detect_rename : rev.diffopt.detect_rename; + rev.diffopt.rename_limit = s->rename_limit >= 0 ? s->rename_limit : rev.diffopt.rename_limit; + rev.diffopt.rename_score = s->rename_score >= 0 ? s->rename_score : rev.diffopt.rename_score; + rev.diffopt.file = s->fp; + rev.diffopt.close_file = 0; + rev.diffopt.use_color = 0; + status_printf_ln(s, c, "Changes to amend:\n"); + + run_diff_index(&rev, 1); + } } static void wt_longstatus_print_tracking(struct wt_status *s) -- 2.24.0