git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Mikhail Terekhov via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Mikhail Terekhov <termim@gmail.com>,
	Pratyush Yadav <me@yadavpratyush.com>,
	Mikhail Terekhov <termim@gmail.com>
Subject: [PATCH] git-gui: allow opening work trees from the startup dialog
Date: Tue, 26 May 2020 15:33:21 +0000	[thread overview]
Message-ID: <pull.644.git.1590507201474.gitgitgadget@gmail.com> (raw)

From: Mikhail Terekhov <termim@gmail.com>

In proc _is_git check that supplied path is a valid work tree path.
This allows the choose_repository::pick dialog to accept path to a
work tree directory.

Signed-off-by: Mikhail Terekhov <termim@gmail.com>
---
    git-gui: allow opening work trees from the startup dialog
    
    Trying to open a working tree from the "Open Existing Repository" link
    of the git-gui startup dialog results in an error: Not a Git repository:
    .... This patch fixes that error.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-644%2Ftermim%2Fgit-gui-open-worktree-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-644/termim/git-gui-open-worktree-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/644

 lib/choose_repository.tcl | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
index e54f3e66d8f..8f911e89fbb 100644
--- a/lib/choose_repository.tcl
+++ b/lib/choose_repository.tcl
@@ -362,8 +362,19 @@ proc _is_git {path {outdir_var ""}} {
 		gets $fp line
 		close $fp
 		if {[regexp "^gitdir: (.+)$" $line line link_target]} {
+			set check_path [file normalize $path]
 			set path [file join [file dirname $path] $link_target]
 			set path [file normalize $path]
+
+			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
+				}
+			}
 		}
 	}
 

base-commit: c195247812f8cd38ba7e1c603112e6c1d8d8e71e
-- 
gitgitgadget

             reply	other threads:[~2020-05-26 15:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 15:33 Mikhail Terekhov via GitGitGadget [this message]
2020-06-05 20:48 ` [PATCH] git-gui: allow opening work trees from the startup dialog Pratyush Yadav
2020-06-05 21:13   ` Eric Sunshine
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=pull.644.git.1590507201474.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --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).