0

Say for instance, I run

git rebase -i HEAD~6

then inside the interactive file I have

p hash1  comment1
r hash2  comment2
f hash3  comment3
f hash4  comment4
f hash5  comment5
p hash6  comment6

and then I save and exit. Git then applies the commits and either stops if theres an error, or successfully completes the rebase.

What I would like to know is if there exists some software that previews your rebase specifications without you having to exit the text file.

Like, on the side, or in another shell, it watches your temporary rebasing file your working on, and attempts the rebase each time you change the configuration/ordering of commits.

Alex Pan
  • 4,341
  • 8
  • 34
  • 45
Ryu S.
  • 1,538
  • 2
  • 22
  • 41

1 Answers1

1

No, there is no such program.

It would be difficult to write in general: the only way Git can know that you are finished editing the sequence control file is for you to exit the editor. Git can tell that you have exited the editor because Git itself started the editor, so it sees the exit.

Assuming you provide a magic solution to this problem,1 such a program would be relatively easy2 to write, once you decide precisely what it should do. That is, how would it attempt the rebase, and what state should it leave behind to mark success or failure? Presumably, whether it succeeds or fails, it should leave the repository and work-tree unchanged, so that when you exit the editor and invoke the rebase "for real", it can still happen.

Anyway, should you decide to attempt to write this, simply start with the existing rebase -i script, which is in $(git --exec-path)/git-rebase--interactive. Your task will be: strip out the "setup" and "finish" code paths (because you are already set up—you're just testing, and don't want to run post-rebase hooks, nor move branch pointers); add code to reset HEAD to the starting-point; implement reword as pick instead of reword (presumably you don't want to have your test script attempt to interact—but note that I am making assumptions here); and, I think the hardest part, figure out how to decide on "success" vs "failure".


1Probably, the magic solution is just to have a second window open, in which you run your "test my rebase" script.

2For some value of "easy".

torek
  • 448,244
  • 59
  • 642
  • 775