views:

285

answers:

2

I'm using so many git-svn repositories (at the same time) that it's becoming a chore to update them all. I'd like to write a script that automates this, so I can just run it every morning while I fetch a coffee.

Basically my workflow is like this

cd ~/module1
git svn fetch
git checkout master
git svn rebase

git checkout topicbranch
git svn rebase

cd ~/module2
git svn fetch
git checkout master
git svn rebase

I've already automated the git svn fetch part, which can be safely done anytime. But it's not so safe to do git svn rebase automatically as there might be conflicts.

How can a script figure out if there was a conflict after a rebase? Then I could run git rebase --abort, and write a line to a log file so I can review the failures when I get back with my coffee :)

+1  A: 

From what I can gather from git-svn, git-rebase, and git-sh-setup git will exit with an exit code of 1 if the rebase can not be performed due to conflicts.

Bombe
That seems right, although it will also return 1 if the rebase cannot be performed because e.g. there are uncommitted changes in the working copy. Should I just run git rebase --abort anyway?
amarillion
Well, if a rebase can not be performed without interaction you don’t really have a choice when it’s being run automated, do you?
Bombe
+2  A: 

After doing "git svn fetch", you can use a merge instead of a rebase to get the latest svn stuff into your local branch. If the merge is successful, you'll know because there are no conflicts (which you can find with tools like git ls-files). If the merge doesn't work, you haven't mangled anything and can just ignore those toplevel changes to your work tree.

Then do a rebase as a last step before committing (if you want; it's not strictly needed) and you can handle the error-prone rebasing interactively only once.

apenwarr