aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-04-23 15:05:56 -0700
committerJunio C Hamano <gitster@pobox.com>2024-04-23 15:05:56 -0700
commit5b7877482082698a730f1045c78cf90af544ab6c (patch)
tree69605e75f7233186df9301ba4a561e0767e15dc5
parent10f1281498467654abdb13c6c7c7b23af4b97aeb (diff)
parent8198993c817b6c3b42f91c7345469c113c6eeabc (diff)
Merge branch 'pk/bisect-use-show'
When "git bisect" reports the commit it determined to be the culprit, we used to show it in a format that does not honor common UI tweaks, like log.date and log.decorate. The code has been taught to use "git show" to follow more customizations. * pk/bisect-use-show: bisect: report the found commit with "show"
-rw-r--r--bisect.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/bisect.c b/bisect.c
index 60aae2fe50..29aae879b8 100644
--- a/bisect.c
+++ b/bisect.c
@@ -946,23 +946,32 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r,
}
/*
- * This does "git diff-tree --pretty COMMIT" without one fork+exec.
+ * Display a commit summary to the user.
*/
-static void show_diff_tree(struct repository *r,
- const char *prefix,
- struct commit *commit)
+static void show_commit(struct commit *commit)
{
- const char *argv[] = {
- "diff-tree", "--pretty", "--stat", "--summary", "--cc", NULL
- };
- struct rev_info opt;
-
- git_config(git_diff_ui_config, NULL);
- repo_init_revisions(r, &opt, prefix);
+ struct child_process show = CHILD_PROCESS_INIT;
- setup_revisions(ARRAY_SIZE(argv) - 1, argv, &opt, NULL);
- log_tree_commit(&opt, commit);
- release_revisions(&opt);
+ /*
+ * Call git show with --no-pager, as it would otherwise
+ * paginate the "git show" output only, not the output
+ * from bisect_next_all(); this can be fixed by moving
+ * it into a --format parameter, but that would override
+ * the user's default options for "git show", which we
+ * are trying to honour.
+ */
+ strvec_pushl(&show.args,
+ "--no-pager",
+ "show",
+ "--stat",
+ "--summary",
+ "--no-abbrev-commit",
+ "--diff-merges=first-parent",
+ oid_to_hex(&commit->object.oid), NULL);
+ show.git_cmd = 1;
+ if (run_command(&show))
+ die(_("unable to start 'show' for object '%s'"),
+ oid_to_hex(&commit->object.oid));
}
/*
@@ -1079,7 +1088,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
term_bad);
- show_diff_tree(r, prefix, revs.commits->item);
+ show_commit(revs.commits->item);
/*
* This means the bisection process succeeded.
* Using BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND (-10)