|
10 | 10 | # The original idea comes from Eric W. Biederman, in
|
11 | 11 | # http://article.gmane.org/gmane.comp.version-control.git/22407
|
12 | 12 |
|
13 |
| -OPTIONS_KEEPDASHDASH= |
14 |
| -OPTIONS_SPEC="\ |
15 |
| -git-rebase [-i] [options] [--] <upstream> [<branch>] |
16 |
| -git-rebase [-i] (--continue | --abort | --skip) |
17 |
| --- |
18 |
| - Available options are |
19 |
| -v,verbose display a diffstat of what changed upstream |
20 |
| -onto= rebase onto given branch instead of upstream |
21 |
| -p,preserve-merges try to recreate merges instead of ignoring them |
22 |
| -s,strategy= use the given merge strategy |
23 |
| -no-ff cherry-pick all commits, even if unchanged |
24 |
| -m,merge always used (no-op) |
25 |
| -i,interactive always used (no-op) |
26 |
| - Actions: |
27 |
| -continue continue rebasing process |
28 |
| -abort abort rebasing process and restore original branch |
29 |
| -skip skip current patch and continue rebasing process |
30 |
| -no-verify override pre-rebase hook from stopping the operation |
31 |
| -verify allow pre-rebase hook to run |
32 |
| -root rebase all reachable commmits up to the root(s) |
33 |
| -autosquash move commits that begin with squash!/fixup! under -i |
34 |
| -" |
35 |
| - |
36 | 13 | . git-sh-setup
|
37 |
| -require_work_tree |
38 | 14 |
|
39 | 15 | dotest="$GIT_DIR/rebase-merge"
|
40 | 16 |
|
@@ -105,16 +81,6 @@ amend="$dotest"/amend
|
105 | 81 | rewritten_list="$dotest"/rewritten-list
|
106 | 82 | rewritten_pending="$dotest"/rewritten-pending
|
107 | 83 |
|
108 |
| -preserve_merges= |
109 |
| -strategy= |
110 |
| -onto= |
111 |
| -verbose= |
112 |
| -ok_to_skip_pre_rebase= |
113 |
| -rebase_root= |
114 |
| -autosquash= |
115 |
| -test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t |
116 |
| -force_rebase= |
117 |
| - |
118 | 84 | GIT_CHERRY_PICK_HELP="\
|
119 | 85 | hint: after resolving the conflicts, mark the corrected paths
|
120 | 86 | hint: with 'git add <paths>' and run 'git rebase --continue'"
|
@@ -648,15 +614,6 @@ skip_unnecessary_picks () {
|
648 | 614 | die "Could not skip unnecessary pick commands"
|
649 | 615 | }
|
650 | 616 |
|
651 |
| -# check if no other options are set |
652 |
| -is_standalone () { |
653 |
| - test $# -eq 2 -a "$2" = '--' && |
654 |
| - test -z "$onto" && |
655 |
| - test -z "$preserve_merges" && |
656 |
| - test -z "$strategy" && |
657 |
| - test -z "$verbose" |
658 |
| -} |
659 |
| - |
660 | 617 | get_saved_options () {
|
661 | 618 | test -d "$rewritten" && preserve_merges=t
|
662 | 619 | test -f "$dotest"/strategy && strategy="$(cat "$dotest"/strategy)"
|
@@ -744,134 +701,77 @@ parse_onto () {
|
744 | 701 | git rev-parse --verify "$1^0"
|
745 | 702 | }
|
746 | 703 |
|
747 |
| -while test $# != 0 |
748 |
| -do |
749 |
| - case "$1" in |
750 |
| - --no-verify) |
751 |
| - ok_to_skip_pre_rebase=yes |
752 |
| - ;; |
753 |
| - --verify) |
754 |
| - ok_to_skip_pre_rebase= |
755 |
| - ;; |
756 |
| - --continue) |
757 |
| - is_standalone "$@" || usage |
758 |
| - get_saved_options |
759 |
| - comment_for_reflog continue |
760 |
| - |
761 |
| - test -d "$dotest" || die "No interactive rebase running" |
762 |
| - |
763 |
| - # Sanity check |
764 |
| - git rev-parse --verify HEAD >/dev/null || |
765 |
| - die "Cannot read HEAD" |
766 |
| - git update-index --ignore-submodules --refresh && |
767 |
| - git diff-files --quiet --ignore-submodules || |
768 |
| - die "Working tree is dirty" |
769 |
| - |
770 |
| - # do we have anything to commit? |
771 |
| - if git diff-index --cached --quiet --ignore-submodules HEAD -- |
| 704 | +case "$action" in |
| 705 | +continue) |
| 706 | + get_saved_options |
| 707 | + comment_for_reflog continue |
| 708 | + |
| 709 | + test -d "$dotest" || die "No interactive rebase running" |
| 710 | + |
| 711 | + # Sanity check |
| 712 | + git rev-parse --verify HEAD >/dev/null || |
| 713 | + die "Cannot read HEAD" |
| 714 | + git update-index --ignore-submodules --refresh && |
| 715 | + git diff-files --quiet --ignore-submodules || |
| 716 | + die "Working tree is dirty" |
| 717 | + |
| 718 | + # do we have anything to commit? |
| 719 | + if git diff-index --cached --quiet --ignore-submodules HEAD -- |
| 720 | + then |
| 721 | + : Nothing to commit -- skip this |
| 722 | + else |
| 723 | + . "$author_script" || |
| 724 | + die "Cannot find the author identity" |
| 725 | + current_head= |
| 726 | + if test -f "$amend" |
772 | 727 | then
|
773 |
| - : Nothing to commit -- skip this |
774 |
| - else |
775 |
| - . "$author_script" || |
776 |
| - die "Cannot find the author identity" |
777 |
| - current_head= |
778 |
| - if test -f "$amend" |
779 |
| - then |
780 |
| - current_head=$(git rev-parse --verify HEAD) |
781 |
| - test "$current_head" = $(cat "$amend") || |
782 |
| - die "\ |
| 728 | + current_head=$(git rev-parse --verify HEAD) |
| 729 | + test "$current_head" = $(cat "$amend") || |
| 730 | + die "\ |
783 | 731 | You have uncommitted changes in your working tree. Please, commit them
|
784 | 732 | first and then run 'git rebase --continue' again."
|
785 |
| - git reset --soft HEAD^ || |
786 |
| - die "Cannot rewind the HEAD" |
787 |
| - fi |
788 |
| - do_with_author git commit --no-verify -F "$msg" -e || { |
789 |
| - test -n "$current_head" && git reset --soft $current_head |
790 |
| - die "Could not commit staged changes." |
791 |
| - } |
| 733 | + git reset --soft HEAD^ || |
| 734 | + die "Cannot rewind the HEAD" |
792 | 735 | fi
|
| 736 | + do_with_author git commit --no-verify -F "$msg" -e || { |
| 737 | + test -n "$current_head" && git reset --soft $current_head |
| 738 | + die "Could not commit staged changes." |
| 739 | + } |
| 740 | + fi |
793 | 741 |
|
794 |
| - record_in_rewritten "$(cat "$dotest"/stopped-sha)" |
| 742 | + record_in_rewritten "$(cat "$dotest"/stopped-sha)" |
795 | 743 |
|
796 |
| - require_clean_work_tree "rebase" |
797 |
| - do_rest |
798 |
| - ;; |
799 |
| - --abort) |
800 |
| - is_standalone "$@" || usage |
801 |
| - get_saved_options |
802 |
| - comment_for_reflog abort |
803 |
| - |
804 |
| - git rerere clear |
805 |
| - test -d "$dotest" || die "No interactive rebase running" |
806 |
| - |
807 |
| - headname=$(cat "$dotest"/head-name) |
808 |
| - head=$(cat "$dotest"/head) |
809 |
| - case $headname in |
810 |
| - refs/*) |
811 |
| - git symbolic-ref HEAD $headname |
812 |
| - ;; |
813 |
| - esac && |
814 |
| - output git reset --hard $head && |
815 |
| - rm -rf "$dotest" |
816 |
| - exit |
817 |
| - ;; |
818 |
| - --skip) |
819 |
| - is_standalone "$@" || usage |
820 |
| - get_saved_options |
821 |
| - comment_for_reflog skip |
| 744 | + require_clean_work_tree "rebase" |
| 745 | + do_rest |
| 746 | + ;; |
| 747 | +abort) |
| 748 | + get_saved_options |
| 749 | + comment_for_reflog abort |
822 | 750 |
|
823 |
| - git rerere clear |
824 |
| - test -d "$dotest" || die "No interactive rebase running" |
| 751 | + git rerere clear |
| 752 | + test -d "$dotest" || die "No interactive rebase running" |
825 | 753 |
|
826 |
| - output git reset --hard && do_rest |
827 |
| - ;; |
828 |
| - -s) |
829 |
| - case "$#,$1" in |
830 |
| - *,*=*) |
831 |
| - strategy=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;; |
832 |
| - 1,*) |
833 |
| - usage ;; |
834 |
| - *) |
835 |
| - strategy="$2" |
836 |
| - shift ;; |
837 |
| - esac |
838 |
| - ;; |
839 |
| - -m) |
840 |
| - # we use merge anyway |
841 |
| - ;; |
842 |
| - -v) |
843 |
| - verbose=t |
844 |
| - ;; |
845 |
| - -p) |
846 |
| - preserve_merges=t |
847 |
| - ;; |
848 |
| - -i) |
849 |
| - # yeah, we know |
850 |
| - ;; |
851 |
| - --no-ff) |
852 |
| - force_rebase=t |
853 |
| - ;; |
854 |
| - --root) |
855 |
| - rebase_root=t |
856 |
| - ;; |
857 |
| - --autosquash) |
858 |
| - autosquash=t |
859 |
| - ;; |
860 |
| - --no-autosquash) |
861 |
| - autosquash= |
862 |
| - ;; |
863 |
| - --onto) |
864 |
| - test 2 -le "$#" || usage |
865 |
| - onto="$2" |
866 |
| - shift |
867 |
| - ;; |
868 |
| - --) |
869 |
| - shift |
870 |
| - break |
| 754 | + headname=$(cat "$dotest"/head-name) |
| 755 | + head=$(cat "$dotest"/head) |
| 756 | + case $headname in |
| 757 | + refs/*) |
| 758 | + git symbolic-ref HEAD $headname |
871 | 759 | ;;
|
872 |
| - esac |
873 |
| - shift |
874 |
| -done |
| 760 | + esac && |
| 761 | + output git reset --hard $head && |
| 762 | + rm -rf "$dotest" |
| 763 | + exit |
| 764 | + ;; |
| 765 | +skip) |
| 766 | + get_saved_options |
| 767 | + comment_for_reflog skip |
| 768 | + |
| 769 | + git rerere clear |
| 770 | + test -d "$dotest" || die "No interactive rebase running" |
| 771 | + |
| 772 | + output git reset --hard && do_rest |
| 773 | + ;; |
| 774 | +esac |
875 | 775 |
|
876 | 776 | if test -n "$onto"
|
877 | 777 | then
|
|
0 commit comments