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

Re: [PATCH 2/3] git-gui: use the actual worktree

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 18, 2009, 17:22 UTC
Message-ID
<20090218172219.GF22848@spearce.org>
In-Reply-To
<1234144850-2903-3-git-send-email-giuseppe.bilotta@gmail.com>
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:
Show 19 quoted lines
> Don't rely on the git worktree being the updir of the gitdir, since it
> might not be. Instead, define (and use) a new _gitworktree global
> variable, setting it to $GIT_WORK_TREE if present, or to whatever we
> guess the correct worktree is.
> 
> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
> ---
>  git-gui/git-gui.sh |   25 +++++++++++++++++++------
>  1 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
> index 658a728..94317c7 100755
> --- a/git-gui/git-gui.sh
> +++ b/git-gui/git-gui.sh
> @@ -1062,13 +1063,19 @@ if {![file isdirectory $_gitdir]} {
>  	error_popup [strcat [mc "Git directory not found:"] "\n\n$_gitdir"]
>  	exit 1
>  }
> +set _gitworktree $env(GIT_WORK_TREE)

In TCL it is an error if an environment variable is undefined when accessed. You need to wrap this up in a catch block to handle the error:

Error in startup script: can't read "env(GIT_WORK_TREE)": no such variable
    while executing
"set _gitworktree $env(GIT_WORK_TREE)"
    (file "./git-gui.sh" line 1066)

Also, what about honoring core.worktree as a setting, in addition to $env(GIT_WORK_TREE) like the git wrapper does?

-- 
Shawn.
Previous: Giuseppe BilottaNext: Giuseppe Bilotta
Message 7 of 9 in “git-gui: generic and robust worktree/gitdir support”
  1. 0/3 git-gui: generic and robust worktree/gitdir supportGiuseppe Bilotta, Feb 9, 2009
  2. 1/3 git-gui: properly check for a bare repoGiuseppe Bilotta, Feb 9, 2009
  3. Shawn O. PearceFeb 18, 2009
  4. Giuseppe BilottaFeb 18, 2009
  5. Shawn O. PearceFeb 18, 2009
  6. 2/3 git-gui: use the actual worktreeGiuseppe Bilotta, Feb 9, 2009
  7. Shawn O. PearceFeb 18, 2009
  8. 3/3 git-gui: define correct GIT_DIR for gitkGiuseppe Bilotta, Feb 9, 2009
  9. Shawn O. PearceFeb 18, 2009

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.