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.