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

Re: [PATCH] gitk: to run in a bare repository (was: gitk can't be run from non-worktree folders)

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 23, 2020, 19:26 UTC
Message-ID
<20200123192638.GA3177@flurp.local>
In-Reply-To
<xmqqk15i3rp7.fsf_-_@gitster-ct.c.googlers.com>
On Thu, Jan 23, 2020 at 11:20:36AM -0800, Junio C Hamano wrote:
Show 19 quoted lines
> 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 ;-)
> 
> Helped-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff --git a/gitk b/gitk
> @@ -12599,7 +12599,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]
This helps but doesn't quite make it functional due to a bug in gitworktree() which results in:
    Error in startup script: can't read "_gitworktree": no such variable
        while executing
    "if {$_gitworktree eq ""} {
So, to make this work, it also needs:
--- >8 ---
diff --git a/gitk-git/gitk b/gitk-git/gitk
index abe4805ade..8cbca113e3 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -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]]
 	    }
         }
--- >8 ---
Previous: Junio C HamanoNext: Jeff King
Message 8 of 15 in “[REGRESSION] gitk can't be run from non-worktree folders”
  1. chJan 23, 2020
  2. SZEDER GáborJan 23, 2020
  3. Eric SunshineJan 23, 2020
  4. SZEDER GáborJan 23, 2020
  5. SZEDER GáborJan 23, 2020
  6. Junio C HamanoJan 23, 2020
  7. gitk: to run in a bare repository (was: gitk can't be run from non-worktree folders)Junio C Hamano, Jan 23, 2020
  8. Eric SunshineJan 23, 2020
  9. Jeff KingJan 23, 2020
  10. chMar 30, 2020
  11. Eric SunshineOct 11, 2020
  12. chOct 13, 2020
  13. Pratyush YadavOct 13, 2020
  14. chApr 2, 2020
  15. Junio C HamanoApr 2, 2020

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.