Skip to content

Commit b02be8b

Browse files
peffgitster
authored andcommitted
bisect: make diff-tree output prettier
After completing a bisection, we print out the commit we found using an internal version of diff-tree. The result is aesthetically lacking: - it shows a raw diff, which is generally less informative for human readers than "--stat --summary" (which we already decided was nice for humans in format-patch's output). - by not abbreviating hashes, the result is likely to wrap on most people's terminals - we don't use "-r", so if the commit touched files in a directory, you only get to see the top-level directory mentioned - we don't specify "--cc" or similar, so merges print nothing (not even the commit message!) Even though bisect might be driven by scripts, there's no reason to consider this part of the output as machine-readable (if anything, the initial "$hash is the first bad commit" might be parsed, but we won't touch that here). Let's make it prettier and more informative for a human reading the output. While we're tweaking the options, let's also switch to using the diff "ui" config. If we're accepting that this is human-readable output, then we should respect the user's options for how to display it. Note that we have to touch a few tests in t6030. These check bisection in a corrupted repository (it's missing a subtree). They didn't fail with the previous code, because it didn't actually recurse far enough in the diff to find the broken tree. But now we'll see the corruption and complain. Adjusting the tests to expect the die() is the best fix. We still confirm that we're able to bisect within the broken repo. And we'll still print "$hash is the first bad commit" as usual before dying; showing that is a reasonable outcome in a corrupt repository (and was what might happen already, if the root tree was corrupt). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 40ae3d3 commit b02be8b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

bisect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,11 +897,11 @@ static void show_diff_tree(struct repository *r,
897897
struct commit *commit)
898898
{
899899
const char *argv[] = {
900-
"diff-tree", "--pretty", "--no-abbrev", "--raw", NULL
900+
"diff-tree", "--pretty", "--stat", "--summary", "--cc", NULL
901901
};
902902
struct rev_info opt;
903903

904-
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
904+
git_config(git_diff_ui_config, NULL);
905905
repo_init_revisions(r, &opt, prefix);
906906

907907
setup_revisions(ARRAY_SIZE(argv) - 1, argv, &opt, NULL);

t/t6030-bisect-porcelain.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ test_expect_success 'bisect: --no-checkout - target in breakage' '
681681
check_same BROKEN_HASH6 BISECT_HEAD &&
682682
git bisect bad BISECT_HEAD &&
683683
check_same BROKEN_HASH5 BISECT_HEAD &&
684-
git bisect good BISECT_HEAD &&
684+
test_must_fail git bisect good BISECT_HEAD &&
685685
check_same BROKEN_HASH6 bisect/bad &&
686686
git bisect reset
687687
'
@@ -692,7 +692,7 @@ test_expect_success 'bisect: --no-checkout - target after breakage' '
692692
check_same BROKEN_HASH6 BISECT_HEAD &&
693693
git bisect good BISECT_HEAD &&
694694
check_same BROKEN_HASH8 BISECT_HEAD &&
695-
git bisect good BISECT_HEAD &&
695+
test_must_fail git bisect good BISECT_HEAD &&
696696
check_same BROKEN_HASH9 bisect/bad &&
697697
git bisect reset
698698
'
@@ -701,7 +701,7 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
701701
git bisect reset &&
702702
git checkout broken &&
703703
git bisect start broken master --no-checkout &&
704-
git bisect run \"\$SHELL_PATH\" -c '
704+
test_must_fail git bisect run \"\$SHELL_PATH\" -c '
705705
GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
706706
git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
707707
git pack-objects --stdout >/dev/null < tmp.\$\$

0 commit comments

Comments
 (0)