{"thread":{"id":"6220","subject":"git-svn usability","startedAt":"2007-01-04T17:34:52Z","lastAt":"2007-01-08T13:11:21Z","messageCount":8,"participants":["David Kågedal","Eric Wong","Seth Falcon"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"30821","messageId":"87fyaqvgoz.fsf@morpheus.local","threadId":"6220","inReplyTo":null,"subject":"git-svn usability","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-01-04T17:34:52Z","receivedAt":"2007-01-04T17:34:52Z","isPatch":false,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"I wanted to try out \"git svn\" and did a \"git help svn\" and got the man\npage for git-svn.  That page starts out by describing that git-svn\nonly is useful for working with a single svn branch.  But then,\nfurther down, it describes the commands \"multi-init\" and\n\"multi-fetch\" anyway.  Confusing.  But I decided to give them a try.\nBut there isn't really any clear description on what the command line\nshould look like when you use multi-init (or any other git-svn command\nfor that matter).  So I boldly decided to try to run \"git svn help\nmulti-init\".  You never know, it might tell you something.  This is\nwhat happened:\n\n  morpheus% git svn help multi-init\n  GIT_SVN_ID set to 'trunk' for help/trunk\n  Initialized empty Git repository in /home/david/tmp/.git/\n  W: --branches/-b not specified\n  W: --tags/-t not specified\n\nNot exactly what I wanted.  The command-line parser in git-svn is\nbroken since it picks the first argument that looks like a command\nname.\n\n-- \nDavid Kågedal\n"},{"id":"30849","messageId":"20070105020158.GA21925@localdomain","threadId":"6220","inReplyTo":"87fyaqvgoz.fsf@morpheus.local","subject":"[1/2 PATCH] git-svn: make multi-init less confusing","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-01-05T02:02:00Z","receivedAt":"2007-01-05T02:02:00Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"It now requires at least one of the (trunk|branch|tags) arguments\n(either from the command-line or in .git/config).  Also we make\nsure that anything that is passed as a URL ('help') in David's\ncase is actually a URL.\n\nThanks to David Kågedal for reporting this issue.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   78 +++++++++++++++++++++++++++++----------------------------\n 1 files changed, 40 insertions(+), 38 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex b28c5bb..0fc386a 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -571,28 +571,25 @@ sub graft_branches {\n \n sub multi_init {\n \tmy $url = shift;\n-\t$_trunk ||= 'trunk';\n-\t$_trunk =~ s#/+$##;\n-\t$url =~ s#/+$## if $url;\n-\tif ($_trunk !~ m#^[a-z\\+]+://#) {\n-\t\t$_trunk = '/' . $_trunk if ($_trunk !~ m#^/#);\n-\t\tunless ($url) {\n-\t\t\tprint STDERR \"E: '$_trunk' is not a complete URL \",\n-\t\t\t\t\"and a separate URL is not specified\\n\";\n-\t\t\texit 1;\n-\t\t}\n-\t\t$_trunk = $url . $_trunk;\n-\t}\n-\tmy $ch_id;\n-\tif ($GIT_SVN eq 'git-svn') {\n-\t\t$ch_id = 1;\n-\t\t$GIT_SVN = $ENV{GIT_SVN_ID} = 'trunk';\n+\tunless (defined $_trunk || defined $_branches || defined $_tags) {\n+\t\tusage(1);\n \t}\n-\tinit_vars();\n-\tunless (-d $GIT_SVN_DIR) {\n-\t\tprint \"GIT_SVN_ID set to 'trunk' for $_trunk\\n\" if $ch_id;\n-\t\tinit($_trunk);\n-\t\tcommand_noisy('repo-config', 'svn.trunk', $_trunk);\n+\tif (defined $_trunk) {\n+\t\tmy $trunk_url = complete_svn_url($url, $_trunk);\n+\t\tmy $ch_id;\n+\t\tif ($GIT_SVN eq 'git-svn') {\n+\t\t\t$ch_id = 1;\n+\t\t\t$GIT_SVN = $ENV{GIT_SVN_ID} = 'trunk';\n+\t\t}\n+\t\tinit_vars();\n+\t\tunless (-d $GIT_SVN_DIR) {\n+\t\t\tif ($ch_id) {\n+\t\t\t\tprint \"GIT_SVN_ID set to 'trunk' for \",\n+\t\t\t\t      \"$trunk_url ($_trunk)\\n\";\n+\t\t\t}\n+\t\t\tinit($trunk_url);\n+\t\t\tcommand_noisy('repo-config', 'svn.trunk', $trunk_url);\n+\t\t}\n \t}\n \tcomplete_url_ls_init($url, $_branches, '--branches/-b', '');\n \tcomplete_url_ls_init($url, $_tags, '--tags/-t', 'tags/');\n@@ -872,29 +869,34 @@ sub rec_fetch {\n \t}\n }\n \n+sub complete_svn_url {\n+\tmy ($url, $path) = @_;\n+\t$path =~ s#/+$##;\n+\t$url =~ s#/+$## if $url;\n+\tif ($path !~ m#^[a-z\\+]+://#) {\n+\t\t$path = '/' . $path if ($path !~ m#^/#);\n+\t\tif (!defined $url || $url !~ m#^[a-z\\+]+://#) {\n+\t\t\tfatal(\"E: '$path' is not a complete URL \",\n+\t\t\t      \"and a separate URL is not specified\\n\");\n+\t\t}\n+\t\t$path = $url . $path;\n+\t}\n+\treturn $path;\n+}\n+\n sub complete_url_ls_init {\n-\tmy ($url, $var, $switch, $pfx) = @_;\n-\tunless ($var) {\n+\tmy ($url, $path, $switch, $pfx) = @_;\n+\tunless ($path) {\n \t\tprint STDERR \"W: $switch not specified\\n\";\n \t\treturn;\n \t}\n-\t$var =~ s#/+$##;\n-\tif ($var !~ m#^[a-z\\+]+://#) {\n-\t\t$var = '/' . $var if ($var !~ m#^/#);\n-\t\tunless ($url) {\n-\t\t\tprint STDERR \"E: '$var' is not a complete URL \",\n-\t\t\t\t\"and a separate URL is not specified\\n\";\n-\t\t\texit 1;\n-\t\t}\n-\t\t$var = $url . $var;\n-\t}\n-\tmy @ls = libsvn_ls_fullurl($var);\n-\tmy $old = $GIT_SVN;\n+\tmy $full_url = complete_svn_url($url, $path);\n+\tmy @ls = libsvn_ls_fullurl($full_url);\n \tdefined(my $pid = fork) or croak $!;\n \tif (!$pid) {\n-\t\tforeach my $u (map { \"$var/$_\" } (grep m!/$!, @ls)) {\n+\t\tforeach my $u (map { \"$full_url/$_\" } (grep m!/$!, @ls)) {\n \t\t\t$u =~ s#/+$##;\n-\t\t\tif ($u !~ m!\\Q$var\\E/(.+)$!) {\n+\t\t\tif ($u !~ m!\\Q$full_url\\E/(.+)$!) {\n \t\t\t\tprint STDERR \"W: Unrecognized URL: $u\\n\";\n \t\t\t\tdie \"This should never happen\\n\";\n \t\t\t}\n@@ -912,7 +914,7 @@ sub complete_url_ls_init {\n \twaitpid $pid, 0;\n \tcroak $? if $?;\n \tmy ($n) = ($switch =~ /^--(\\w+)/);\n-\tcommand_noisy('repo-config', \"svn.$n\", $var);\n+\tcommand_noisy('repo-config', \"svn.$n\", $full_url);\n }\n \n sub common_prefix {\n\n-- \nEric Wong\n"},{"id":"30850","messageId":"20070105020405.GA17716@localdomain","threadId":"6220","inReplyTo":"87fyaqvgoz.fsf@morpheus.local","subject":"[PATCH 2/2] git-svn: update documentation for multi-{init|fetch}","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-01-05T02:04:06Z","receivedAt":"2007-01-05T02:04:06Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Signed-off-by: Eric Wong <normalperson@yhbt.net>\n---\n Documentation/git-svn.txt |   54 ++++++++++++++++++++++++++++++--------------\n 1 files changed, 37 insertions(+), 17 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex f5f57e8..f754d2f 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -3,7 +3,7 @@ git-svn(1)\n \n NAME\n ----\n-git-svn - bidirectional operation between a single Subversion branch and git\n+git-svn - bidirectional operation between Subversion and git\n \n SYNOPSIS\n --------\n@@ -11,24 +11,20 @@ SYNOPSIS\n \n DESCRIPTION\n -----------\n-git-svn is a simple conduit for changesets between a single Subversion\n-branch and git. It is not to be confused with gitlink:git-svnimport[1].\n-They were designed with very different goals in mind.\n+git-svn is a simple conduit for changesets between Subversion and git.\n+It is not to be confused with gitlink:git-svnimport[1], which is\n+read-only and geared towards tracking multiple branches.\n \n-git-svn is designed for an individual developer who wants a\n+git-svn was originally designed for an individual developer who wants a\n bidirectional flow of changesets between a single branch in Subversion\n-and an arbitrary number of branches in git.  git-svnimport is designed\n-for read-only operation on repositories that match a particular layout\n-(albeit the recommended one by SVN developers).\n+and an arbitrary number of branches in git.  Since its inception,\n+git-svn has gained the ability to track multiple branches in a manner\n+similar to git-svnimport; but it cannot (yet) automatically detect new\n+branches and tags like git-svnimport does.\n \n-For importing svn, git-svnimport is potentially more powerful when\n-operating on repositories organized under the recommended\n-trunk/branch/tags structure, and should be faster, too.\n-\n-git-svn mostly ignores the very limited view of branching that\n-Subversion has.  This allows git-svn to be much easier to use,\n-especially on repositories that are not organized in a manner that\n-git-svnimport is designed for.\n+git-svn is especially useful when it comes to tracking repositories\n+not organized in the way Subversion developers recommend (trunk,\n+branches, tags directories).\n \n COMMANDS\n --------\n@@ -370,7 +366,7 @@ SVN was very wrong.\n Basic Examples\n ~~~~~~~~~~~~~~\n \n-Tracking and contributing to a Subversion-managed project:\n+Tracking and contributing to a the trunk of a Subversion-managed project:\n \n ------------------------------------------------------------------------\n # Initialize a repo (like git init-db):\n@@ -388,6 +384,30 @@ Tracking and contributing to a Subversion-managed project:\n \tgit-svn show-ignore >> .git/info/exclude\n ------------------------------------------------------------------------\n \n+Tracking and contributing to an entire Subversion-managed project\n+(complete with a trunk, tags and branches):\n+See also:\n+'<<tracking-multiple-repos,Tracking Multiple Repositories or Branches>>'\n+\n+------------------------------------------------------------------------\n+# Initialize a repo (like git init-db):\n+\tgit-svn multi-init http://svn.foo.org/project \\\n+\t\t-T trunk -b branches -t tags\n+# Fetch remote revisions:\n+\tgit-svn multi-fetch\n+# Create your own branch of trunk to hack on:\n+\tgit checkout -b my-trunk remotes/trunk\n+# Do some work, and then commit your new changes to SVN, as well as\n+# automatically updating your working HEAD:\n+\tgit-svn dcommit -i trunk\n+# Something has been committed to trunk, rebase the latest into your branch:\n+\tgit-svn multi-fetch && git rebase remotes/trunk\n+# Append svn:ignore settings of trunk to the default git exclude file:\n+\tgit-svn show-ignore -i trunk >> .git/info/exclude\n+# Check for new branches and tags (no arguments are needed):\n+\tgit-svn multi-init\n+------------------------------------------------------------------------\n+\n REBASE VS. PULL\n ---------------\n \n-- \n1.5.0.rc0.g0d67\n"},{"id":"30861","messageId":"871wmaugh6.fsf@morpheus.local","threadId":"6220","inReplyTo":"20070105020158.GA21925@localdomain","subject":"Re: [1/2 PATCH] git-svn: make multi-init less confusing","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-01-05T06:37:09Z","receivedAt":"2007-01-05T06:37:09Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> It now requires at least one of the (trunk|branch|tags) arguments\n> (either from the command-line or in .git/config).  Also we make\n> sure that anything that is passed as a URL ('help') in David's\n> case is actually a URL.\n\nIf I understand correctly, this still allows you to write\n\n  $ git svn svn://foo/bar multi-init\n\nwhich is kindof confusing.  But I guess it's less likely that anyone\ndoes it by mistake.\n\nThanks for the quick response, anyway.  The documentation patch is\nalso a great improvement.\n\nNow if you could only clarify the documentation of dcommit to explain\nwhether it creates one svn revision per commit in your branch, or if\nit creates a single svn revision with the full diff, and the\ndocumentation would be perfect :-)\n\n-- \nDavid Kågedal\n"},{"id":"30886","messageId":"m2ejq9trf1.fsf@gmail.com","threadId":"6220","inReplyTo":"871wmaugh6.fsf@morpheus.local","subject":"Re: [1/2 PATCH] git-svn: make multi-init less confusing","fromName":"Seth Falcon","fromEmail":"sethfalcon@gmail.com","sentAt":"2007-01-05T15:38:26Z","receivedAt":"2007-01-05T15:38:26Z","isPatch":true,"sender":{"key":"sethfalcon@gmail.com","avatar":"https://gravatar.com/avatar/fd62fe73d3013b12fce71d5269ec52eaca3c4cee479efc6eea3603d6f1d8bf8d?d=mp&s=160"},"body":"David Kågedal <davidk@lysator.liu.se> writes:\n> Now if you could only clarify the documentation of dcommit to explain\n> whether it creates one svn revision per commit in your branch, or if\n> it creates a single svn revision with the full diff, and the\n> documentation would be perfect :-)\n\ndcommit creates one svn rev for each commit listed by:\n\n   git log remotes/git-svn..HEAD\n\n+ seth\n"},{"id":"31131","messageId":"87lkkdr82g.fsf@morpheus.local","threadId":"6220","inReplyTo":"m2ejq9trf1.fsf@gmail.com","subject":"Re: [1/2 PATCH] git-svn: make multi-init less confusing","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-01-08T12:56:07Z","receivedAt":"2007-01-08T12:56:07Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Seth Falcon <sethfalcon@gmail.com> writes:\n\n> David Kågedal <davidk@lysator.liu.se> writes:\n>> Now if you could only clarify the documentation of dcommit to explain\n>> whether it creates one svn revision per commit in your branch, or if\n>> it creates a single svn revision with the full diff, and the\n>> documentation would be perfect :-)\n>\n> dcommit creates one svn rev for each commit listed by:\n>\n>    git log remotes/git-svn..HEAD\n>\n> + seth\n\nOk, so I tried rewriting the documentation.  But I'm still not sure I\nunderstand fully how it works.\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex f5f57e8..8c91e78 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -57,15 +57,18 @@ See '<<fetch-args,Additional Fetch Arguments>>' if you are interested in\n manually joining branches on commit.\n \n 'dcommit'::\n-\tCommit all diffs from a specified head directly to the SVN\n-\trepository, and then rebase or reset (depending on whether or\n-\tnot there is a diff between SVN and head).  It is recommended\n-\tthat you run git-svn fetch and rebase (not pull) your commits\n-\tagainst the latest changes in the SVN repository.\n-\tAn optional command-line argument may be specified as an\n-\talternative to HEAD.\n-\tThis is advantageous over 'set-tree' (below) because it produces\n-\tcleaner, more linear history.\n+\tCommit to the Subversion repository all commits in a branch\n+\tthat are not yet in Subversion.  If no branch name is given,\n+\tHEAD is used.\n+\t\n+\tAfter committing, the branch is rebased or reset (depending on\n+\twhether or not there is a diff between SVN and the branch).\n+\tIt is recommended that you run git-svn fetch and rebase (not\n+\tpull) your commits against the latest changes in the SVN\n+\trepository.\n+\n+\tThis is advantageous over 'set-tree' (below) because it\n+\tproduces cleaner, more linear history.\n \n 'log'::\n \tThis should make it easy to look up svn log messages when svn\n\nFirst of all, I would like to see the 'dcommit' header show that a\nbranch name can be given, and what else you might want to write there.\n\nSecondly, the second paragraph is not very clear.  What does it mean\nthat the branch is \"rebased or reset\"? Against what? And why does it\nmatter if I have a diff? And does it still work if I'm dcommitting\nanother branch than HEAD?\n\nI can probably guess the answer to some of these questions, but I\nwould like to improve the documentation so nobody has to guess.\n\n-- \nDavid Kågedal\n"},{"id":"31132","messageId":"87hcv1r7xv.fsf@morpheus.local","threadId":"6220","inReplyTo":"m2ejq9trf1.fsf@gmail.com","subject":"Re: [1/2 PATCH] git-svn: make multi-init less confusing","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-01-08T12:58:52Z","receivedAt":"2007-01-08T12:58:52Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Seth Falcon <sethfalcon@gmail.com> writes:\n\n> David Kågedal <davidk@lysator.liu.se> writes:\n>> Now if you could only clarify the documentation of dcommit to explain\n>> whether it creates one svn revision per commit in your branch, or if\n>> it creates a single svn revision with the full diff, and the\n>> documentation would be perfect :-)\n>\n> dcommit creates one svn rev for each commit listed by:\n>\n>    git log remotes/git-svn..HEAD\n\nSo if I want to commit a different subset, is that possible?  In my\ncase, I have a \"master\" branch with a few changes on top of git-svn\nthat I never want to commit to svn.  So what I want is to commit\n\"master..HEAD\".  Can I do that with dcommit?  It seems that \"git svn\nset-tree master..HEAD\" might do the trick.\n\n-- \nDavid Kågedal\n"},{"id":"31134","messageId":"877ivxr7d2.fsf@morpheus.local","threadId":"6220","inReplyTo":"87hcv1r7xv.fsf@morpheus.local","subject":"Re: [1/2 PATCH] git-svn: make multi-init less confusing","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-01-08T13:11:21Z","receivedAt":"2007-01-08T13:11:21Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"David Kågedal <davidk@lysator.liu.se> writes:\n\n> Seth Falcon <sethfalcon@gmail.com> writes:\n>\n>> David Kågedal <davidk@lysator.liu.se> writes:\n>>> Now if you could only clarify the documentation of dcommit to explain\n>>> whether it creates one svn revision per commit in your branch, or if\n>>> it creates a single svn revision with the full diff, and the\n>>> documentation would be perfect :-)\n>>\n>> dcommit creates one svn rev for each commit listed by:\n>>\n>>    git log remotes/git-svn..HEAD\n>\n> So if I want to commit a different subset, is that possible?  In my\n> case, I have a \"master\" branch with a few changes on top of git-svn\n> that I never want to commit to svn.  So what I want is to commit\n> \"master..HEAD\".  Can I do that with dcommit?  It seems that \"git svn\n> set-tree master..HEAD\" might do the trick.\n\nI tried set-tree now, and all I got was a perl crash:\n\nmorpheus% git svn set-tree master..\ndiff-tree 8dba2b29df78184fef96bbbf9521387846b140b3 b5561ab7309e9b7b3acfacaa786358e7d90665c6\n        A       .gitignore\n... more files\nUse of uninitialized value in concatenation (.) or string at /usr/lib/perl5/SVN/Core.pm line 579.\nMalformed file:  at /usr/local/bin/git-svn line 459\n\nThis is git f4bf2184ae8b79f95b9f56c1ea5455d04e559299 from Jan 1.\n\nPerl is v5.8.8 (Ubunty edgy)\n\n-- \nDavid Kågedal\n"}]}