嘗試設定 git diff 工具的各種方法都會導致“致命:無法執行 [...]:錯誤地址”

嘗試設定 git diff 工具的各種方法都會導致“致命:無法執行 [...]:錯誤地址”

我使用的是 Linux Mint 17 64 位元。剛剛清除git並重新安裝apt。已刪除~/.gitconfig。我在所謂的全新安裝後所做的唯一配置是(在儲存庫內)

git config diff.tool vimdiff

然後我跑

git difftool HEAD:switch-monitor.sh master:switch-monitor.sh

並得到

fatal: cannot exec 'git-difftool--helper': Bad address
external diff died, stopping at HEAD:switch-monitor.sh.

因此,我刪除了相關行.git/config並再次嘗試該命令,果然內建的基本git diff工作正常。

我還嘗試過本教程中的說明:http://technotales.wordpress.com/2009/05/17/git-diff-with-vimdiff/

這會導致略有不同但相似的錯誤。我將以下內容放入新的~/.gitconfig

[diff]
  external = git_diff_wrapper
[pager]
  diff =

git_diff_wrapper並在 my 上放置一個可執行文件PATH,然後運行

git diff HEAD:switch-monitor.sh master:switch-monitor.sh 

並得到

fatal: cannot exec 'git_diff_wrapper': Bad address
external diff died, stopping at HEAD:switch-monitor.sh.

不過好像跟內容沒什麼關係git_diff_wrapper。我放置了

#!/bin/bash
echo hello

進入它並不會改變任何東西。然而,如果我消除文件或重命名它,然後我就明白了

error: cannot run git_diff_wrapper: No such file or directory
external diff died, stopping at HEAD:switch-monitor.sh.

請注意,在這種情況下,它顯示“沒有這樣的檔案或目錄”而不是“錯誤地址”。

我在網路上搜尋過,但找不到類似問題的實例。

更新

我在虛擬機器上全新安裝 Ubuntu 14.04 時遇到相同的問題

更新

我花了一些時間查看 git 的源代碼,我很確定在這個函數的過程中errno被設定為(“錯誤地址”):EFAULT

static int execv_shell_cmd(const char **argv)
{
    const char **nargv = prepare_shell_cmd(argv);
    trace_argv_printf(nargv, "trace: exec:");
    sane_execvp(nargv[0], (char **)nargv);
    free(nargv);
    return -1;
}

這稱為:

int sane_execvp(const char *file, char * const argv[])
{
    if (!execvp(file, argv))
        return 0; /* cannot happen ;-) */

    /*
     * When a command can't be found because one of the directories
     * listed in $PATH is unsearchable, execvp reports EACCES, but
     * careful usability testing (read: analysis of occasional bug
     * reports) reveals that "No such file or directory" is more
     * intuitive.
     *
     * We avoid commands with "/", because execvp will not do $PATH
     * lookups in that case.
     *
     * The reassignment of EACCES to errno looks like a no-op below,
     * but we need to protect against exists_in_PATH overwriting errno.
     */
    if (errno == EACCES && !strchr(file, '/'))
        errno = exists_in_PATH(file) ? EACCES : ENOENT;
    else if (errno == ENOTDIR && !strchr(file, '/'))
        errno = ENOENT;
    return -1;
}

有任何想法嗎?

謝謝

答案1

我知道這是一個舊線程,但它似乎沒有關閉...

我遇到過類似的錯誤(我也想使用 vimdiff 來檢查兩次提交之間的差異)。對我有用的: git difftool HEAD..HEAD~1 --path-to-file/file

https://stackoverflow.com/questions/3338126/git-how-to-diff-the-same-file- Between-two- different-commits-on-the-same-branch

乾杯

答案2

我的解決方案是升級到 git 2.x。使用 git 2.3.4,我不再遇到這個問題。

答案3

我在 Ubuntu14 上遇到了同樣的問題,透過將 git 從 v1.9.1 升級到 v2.11.0 修復了。

我必須使用 git Maintenanceer repo 進行升級,如上所述這裡

相關內容