{"thread":{"id":"15662","subject":"[PATCH 2/3] git-gui: Use git web--browse --stdin for safe URL passing","startedAt":"2008-09-24T23:57:34Z","lastAt":"2008-09-25T10:24:47Z","messageCount":7,"participants":["pasky@suse.cz","Andreas Ericsson","Peter Krefting","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"91549","messageId":"20080924235734.697978308@suse.cz","threadId":"15662","inReplyTo":null,"subject":"[PATCH 0/3] [RFC] Support for publishing projects at central site","fromName":"","fromEmail":"pasky@suse.cz","sentAt":"2008-09-24T23:57:34Z","receivedAt":"2008-09-24T23:57:34Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"This series implements a special variant of the 'add remote' dialog\ndesigned for publishing new projects at a central site - it fixes\ncertain parameters and launches web browser during the push for\nproject registration in a repo.or.cz-like fashion. The feature is\naimed especially at corporate Git deployment.\n\nThis is not really meant for as-is application, of course, but more\nto see if people think it is good idea to have this kind of functionality\nin git-gui at all and how generic it should be. This mini-series depends\non pretty much all the other patches I have submitted tonight.\n"},{"id":"91548","messageId":"20080925000156.372683193@suse.cz","threadId":"15662","inReplyTo":"20080924235734.697978308@suse.cz","subject":"[PATCH 1/3] git web--browse: Add --stdin option support","fromName":"","fromEmail":"pasky@suse.cz","sentAt":"2008-09-24T23:57:35Z","receivedAt":"2008-09-24T23:57:35Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"This ugly hack seems to be necessary to safely pass URLs containing\nquery string even in the MinGW environment from TCL (git-gui). I admit\nthat it is not nice, but I at least did not manage to find any other\nway to achieve that even after spending very long time debugging this\nmysterious problem.\n\nThis patch has been sponsored by Novartis.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n Documentation/git-web--browse.txt |    5 ++++-\n git-web--browse.sh                |    6 +++++-\n 2 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt\nindex 7f7a45b..15d2c25 100644\n--- a/Documentation/git-web--browse.txt\n+++ b/Documentation/git-web--browse.txt\n@@ -7,7 +7,7 @@ git-web--browse - git helper script to launch a web browser\n \n SYNOPSIS\n --------\n-'git web--browse' [OPTIONS] URL/FILE ...\n+'git web--browse' [OPTIONS] {--stdin,URL/FILE...}\n \n DESCRIPTION\n -----------\n@@ -45,6 +45,9 @@ OPTIONS\n \tCONF.VAR is looked up in the git config files. If it's set,\n \tthen its value specify the browser that should be used.\n \n+--stdin::\n+\tRead the location to open from stdin.\n+\n CONFIGURATION VARIABLES\n -----------------------\n \ndiff --git a/git-web--browse.sh b/git-web--browse.sh\nindex 384148a..68234fa 100755\n--- a/git-web--browse.sh\n+++ b/git-web--browse.sh\n@@ -16,7 +16,7 @@\n # git maintainer.\n #\n \n-USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...'\n+USAGE='[--browser=browser|--tool=browser] [--config=conf.var] {--stdin,url/file...}'\n \n # This must be capable of running outside of git directory, so\n # the vanilla git-sh-setup should not be used.\n@@ -71,6 +71,10 @@ do\n \t\t    shift ;;\n \t    esac\n \t    ;;\n+\t--stdin*)\n+\t    shift\n+\t    set \"$(cat)\"\n+\t    break ;;\n \t--)\n \t    break\n \t    ;;\n-- \ntg: (c427559..) t/web--browse/stdin (depends on: vanilla/master)\n"},{"id":"91547","messageId":"20080925000156.857197915@suse.cz","threadId":"15662","inReplyTo":"20080924235734.697978308@suse.cz","subject":"[PATCH 2/3] git-gui: Use git web--browse --stdin for safe URL passing","fromName":"","fromEmail":"pasky@suse.cz","sentAt":"2008-09-24T23:57:36Z","receivedAt":"2008-09-24T23:57:36Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"The current code does not actually require this since the documentation\nURL should always pass through unmangled, but future users of\nstart_browser() (as in the patch to follow) might require this.\n\nThis patch has been sponsored by Novartis.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n git-gui/git-gui.sh |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex fc67eb8..4d2d600 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -2360,7 +2360,11 @@ if {[file isfile $doc_path]} {\n }\n \n proc start_browser {url} {\n-\tgit \"web--browse\" $url\n+\t# We use --stdin here since passing URLs (especially with query\n+\t# strings) does insane things in MSysGit.\n+\tset fd [git_write \"web--browse\" \"--stdin\"]\n+\tputs $fd $url\n+\tclose $fd\n }\n \n .mbar.help add command -label [mc \"Online Documentation\"] \\\n-- \ntg: (6e32399..) t/git-gui/web-browse-stdin (depends on: t/git-gui/web-browse t/web--browse/stdin)\n"},{"id":"91550","messageId":"20080925000157.506352696@suse.cz","threadId":"15662","inReplyTo":"20080924235734.697978308@suse.cz","subject":"[PATCH 3/3] [FYI]git-gui: repo.or.cz-ish fork integration","fromName":"","fromEmail":"pasky@suse.cz","sentAt":"2008-09-24T23:57:37Z","receivedAt":"2008-09-24T23:57:37Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"During my internship at Novartis, I have deployed a local instance of the\nrepo.or.cz software and for our Git deployment, some kind of integration with\ngit-gui was very desirable - if someone makes local changes in his repository,\nhe can easily publish them on the local repo.or.cz instance as a fork of the\noriginal project. They can use the extra 'Register on repo.or.cz' item in the\n'Remote' menu, which will enforce the default locator and aside of initializing\nthe remote repository and pushing will also open the web browser with the\nproject registration form of repo.or.cz.\n\nI'm not sure if something like this would be desirable for upstream, even as an\noptional feature, and to what degree should it be configurable - but I imagine\nthat something like this could be very useful for corporate Git deployments\nespecially among less technical users and in scenarios using some kind of\ncentral place to store all the repositories. Perhaps people deploying Git\nin these cases will find the patch useful to apply locally even if it won't\nend up merged.\n\nThis patch has been sponsored by Novartis.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n git-gui/git-gui.sh         |    4 ++++\n git-gui/lib/remote_add.tcl |   42 +++++++++++++++++++++++++++++++++++++-----\n git-gui/lib/transport.tcl  |    7 +++++++\n 3 files changed, 48 insertions(+), 5 deletions(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex aef9d66..a79d734 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -2305,6 +2305,10 @@ if {[is_enabled transport]} {\n \tmenu .mbar.remote\n \n \t.mbar.remote add command \\\n+\t\t-label [mc \"Register on repo.or.cz\"] \\\n+\t\t-command remote_add::dialog_reg \\\n+\t\t-accelerator $M1T-L\n+\t.mbar.remote add command \\\n \t\t-label [mc \"Add...\"] \\\n \t\t-command remote_add::dialog \\\n \t\t-accelerator $M1T-A\ndiff --git a/git-gui/lib/remote_add.tcl b/git-gui/lib/remote_add.tcl\nindex 94662fb..fb43abd 100644\n--- a/git-gui/lib/remote_add.tcl\n+++ b/git-gui/lib/remote_add.tcl\n@@ -6,22 +6,36 @@ class remote_add {\n field w              ; # widget path\n field w_name         ; # new remote name widget\n field w_loc          ; # new remote location widget\n+field is_reg        0; # are we the REGistering dialog, or normal add remote?\n+field base_name      ; # name of base project if is_reg\n \n field name         {}; # name of the remote the user has chosen\n field location     {}; # location of the remote the user has chosen\n \n-field opt_action fetch; # action to do after registering the remote locally\n+field opt_action   {}; # action to do after registering the remote locally\n \n-constructor dialog {} {\n+proc dialog {} {\n+\tdialog_create \"\" 0 \"fetch\" \"Add New Remote\"\n+}\n+\n+proc dialog_reg {} {\n+\tdialog_create \"public\" 1 \"push\" \"Register On repo.or.cz\"\n+}\n+\n+constructor dialog_create {name_ is_reg_ opt_action_ title} {\n \tglobal repo_config\n \n+\tset name $name_\n+\tset is_reg $is_reg_\n+\tset opt_action $opt_action_\n+\n \tmake_toplevel top w\n-\twm title $top [append \"[appname] ([reponame]): \" [mc \"Add Remote\"]]\n+\twm title $top [append \"[appname] ([reponame]): \" [mc $title]]\n \tif {$top ne {.}} {\n \t\twm geometry $top \"+[winfo rootx .]+[winfo rooty .]\"\n \t}\n \n-\tlabel $w.header -text [mc \"Add New Remote\"] -font font_uibold\n+\tlabel $w.header -text [mc $title] -font font_uibold\n \tpack $w.header -side top -fill x\n \n \tframe $w.buttons\n@@ -49,7 +63,9 @@ constructor dialog {} {\n \n \tlabel $w.desc.loc_l -text [mc \"Location:\"]\n \tset w_loc $w.desc.loc_t\n-\tlocation_input $w_loc @location remote\n+\tset location_op \"remote\"\n+\tif {$is_reg} { set location_op \"reg\" }\n+\tlocation_input $w_loc @location $location_op\n \tgrid $w.desc.loc_l $w_loc -sticky we -padx {0 5}\n \n \tgrid columnconfigure $w.desc 1 -weight 1\n@@ -78,6 +94,18 @@ constructor dialog {} {\n \tgrid columnconfigure $w.action 1 -weight 1\n \tpack $w.action -anchor nw -fill x -pady 5 -padx 5\n \n+\tif {$is_reg} {\n+\t\tfocus $w_loc\n+\t\tset matcher [regsub -all %s \"$repo_config(locator.repo.template)\" \"(.*)\"]\n+\t\tset origin willnevermatch\n+\t\tcatch { set origin $repo_config(remote.origin.url) }\n+\t\tif {![regexp $matcher $origin xx base_name]} {\n+\t\t\terror_popup \"This repository is not based on a repo.or.cz project; you need to register your project manually.\"\n+\t\t\tdestroy $w\n+\t\t\treturn\n+\t\t}\n+\t}\n+\n \tbind $w <Visibility> [cb _visible]\n \tbind $w <Key-Escape> [list destroy $w]\n \tbind $w <Key-Return> [cb _add]\\;break\n@@ -160,6 +188,10 @@ method _add {} {\n \t\t\t[mc \"Setting up the %s (at %s)\" $name $location]]\n \n \t\tlappend cmds [list exec git push -v --all $name]\n+\t\tif {$is_reg} {\n+\t\t\tglobal _locator_input\n+\t\t\tstart_browser \"http://repo.or.cz/m/regproj.cgi?fork=$base_name;LOC_i1=$_locator_input\"\n+\t\t}\n \t\tconsole::chain $c $cmds\n \t}\n \tnone {\ndiff --git a/git-gui/lib/transport.tcl b/git-gui/lib/transport.tcl\nindex 277e6b8..b80d526 100644\n--- a/git-gui/lib/transport.tcl\n+++ b/git-gui/lib/transport.tcl\n@@ -62,6 +62,12 @@ proc location_input {widget urlvar op} {\n \t\treturn 0\n \t}\n \n+\tset state \"normal\"\n+\tif {$op == \"reg\"} {\n+\t\tset state \"disabled\"\n+\t\tset op \"remote\"\n+\t}\n+\n \tif {[catch {set default_locator $repo_config(gui.${op}locator)}]} {\n \t\tset default_locator [lindex $all_locators 0]\n \t}\n@@ -75,6 +81,7 @@ proc location_input {widget urlvar op} {\n \n \tframe $widget\n \teval tk_optionMenu $widget.l _locator_template $all_locators\n+\t$widget.l configure -state $state\n \tentry $widget.s \\\n \t\t-borderwidth 1 \\\n \t\t-relief sunken \\\n-- \ntg: (2735999..) t/git-gui/remote-publish (depends on: git-gui/remotes git-gui/locators git-gui/web-browse t/git-gui/remote-fetch)\n"},{"id":"91556","messageId":"48DB2C99.5060909@op5.se","threadId":"15662","inReplyTo":"20080925000157.506352696@suse.cz","subject":"Re: [PATCH 3/3] [FYI]git-gui: repo.or.cz-ish fork integration","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-25T06:15:53Z","receivedAt":"2008-09-25T06:15:53Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"pasky@suse.cz wrote:\n\n[ a lot of stuff as an attachment ]\n\nFWIW, I thoroughly like this idea and I'm very excited to see how\nit'll work in op5's development environment.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"91567","messageId":"Pine.LNX.4.64.0809250951090.5683@ds9.cixit.se","threadId":"15662","inReplyTo":"20080924235734.697978308@suse.cz","subject":"Re: [PATCH 0/3] [RFC] Support for publishing projects at central site","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2008-09-25T08:56:18Z","receivedAt":"2008-09-25T08:56:18Z","isPatch":true,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Hi!\n\npasky@suse.cz:\n\n> This is not really meant for as-is application, of course, but more\n> to see if people think it is good idea to have this kind of\n> functionality in git-gui at all and how generic it should be. This\n> mini-series depends on pretty much all the other patches I have\n> submitted tonight.\n\nAs long as it is easy to implement the server-side back-end needed to\nautomatically accept projects that you publish through this hook, then\nthis is something that would really help out in this conext.\n\nI currently need to perform some \"magic\" on the server-side to set up\nnew projects, it would be nice if all the people using it have to do is\nto select a menu option saying \"publish\". Preferrably through the git\nprotocol, so that I don't have to set up ssh on people's machines\n(working in a Windows environment here, so all central repositories are\nset up to use the git protocol for both pull and push).\n\n\nHow do you envision discovering the location to publish to? Some kind\nof automatic configuration option would be nice. Perhaps be able to\npoint git gui at some magic URI that would download an XML (or text)\nfile describing the central server, perhaps?\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"91572","messageId":"20080925102447.GG10360@machine.or.cz","threadId":"15662","inReplyTo":"Pine.LNX.4.64.0809250951090.5683@ds9.cixit.se","subject":"Re: [PATCH 0/3] [RFC] Support for publishing projects at central site","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-09-25T10:24:47Z","receivedAt":"2008-09-25T10:24:47Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Hi!\n\nOn Thu, Sep 25, 2008 at 09:56:18AM +0100, Peter Krefting wrote:\n> pasky@suse.cz:\n> \n> > This is not really meant for as-is application, of course, but more\n> > to see if people think it is good idea to have this kind of\n> > functionality in git-gui at all and how generic it should be. This\n> > mini-series depends on pretty much all the other patches I have\n> > submitted tonight.\n> \n> As long as it is easy to implement the server-side back-end needed to\n> automatically accept projects that you publish through this hook, then\n> this is something that would really help out in this conext.\n\nWell, the example URL points to a Girocco script - Girocco is cleaned up\nand modernized version of the repo.or.cz duct tape, that should be easy\nto reconfigure for any kind of deployment and then simply make\ninstall-able. But any kind of CGI script can be in principle hooked up\nto this, so you can just write short shell thing that will do the magic\nand then\n\n\techo -e 'Content-type: text/plain\\n\\nRegistration succeeded!'\n\n> I currently need to perform some \"magic\" on the server-side to set up\n> new projects, it would be nice if all the people using it have to do is\n> to select a menu option saying \"publish\". Preferrably through the git\n> protocol, so that I don't have to set up ssh on people's machines\n> (working in a Windows environment here, so all central repositories are\n> set up to use the git protocol for both pull and push).\n\nWhich protocol do you use does not really matter, just set up the\nlocators right (or don't use them if you don't want to). I ended up\nusing samba exports mapped to Windows drives, but just using the git\nprotocol might make more sense in many scenarios.\n\n> How do you envision discovering the location to publish to? Some kind\n> of automatic configuration option would be nice. Perhaps be able to\n> point git gui at some magic URI that would download an XML (or text)\n> file describing the central server, perhaps?\n\nI provide customized MSysGit package with tweaked installer and with\ncustom /etc/gitconfig. I think in these deployments there is either this\npossibility or the machines are centrally administrated so the sysadmin\ncan adjust /etc/gitconfigs.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nPeople who take cold baths never have rheumatism, but they have\ncold baths.\n"}]}