[PATCH 00/31] Refactor rebase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For the past two months, I have been working on refactoring the rebase
code. See [1] for background information. I have been trying to polish
the patch set for some time, but now I don't think I will get much
further without your help.

My goals with this series were:

 (1) Make it easier to add new features to git rebase by reducing the
 amount of duplicated code. FWIW, this series removes about 140 lines
 non-test code.

 (2) Make the behavior (towards the user) more consistent between
 interactive and non-interactive rebase. This mainly involves error
 messages and command line options.

While not being a goal from the beginning, I have also tried to make
the code more readable. This is of course very subjective, so we'll
see - maybe in your eyes I just made things worse :-).


At a high level, I tried to do what was suggested by Johannes Sixt in
the second entry on [1], 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
by factoring out the code that reads the saved state from
.git/rebase-apply or .git/rebase-merge.

Patches 05-09 set the stage for further refactoring by aligning
git-rebase.sh and git-rebase--interactive.sh.

Patches 10-16 factor out parts from git-rebase--interactive.sh and let
it rely on the corresponding code in git-rebase.sh.

Patch 17 just removes a duplicated variable.

Patches 18 and 19 extract the am-specific and merge-specifc rebase
code into two new source files (as suggested by Hannes).

Patch 20 makes interactive rebase print the same message as
non-interactive rebase in case of conflict.

Patches 21 and 22 prepare for further refactoring by aligning
interactive and non-interactive rebase a bit more.

Patch 23 factors out part or all of the handling of --continue, --skip
and --abort from git-rebase--interactive to git-rebase.sh.

Patches 24-27 makes rebase remember more options passed on the command
line thoughout the rebase (past any conflicts).

Patches 28-31 remove some unnecessary code.


I have tried to separate pure refactoring from changes that make
functional changes, but there are still some functional changes hiding
in the "refactoring" patches. I have tried to point this out in the
commit message where applicable, but I'm sure I have missed a lot of
places.


/Martin


[1] http://thread.gmane.org/gmane.comp.version-control.git/160517


Martin von Zweigbergk (31):
  rebase: clearer names for directory variables
  rebase: refactor reading of state
  rebase: read state outside loop
  rebase: remove unused rebase state 'prev_head'
  rebase: improve detection of rebase in progress
  rebase: act on command line outside parsing loop
  rebase: stricter check of standalone sub command
  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: remove $branch as synonym for $orig_head
  rebase: extract merge code to new source file
  rebase: extract am code to new source file
  rebase: show consistent conflict resolution hint
  rebase -i: align variable names
  rebase: make -v a tiny bit more verbose
  rebase: factor out sub command handling
  rebase: extract code for writing basic state
  rebase: remember verbose option
  rebase: remember strategy and strategy options
  rebase -m: remember allow_rerere_autoupdate option
  rebase -m: don't print exit code 2 when merge fails
  git-rebase--am: remove unnecessary --3way option
  rebase -i: don't read unused variable preserve_merges
  rebase -i: remove unnecessary state rebase-root

 .gitignore                 |    2 +
 Makefile                   |    2 +
 git-rebase--am.sh          |   30 +++
 git-rebase--interactive.sh |  589 ++++++++++++++------------------------------
 git-rebase--merge.sh       |  151 +++++++++++
 git-rebase.sh              |  477 ++++++++++++++---------------------
 t/t3403-rebase-skip.sh     |    5 +
 t/t3407-rebase-abort.sh    |   10 +
 t/t3418-rebase-continue.sh |   55 ++++
 9 files changed, 627 insertions(+), 694 deletions(-)
 create mode 100644 git-rebase--am.sh
 create mode 100644 git-rebase--merge.sh

-- 
1.7.3.2.864.gbbb96

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]