{"thread":{"id":"3595","subject":"git-svn, tree moves, and --no-stop-on-copy","startedAt":"2006-03-07T22:08:37Z","lastAt":"2006-03-09T11:50:34Z","messageCount":9,"participants":["Yann Dirson","Eric Wong","Matthias Urlichs","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"17314","messageId":"20060307220837.GB27397@nowhere.earth","threadId":"3595","inReplyTo":null,"subject":"git-svn, tree moves, and --no-stop-on-copy","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-03-07T22:08:37Z","receivedAt":"2006-03-07T22:08:37Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"It looks that the --no-stop-on-copy flag has been dropped by error\nduring the \"options cleanup\" commit a couple of days ago.  This\ntrivial patch appears at first sight to address the problem:\n\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex 3c860e4..91a0d3b 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -36,7 +36,9 @@ my %fc_opts = ( 'no-ignore-externals' =>\n                'authors-file|A=s' => \\$_authors );\n my %cmd = (\n        fetch => [ \\&fetch, \"Download new revisions from SVN\",\n-                       { 'revision|r=s' => \\$_revision, %fc_opts } ],\n+                       { 'revision|r=s' => \\$_revision,\n+                         'no-stop-on-copy' => \\$_no_stop_copy,\n+                         %fc_opts } ],\n        init => [ \\&init, \"Initialize and fetch (import)\", { } ],\n        commit => [ \\&commit, \"Commit git revisions to SVN\",\n                        {       'stdin|' => \\$_stdin,\n\nBut then, \"git-svn fetch\" fails when trying to deal with the renaming:\n\n$ git-svn.perl init https://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk/src\n$ git-svn.perl fetch --no-stop-on-copy\n[...]\nUpdated to revision 163.\nr163 = 68da9a01b2d5a2372262ada33a401e03aef41e97\nsvn: REPORT request failed on '/svnroot/ufoai/!svn/vcc/default'\nsvn: Cannot replace a directory from within\n256 at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 812\n        main::sys('svn', 'up', '--ignore-externals', '-r166') called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 243\n        main::fetch() called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 83\n\nThe impacted revision in svn is:\n\n------------------------------------------------------------------------\nr166 | ydirson | 2006-03-02 01:36:55 +0100 (Thu, 02 Mar 2006) | 1 line\nChanged paths:\n   D /trunk\n   A /ufoai/trunk (from /trunk:165)\n\nAdding an ufoai toplevel module\n------------------------------------------------------------------------\n\nObviously \"svn update\" does not like it at all.\n\n\"svn switch --relocate\" does not seem to be of any help.  Switching\nmanually .git/git-svn/tree/ to the new repository location does not\nhelp either, since I must obviously update to r166 in that case, and\nthen a further \"git-svn fetch\" fails because it does not find\n.git/git-svn/revs/166 aleady imported.\n\nAny idea as to how to get the work done ?\nI could surely import in another branch not using --no-stop-on-copy,\nand then use a graft, but if we could make it work in a more\nstreamlined manner, it would surely be useful.\n\n\nBefore I find out in the doc about --no-stop-on-copy, I did a coupld\nof experimentation.  Among them, was using a peg-revision in the URL\npassed to \"git-svn init\":\n\n$ GIT_SVN_ID=git-oldsvn git-svn init https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165\n\nThat succeeds, but then \"git-svn fetch\" will fail with:\n\nsvn: REPORT request failed on '/svnroot/ufoai/!svn/bc/190/trunk/src@165'\nsvn: '/svnroot/ufoai/!svn/bc/190/trunk/src@165' path not found\n256 at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 783\n        main::svn_log_raw('https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165', '-r0:HEAD', '--stop-on-copy') called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 219\n        main::fetch() called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 81\n\n\nMaybe git-svn could also be guarded against peg-revisions on init\ncommand-line, since that appears to confuse it quite a bit :)\n\n\nAdditionally, it may be worth poiting out in the doc at least one\nvalid use of the --no-stop-on-copy flag that is friendly to the user's\nsanity: when the svn repository has undergone a reorg, such that the\nURL passed to \"init\" indeed moved - at least, when/if it is made to\nwork :)\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"17319","messageId":"20060308014207.GA31137@localdomain","threadId":"3595","inReplyTo":"20060307220837.GB27397@nowhere.earth","subject":"Re: git-svn, tree moves, and --no-stop-on-copy","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-08T01:42:07Z","receivedAt":"2006-03-08T01:42:07Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Yann Dirson <ydirson@altern.org> wrote:\n> It looks that the --no-stop-on-copy flag has been dropped by error\n> during the \"options cleanup\" commit a couple of days ago.  This\n> trivial patch appears at first sight to address the problem:\n\nThanks for the patch, but on second thought...\n\nI'm tempted to drop it as an option...  IIRC, the only reason\n--no-stop-on-copy exists in git-svn is in case ancient versions of svn\ndid not support --stop-on-copy.  I haven't bothered looking deeply into\nSVN history to see if it was always supported or not.\n \n> Before I find out in the doc about --no-stop-on-copy, I did a coupld\n> of experimentation.  Among them, was using a peg-revision in the URL\n> passed to \"git-svn init\":\n> \n> $ GIT_SVN_ID=git-oldsvn git-svn init https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165\n> \n> That succeeds, but then \"git-svn fetch\" will fail with:\n> \n> svn: REPORT request failed on '/svnroot/ufoai/!svn/bc/190/trunk/src@165'\n> svn: '/svnroot/ufoai/!svn/bc/190/trunk/src@165' path not found\n> 256 at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 783\n>         man::svn_log_raw('https://svn.sourceforge.net/svnroot/ufoai/trunk/src@165', '-r0:HEAD', '--stop-on-copy') called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 219\n>         main::fetch() called at /export/work/yann/git/git/contrib/git-svn/git-svn.perl line 81\n\nIf you want full repository history for reorganized repositories,\neasiest way is to pay the price for full repository and all of its\nhistory.\n\n\tgit-svn init https://svn.sourceforge.net/svnroot/ufoai\n\tgit-svn fetch\n\t# this puts all your branches and tags into one single big git tree.\n\nHowever, the following should always work: (after the following patch,\n\n\tGIT_SVN_ID=git-oldsvn git-svn init \\\n\t\thttps://svn.sourceforge.net/svnroot/ufoai/trunk\n\tGIT_SVN_ID=git-oldsvn git-svn fetch -r1:165\n\n\tGIT_SVN_ID=git-newsvn git-svn init\n\t\thttps://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk\n\tGIT_SVN_ID=git-newsvn git-svn fetch \\\n\t\t166=`git-rev-parse refs/remotes/git-oldsvn`\n\nUnfortunately, it does not, at least with svn 1.2.3...  I have a patch\ncoming that should fix things for 1.1.1 (and give better 1.1.x support\nin general).  I'm not sure, but it feels like something is screwed up\nwith svn 1.2.3dfsg1-3:\n\nThis works:\tsvn log -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk\n\nThis doesn't:\tsvn  co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk\n\nBut this:\tsvn  co -r1 https://svn.sourceforge.net/svnroot/ufoai\nwill create the following structure:\n\tufoai/{trunk,branches,tags}\n\nI'm quite puzzled about it, as I swear I've seen it work on a different\nproject recently (of course I cannot remember which :<)\n\n> Maybe git-svn could also be guarded against peg-revisions on init\n> command-line, since that appears to confuse it quite a bit :)\n\nPossibly, but having '@' in URLs is valid in some cases outside of\npeg-revisions.\n\n> Additionally, it may be worth poiting out in the doc at least one\n> valid use of the --no-stop-on-copy flag that is friendly to the user's\n> sanity: when the svn repository has undergone a reorg, such that the\n> URL passed to \"init\" indeed moved - at least, when/if it is made to\n> work :)\n\nIn the face of repository reorgs, git-svn is happiest tracking partial\nhistory.  Or tracking the entire repository from the root.\n\nHopefully I've been reasonably coherent, having insomnia lately.\n\n-- \nEric Wong\n"},{"id":"17320","messageId":"20060308015730.GA28056@localdomain","threadId":"3595","inReplyTo":"20060308014207.GA31137@localdomain","subject":"[PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-08T01:57:30Z","receivedAt":"2006-03-08T01:57:30Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Junio: please don't apply this patch to git.git just yet.  It seems fine\nto me, but I haven't tested it heavily yet (Yann can help me, I hope :)\nI hardly slept the past few days and I may have broken something badly\n(it pasts all the tests, though).\n\n---\n\nAs a side effect, this should also work better for 'init' off\ndirectories that are no longer in the latest revision of the\nrepository.\n\nFix 'fetch' args (<rev>=<commit> options) on brand-new heads\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn.perl |   26 ++++++++++++++++++--------\n 1 files changed, 18 insertions(+), 8 deletions(-)\n\n9f59596bde5bdd68d1a0a116f7383df74966de44\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex c575883..b8d2b3e 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -162,7 +162,8 @@ sub rebuild {\n \t\t\t\tcroak \"SVN repository location required: $url\\n\";\n \t\t\t}\n \t\t\t$SVN_URL ||= $url;\n-\t\t\t$SVN_UUID ||= setup_git_svn();\n+\t\t\t$SVN_UUID ||= $uuid;\n+\t\t\tsetup_git_svn();\n \t\t\t$latest = $rev;\n \t\t}\n \t\tassert_revision_eq_or_unknown($rev, $c);\n@@ -226,10 +227,12 @@ sub fetch {\n \t\tpush @svn_co,'--ignore-externals' unless $_no_ignore_ext;\n \t\tsys(@svn_co, $SVN_URL, $SVN_WC);\n \t\tchdir $SVN_WC or croak $!;\n+\t\tread_uuid();\n \t\t$last_commit = git_commit($base, @parents);\n \t\tassert_svn_wc_clean($base->{revision}, $last_commit);\n \t} else {\n \t\tchdir $SVN_WC or croak $!;\n+\t\tread_uuid();\n \t\t$last_commit = file_to_s(\"$REV_DIR/$base->{revision}\");\n \t}\n \tmy @svn_up = qw(svn up);\n@@ -275,7 +278,9 @@ sub commit {\n \n \tfetch();\n \tchdir $SVN_WC or croak $!;\n-\tmy $svn_current_rev =  svn_info('.')->{'Last Changed Rev'};\n+\tmy $info = svn_info('.');\n+\tread_uuid($info);\n+\tmy $svn_current_rev =  $info->{'Last Changed Rev'};\n \tforeach my $c (@revs) {\n \t\tmy $mods = svn_checkout_tree($svn_current_rev, $c);\n \t\tif (scalar @$mods == 0) {\n@@ -314,6 +319,14 @@ sub show_ignore {\n \n ########################### utility functions #########################\n \n+sub read_uuid {\n+\treturn if $SVN_UUID;\n+\tmy $info = shift || svn_info('.');\n+\t$SVN_UUID = $info->{'Repository UUID'} or\n+\t\t\t\t\tcroak \"Repository UUID unreadable\\n\";\n+\ts_to_file($SVN_UUID,\"$GIT_DIR/$GIT_SVN/info/uuid\");\n+}\n+\n sub setup_git_svn {\n \tdefined $SVN_URL or croak \"SVN repository location required\\n\";\n \tunless (-d $GIT_DIR) {\n@@ -323,14 +336,10 @@ sub setup_git_svn {\n \tmkpath([\"$GIT_DIR/$GIT_SVN/info\"]);\n \tmkpath([$REV_DIR]);\n \ts_to_file($SVN_URL,\"$GIT_DIR/$GIT_SVN/info/url\");\n-\t$SVN_UUID = svn_info($SVN_URL)->{'Repository UUID'} or\n-\t\t\t\t\tcroak \"Repository UUID unreadable\\n\";\n-\ts_to_file($SVN_UUID,\"$GIT_DIR/$GIT_SVN/info/uuid\");\n \n \topen my $fd, '>>', \"$GIT_DIR/$GIT_SVN/info/exclude\" or croak $!;\n \tprint $fd '.svn',\"\\n\";\n \tclose $fd or croak $!;\n-\treturn $SVN_UUID;\n }\n \n sub assert_svn_wc_clean {\n@@ -860,7 +869,6 @@ sub git_commit {\n \tmy ($log_msg, @parents) = @_;\n \tassert_revision_unknown($log_msg->{revision});\n \tmy $out_fh = IO::File->new_tmpfile or croak $!;\n-\t$SVN_UUID ||= svn_info('.')->{'Repository UUID'};\n \n \tmap_tree_joins() if (@_branch_from && !%tree_map);\n \n@@ -922,7 +930,9 @@ sub git_commit {\n \t}\n \tmy @update_ref = ('git-update-ref',\"refs/remotes/$GIT_SVN\",$commit);\n \tif (my $primary_parent = shift @exec_parents) {\n-\t\tpush @update_ref, $primary_parent;\n+\t\tif (!system('git-rev-parse',\"refs/remotes/$GIT_SVN\")){\n+\t\t\tpush @update_ref, $primary_parent;\n+\t\t}\n \t}\n \tsys(@update_ref);\n \tsys('git-update-ref',\"$GIT_SVN/revs/$log_msg->{revision}\",$commit);\n-- \n1.2.4.g198d\n"},{"id":"17336","messageId":"pan.2006.03.08.17.02.04.503230@smurf.noris.de","threadId":"3595","inReplyTo":"20060307220837.GB27397@nowhere.earth","subject":"Re: git-svn, tree moves, and --no-stop-on-copy","fromName":"Matthias Urlichs","fromEmail":"smurf@smurf.noris.de","sentAt":"2006-03-08T17:02:05Z","receivedAt":"2006-03-08T17:02:05Z","isPatch":false,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi, Yann Dirson wrote:\n\n> \"svn switch --relocate\" does not seem to be of any help.  Switching\n> manually .git/git-svn/tree/ to the new repository location does not\n> help either, since I must obviously update to r166 in that case, and\n> then a further \"git-svn fetch\" fails because it does not find\n> .git/git-svn/revs/166 aleady imported.\n> \n> Any idea as to how to get the work done ?\n\nYou can manually edit the .git/corr file. Simply add an entry for #166\nthat has your reorganized (if necessary) head's SHA1.\n-- \nMatthias Urlichs\n"},{"id":"17345","messageId":"20060308221524.GF12638@nowhere.earth","threadId":"3595","inReplyTo":"20060308014207.GA31137@localdomain","subject":"Re: git-svn, tree moves, and --no-stop-on-copy","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-03-08T22:15:24Z","receivedAt":"2006-03-08T22:15:24Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Tue, Mar 07, 2006 at 05:42:07PM -0800, Eric Wong wrote:\n> If you want full repository history for reorganized repositories,\n> easiest way is to pay the price for full repository and all of its\n> history.\n> \n> \tgit-svn init https://svn.sourceforge.net/svnroot/ufoai\n> \tgit-svn fetch\n> \t# this puts all your branches and tags into one single big git tree.\n> \n> However, the following should always work: (after the following patch,\n> \n> \tGIT_SVN_ID=git-oldsvn git-svn init \\\n> \t\thttps://svn.sourceforge.net/svnroot/ufoai/trunk\n> \tGIT_SVN_ID=git-oldsvn git-svn fetch -r1:165\n> \n> \tGIT_SVN_ID=git-newsvn git-svn init\n> \t\thttps://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk\n> \tGIT_SVN_ID=git-newsvn git-svn fetch \\\n> \t\t166=`git-rev-parse refs/remotes/git-oldsvn`\n\nThanks much for the hint - it should definitively be a good example\nfor the doc.\n\n> Unfortunately, it does not, at least with svn 1.2.3...  I have a patch\n> coming that should fix things for 1.1.1 (and give better 1.1.x support\n> in general).  I'm not sure, but it feels like something is screwed up\n> with svn 1.2.3dfsg1-3:\n> \n> This works:\tsvn log -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk\n\n> This doesn't:\tsvn  co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk\n> \n> But this:\tsvn  co -r1 https://svn.sourceforge.net/svnroot/ufoai\n> will create the following structure:\n> \tufoai/{trunk,branches,tags}\n> \n> I'm quite puzzled about it, as I swear I've seen it work on a different\n> project recently (of course I cannot remember which :<)\n\nLooks like svn may be looking at the current revision to find out\nwhich path you are requesting, and that path does not exist any more.\nCould look like something normal, if \"svn log\" complained - but the\nproblem may just be with \"svn log\".\n\nOTOH, this does work:\n\n svn co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk@1\n\n\n> In the face of repository reorgs, git-svn is happiest tracking partial\n> history.  Or tracking the entire repository from the root.\n\nWell, that could be a solution, if I could 1) filter out parts of the\ntree I do not care about, and 2) strip the leading /whatever/trunk.\nNot sure it's worth it :)\n\n\n> Hopefully I've been reasonably coherent, having insomnia lately.\n\nAt least, my state of insomnia makes it look perferctly coherent :)\n\nBest regards,\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"17346","messageId":"20060308224104.GC27397@nowhere.earth","threadId":"3595","inReplyTo":"20060308221524.GF12638@nowhere.earth","subject":"Re: git-svn, tree moves, and --no-stop-on-copy","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-03-08T22:41:04Z","receivedAt":"2006-03-08T22:41:04Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"On Wed, Mar 08, 2006 at 11:15:24PM +0100, Yann Dirson wrote:\n> OTOH, this does work:\n> \n>  svn co -r1 https://svn.sourceforge.net/svnroot/ufoai/trunk@1\n\nLet's go further:\n\n@@ -224,12 +227,14 @@ sub fetch {\n        unless (-d $SVN_WC) {\n                my @svn_co = ('svn','co',\"-r$base->{revision}\");\n                push @svn_co,'--ignore-externals' unless $_no_ignore_ext;\n-               sys(@svn_co, $SVN_URL, $SVN_WC);\n+               sys(@svn_co, $SVN_URL . \"\\@$base->{revision}\", $SVN_WC);\n                chdir $SVN_WC or croak $!;\n\n\nThat allows git-svn not to fail at r1 (or at r3 when checking out\ntrunk/src only), and the 1st fetch runs OK.\n\nThe second fetch runs OK as well, but it shows the following somewhat\nscary stuff before starting the import:\n\nChecked out revision 166.\nrefs/remotes/git-newsvn\nfatal: 'refs/remotes/git-newsvn': No such file or directory\nr166 = 38a6ba0e3db486c65a611c54c53f838210ce7551\n\n\nThe results looks fine.  I don't know if it is expected to have the\nmaster head stuck at remotes/git-oldsvn, though.\n\nThanks much for your help!\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"17360","messageId":"7vacc07wwp.fsf@assigned-by-dhcp.cox.net","threadId":"3595","inReplyTo":"20060308015730.GA28056@localdomain","subject":"Re: [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-09T10:08:38Z","receivedAt":"2006-03-09T10:08:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> Junio: please don't apply this patch to git.git just yet.  It seems fine\n> to me, but I haven't tested it heavily yet (Yann can help me, I hope :)\n> I hardly slept the past few days and I may have broken something badly\n> (it pasts all the tests, though).\n\nI won't be applying it then.\n\nI think this part is wrong.\n\n> @@ -922,7 +930,9 @@ sub git_commit {\n>  \t}\n>  \tmy @update_ref = ('git-update-ref',\"refs/remotes/$GIT_SVN\",$commit);\n>  \tif (my $primary_parent = shift @exec_parents) {\n> -\t\tpush @update_ref, $primary_parent;\n> +\t\tif (!system('git-rev-parse',\"refs/remotes/$GIT_SVN\")){\n> +\t\t\tpush @update_ref, $primary_parent;\n> +\t\t}\n\nI think you are trying to see if you have .git/refs/remotes/foo,\nand I think you actually have tried it to determine that is the\ncase.\n\nBut \"git-rev-parse refs/remotes/foo\" dies not because there is\nno valid file .git/refs/remotes/foo that records SHA1 of an\nexisting commit.  If there is refs/remotes/foo file, it thinks\nyou have asked for it and gives it back happily.\n\nA demonstration:\n\n\t$ cd /var/tmp/ && rm -fr junk && mkdir junk && cd junk\n        $ git init-db\n\tdefaulting to local storage area\n        $ git-rev-parse refs/remotes/foo ; echo $?\n        refs/remotes/foo\n        fatal: 'refs/remotes/foo': No such file or directory\n        128\n        $ mkdir -p refs/remotes/foo\n        $ ls -a\n        ./  ../  .git/\trefs/\n        $ git-rev-parse refs/remotes/foo; echo $?\n        refs/remotes/foo\n        0\n\nIf you are trying to see if there is such a ref, I would do\nthis:\n\n\t$ git-rev-parse --verify refs/remotes/foo^0\n        git-rev-parse --verify refs/remotes/foo^0\n        fatal: Needed a single revision\n\t128\n\nThe --verify flag makes sure that the argument resolves to a\nvalid 40-hexadigit string (note that it does not verify if that\nobject actually exists), so asking for zeroth parent makes sure\nyou are dealing with a ref that actually points at a commit\nobject that exists.\n"},{"id":"17369","messageId":"20060309114846.GA11934@localdomain","threadId":"3595","inReplyTo":"7vacc07wwp.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] contrib/git-svn: fix svn compat and fetch args","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-09T11:48:47Z","receivedAt":"2006-03-09T11:48:47Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"'svn info' doesn't work with URLs in svn <= 1.1.  Now we\nonly run svn info in local directories.\n\nAs a side effect, this should also work better for 'init' off\ndirectories that are no longer in the latest revision of the\nrepository.\n\nsvn checkout -r<revision> arguments are fixed.\nNewer versions of svn (1.2.x) seem to need URL@REV as well as\n-rREV to checkout a particular revision...\n\nAdd an example in the manpage of how to track directory that has\nbeen moved since its initial revision.\n\nA huge thanks to Yann Dirson for the bug reporting and testing\nmy original patch.  Thanks also to Junio C Hamano for suggesting\na safer way to use git-rev-parse.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n  Junio C Hamano <junkio@cox.net> wrote:\n  > Eric Wong <normalperson@yhbt.net> writes:\n  > \n  > > Junio: please don't apply this patch to git.git just yet.  It seems fine\n  > > to me, but I haven't tested it heavily yet (Yann can help me, I hope :)\n  > > I hardly slept the past few days and I may have broken something badly\n  > > (it pasts all the tests, though).\n  > \n  > I won't be applying it then.\n\n  You can apply this one :)\n\n  > I think this part is wrong.\n\n  Cool, thanks for the example.\n\n contrib/git-svn/git-svn.perl |   63 ++++++++++++++++++++++++++++++------------\n contrib/git-svn/git-svn.txt  |   32 ++++++++++++++++++++-\n 2 files changed, 75 insertions(+), 20 deletions(-)\n\n1e07c915bbc3ff06967a85a71c0cbad82fa40cf6\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex 3c860e4..dca4e5c 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -30,6 +30,7 @@ my $sha1_short = qr/[a-f\\d]{4,40}/;\n my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,\n \t$_find_copies_harder, $_l, $_version, $_upgrade, $_authors);\n my (@_branch_from, %tree_map, %users);\n+my $_svn_co_url_revs;\n \n my %fc_opts = ( 'no-ignore-externals' => \\$_no_ignore_ext,\n \t\t'branch|b=s' => \\@_branch_from,\n@@ -77,7 +78,7 @@ usage(0) if $_help;\n version() if $_version;\n usage(1) unless defined $cmd;\n load_authors() if $_authors;\n-svn_check_ignore_externals();\n+svn_compat_check();\n $cmd{$cmd}->[0]->(@ARGV);\n exit 0;\n \n@@ -162,7 +163,8 @@ sub rebuild {\n \t\t\t\tcroak \"SVN repository location required: $url\\n\";\n \t\t\t}\n \t\t\t$SVN_URL ||= $url;\n-\t\t\t$SVN_UUID ||= setup_git_svn();\n+\t\t\t$SVN_UUID ||= $uuid;\n+\t\t\tsetup_git_svn();\n \t\t\t$latest = $rev;\n \t\t}\n \t\tassert_revision_eq_or_unknown($rev, $c);\n@@ -171,9 +173,7 @@ sub rebuild {\n \t}\n \tclose $rev_list or croak $?;\n \tif (!chdir $SVN_WC) {\n-\t\tmy @svn_co = ('svn','co',\"-r$latest\");\n-\t\tpush @svn_co, '--ignore-externals' unless $_no_ignore_ext;\n-\t\tsys(@svn_co, $SVN_URL, $SVN_WC);\n+\t\tsvn_cmd_checkout($SVN_URL, $latest, $SVN_WC);\n \t\tchdir $SVN_WC or croak $!;\n \t}\n \n@@ -222,14 +222,14 @@ sub fetch {\n \tmy $base = shift @$svn_log or croak \"No base revision!\\n\";\n \tmy $last_commit = undef;\n \tunless (-d $SVN_WC) {\n-\t\tmy @svn_co = ('svn','co',\"-r$base->{revision}\");\n-\t\tpush @svn_co,'--ignore-externals' unless $_no_ignore_ext;\n-\t\tsys(@svn_co, $SVN_URL, $SVN_WC);\n+\t\tsvn_cmd_checkout($SVN_URL,$base->{revision},$SVN_WC);\n \t\tchdir $SVN_WC or croak $!;\n+\t\tread_uuid();\n \t\t$last_commit = git_commit($base, @parents);\n \t\tassert_svn_wc_clean($base->{revision}, $last_commit);\n \t} else {\n \t\tchdir $SVN_WC or croak $!;\n+\t\tread_uuid();\n \t\t$last_commit = file_to_s(\"$REV_DIR/$base->{revision}\");\n \t}\n \tmy @svn_up = qw(svn up);\n@@ -275,7 +275,9 @@ sub commit {\n \n \tfetch();\n \tchdir $SVN_WC or croak $!;\n-\tmy $svn_current_rev =  svn_info('.')->{'Last Changed Rev'};\n+\tmy $info = svn_info('.');\n+\tread_uuid($info);\n+\tmy $svn_current_rev =  $info->{'Last Changed Rev'};\n \tforeach my $c (@revs) {\n \t\tmy $mods = svn_checkout_tree($svn_current_rev, $c);\n \t\tif (scalar @$mods == 0) {\n@@ -314,6 +316,14 @@ sub show_ignore {\n \n ########################### utility functions #########################\n \n+sub read_uuid {\n+\treturn if $SVN_UUID;\n+\tmy $info = shift || svn_info('.');\n+\t$SVN_UUID = $info->{'Repository UUID'} or\n+\t\t\t\t\tcroak \"Repository UUID unreadable\\n\";\n+\ts_to_file($SVN_UUID,\"$GIT_DIR/$GIT_SVN/info/uuid\");\n+}\n+\n sub setup_git_svn {\n \tdefined $SVN_URL or croak \"SVN repository location required\\n\";\n \tunless (-d $GIT_DIR) {\n@@ -323,14 +333,10 @@ sub setup_git_svn {\n \tmkpath([\"$GIT_DIR/$GIT_SVN/info\"]);\n \tmkpath([$REV_DIR]);\n \ts_to_file($SVN_URL,\"$GIT_DIR/$GIT_SVN/info/url\");\n-\t$SVN_UUID = svn_info($SVN_URL)->{'Repository UUID'} or\n-\t\t\t\t\tcroak \"Repository UUID unreadable\\n\";\n-\ts_to_file($SVN_UUID,\"$GIT_DIR/$GIT_SVN/info/uuid\");\n \n \topen my $fd, '>>', \"$GIT_DIR/$GIT_SVN/info/exclude\" or croak $!;\n \tprint $fd '.svn',\"\\n\";\n \tclose $fd or croak $!;\n-\treturn $SVN_UUID;\n }\n \n sub assert_svn_wc_clean {\n@@ -860,7 +866,6 @@ sub git_commit {\n \tmy ($log_msg, @parents) = @_;\n \tassert_revision_unknown($log_msg->{revision});\n \tmy $out_fh = IO::File->new_tmpfile or croak $!;\n-\t$SVN_UUID ||= svn_info('.')->{'Repository UUID'};\n \n \tmap_tree_joins() if (@_branch_from && !%tree_map);\n \n@@ -922,7 +927,16 @@ sub git_commit {\n \t}\n \tmy @update_ref = ('git-update-ref',\"refs/remotes/$GIT_SVN\",$commit);\n \tif (my $primary_parent = shift @exec_parents) {\n-\t\tpush @update_ref, $primary_parent;\n+\t\t$pid = fork;\n+\t\tdefined $pid or croak $!;\n+\t\tif (!$pid) {\n+\t\t\tclose STDERR;\n+\t\t\tclose STDOUT;\n+\t\t\texec 'git-rev-parse','--verify',\n+\t\t\t\t\t\t\"refs/remotes/$GIT_SVN^0\";\n+\t\t}\n+\t\twaitpid $pid, 0;\n+\t\tpush @update_ref, $primary_parent unless $?;\n \t}\n \tsys(@update_ref);\n \tsys('git-update-ref',\"$GIT_SVN/revs/$log_msg->{revision}\",$commit);\n@@ -995,13 +1009,26 @@ sub safe_qx {\n \treturn wantarray ? @ret : join('',@ret);\n }\n \n-sub svn_check_ignore_externals {\n-\treturn if $_no_ignore_ext;\n-\tunless (grep /ignore-externals/,(safe_qx(qw(svn co -h)))) {\n+sub svn_compat_check {\n+\tmy @co_help = safe_qx(qw(svn co -h));\n+\tunless (grep /ignore-externals/,@co_help) {\n \t\tprint STDERR \"W: Installed svn version does not support \",\n \t\t\t\t\"--ignore-externals\\n\";\n \t\t$_no_ignore_ext = 1;\n \t}\n+\tif (grep /usage: checkout URL\\[\\@REV\\]/,@co_help) {\n+\t\t$_svn_co_url_revs = 1;\n+\t}\n+}\n+\n+# *sigh*, new versions of svn won't honor -r<rev> without URL@<rev>,\n+# (and they won't honor URL@<rev> without -r<rev>, too!)\n+sub svn_cmd_checkout {\n+\tmy ($url, $rev, $dir) = @_;\n+\tmy @cmd = ('svn','co', \"-r$rev\");\n+\tpush @cmd, '--ignore-externals' unless $_no_ignore_ext;\n+\t$url .= \"\\@$rev\" if $_svn_co_url_revs;\n+\tsys(@cmd, $url, $dir);\n }\n \n sub check_upgrade_needed {\ndiff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt\nindex 8e9a971..5fb5b7c 100644\n--- a/contrib/git-svn/git-svn.txt\n+++ b/contrib/git-svn/git-svn.txt\n@@ -175,8 +175,8 @@ COMPATIBILITY OPTIONS\n \tDo not use this flag unless you know exactly what you're getting\n \tyourself into.  You have been warned.\n \n-Examples\n-~~~~~~~~\n+Basic Examples\n+~~~~~~~~~~~~~~\n \n Tracking and contributing to an Subversion managed-project:\n \n@@ -234,6 +234,34 @@ This allows you to tie unfetched SVN rev\n \n \tgit-svn fetch 375=$(git-rev-parse HEAD)\n \n+Advanced Example: Tracking a Reorganized Repository\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+If you're tracking a directory that has moved, or otherwise been\n+branched or tagged off of another directory in the repository and you\n+care about the full history of the project, then you can read this\n+section.\n+\n+This is how Yann Dirson tracked the trunk of the ufoai directory when\n+the /trunk directory of his repository was moved to /ufoai/trunk and\n+he needed to continue tracking /ufoai/trunk where /trunk left off.\n+\n+\t# This log message shows when the repository was reorganized::\n+\tr166 | ydirson | 2006-03-02 01:36:55 +0100 (Thu, 02 Mar 2006) | 1 line\n+\tChanged paths:\n+\t   D /trunk\n+\t   A /ufoai/trunk (from /trunk:165)\n+\n+\t# First we start tracking the old revisions::\n+\tGIT_SVN_ID=git-oldsvn git-svn init \\\n+\t      https://svn.sourceforge.net/svnroot/ufoai/trunk\n+\tGIT_SVN_ID=git-oldsvn git-svn fetch -r1:165\n+\n+\t# And now, we continue tracking the new revisions::\n+\tGIT_SVN_ID=git-newsvn git-svn init \\\n+\t      https://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk\n+\tGIT_SVN_ID=git-newsvn git-svn fetch \\\n+\t      166=`git-rev-parse refs/remotes/git-oldsvn`\n+\n BUGS\n ----\n If somebody commits a conflicting changeset to SVN at a bad moment\n-- \n1.2.4.ga2910\n"},{"id":"17370","messageId":"20060309115034.GB11934@localdomain","threadId":"3595","inReplyTo":"20060308014207.GA31137@localdomain","subject":"[PATCH] contrib/git-svn: remove the --no-stop-on-copy flag","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-09T11:50:34Z","receivedAt":"2006-03-09T11:50:34Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Output a big warning if somebody actually has a pre-1.0 version\nof svn that doesn't support it.\n\nThanks to Yann Dirson for reminding me it still existed\nand attempting to re-enable it :)\n\nI think I subconciously removed support for it earlier...\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn.perl |   11 +++++++++++\n contrib/git-svn/git-svn.txt  |   13 -------------\n 2 files changed, 11 insertions(+), 13 deletions(-)\n\n0ec45e489232fad4f1aa3d2c648fa53295efd7ec\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex dca4e5c..43b50ec 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -1019,6 +1019,17 @@ sub svn_compat_check {\n \tif (grep /usage: checkout URL\\[\\@REV\\]/,@co_help) {\n \t\t$_svn_co_url_revs = 1;\n \t}\n+\n+\t# I really, really hope nobody hits this...\n+\tunless (grep /stop-on-copy/, (safe_qx(qw(svn log -h)))) {\n+\t\tprint STDERR <<'';\n+W: The installed svn version does not support the --stop-on-copy flag in\n+   the log command.\n+   Lets hope the directory you're tracking is not a branch or tag\n+   and was never moved within the repository...\n+\n+\t\t$_no_stop_copy = 1;\n+\t}\n }\n \n # *sigh*, new versions of svn won't honor -r<rev> without URL@<rev>,\ndiff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt\nindex 5fb5b7c..7a6e0c4 100644\n--- a/contrib/git-svn/git-svn.txt\n+++ b/contrib/git-svn/git-svn.txt\n@@ -162,19 +162,6 @@ COMPATIBILITY OPTIONS\n \tOtherwise, do not enable this flag unless you know what you're\n \tdoing.\n \n---no-stop-on-copy::\n-\tOnly used with the 'fetch' command.\n-\n-\tBy default, git-svn passes --stop-on-copy to avoid dealing with\n-\tthe copied/renamed branch directory problem entirely.  A\n-\tcopied/renamed branch is the result of a <SVN_URL> being created\n-\tin the past from a different source.  These are problematic to\n-\tdeal with even when working purely with svn if you work inside\n-\tsubdirectories.\n-\n-\tDo not use this flag unless you know exactly what you're getting\n-\tyourself into.  You have been warned.\n-\n Basic Examples\n ~~~~~~~~~~~~~~\n \n-- \n1.2.4.ga2910\n"}]}