From ee7fb0b1d433cbb433d2ed5cd9d8738023836b27 Mon Sep 17 00:00:00 2001 From: Zoltan Klinger Date: Fri, 6 Dec 2013 10:38:46 +1100 Subject: 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 Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index b00ed95dba..7ef36b9482 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -40,7 +40,8 @@ launch_merge_tool () { # the user with the real $MERGED name before launching $merge_tool. if should_prompt then - printf "\nViewing: '%s'\n" "$MERGED" + printf "\nViewing (%s/%s): '%s'\n" "$GIT_DIFF_PATH_COUNTER" \ + "$GIT_DIFF_PATH_TOTAL" "$MERGED" if use_ext_cmd then printf "Launch '%s' [Y/n]: " \ -- cgit v1.2.3