git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] Makes chooser set 'gitdir' to the resolved path
  2015-02-05 16:20 ` [PATCH 0/2] gitfile support git git-gui Remi Rampin
@ 2015-02-05 16:20   ` Remi Rampin
  0 siblings, 0 replies; 5+ messages in thread
From: Remi Rampin @ 2015-02-05 16:20 UTC (permalink / raw)
  To: git; +Cc: patthoyts, Remi Rampin

If _is_git follows a "gitdir: ..." file link to get to the actual
repository, we want _gitdir to be set to that final path.
---
 lib/choose_repository.tcl | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
index abc6b1d..75d1da8 100644
--- a/lib/choose_repository.tcl
+++ b/lib/choose_repository.tcl
@@ -338,7 +338,10 @@ method _git_init {} {
 	return 1
 }
 
-proc _is_git {path} {
+proc _is_git {path {outdir_var ""}} {
+	if {$outdir_var ne ""} {
+		upvar 1 $outdir_var outdir
+	}
 	if {[file isfile $path]} {
 		set fp [open $path r]
 		gets $fp line
@@ -352,12 +355,14 @@ proc _is_git {path} {
 	if {[file exists [file join $path HEAD]]
 	 && [file exists [file join $path objects]]
 	 && [file exists [file join $path config]]} {
+		set outdir $path
 		return 1
 	}
 	if {[is_Cygwin]} {
 		if {[file exists [file join $path HEAD]]
 		 && [file exists [file join $path objects.lnk]]
 		 && [file exists [file join $path config.lnk]]} {
+			set outdir $path
 			return 1
 		}
 	}
@@ -1103,7 +1108,7 @@ method _open_local_path {} {
 }
 
 method _do_open2 {} {
-	if {![_is_git [file join $local_path .git]]} {
+	if {![_is_git [file join $local_path .git] actualgit]} {
 		error_popup [mc "Not a Git repository: %s" [file tail $local_path]]
 		return
 	}
@@ -1116,7 +1121,7 @@ method _do_open2 {} {
 	}
 
 	_append_recentrepos [pwd]
-	set ::_gitdir .git
+	set ::_gitdir $actualgit
 	set ::_prefix {}
 	set done 1
 }
-- 
1.9.5.msysgit.0

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

* [PATCH 0/2] [git-gui] "Open existing repository" with submodules
@ 2015-03-06 16:21 Remi Rampin
  2015-03-06 16:21 ` [PATCH 1/2] Fixes chooser not accepting gitfiles Remi Rampin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Remi Rampin @ 2015-03-06 16:21 UTC (permalink / raw)
  To: git, patthoyts; +Cc: Remi Rampin

I'm resubmitting this patch series, hopefully someone takes notice
this time.

The GUI cannot currently open a submodule because it fails to recognize
the git link file (regular .git file with content "gitdir: ...").

Previous thread:
http://thread.gmane.org/gmane.comp.version-control.git/263199

I'm really not sure if/how git-gui is maintained but I do hope somebody
cares about this component, that is still AFAIK distributed with Git.

Remi Rampin (2):
  Fixes chooser not accepting gitfiles
  Makes chooser set 'gitdir' to the resolved path

 lib/choose_repository.tcl | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

-- 
1.9.5.msysgit.0

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

* [PATCH 1/2] Fixes chooser not accepting gitfiles
  2015-03-06 16:21 [PATCH 0/2] [git-gui] "Open existing repository" with submodules Remi Rampin
@ 2015-03-06 16:21 ` Remi Rampin
  2015-03-06 16:21 ` [PATCH 2/2] Makes chooser set 'gitdir' to the resolved path Remi Rampin
  2015-03-12 21:57 ` [PATCH 0/2] [git-gui] "Open existing repository" with submodules Pat Thoyts
  2 siblings, 0 replies; 5+ messages in thread
From: Remi Rampin @ 2015-03-06 16:21 UTC (permalink / raw)
  To: git, patthoyts; +Cc: Remi Rampin

Makes _is_git handle the case where the path is a "gitdir: ..." file.

Signed-off-by: Remi Rampin <remirampin@gmail.com>
---
 lib/choose_repository.tcl | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
index 92d6022..abc6b1d 100644
--- a/lib/choose_repository.tcl
+++ b/lib/choose_repository.tcl
@@ -339,6 +339,16 @@ method _git_init {} {
 }
 
 proc _is_git {path} {
+	if {[file isfile $path]} {
+		set fp [open $path r]
+		gets $fp line
+		close $fp
+		if {[regexp "^gitdir: (.+)$" $line line link_target]} {
+			set path [file join [file dirname $path] $link_target]
+			set path [file normalize $path]
+		}
+	}
+
 	if {[file exists [file join $path HEAD]]
 	 && [file exists [file join $path objects]]
 	 && [file exists [file join $path config]]} {
-- 
1.9.5.msysgit.0

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

* [PATCH 2/2] Makes chooser set 'gitdir' to the resolved path
  2015-03-06 16:21 [PATCH 0/2] [git-gui] "Open existing repository" with submodules Remi Rampin
  2015-03-06 16:21 ` [PATCH 1/2] Fixes chooser not accepting gitfiles Remi Rampin
@ 2015-03-06 16:21 ` Remi Rampin
  2015-03-12 21:57 ` [PATCH 0/2] [git-gui] "Open existing repository" with submodules Pat Thoyts
  2 siblings, 0 replies; 5+ messages in thread
From: Remi Rampin @ 2015-03-06 16:21 UTC (permalink / raw)
  To: git, patthoyts; +Cc: Remi Rampin

If _is_git follows a "gitdir: ..." file link to get to the actual
repository, we want _gitdir to be set to that final path.

Signed-off-by: Remi Rampin <remirampin@gmail.com>
---
 lib/choose_repository.tcl | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
index abc6b1d..75d1da8 100644
--- a/lib/choose_repository.tcl
+++ b/lib/choose_repository.tcl
@@ -338,7 +338,10 @@ method _git_init {} {
 	return 1
 }
 
-proc _is_git {path} {
+proc _is_git {path {outdir_var ""}} {
+	if {$outdir_var ne ""} {
+		upvar 1 $outdir_var outdir
+	}
 	if {[file isfile $path]} {
 		set fp [open $path r]
 		gets $fp line
@@ -352,12 +355,14 @@ proc _is_git {path} {
 	if {[file exists [file join $path HEAD]]
 	 && [file exists [file join $path objects]]
 	 && [file exists [file join $path config]]} {
+		set outdir $path
 		return 1
 	}
 	if {[is_Cygwin]} {
 		if {[file exists [file join $path HEAD]]
 		 && [file exists [file join $path objects.lnk]]
 		 && [file exists [file join $path config.lnk]]} {
+			set outdir $path
 			return 1
 		}
 	}
@@ -1103,7 +1108,7 @@ method _open_local_path {} {
 }
 
 method _do_open2 {} {
-	if {![_is_git [file join $local_path .git]]} {
+	if {![_is_git [file join $local_path .git] actualgit]} {
 		error_popup [mc "Not a Git repository: %s" [file tail $local_path]]
 		return
 	}
@@ -1116,7 +1121,7 @@ method _do_open2 {} {
 	}
 
 	_append_recentrepos [pwd]
-	set ::_gitdir .git
+	set ::_gitdir $actualgit
 	set ::_prefix {}
 	set done 1
 }
-- 
1.9.5.msysgit.0

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

* Re: [PATCH 0/2] [git-gui] "Open existing repository" with submodules
  2015-03-06 16:21 [PATCH 0/2] [git-gui] "Open existing repository" with submodules Remi Rampin
  2015-03-06 16:21 ` [PATCH 1/2] Fixes chooser not accepting gitfiles Remi Rampin
  2015-03-06 16:21 ` [PATCH 2/2] Makes chooser set 'gitdir' to the resolved path Remi Rampin
@ 2015-03-12 21:57 ` Pat Thoyts
  2 siblings, 0 replies; 5+ messages in thread
From: Pat Thoyts @ 2015-03-12 21:57 UTC (permalink / raw)
  To: Remi Rampin; +Cc: git, Chris Packham

Remi Rampin <remirampin@gmail.com> writes:

>I'm resubmitting this patch series, hopefully someone takes notice
>this time.
>
>The GUI cannot currently open a submodule because it fails to recognize
>the git link file (regular .git file with content "gitdir: ...").
>
>Previous thread:
>http://thread.gmane.org/gmane.comp.version-control.git/263199
>
>I'm really not sure if/how git-gui is maintained but I do hope somebody
>cares about this component, that is still AFAIK distributed with Git.
>
>Remi Rampin (2):
>  Fixes chooser not accepting gitfiles
>  Makes chooser set 'gitdir' to the resolved path
>
> lib/choose_repository.tcl | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)

Thanks. I've applied these onto git-gui's upstream repository with minor
changes to the commit comment to clarify where this becomes useful.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

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

end of thread, other threads:[~2015-03-12 22:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-06 16:21 [PATCH 0/2] [git-gui] "Open existing repository" with submodules Remi Rampin
2015-03-06 16:21 ` [PATCH 1/2] Fixes chooser not accepting gitfiles Remi Rampin
2015-03-06 16:21 ` [PATCH 2/2] Makes chooser set 'gitdir' to the resolved path Remi Rampin
2015-03-12 21:57 ` [PATCH 0/2] [git-gui] "Open existing repository" with submodules Pat Thoyts
  -- strict thread matches above, loose matches on Subject: below --
2015-02-02 15:59 [git-gui] bug report: "Open existing repository" dialog fails on submodules Rémi Rampin
2015-02-05 16:20 ` [PATCH 0/2] gitfile support git git-gui Remi Rampin
2015-02-05 16:20   ` [PATCH 2/2] Makes chooser set 'gitdir' to the resolved path Remi Rampin

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).