diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-01-23 11:20:36 -0800 |
|---|---|---|
| committer | Paul Mackerras <paulus@ozlabs.org> | 2020-04-13 14:36:05 +1000 |
| commit | e272a77964d95e2fd8b3b47b7f3840ed3e42b81c (patch) | |
| tree | 1a295d0fb0b02c28fe0b785865fbc7dafce5b4e4 | |
| parent | c1a63459ed7364bb03e0549c1f042bca469d278f (diff) | |
| download | git-e272a77964d95e2fd8b3b47b7f3840ed3e42b81c.tar.gz | |
gitk: be prepared to be run in a bare repository
784b7e2f ("gitk: Fix "External diff" with separate work tree",
2011-04-04) added an unconditional call to "git rev-parse
--show-toplevel" to set up a global variable quite early in the
course of the program, so that the location of the working tree can
later be known if/when the user chooses to run the external diff via
the external_diff_get_one_file proc. Before that change, the
external diff code used to assume that the parent directory of ".git"
directory is the top-level of the working tree.
Recent versions of git however notices that "rev-parse --show-toplevel"
executed in a bare repository is an error, which makes gitk stop,
even before the user could attempt to run external diff.
Use the gitworktree helper introduced in 65bb0bda ("gitk: Fix the
display of files when filtered by path", 2011-12-13), which is
prepared to see failures from "rev-parse --show-toplevel" and other
means it tries to find the top-level of the working tree instead to
work around this issue. The resulting value in $worktree global,
when run in a bare repository, is bogus, but the code is not
prepared to run external diff correctly without a working tree
anyway ;-)
[paulus@ozlabs.org - folded in fix from Eric Sunshine]
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
| -rwxr-xr-x | gitk | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -34,8 +34,7 @@ proc gitworktree {} { # cdup to obtain a relative path to the top of the worktree. If # run from the top, the ./ prefix ensures normalize expands pwd. if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} { - catch {set _gitworktree [exec git config --get core.worktree]} - if {$_gitworktree eq ""} { + if {[catch {set _gitworktree [exec git config --get core.worktree]}]} { set _gitworktree [file normalize ./[exec git rev-parse --show-cdup]] } } @@ -12603,7 +12602,7 @@ set cdup {} if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} { set cdup [exec git rev-parse --show-cdup] } -set worktree [exec git rev-parse --show-toplevel] +set worktree [gitworktree] setcoords makewindow catch { |
