difftool: display the number of files in the diff queue in the prompt
When --prompt option is set, git-difftool displays a prompt for each modified file to be viewed in an external diff program. At that point, it could be useful to display a counter and the total number of files in the diff queue. Below is the current difftool prompt for the first of 5 modified files: Viewing: 'diff.c' Launch 'vimdiff' [Y/n]: Consider the modified prompt: Viewing (1/5): 'diff.c' Launch 'vimdiff' [Y/n]: The current GIT_EXTERNAL_DIFF mechanism does not tell the number of paths in the diff queue nor the current counter. To make this "counter/total" info available for GIT_EXTERNAL_DIFF programs without breaking existing ones by doing the following: - Keep track of the number of paths shown so far in diff_options; - Export two new environment variables from run_external_diff() to show the total number of paths (from diff_queue_struct) and the current value of the counter (from diff_options); and - Update git-difftool--helper to use these two environment variables. Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d2446dfd7f
commit
ee7fb0b1d4
@ -193,6 +193,19 @@ test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' '
|
||||
GIT_EXTERNAL_DIFF=echo git diff
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_EXTERNAL_DIFF path counter/total' '
|
||||
write_script external-diff.sh <<-\EOF &&
|
||||
echo $GIT_DIFF_PATH_COUNTER of $GIT_DIFF_PATH_TOTAL >>counter.txt
|
||||
EOF
|
||||
>counter.txt &&
|
||||
cat >expect <<-\EOF &&
|
||||
1 of 2
|
||||
2 of 2
|
||||
EOF
|
||||
GIT_EXTERNAL_DIFF=./external-diff.sh git diff &&
|
||||
test_cmp expect counter.txt
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_EXTERNAL_DIFF generates pretty paths' '
|
||||
touch file.ext &&
|
||||
git add file.ext &&
|
||||
|
Reference in New Issue
Block a user