[PATCH] git-gui: Correctly set up locators in case of preset URL variable

Previous thread: How Blobs Work ( Blobs Vs. Deltas) by Feanil Patel on Tuesday, September 30, 2008 - 8:14 am. (4 messages)

Next thread: git gui rescane_stage2 error on windows by astubbs on Tuesday, September 30, 2008 - 10:41 am. (2 messages)
From: Petr Baudis
Date: Tuesday, September 30, 2008 - 9:51 am

This enables git-gui to be started with the clone dialog opened right
away, possibly with the URL prefilled when it is passed as another
argument. git-gui can then be e.g. registered as the git:// protocol
handler.

This is just a simple implementation - we construct the front actions
page, then throw it away immediately; I wanted to avoid unnecessary
refactoring and complication of the code, though.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>

---
 Documentation/git-gui.txt         |    5 +++++
 git-gui/git-gui.sh                |   21 ++++++++++++++++++---
 git-gui/lib/choose_repository.tcl |   11 ++++++++++-
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-gui.txt b/Documentation/git-gui.txt
index 0e650f4..9ce63be 100644
--- a/Documentation/git-gui.txt
+++ b/Documentation/git-gui.txt
@@ -43,6 +43,11 @@ citool::
 	to only commit actions, slightly reducing the application's
 	startup time and simplifying the menubar.
 
+clone::
+	Start the 'git-gui' clone dialog, optionally taking
+	a source location as an extra argument to pre-fill
+	in the dialog.
+
 version::
 	Display the currently running version of 'git-gui'.
 
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 4085e8f..86f0151 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -950,6 +950,8 @@ enable_option multicommit
 enable_option branch
 enable_option transport
 disable_option bare
+set init_action {}
+set clone_url {}
 
 switch -- $subcommand {
 browser -
@@ -960,6 +962,13 @@ blame {
 	disable_option branch
 	disable_option transport
 }
+clone {
+	set init_action "clone"
+	if {[llength $argv] > 0} {
+		set clone_url [lindex $argv 0]
+		set argv [lrange $argv 1 end]
+	}
+}
 citool {
 	enable_option singlecommit
 	enable_option retcode
@@ -995,7 +1004,12 @@ citool {
 ##
 ## repository setup
 
-if {[catch {
+if {$init_action != ""} {
+	load_config 1
+	apply_config
+	choose_repository::pick $init_action
+
+} elseif ...
From: Shawn O. Pearce
Date: Tuesday, September 30, 2008 - 12:53 pm

This looks fine, except for the diffstat.  You can't patch
the docs and the code in the same patch as they are in two
different repositories...  :-|

Also, I don't know if you've noticed but I think tg is
sending duplicate "To" headers in the messages:

	From: Petr Baudis <pasky@suse.cz>
*	To: git@vger.kernel.org
	Cc: spearce@spearce.org, Petr Baudis <petr.baudis@novartis.com>
	Subject: [PATCH] git-gui: Implement a 'clone' subcommand
	Date: Tue, 30 Sep 2008 18:51:41 +0200
	Message-Id: <1222793501-17997-1-git-send-email-pasky@suse.cz>
	X-Mailer: git-send-email 1.5.6.3.392.g292f1
*	To: git@vger.kernel.org
	Sender: git-owner@vger.kernel.org
	Precedence: bulk
	List-ID: <git.vger.kernel.org>
	X-Mailing-List: git@vger.kernel.org
 
-- 
Shawn.
--

From: Shawn O. Pearce
Date: Tuesday, September 30, 2008 - 12:58 pm

I take that back.  "git gui clone git://repo.or.cz/alt-git.git"
didn't show the URL in the clone dialog for me.  This is on top
of your previous series, including the "locator" feature, and
with two locators configured in my .git/config.

-- 
Shawn.
--

From: Petr Baudis
Date: Friday, October 3, 2008 - 3:13 am

This patch fixes locators setup in case the URL variable is already set,
e.g. in the clone dialog during 'git gui clone'.

Signed-off-by: Petr Baudis <petr.baudis@novartis.com>

---
 git-gui/lib/transport.tcl |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/git-gui/lib/transport.tcl b/git-gui/lib/transport.tcl
index 277e6b8..02c4eca 100644
--- a/git-gui/lib/transport.tcl
+++ b/git-gui/lib/transport.tcl
@@ -68,8 +68,13 @@ proc location_input {widget urlvar op} {
 
 	global _locator_template _locator_input _locator_var
 	trace remove variable _locator_input write locator_update
-	set _locator_template $default_locator
-	set _locator_input {}
+	if {[set $urlvar] == {}} {
+		set _locator_template $default_locator
+		set _locator_input {}
+	} else {
+		set _locator_template "URL"
+		set _locator_input [set $urlvar]
+	}
 	set _locator_var $urlvar
 	trace add variable _locator_input write locator_update
 
-- 
tg: (3c6c738..) t/git-gui/locator-preset (depends on: git-gui/locators t/git-gui/clonecmd)
--

From: H.Merijn Brand
Date: Friday, October 3, 2008 - 3:23 am

While you are working on git-gui's transport.tcl, would you consider a
user setting to set the default for pushing tags to remote repositories?


-- 
H.Merijn Brand          Amsterdam Perl Mongers  http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, SuSE 10.1, 10.2, and 10.3, AIX 5.2, and Cygwin.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/
--

From: Petr Baudis
Date: Friday, October 3, 2008 - 3:48 am

Actually, I think for the time being I'm finished with transport.tcl,
I'm sorry. :-) I probably won't work further on git-gui now that my
Novartis stay is almost over. My last stab will be probably trying to
change locators support to use insteadOf and possibly configurability of
the publish dialog if people decide they want it.

-- 
				Petr "Pasky" Baudis
People who take cold baths never have rheumatism, but they have
cold baths.
--

From: Shawn O. Pearce
Date: Friday, October 10, 2008 - 9:42 am

Huh.  Better, but Remote->Push... still crashes with your series:

can't read "push_url": no such variable
can't read "push_url": no such variable
    while executing
"set $urlvar"
    (procedure "location_input" line 26)
    invoked from within
"location_input $w.dest.url_t push_url push"
    (procedure "do_push_anywhere" line 53)
    invoked from within
"do_push_anywhere"
    invoked from within
".#mbar.#mbar#remote invoke active"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list $w invoke active]"
    (procedure "tk::MenuInvoke" line 50)
    invoked from within
"tk::MenuInvoke .#mbar.#mbar#remote 1"

-- 
Shawn.
--

From: Petr Baudis
Date: Friday, October 3, 2008 - 3:17 am

Oh, I forgot again, sorry. :-( But I think this shows rather bad design
of the layout, doesn't it? Shouldn't this documentation be kept in
git-gui/Documentation/{git-gui,config}.txt and included from git's

Thanks - I have noticed already but I didn't have time yet to fix it and
it seems generally pretty harmless. I will try to do something with that
later.

-- 
				Petr "Pasky" Baudis
People who take cold baths never have rheumatism, but they have
cold baths.
--

Previous thread: How Blobs Work ( Blobs Vs. Deltas) by Feanil Patel on Tuesday, September 30, 2008 - 8:14 am. (4 messages)

Next thread: git gui rescane_stage2 error on windows by astubbs on Tuesday, September 30, 2008 - 10:41 am. (2 messages)