git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC 00/20] Refactor rebase

From
Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Date
Nov 25, 2010, 19:57 UTC
Message-ID
<1290715083-16919-1-git-send-email-martin.von.zweigbergk@gmail.com>

This is a first draft of my attempt to refactor the rebase code. I have tried to refactor it as Hannes suggested, namely "to write a command line processor, git-rebase.sh, that sets shell variables from options that it collects from various sources, then dispatches to one of git-rebase--interactive.sh, git-rebase--merge.sh, or git-rebase--am.sh (the latter two would be stripped-down copies of the current git-rebase.sh)."

Patches 01-04 try to make git-rebase.sh more readable and extensible.

Patches 05-16 factor out common code between git-rebase.sh and git-rebase--interactive.sh.

Patches 17-20 finally achieve, I hope, what Hannes suggested.

I have aligned a lot of the error checking and error messages, but I still have barely gotten to align any of the command line options supported by 'git rebase' and 'git rebase -i'. How do you think I should continue? Some specific questions:

1. What should -v do? Interactive rebase currently prints most
commands it is about to execute, while non-interactive rebase only
prints a header to the diffstat. Is there any reason they should be
different? If not, what should they print?
2. Interactive rebase currently saves most command line options when
the rebase is initiated and then reads then back on '--continue'
etc. Non-interactive rebase does not store any options and allows them
to be passed on the command line when the rebase is continued
instead. Any reason for the difference? What do we want?

All feedback would be greatly appreciated! I'm new to the Git code, new to development on Linux and even quite new to bash, so please review very carefully. Thanks!

Martin von Zweigbergk (20):
  rebase: clearer names for directory variables
  rebase: refactor reading of state
  rebase: read state outside loop
  rebase: remove unused rebase state 'prev_head'
  rebase: act on command line outside parsing loop
  rebase: collect check for existing rebase
  rebase: stricter check on arguments
  rebase: align variable names
  rebase: align variable content
  rebase: factor out command line option processing
  rebase -i: remove now unnecessary directory checks
  rebase: reorder validation steps
  rebase: factor out reference parsing
  rebase: factor out clean work tree check
  rebase: factor out call to pre-rebase hook
  rebase -i: support --stat
  rebase: improve detection of rebase in progress
  rebase -m: extract code to new source file
  rebase: extract am code to new source file
  rebase: show consistent conflict resolution hint
 .gitignore                 |    2 +
 Makefile                   |    2 +
 git-rebase--am.sh          |   34 +++
 git-rebase--interactive.sh |  554 ++++++++++++++++----------------------------
 git-rebase--merge.sh       |  154 ++++++++++++
 git-rebase.sh              |  434 ++++++++++++-----------------------
 6 files changed, 538 insertions(+), 642 deletions(-)
 create mode 100644 git-rebase--am.sh
 create mode 100644 git-rebase--merge.sh
-- 
1.7.3.2.864.gbbb96
Next: Martin von Zweigbergk
Message 1 of 29 in “Refactor rebase”
  1. 00/20 Refactor rebaseMartin von Zweigbergk, Nov 25, 2010
  2. 01/20 rebase: clearer names for directory variablesMartin von Zweigbergk, Nov 25, 2010
  3. 02/20 rebase: refactor reading of stateMartin von Zweigbergk, Nov 25, 2010
  4. 03/20 rebase: read state outside loopMartin von Zweigbergk, Nov 25, 2010
  5. 04/20 rebase: remove unused rebase state 'prev_head'Martin von Zweigbergk, Nov 25, 2010
  6. Michael J GruberNov 26, 2010
  7. Martin von ZweigbergkNov 26, 2010
  8. Junio C HamanoNov 29, 2010
  9. Michael J GruberNov 30, 2010
  10. 05/20 rebase: act on command line outside parsing loopMartin von Zweigbergk, Nov 25, 2010
  11. 06/20 rebase: collect check for existing rebaseMartin von Zweigbergk, Nov 25, 2010
  12. 07/20 rebase: stricter check on argumentsMartin von Zweigbergk, Nov 25, 2010
  13. 08/20 rebase: align variable namesMartin von Zweigbergk, Nov 25, 2010
  14. 09/20 rebase: align variable contentMartin von Zweigbergk, Nov 25, 2010
  15. 10/20 rebase: factor out command line option processingMartin von Zweigbergk, Nov 25, 2010
  16. 11/20 rebase -i: remove now unnecessary directory checksMartin von Zweigbergk, Nov 25, 2010
  17. 12/20 rebase: reorder validation stepsMartin von Zweigbergk, Nov 25, 2010
  18. 13/20 rebase: factor out reference parsingMartin von Zweigbergk, Nov 25, 2010
  19. 14/20 rebase: factor out clean work tree checkMartin von Zweigbergk, Nov 25, 2010
  20. 15/20 rebase: factor out call to pre-rebase hookMartin von Zweigbergk, Nov 25, 2010
  21. 16/20 rebase -i: support --statMartin von Zweigbergk, Nov 25, 2010
  22. 17/20 rebase: improve detection of rebase in progressMartin von Zweigbergk, Nov 25, 2010
  23. 18/20 rebase -m: extract code to new source fileMartin von Zweigbergk, Nov 25, 2010
  24. 19/20 rebase: extract am code to new source fileMartin von Zweigbergk, Nov 25, 2010
  25. 20/20 rebase: show consistent conflict resolution hintMartin von Zweigbergk, Nov 25, 2010
  26. Martin von ZweigbergkNov 25, 2010
  27. Sverre RabbelierNov 26, 2010
  28. Martin von ZweigbergkNov 26, 2010
  29. Sverre RabbelierNov 27, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.