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

Re: [PATCH] git-gui: allow opening work trees from the startup dialog

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 5, 2020, 21:13 UTC
Message-ID
<CAPig+cQhm7XwKEJdjzmaG_gbOJZp1RbktJBeC0d8vTQfgLbydQ@mail.gmail.com>
In-Reply-To
<20200605204803.lbolbny5m5dczynn@yadavpratyush.com>
On Fri, Jun 5, 2020 at 4:48 PM Pratyush Yadav <me@yadavpratyush.com> wrote:
Show 15 quoted lines
> On 26/05/20 03:33PM, Mikhail Terekhov via GitGitGadget wrote:
> > From: Mikhail Terekhov <termim@gmail.com>
> > +                     if {[file exists [file join $path gitdir]]} {
> > +                             set fp [open [file join $path gitdir] r]
> > +                             gets $fp worktree_path
> > +                             close $fp
> > +                             if {[string equal $check_path $worktree_path]} {
> > +                                     set outdir $path
> > +                                     return 1
> > +                             }
> > +                     }
>
> I wonder if there is a way of finding if the path is a worktree path
> using a Git plumbing command. That IMO would be better than rolling our
> own logic to check if something is a worktree.
Perhaps use:
    (cd "$path" && git rev-parse --is-inside-work-tree)

That will return "true" for both the main worktree and a linked worktree. You may need to suppress stderr if you expect to run the command in an arbitrary directory since it will error out if the directory is not under Git's control.

Previous: Pratyush YadavNext: Mikhail Terekhov via GitGitGadget
Message 3 of 6 in “git-gui: allow opening work trees from the startup dialog”
  1. git-gui: allow opening work trees from the startup dialogMikhail Terekhov via GitGitGadget, May 26, 2020
  2. Pratyush YadavJun 5, 2020
  3. Eric SunshineJun 5, 2020
  4. git-gui: allow opening work trees from the startup dialogMikhail Terekhov via GitGitGadget, Jun 6, 2020
  5. Pratyush YadavJun 8, 2020
  6. Pratyush YadavJun 22, 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.