git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-gui: allow opening work trees from the startup dialog
@ 2020-05-26 15:33 Mikhail Terekhov via GitGitGadget
  2020-06-05 20:48 ` Pratyush Yadav
  2020-06-06  4:33 ` [PATCH v2] " Mikhail Terekhov via GitGitGadget
  0 siblings, 2 replies; 6+ messages in thread
From: Mikhail Terekhov via GitGitGadget @ 2020-05-26 15:33 UTC (permalink / raw)
  To: git; +Cc: Mikhail Terekhov, Pratyush Yadav, Mikhail Terekhov

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-22 14:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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 NNTP newsgroup(s).