[LLVMdev] [Git-fu] How to commit inter-repositories atomically to svn

NAKAMURA Takumi geek4civic at gmail.com
Wed Dec 5 06:21:38 PST 2012


Sean Silva asked me, "How are you committing across both projects
simultaneously?"

For example, r167595.
http://llvm.org/viewvc/llvm-project?view=rev&revision=167595

For the record, I introduce a how-to.
Yeah it's troublesome. I don't do usually.

[Prerequisites]

* subtree-merged git repo. https://github.com/chapuni/llvm-project
* Assume you are working on llvm-project.
* You are about to commit to both llvm and clang.
* Of course, you are a developer capable to commit llvm.org/svn.

[How to make commit from by-project git repos]

* Checkout tracking branch on llvm-project.
  $ git checkout --track origin/master
* Collect your commits with squashed.
    $ git fetch /path/to/your/repo (.git)
    $ git cherry-pick --strategy subtree --no-commit FETCH_HEAD
  $ git commit
  You may do whatever you want.
  FYI, it could be easily to add your repositories to
GIT_DIR/objects/info/alternates.

[Preparations]

* Checkout latest head of upstream as detached.
  $ git fetch origin
  $ git checkout origin/master
* Set up svn-emulated tree.
  $ for x in *;do git mv $x trunk;mkdir $x;git mv trunk $x/;done
    Imagine, clang => cfe/trunk, llvm => llvm/trunk.
  $ git mv clang/trunk cfe/trunk
  $ git commit
  Then you can see the tree like llvm.org/svn/llvm-project.
* Pick up you commit
  $ git cherry-pick --strategy subtree master (or certain sha1)

[Committing...]
  $ git svn commit-diff -rHEAD HEAD^ HEAD https://llvm.org/svn/llvm-project
  If HEAD is not tree but commit, git-svn uses corresponding commit
message in HEAD.


It could be done without working tree, to assemble commit object(s)
and tree(s) with plumbing. I could provide an express script if anyone
requested me. (TBD)

Feel free to ask me wherever I am, the list or the IRC, oftc#llvm.

HTH, Takumi



More information about the llvm-dev mailing list