git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* Specify resume point with git difftool?
@ 2020-11-16 16:45 Ryan Zoeller
  2020-11-16 19:26 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Ryan Zoeller @ 2020-11-16 16:45 UTC (permalink / raw)
  To: git

Hi everyone,

I use git quite a bit while working with some binary files which require a custom diff tool. I'll typically review changes with a command like

git difftool --tool toolname main... -- *.extension

Frequently I'll finish reviewing a file and close the diffing program, only to realize that I wanted to look at part of the diff again -- e.g. after viewing a few other files and wanting some additional context.

Typically I end up killing the current difftool prompt, rewriting my difftool command to specify the file I want to re-review, and upon finishing that re-review running the original difftool command. However upon running the original command I find myself just answering 'n' to all of the prompts until I get back to where I was, which can be a bit painful.

Is there a way to tell git "resume the difftool process at file n"? The difftool prompt counts which file I'm on ("Viewing (10/20): 'filename'"), so it seems like I ought to be able to jump ahead by specifying a starting index (or range to view).

Thanks,
Ryan Zoeller


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Specify resume point with git difftool?
  2020-11-16 16:45 Specify resume point with git difftool? Ryan Zoeller
@ 2020-11-16 19:26 ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-11-16 19:26 UTC (permalink / raw)
  To: Ryan Zoeller; +Cc: git

Ryan Zoeller <rtzoeller@rtzoeller.com> writes:

> Is there a way to tell git "resume the difftool process at file n"?
> The difftool prompt counts which file I'm on ("Viewing (10/20):
> 'filename'"), so it seems like I ought to be able to jump ahead by
> specifying a starting index (or range to view).

There is no such support in the code.

diff.c::run_external_diff() maitains and increments the counters
used to show the prompt in the form of a pair of environment
variables, GIT_DIFF_PATH_TOTAL and GIT_DIFF_PATH_COUNTER, and they
are used in git-difftool--helper::launch_merge_tool() when asking
you if you want to run the difftool backend on that 10th file out of
the 20 files.

Right now, you can only say Yes or No to that prompt, but it
shouldn't be too hard to add another choice to the response to the
prompt, saying "skip to 15th file", for example, and record that
"15" in a temporary file in $GIT_DIR/ and exit without running the
difftool backend on the 10th file, so that later invocation of the
git-difftool-helper script can skip without prompting you until it
is the turn for 15th file.

The launch_merge_tool() function needs to be modified in the
following way to do so:

 - At the beginning, see if $GIT_DIR/difftool-skip-to file exists.

   - If exists, read its contents.

   - See if the value is larger than $GIT_DIFF_PATH_COUNTER.  If so,
     just 'return' without doing anything else.

   - Remove that file (we are at the 15th path and done skipping).

 - Update the "Viewing .../ Launch?" prompt and offer another choice
   "Skip to?".

 - Update the if/then/fi statement that processes the answer to the
   prompt (right now, it takes n as a sign to skip the file).  When
   the user says "skip to 15th", create $GIT_DIR/difftool-skip-to
   file and record "15" in it and 'return'.

#leftoverbits.





     


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Specify resume point with git difftool?
@ 2021-02-07 12:57 胡哲宁
  0 siblings, 0 replies; 3+ messages in thread
From: 胡哲宁 @ 2021-02-07 12:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List, rtzoeller

Hi,Junio,

I try to reslove this issue,but there may be a little change
in my approach:

>  - At the beginning, see if $GIT_DIR/difftool-skip-to file exists.
>
>    - If exists, read its contents.
>
Which have been read now we called it "SAVE_POINT_NUM".

And then,divided into two situations:
If the index of the file($GIT_DIFF_PATH_COUNTER)we are
viewing is 1,if $SAVE_POINT_NUM larger than
$GIT_DIFF_PATH_COUNTER, ask users if they
want to skip to last time save point $SAVE_POINT_NUM:
if the answer is no,we continue show difftool of first file;
if the answer is yes,we `return`.
If the index of the file we are viewing is large than 1,we just check the
if $SAVE_POINT_NUM large than $GIT_DIFF_PATH_COUNTER,if true,
`return` ;if false,we continue show difftool of files.

And everytime before we view the diff,we save the
$GIT_DIFF_PATH_COUNTER to $GIT_DIR/difftool-skip-to.

>    - Remove that file (we are at the 15th path and done skipping).
finally,when success viewed last file diff,we delete the
`$GIT_DIR/difftool-skip-to`.
>
>  - Update the "Viewing .../ Launch?" prompt and offer another choice
>    "Skip to?".
>
>  - Update the if/then/fi statement that processes the answer to the
>    prompt (right now, it takes n as a sign to skip the file).  When
>    the user says "skip to 15th", create $GIT_DIR/difftool-skip-to
>    file and record "15" in it and 'return'.
When we were at an index in the middle, I didn't think there was any
good way to go back to the previous index, so I didn't deal with random jumping.

After all, this question focuses on the save point of the last exit.

I have a question: If the user has two different `git difftool`
(e.g. first time user call `git difftool HEAD~` and exits midway,
second time call `git difftool HEAD~2`, the "GIT_DIR/difftool-skip-to "
still exists), I did not do the consistency check for the two.

But this is not a big hindrance, because the user can choose not to
skip before viewing the first file.

My patch will send soon.
If there are errors or omissions in my thinking,please tell me,thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-07 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 16:45 Specify resume point with git difftool? Ryan Zoeller
2020-11-16 19:26 ` Junio C Hamano
2021-02-07 12:57 胡哲宁

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git