tags:

views:

33

answers:

1

I'm using a little script to fix up past commits. The script assumes that the fix for the broken commit is staged, that the working directory is clean and that broken commit is passed on the command line. Here's the raw Python core of the script:

#!/usr/bin/env python
import os
import sys

broken_commit = sys.argv[1]

logmsg = os.popen( "git log --format=%%s %s~1..%s" % ( broken_commit, broken_commit ), 'r' ).read().strip()
os.system( "git commit --message \"fixup! %s\"" % logmsg )
os.system( "git rebase --interactive --autosquash %s~2" % broken_commit )

At this point, I'm presented with an editor and just need to confirm (:wq in my case) the shown changes. How can I avoid this last step? I'd like the git rebase line to just go on without giving me the chance to edit the steps shown.

I heard you could have special script set via the EDITOR environment variable to achieve. However, I'm using msysGit on Windows, so I'm a bit limited in that area.

+2  A: 

Setting the environment variable EDITOR to true before running git rebase will make it accept the shown changes automatically.

Frerich Raabe
You could use `GIT_EDITOR` to keep from accidentally mucking anything else up, though it ought to be run in a subshell anyway, so moot point. You could also make this an alias: `rbas = '!export GIT_EDITOR=true; git rebase --interactive --autosquash'` or in the case of your python script, just set the environment variable in the same invocation of `system` as the call to git rebase.
Jefromi
@Jefromi: Using `GIT_EDITOR` is a good idea.
Frerich Raabe