All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Paul Mackerras" <paulus@ozlabs.org>,
	"SZEDER Gábor" <szeder.dev@gmail.com>, ch <cr@onlinehome.de>,
	"Martin von Zweigbergk" <martinvonz@gmail.com>,
	"Git List" <git@vger.kernel.org>, "Jeff King" <peff@peff.net>
Subject: Re: [PATCH] gitk: to run in a bare repository (was: gitk can't be run from non-worktree folders)
Date: Thu, 23 Jan 2020 14:26:38 -0500	[thread overview]
Message-ID: <20200123192638.GA3177@flurp.local> (raw)
In-Reply-To: <xmqqk15i3rp7.fsf_-_@gitster-ct.c.googlers.com>

On Thu, Jan 23, 2020 at 11:20:36AM -0800, Junio C Hamano wrote:
> 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 ---

  reply	other threads:[~2020-01-23 19:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-23 16:04 [REGRESSION] gitk can't be run from non-worktree folders ch
2020-01-23 16:31 ` SZEDER Gábor
2020-01-23 16:36   ` Eric Sunshine
2020-01-23 17:04     ` SZEDER Gábor
2020-01-23 17:46       ` SZEDER Gábor
2020-01-23 19:02     ` Junio C Hamano
2020-01-23 19:20       ` [PATCH] gitk: to run in a bare repository (was: gitk can't be run from non-worktree folders) Junio C Hamano
2020-01-23 19:26         ` Eric Sunshine [this message]
2020-01-23 19:27         ` Jeff King
2020-03-30 15:20           ` ch
2020-10-11  5:08             ` Eric Sunshine
2020-10-13 14:25               ` [PATCH] gitk: to run in a bare repository ch
2020-10-13 15:31                 ` Pratyush Yadav
2020-04-02 13:40     ` [REGRESSION] gitk can't be run from non-worktree folders ch
2020-04-02 17:47     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200123192638.GA3177@flurp.local \
    --to=sunshine@sunshineco.com \
    --cc=cr@onlinehome.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martinvonz@gmail.com \
    --cc=paulus@ozlabs.org \
    --cc=peff@peff.net \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.