difftool: print list of valid tools with '--tool-help'
PATCH v9 9/9 difftool: print list of valid tools with '--tool-help'
Since bc7a96a (mergetool--lib: Refactor tools into separate files, 2011-08-18), it is possible to add a new diff tool by creating a simple script in the '$(git --exec-path)/mergetools' directory. Updating the difftool help text is still a manual process, and the documentation can easily go out of sync.
This commit teaches difftool the '--tool-help' option, which:
- Reads the list of valid tools from 'mergetools/*'
- Determines which of them are actually installed
- Determines which are capable of diffing (i.e. not just a merge tool)
- Prints the resulting list for the user
---
This replaces 9/9 in the previous version of the series.
Changes in v9:
- File::Find now ignores sub-directories of '$(git --exec-path)/mergetools'.
- Moved all tool script filter logic into a separate function.
- Filter now rejects anything other than simple files found in 'mergetools'.
Please note that the tool script files are not 'chmod +x', so we cannot test for it.
These changes were suggested during review of the previous version by Junio Hamano on the Git developers list [1].
[1]: http://thread.gmane.org/gmane.comp.version-control.git/194158/focus=194181
Documentation/git-difftool.txt | 11 ++++---- git-difftool.perl | 55 ++++++++++++++++++++++++++++++++++++++-- t/t7800-difftool.sh | 5 ++++ 3 files changed, 64 insertions(+), 7 deletions(-)
Documentation/git-difftool.txt +6 -5
@@ -36,11 +36,9 @@ OPTIONS -t <tool>:: --tool=<tool>:: - Use the diff tool specified by <tool>. - Valid diff tools are: - araxis, bc3, deltawalker, diffuse, emerge, ecmerge, gvimdiff, - kdiff3, kompare, meld, opendiff, p4merge, tkdiff, vimdiff and - xxdiff. + Use the diff tool specified by <tool>. Valid values include + emerge, kompare, meld, and vimdiff. Run `git difftool --tool-help` + for the list of valid <tool> settings. + If a diff tool is not specified, 'git difftool' will use the configuration variable `diff.tool`. If the
@@ -68,6 +66,9 @@ of the diff post-image. `$MERGED` is the name of the file which is being compared. `$BASE` is provided for compatibility with custom merge tool commands and has the same value as `$MERGED`. +--tool-help:: + Print a list of diff tools that may be used with `--tool`. + -x <command>:: --extcmd=<command>:: Specify a custom command for viewing diffs.
git-difftool.perl +53 -2
96 lines not on this page · raw message
t/t7800-difftool.sh +5 -0
@@ -319,6 +319,11 @@ test_expect_success PERL 'say no to the second file' ' echo "$diff" | stdin_doesnot_contain br2 ' +test_expect_success PERL 'difftool --tool-help' ' + tool_help=$(git difftool --tool-help) && + echo "$tool_help" | stdin_contains tool +' + test_expect_success PERL 'setup change in subdirectory' ' git checkout master && mkdir sub &&
Signature · 1 line
1.7.10.rc2.21.g42bdb