git difftool: how to measure progress, that is number of files diff'ed and to diff?

636 views Asked by At

I know I can use git difftool with the --dir-diff option in order to compare all the files in one go.

But using difftool with prompt has its use (for a reasonably small number of files to diff), especially since git 1.7.8, where you can skip a file.

However, that prompt doesn't show how many files are in the diff queue or how many has already been diff'ed.
How would you display that information in the difftool prompt?

1

There are 1 answers

2
VonC On BEST ANSWER

With git alone, you can't (git 1.8.x).
But that feature is coming (in Git 1.9/2.0 Q1 2014)

See commit 6904f9a from Zoltan Klinger's patch.

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:

  1. Modify run_external_diff() function in diff.c to set one environment variable for a counter and one for the total number of files in the diff queue.
    The size of the diff queue is already available in the diff_queue_struct.
    For the counter define a new variable in the diff_options struct and reset it to zero in diff_setup_done() function.
    Pre-increment the counter inside the run_external_diff() function.
  2. Modify git-difftool--helper.sh script to display the counter and the diff queue count values in the difftool prompt.

That results in:

git-difftool--helper.sh @@ launch_merge_tool () {

 # the user with the real $MERGED name before launching $merge_tool.
 if should_prompt
 then
   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]: " \