beyond compare with `git difftool --dir-diff` -- 使用符号链接遇到问题

beyond compare with `git difftool --dir-diff` -- Hitting an issue with sym-links

设置一个新的 git 存储库并添加一些文件:

[Feb-09 18:35][Desktop]$ mkdir exampleForWhosebug
[Feb-09 18:35][Desktop]$ cd exampleForWhosebug/

[Feb-09 18:35][exampleForWhosebug]$ git init
Initialized empty Git repository in ~/Desktop/exampleForWhosebug/.git/

[Feb-09 18:35][exampleForWhosebug]$ touch foo.txt
[Feb-09 18:35][exampleForWhosebug]$ touch bar.txt
[Feb-09 18:35][exampleForWhosebug]$ touch baz.txt

[Feb-09 18:36][exampleForWhosebug]$ git add *

[Feb-09 18:36][exampleForWhosebug]$ git commit -m "Create files"
[master (root-commit) 42bfa60] Create files
 3 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 bar.txt
 create mode 100644 baz.txt
 create mode 100644 foo.txt

修改文件:

[Feb-09 18:37][exampleForWhosebug]$ echo "Foo" > foo.txt 
[Feb-09 18:37][exampleForWhosebug]$ echo "Bar" > bar.txt 
[Feb-09 18:37][exampleForWhosebug]$ echo "Baz" > baz.txt

当前状态:

[Feb-09 18:38][exampleForWhosebug]$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   bar.txt
    modified:   baz.txt
    modified:   foo.txt

no changes added to commit (use "git add" and/or "git commit -a")

当前差异:

[Feb-09 18:38][exampleForWhosebug]$ git diff
diff --git a/bar.txt b/bar.txt
index e69de29..ebd7525 100644
--- a/bar.txt
+++ b/bar.txt
@@ -0,0 +1 @@
+Bar
diff --git a/baz.txt b/baz.txt
index e69de29..a688182 100644
--- a/baz.txt
+++ b/baz.txt
@@ -0,0 +1 @@
+Baz
diff --git a/foo.txt b/foo.txt
index e69de29..bc56c4d 100644
--- a/foo.txt
+++ b/foo.txt
@@ -0,0 +1 @@
+Foo

现在使用 bcompare 我得到以下结果:

[Feb-09 18:38][exampleForWhosebug]$ git difftool --dir-diff

这显然不是预期的行为。文件未对齐,因此看不到差异


我是 运行:

[Feb-09 18:44][exampleForWhosebug]$ git --version
git version 2.7.1

[Feb-09 18:44][exampleForWhosebug]$ cat /etc/redhat-release 
CentOS release 6.6 (Final)

超越比较:Version 4.1.3 (build 20814)

git 配置:

[Feb-09 18:45][exampleForWhosebug]$ git config --list
color.ui=true
user.name=FOO
user.email=BAR@BAZ.com
log.decorate=full
diff.tool=bc3
difftool.bc3=trustExitCode
merge.tool=bc3
mergetool.bc3=trustExitCode
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true

问题:(来自Ismail Badawi)这与符号链接有什么关系?

回答: 抱歉,屏幕截图不是很清楚,但右侧的文件是符号链接。见下文:

[Feb-09 18:52][exampleForWhosebug]$ cd /tmp/git-difftool.RWDqE/right
[Feb-09 18:52][right]$ ll
total 0
lrwxrwxrwx 1 BAZ BAZ_g 54 Feb  9 18:51 bar.txt -> /home/BAZ/Desktop/exampleForWhosebug/bar.txt
lrwxrwxrwx 1 BAZ BAZ_g 54 Feb  9 18:51 baz.txt -> /home/BAZ/Desktop/exampleForWhosebug/baz.txt
lrwxrwxrwx 1 BAZ BAZ_g 54 Feb  9 18:51 foo.txt -> /home/BAZ/Desktop/exampleForWhosebug/foo.txt

使用这个会起作用:

git difftool --dir-diff --no-symlinks

来自git doc

--[no-]symlinks

git difftool's default behavior is create symlinks to the working tree when run in --dir-diff mode and the right-hand side of the comparison yields the same content as the file in the working tree.

Specifying --no-symlinks instructs git difftool to create copies instead. --no-symlinks is the default on Windows.

除了 sixtyfootersdude 的建议之外,另一个选择是让 Beyond Compare 遵循符号链接。这会将符号链接与同名文件对齐。

文件夹比较中,单击规则工具栏按钮(裁判图标)。 转到 处理 选项卡。 检查跟随符号链接

要使其影响所有新会话,请将对话框底部的下拉菜单从仅用于此视图更改为同时更新会话默认值,然后单击“确定”。


快照: