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

Re: [RFC PATCH] mergetools: support difftool.tabbed setting

From
David Aguilar <davvid@gmail.com>
Date
Feb 12, 2021, 05:51 UTC
Message-ID
<CAJDDKr4zM1ZuNc+JpQnAtqwa5Ljv7_5bL3X-cC3e5Xg3z2Cbcw@mail.gmail.com>
In-Reply-To
<2fb58fd30ae730ccd3e88ec51b5fe6d80ab7a8c7.camel@guriev.su>
On Tue, Jan 12, 2021 at 10:07 PM Nicholas Guriev <nicholas@guriev.su> wrote:
Show 42 quoted lines
>
> I was asked how to configure "git difftool" to open files using several
> tabs and stop spawning diff application on every modified file. I looked
> into Git source and found no possibility to run diff tool at one step.
>
> The patch allows a user to view diffs in single window at one go. The
> current implementation is still poor and it can be used solely for
> demonstration purposes. To see it in action, tweak the local gitconfig:
>
>     git config difftool.prompt false
>     git config difftool.tabbed true
>
> Then run:
>
>     git difftool -t vimdiff
>
> Or:
>
>     git difftool -t meld
>
> The solution has some restrictions, diffing up to ten files works now (I
> did not bother with dynamic memory allocation), and it does not handle spaces
> in file names (I do not know how to pass them correctly to underlying tools
> without "xargs -0").
>
> I think the git-difftool--helper should be changed so that it could
> process many files in single invocation and it would not use a temporary
> file by itself. A similar behaviour can be done in git-mergetool, too.
>
> Do you have ideas how to better implement such a feature? Any comments
> are welcome.
>
> P.S.: I'm attaching screenshots for a clear demo what I mean.
> ---
>  diff.c                |  4 ++--
>  git-mergetool--lib.sh | 36 +++++++++++++++++++++++++++++++++++-
>  mergetools/meld       |  4 ++++
>  mergetools/vimdiff    | 17 +++++++++++++++++
>  4 files changed, 58 insertions(+), 3 deletions(-)
>
>
>

I'm not really sure if "tabbed" is the best name for what's going on, though. It's really more of a "diff everything in one shot" mode, and it just so happens that the tools in question use tabs.

General note -- similar to the convention followed by mergetool.hideResolved and other difftool things I think it would make sense for tools to be able to override this on a per-tool basis.

That said, I wonder whether we need this new feature, or whether we should instead improve an existing one. I'm leaning towards improving the existing dir-diff feature as a better alternative.

It's unfortunate that the "git difftool --dir-diff" feature doesn't seem to mesh well with vimdiff. It does work well with other tools that support diffing arbitrary directories, notably meld, xxdiff, etc.

Regarding vimdiff + git difftool -d, there is this advice: https://stackoverflow.com/questions/8156493/git-vimdiff-and-dirdiff

meld works just fine with "git difftool -d" (arguably nicer, since it gives you a directory view and a diff view in separate tabs), so if the only improvement is for vimdiff, then maybe the advice with the DirDiff plugin might be a better way to go.

Having something like a "difftool.vimdiff.useDirDiff" configuration variable could be a way for us to adopt the advice that they offer there. We could have the dir-diff difftool mode set a variable that the vimdiff scriptlet could use to detect that we're in dir-diff mode. Then, when that variable is set, vimdiff could use,

    vim -f '+next' '+execute \"DirDiff\" argv(0) argv(1)' $LOCAL $REMOTE
(as mentioned in the SO page) to invoke dir-diff mode in vim.
That way the user only needs to set:
git config difftool.vimdiff.useDirDiff
... and then "git diffftool -d" will integrate with the DirDiff plugin.

What do you think about improving the vimdiff scriptlet to better integrate with "git difftool -d" instead?

-- 
David
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 14 in “mergetools: support difftool.tabbed setting”
  1. mergetools: support difftool.tabbed settingNicholas Guriev, Jan 13, 2021
  2. 0/3 implement tabbed mode in difftoolsNicholas Guriev, Jan 18, 2021
  3. 2/3 difftool-helper: conciliate difftool.tabbed and difftool.prompt settingsNicholas Guriev, Jan 18, 2021
  4. 1/3 mergetools: support difftool.tabbed settingNicholas Guriev, Jan 18, 2021
  5. Junio C HamanoJan 18, 2021
  6. 3/3 doc: describe new difftool.tabbed featureNicholas Guriev, Jan 18, 2021
  7. 0/4 difftools in tabbed modeNicholas Guriev, Jan 25, 2021
  8. 4/4 t7800: new tests of difftool.tabbed featureNicholas Guriev, Jan 25, 2021
  9. 3/4 doc: describe new difftool.tabbed featureNicholas Guriev, Jan 25, 2021
  10. 1/4 mergetools: support difftool.tabbed settingNicholas Guriev, Jan 25, 2021
  11. 2/4 difftool-helper: conciliate difftool.tabbed and difftool.prompt settingsNicholas Guriev, Jan 25, 2021
  12. Junio C HamanoJan 25, 2021
  13. David AguilarFeb 12, 2021
  14. Junio C HamanoFeb 12, 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.