git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v5 2/2] difftool.c: learn a new way start at specified file

From
ZheNing Hu <adlternative@gmail.com>
Date
Feb 17, 2021, 16:18 UTC
Message-ID
<CAOLTT8QSuNs6=Um=E0FOBWM+xXx3sbmCx1j+GkeyomTsuwjjKw@mail.gmail.com>
In-Reply-To
<xmqq8s7nm1dv.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2021年2月17日周三 下午6:31写道:
Show 25 quoted lines
>
> "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: ZheNing Hu <adlternative@gmail.com>
> >
> > `git difftool` only allow us to select file to view in turn.
> > If there is a commit with many files and we exit in the search,
>
> I am not sure what "in the search" refers to.  "in the middle" I
> would understand, though.
>
> > We will have to traverse list again to get the file diff which
>
> Let's downcase this "We".
>
> > we want to see. Therefore, here is a new method: user can use
> > `git difftool --rotate-to=<filename>` or `git difftool --skip-to=<filename>`
> > to start viewing from the specified file, This will improve the
> > user experience.
>
> Do we need both?  I'd rather not to give end-user-facing commands
> too many knobs that would do similar things.  Too many choices to
> choose from without clear answer to "which one should I prefer to
> use?" is a bad combination for end-users.
>

So users will not need to use `git difftool --skip-to`? Then I am confused about the meaning of `git difftool --skip-to`.

Show 18 quoted lines
> > diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
> > index 7c5b3cf42bcc..aa2b5c11f20b 100644
> > --- a/Documentation/diff-options.txt
> > +++ b/Documentation/diff-options.txt
> > @@ -701,7 +701,7 @@ components matches the pattern.  For example, the pattern "`foo*bar`"
> >  matches "`fooasdfbar`" and "`foo/bar/baz/asdf`" but not "`foobarx`".
> >
> >  --skip-to=<file>::
> > ---rotate-to=<file::
> > +--rotate-to=<file>::
> >       Discard the files before the named <file> from the output
> >       (i.e. 'skip to'), or move them to the end of the output
> >       (i.e. 'rotate to').  These were invented primarily for use
>
> Thanks for correcting, but this change should not be a part of this
> patch.  Instead, you help the other's topic by giving a review (and
> you could just have said "there there is closing '>' missing").
>
Okay, I will pay attention later.
Show 46 quoted lines
> > diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
> > index 484c485fd06c..c64dff69c976 100644
> > --- a/Documentation/git-difftool.txt
> > +++ b/Documentation/git-difftool.txt
> > @@ -34,6 +34,16 @@ OPTIONS
> >       This is the default behaviour; the option is provided to
> >       override any configuration settings.
> >
> > +--rotate-to=<file>::
> > +     Internally call `git diff --rotate-to=<file>`,
> > +     show the change in the specified path first.
> > +     Files before the specified path will be moved to the last output.
> > +
> > +--skip-to=<file>::
> > +     Internally call `git diff --skip-to=<file>`,
> > +     skip the output to the specified path.
> > +     Files before the specified path will not output.
> > +
>
> This, unlike the "diffcore" stuff, is end-user facing, and it is
> better not to force the readers even know what --skip-to option
> to the diff does (after all, difftool users are using 'git difftool'
> and they are not necessarily 'git diff' users).
>
>     --skip-to=<file>::
>             Start showing the diff for the given path, skipping all
>             the paths before it.
>
> or something, perhaps.
>
> > +test_expect_success 'difftool --skip-to' '
> > +     difftool_test_setup &&
> > +     test_when_finished git reset --hard &&
> > +     git difftool --no-prompt --extcmd=cat --skip-to="2" HEAD^ >output &&
> > +     cat >expect <<-\EOF &&
> > +     2
> > +     4
> > +     EOF
> > +     test_cmp output expect &&
> > +     test_must_fail git difftool --no-prompt --extcmd=cat --skip-to="3" HEAD^
> > +'
>
> This probably should be split into two independent tests.  One to
> check that the non-failing case works as expected, the other to
> check that a bogus command line option errors out as expected.
>
I will finish it.
> Thanks.

Besides, I have some curiosity about one place in the code in your patch:

Show 6 quoted lines
> int cmd_diff_tree(...)
> ...
> if (read_stdin) {
> ...
> opt->diffopt.rotate_to_strict = 0;
> ...

} This is the only place where rotate_to_strict is set to zero, So the "git log -p" you mentioned earlier is here Called this code to avoid exiting the program because of the wrong path, right?

Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 23 of 37 in “git-difftool-helper.sh: learn a new way skip to save point”
  1. git-difftool-helper.sh: learn a new way skip to save point阿德烈 via GitGitGadget, Feb 7, 2021
  2. Junio C HamanoFeb 7, 2021
  3. Junio C HamanoFeb 7, 2021
  4. 胡哲宁Feb 8, 2021
  5. git-difftool-helper.sh: learn a new way go back to last save pointZheNing Hu via GitGitGadget, Feb 8, 2021
  6. Junio C HamanoFeb 8, 2021
  7. David AguilarFeb 8, 2021
  8. Junio C HamanoFeb 8, 2021
  9. 胡哲宁Feb 9, 2021
  10. 胡哲宁Feb 9, 2021
  11. difftool.c: learn a new way start from specified fileZheNing Hu via GitGitGadget, Feb 9, 2021
  12. Junio C HamanoFeb 9, 2021
  13. 胡哲宁Feb 10, 2021
  14. Junio C HamanoFeb 10, 2021
  15. Junio C HamanoFeb 10, 2021
  16. ZheNing HuFeb 14, 2021
  17. difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 14, 2021
  18. Junio C HamanoFeb 16, 2021
  19. 0/2 difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 16, 2021
  20. 1/2 diff: --{rotate,skip}-to=<path>Junio C Hamano via GitGitGadget, Feb 16, 2021
  21. 2/2 difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 16, 2021
  22. Junio C HamanoFeb 17, 2021
  23. ZheNing HuFeb 17, 2021
  24. Junio C HamanoFeb 16, 2021
  25. ZheNing HuFeb 17, 2021
  26. Denton LiuFeb 17, 2021
  27. ZheNing HuFeb 17, 2021
  28. Junio C HamanoFeb 17, 2021
  29. ZheNing HuFeb 18, 2021
  30. ZheNing HuFeb 18, 2021
  31. Junio C HamanoFeb 18, 2021
  32. ZheNing HuFeb 19, 2021
  33. Johannes SchindelinFeb 25, 2021
  34. Junio C HamanoFeb 25, 2021
  35. difftool.c: learn a new way start at specified fileZheNing Hu via GitGitGadget, Feb 19, 2021
  36. ZheNing HuFeb 22, 2021
  37. Junio C HamanoFeb 22, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.