{"thread":{"id":"12713","subject":"git-svn dcommit fails in a repository with submodules","startedAt":"2008-03-16T10:50:22Z","lastAt":"2008-03-16T10:50:22Z","messageCount":1,"participants":["Nazar Aziz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"72215","messageId":"60dc6b330803160350o3481b7b5vee1795919101cce2@mail.gmail.com","threadId":"12713","inReplyTo":null,"subject":"git-svn dcommit fails in a repository with submodules","fromName":"Nazar Aziz","fromEmail":"mcnazar@gmail.com","sentAt":"2008-03-16T10:50:22Z","receivedAt":"2008-03-16T10:50:22Z","isPatch":false,"sender":{"key":"mcnazar@gmail.com","avatar":null},"body":"Hi all.\n\nI am struggling with a git repository which I sync with an SVN repos\nusing git-svn. git-svn dcommit fails with (dump from git-svn 1.5.4.1):\n\nCommitting to svn://epia/tmp/Trunc ...\n         A       modules/akismet\nfatal: git-cat-file 5f726f311613171310226d9bf040765\n6ad4a82f4: bad file\n at /usr/bin/git-svn line 3537\n        SVN::Git::Editor::chg_file('SVN::Git::Editor=HASH(0xd0c26c)',\n'_p_void=SCALAR(0x9aee60)', 'HASH(0x9af340)') called at\n/usr/bin/git-svn line 3461\n         SVN::Git::Editor::A('SVN::Git::Editor=HASH(0xd0c26c)',\n'HASH(0x9af340)') called at /usr/bin/git-svn line 3592\n        SVN::Git::Editor::apply_diff('SVN::Git::Editor=HASH(0xd0c26c)')\ncalled at /usr/bin/git-svn line 450\n         main::cmd_dcommit() called at /usr/bin/git-svn line 246\n        eval {...} called at /usr/bin/git-svn line 244\n32768 at /usr/bin/git-svn line 450\n\nJust to explain my setup. I've got an application that has shared\ncode. This shared code was previously accessed in SVN via an\nsvn:externals which pointed to a separate \"shared code\" svn\nrepository. This setup allowed me to share this code in several apps\nwhilst also giving me the ability to modify this shared code in any\nsingle application and commit it to the \"shared code\" repos for use in\nmy other applications.\n\nI've written an article on it here:\nhttp://panthersoftware.com/articles/view/3/svn-s-svn-externals-to-git-s-submodule-for-rails-plugins\n\nI've tried hacking git-svn but my Perl fu is weak. So I would\nappreciate any pointers to help me solve this.\n\nI've done the following hack:\n\nsub valid_object {\n  #check if git-cat can process this sha1..if not then return false\n   my ($self, $sha1) = @_;\n    my $fh = IO::File->new_tmpfile or croak $!;\n    defined(my $pid = fork) or croak $!;\n    if (!$pid) {\n        open STDOUT, '>&', $fh or croak $!;\n        exec qw/git-cat-file blob/, $sha1 or croak $!;\n     }\n    waitpid $pid, 0;\n    if ($?) {\n     return 0;\n    } else {\n      return 1;\n    }\n}\n\nsub A {\n    my ($self, $m) = @_;\n    if ($self->valid_object($m->{sha1_b}) == 1) {\n      my ($dir, $file) = split_path($m->{file_b});\n       my $pbat = $self->ensure_path($dir);\n      my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat,\n                    undef, -1);\n      print \"\\tA\\t$m->{file_b}\\n\" unless $::_q;\n       $self->chg_file($fbat, $m);\n      $self->close_file($fbat,undef,$self->{pool});\n    }\n}\n\nI added sub valid_object to package SVN::Git::Editor. It is a brute\nmethod to see if git-cat-file will choke on a particular sha1. I am\ncertain there is a more elegant method to check if a sha1 is actually\na submodule... I just haven't found it yet.\n\nThe above almost works but not quite:\n\n$ git-svn2 dcommit\nCommitting to svn://epia/tmp/Trunc ...\nfatal: git-cat-file 5f726f311613171310226d9bf0407656ad4a82f4: bad file\nCommitted r24\nW: ea1efb48fb6e03454f9264dd63cd609884c4f780 and refs/remotes/git-svn\ndiffer, using rebase:\n :040000 040000 2bd02aa0d14fd5e16f90d8b9c5322cc101d7f026\n36fbd5e7d921cd5fabe32fe857455f7fec26f521 M      modules\nCurrent branch master is up to date.\n# of revisions changed\nbefore:\n\n\nafter:\n ea1efb48fb6e03454f9264dd63cd609884c4f780\n  If you are attempting to commit  merges, try running:\n         git rebase --interactive --preserve-merges  refs/remotes/git-svn\nBefore dcommitting\n\n\"fatal: git-cat-file 5f726f311613171310226d9bf0407656ad4a82f4: bad\nfile\" comes from sub valid_object and is for info only. I can see that\ngit-svn has bypassed the submodule as I was hoping.\n\nChecking SVN's log I can see an empty commit (ie no files have been\nuploaded). In Git, my Master branch is still ahead of of the\nremotes/git-svn branch (ie not in synch with remotes/git-svn)\n\n>From the above, I can see that I am so almost there... but just need\none final push to get me to the finishing line.\n\nIs there anyway I can tell git-svn to ignore submodules?\n\nAny hints, tips or help would be greatly appreciated.\n\nThank you in advance for any help.\n\nNazar\n"}]}