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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 5, 2020 at 4:48 PM Pratyush Yadav <me@xxxxxxxxxxxxxxxxx> wrote:
> On 26/05/20 03:33PM, Mikhail Terekhov via GitGitGadget wrote:
> > From: Mikhail Terekhov <termim@xxxxxxxxx>
> > +                     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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux