git, vimdiff and dirdiff

后端 未结 4 2096
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 08:17

I\'m trying to use vimdiff+dirdiff.vim to diff inside Vim multiple files versionned with Git.

For Mercurial, it is possible with mercurial extdiff extension.

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 08:50

    It would be interesting to monitor the commits for the Vim module fugitive, because, starting with (git 1.7.11, June 2012), git now can diff directories (ie display all the files to be compared, before opening the difftool)

    See "git difftool to give directory compare?"

    So adding that feature to fugitive.vim would be an evolution from a file to file diff approach.

    However, Zyx points out in the comment the limits of that approach:

    All you need to get this working is:

    1. git diff --name-status and
    2. git cat-file,

    nothing more (except for some vimscript code).
    And, unlike git difftool, this works for any VCS with vcs diff and vcs cat-file support

    Zyx mentions as an example of that file-byfile approach his project aurum:

    My aurum has dirdiff-like functionality (AuVimDiff full opens a bunch of tabs with vimdiff view of files that have differences) and it never used any sort of difftool support.

    (See script aurum / autoload / aurum / vimdiff.vim)

    Zyx adds:

    it cannot be a good guide for a person that wants to add this functionality to fugitive:
    Actual git diff --name-status call is hidden inside the git driver in a function called by s:git.status accessed as repo.functions.status (because mercurial uses hg status -r rev1:rev2, not hg diff --name-status and I find this rather logical).
    Thus you have to traverse three levels of abstraction here (repository interface, shell commands wrapper and only then actual git call).
    It is faster to write everything from scratch

提交回复
热议问题