git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Pratyush Yadav <me@yadavpratyush.com>
Cc: Mikhail Terekhov via GitGitGadget <gitgitgadget@gmail.com>,
	Git List <git@vger.kernel.org>,
	Mikhail Terekhov <termim@gmail.com>
Subject: Re: [PATCH] git-gui: allow opening work trees from the startup dialog
Date: Fri, 5 Jun 2020 17:13:28 -0400	[thread overview]
Message-ID: <CAPig+cQhm7XwKEJdjzmaG_gbOJZp1RbktJBeC0d8vTQfgLbydQ@mail.gmail.com> (raw)
In-Reply-To: <20200605204803.lbolbny5m5dczynn@yadavpratyush.com>

On Fri, Jun 5, 2020 at 4:48 PM Pratyush Yadav <me@yadavpratyush.com> wrote:
> 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.

  reply	other threads:[~2020-06-05 21:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 15:33 [PATCH] git-gui: allow opening work trees from the startup dialog Mikhail Terekhov via GitGitGadget
2020-06-05 20:48 ` Pratyush Yadav
2020-06-05 21:13   ` Eric Sunshine [this message]
2020-06-06  4:33 ` [PATCH v2] " Mikhail Terekhov via GitGitGadget
2020-06-08  9:31   ` Pratyush Yadav
2020-06-22 14:58     ` Pratyush Yadav

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAPig+cQhm7XwKEJdjzmaG_gbOJZp1RbktJBeC0d8vTQfgLbydQ@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=me@yadavpratyush.com \
    --cc=termim@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).