From: pasky@suse.cz
To: git@vger.kernel.org
Cc: spearce@spearce.org
Subject: [PATCH 5/5] git-gui: Support for user-provided locator templates
Date: Thu, 25 Sep 2008 00:12:54 +0200 [thread overview]
Message-ID: <20080924221733.552292124@suse.cz> (raw)
In-Reply-To: 20080924221249.037449176@suse.cz
[-- Attachment #1: t/git-gui/locators.diff --]
[-- Type: text/plain, Size: 6681 bytes --]
Users can now configure their own 'locator' templates, which they
can use to easen entering of common URLs; in all location inputs,
they can choose from the defined locators (and raw URL entry) and
their input is then substituted to the locator template.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Documentation/config.txt | 25 ++++++++++++++++
git-gui/lib/choose_repository.tcl | 7 ++++-
git-gui/lib/remote_add.tcl | 2 +-
git-gui/lib/remote_branch_delete.tcl | 2 +-
git-gui/lib/transport.tcl | 52 +++++++++++++++++++++++++++++++--
5 files changed, 81 insertions(+), 7 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index bea867d..f3e82c6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -788,6 +788,21 @@ gui.pruneduringfetch::
"true" if linkgit:git-gui[1] should prune tracking branches when
performing a fetch. The default value is "false".
+gui.pulllocator::
+ Specifies the locator pre-selected for cloning and pulling
+ in case any locator templates (see 'locator.*.template')
+ are available. Set to 'URL' to default to the URL entry.
+
+gui.pushlocator::
+ Specifies the locator pre-selected for pushing
+ in case any locator templates (see 'locator.*.template')
+ are available. Set to 'URL' to default to the URL entry.
+
+gui.remotelocator::
+ Specifies the locator pre-selected when adding remotes
+ in case any locator templates (see 'locator.*.template')
+ are available. Set to 'URL' to default to the URL entry.
+
gui.trustmtime::
Determines if linkgit:git-gui[1] should trust the file modification
timestamp or not. By default the timestamps are not trusted.
@@ -891,6 +906,16 @@ instaweb.port::
The port number to bind the gitweb httpd to. See
linkgit:git-instaweb[1].
+locator.<name>.template::
+ Normally, you specify repository locations e.g. when cloning
+ or adding remotes by some kind of full-fledged URL-ish specifier.
+ This option lets you specify templates for the most common locations
+ so that you do not have to type out the full URLs all the time;
+ '%s' in the template is substituted by user input. Thus, for example
+ 'locator.ror.template = "git://git.kernel.org/%s"' would let you
+ easily refer to kernel.org projects. Currently, the user-defined
+ locators are supported only by linkgit:git-gui[1].
+
log.date::
Set default date-time mode for the log command. Setting log.date
value is similar to using 'git-log'\'s --date option. The value is one of the
diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 1c951ae..e05d3a9 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -465,7 +465,7 @@ method _do_clone {} {
pack $args -fill both
label $args.origin_l -text [mc "Source Location:"]
- location_input $args.origin_t @origin_url
+ location_input $args.origin_t @origin_url pull
button $args.origin_b \
-text [mc "Browse"] \
-command [cb _open_origin]
@@ -541,6 +541,11 @@ method _open_origin {} {
return
}
set origin_url $p
+
+ # Fix up locators in case we use them
+ global _locator_template _locator_input
+ set _locator_template URL
+ set _locator_input $p
}
method _update_clone {args} {
diff --git a/git-gui/lib/remote_add.tcl b/git-gui/lib/remote_add.tcl
index b4a9ede..dec9dcb 100644
--- a/git-gui/lib/remote_add.tcl
+++ b/git-gui/lib/remote_add.tcl
@@ -49,7 +49,7 @@ constructor dialog {} {
label $w.desc.loc_l -text [mc "Location:"]
set w_loc $w.desc.loc_t
- location_input $w_loc @location
+ location_input $w_loc @location remote
grid $w.desc.loc_l $w_loc -sticky we -padx {0 5}
grid columnconfigure $w.desc 1 -weight 1
diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
index 14a4c15..5cdab49 100644
--- a/git-gui/lib/remote_branch_delete.tcl
+++ b/git-gui/lib/remote_branch_delete.tcl
@@ -66,7 +66,7 @@ constructor dialog {} {
-text [mc "Arbitrary Location:"] \
-value url \
-variable @urltype
- location_input $w.dest.url_t @url
+ location_input $w.dest.url_t @url push
trace add variable @url write [cb _write_url]
grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
grid columnconfigure $w.dest 1 -weight 1
diff --git a/git-gui/lib/transport.tcl b/git-gui/lib/transport.tcl
index b8ceebe..277e6b8 100644
--- a/git-gui/lib/transport.tcl
+++ b/git-gui/lib/transport.tcl
@@ -30,19 +30,63 @@ proc push_to {remote} {
console::exec $w $cmd
}
-proc location_input {widget urlvar} {
+proc locator_update {args} {
global repo_config
+ global _locator_template _locator_input _locator_var
+ regsub -all %s "$repo_config(locator.$_locator_template.template)" \
+ $_locator_input $_locator_var
+}
+
+proc location_input {widget urlvar op} {
+ global repo_config all_locators
+ set all_locators [list]
+
+ set repo_config(locator.URL.template) "%s"
+ foreach line [array names repo_config locator.*.template] {
+ if {![regexp ^locator\.(.*)\.template\$ $line line name]} continue
+ lappend all_locators $name
+ }
+
+ # 1 == just the default URL locator
+ if {[llength $all_locators] == 1} {
+ entry $widget \
+ -borderwidth 1 \
+ -relief sunken \
+ -width 50 \
+ -textvariable $urlvar \
+ -validate key \
+ -validatecommand {
+ if {%d == 1 && [regexp {\s} %S]} {return 0}
+ return 1
+ }
+ return 0
+ }
+
+ if {[catch {set default_locator $repo_config(gui.${op}locator)}]} {
+ set default_locator [lindex $all_locators 0]
+ }
+
+ global _locator_template _locator_input _locator_var
+ trace remove variable _locator_input write locator_update
+ set _locator_template $default_locator
+ set _locator_input {}
+ set _locator_var $urlvar
+ trace add variable _locator_input write locator_update
- entry $widget \
+ frame $widget
+ eval tk_optionMenu $widget.l _locator_template $all_locators
+ entry $widget.s \
-borderwidth 1 \
-relief sunken \
-width 50 \
- -textvariable $urlvar \
+ -textvariable _locator_input \
-validate key \
-validatecommand {
if {%d == 1 && [regexp {\s} %S]} {return 0}
return 1
}
+ pack $widget.l -side left
+ pack $widget.s -side right -fill x
}
proc start_push_anywhere_action {w} {
@@ -164,7 +208,7 @@ proc do_push_anywhere {} {
-text [mc "Arbitrary Location:"] \
-value url \
-variable push_urltype
- location_input $w.dest.url_t push_url
+ location_input $w.dest.url_t push_url push
trace add variable push_url write push_anywhere_urltype
grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
grid columnconfigure $w.dest 1 -weight 1
--
tg: (d617ccd..) t/git-gui/locators (depends on: t/git-gui/ldialogs-refactor)
next prev parent reply other threads:[~2008-09-24 22:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-24 22:12 [PATCH 0/5] git-gui: Support for "Locators" - address templates pasky
2008-09-24 22:12 ` [PATCH 1/5] git-gui: Avoid using the term URL when specifying repositories pasky
2008-09-24 22:12 ` [PATCH 2/5] git-gui: Make input boxes in init/clone/open dialogs consistent pasky
2008-09-24 22:12 ` [PATCH 3/5] git-gui: Squash populate_{push,fetch}_menu to populate_remotes_menu pasky
2008-09-24 22:23 ` Petr Baudis
2008-09-24 22:12 ` [PATCH 4/5] git-gui: Factor out URL inputbox construction to location_input pasky
2008-09-24 22:12 ` pasky [this message]
2008-09-25 21:26 ` [PATCH 0/5] git-gui: Support for "Locators" - address templates Daniel Barkalow
2008-09-26 14:33 ` Shawn O. Pearce
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080924221733.552292124@suse.cz \
--to=pasky@suse.cz \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.