Message ID | pull.825.v3.git.1609981745668.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 80f5a16798b7ff224aeab4a6b6e3627446071345 |
Headers | show |
Series | [v3] mergetool--lib: fix '--tool-help' to correctly show available tools | expand |
Le 2021-01-06 à 20:09, Philippe Blain via GitGitGadget a écrit : > From: Philippe Blain <levraiphilippeblain@gmail.com> > > ... > --- > Fix regression in 'git {diff,merge}tool --tool-help' > > Changes since v1: > > * Changed commit authorship (v1 sent with wrong identity). > > v1: I went with Johannes' suggestion finally because upon further > inspection, René's patch for some reason (I did not debug further) > caused to code to never reach 'any_shown=yes' in show_tool_help, > therefore changing the output of the command. > > I guess it's too late for inclusion in 2.30... Forgot to summarize changes since v2: - rewrote the description of the symptom of the bug to reflect what was really happening - changed the test to not rely on hard-coding the number of tools, and just checking a few known tools are shown instead
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh index 7225abd8112..78f3647ed97 100644 --- a/git-mergetool--lib.sh +++ b/git-mergetool--lib.sh @@ -46,9 +46,11 @@ show_tool_names () { while read scriptname do setup_tool "$scriptname" 2>/dev/null - variants="$variants$(list_tool_variants)\n" + # We need an actual line feed here + variants="$variants +$(list_tool_variants)" done - variants="$(echo "$variants" | sort | uniq)" + variants="$(echo "$variants" | sort -u)" for toolname in $variants do diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index 70afdd06fa7..6ac75b5d4c0 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -828,4 +828,15 @@ test_expect_success 'mergetool -Oorder-file is honored' ' test_cmp expect actual ' +test_expect_success 'mergetool --tool-help shows recognized tools' ' + # Check a few known tools are correctly shown + git mergetool --tool-help >mergetools && + grep vimdiff mergetools && + grep vimdiff3 mergetools && + grep gvimdiff2 mergetools && + grep araxis mergetools && + grep xxdiff mergetools && + grep meld mergetools +' + test_done