rebase: fold git-rebase--common into the -p backend

The only remaining scripted part of `git rebase` is the `--preserve-merges` backend. Meaning: there is little reason to keep the "library of common rebase functions" as a separate file. While moving the functions to `git-rebase--preserve-merges.sh`, we also drop the `move_to_original_branch` function that is no longer used. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 31, 2019 at 08:18 UTC 5efed0ecf936596377c241aa0e0bd40839bafbd5
5 files changed +56 -73
.gitignore
-1
@@ -122,7 +122,6 @@
122 /git-range-diff
123 /git-read-tree
124 /git-rebase
125 -/git-rebase--common
125 /git-rebase--preserve-merges
126 /git-receive-pack
127 /git-reflog
Makefile
-1
@@ -624,7 +624,6 @@ SCRIPT_SH += git-web--browse.sh
624
625 SCRIPT_LIB += git-mergetool--lib
626 SCRIPT_LIB += git-parse-remote
627 -SCRIPT_LIB += git-rebase--common
627 SCRIPT_LIB += git-rebase--preserve-merges
628 SCRIPT_LIB += git-sh-setup
629 SCRIPT_LIB += git-sh-i18n
builtin/rebase.c
+1 -2
@@ -1163,8 +1163,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
1163 }
1164
1165 strbuf_addf(&script_snippet,
1166 - ". git-sh-setup && . git-rebase--common &&"
1167 - " . %s && %s", backend, backend_func);
1166 + ". git-sh-setup && . %s && %s", backend, backend_func);
1167 argv[0] = script_snippet.buf;
1168
1169 status = run_command_v_opt(argv, RUN_USING_SHELL);
git-rebase--common.sh deleted
-69
@@ -1,69 +0,0 @@
1 -
2 -resolvemsg="
3 -$(gettext 'Resolve all conflicts manually, mark them as resolved with
4 -"git add/rm <conflicted_files>", then run "git rebase --continue".
5 -You can instead skip this commit: run "git rebase --skip".
6 -To abort and get back to the state before "git rebase", run "git rebase --abort".')
7 -"
8 -
9 -write_basic_state () {
10 - echo "$head_name" > "$state_dir"/head-name &&
11 - echo "$onto" > "$state_dir"/onto &&
12 - echo "$orig_head" > "$state_dir"/orig-head &&
13 - test t = "$GIT_QUIET" && : > "$state_dir"/quiet
14 - test t = "$verbose" && : > "$state_dir"/verbose
15 - test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy
16 - test -n "$strategy_opts" && echo "$strategy_opts" > \
17 - "$state_dir"/strategy_opts
18 - test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \
19 - "$state_dir"/allow_rerere_autoupdate
20 - test -n "$gpg_sign_opt" && echo "$gpg_sign_opt" > "$state_dir"/gpg_sign_opt
21 - test -n "$signoff" && echo "$signoff" >"$state_dir"/signoff
22 - test -n "$reschedule_failed_exec" && : > "$state_dir"/reschedule-failed-exec
23 -}
24 -
25 -apply_autostash () {
26 - if test -f "$state_dir/autostash"
27 - then
28 - stash_sha1=$(cat "$state_dir/autostash")
29 - if git stash apply $stash_sha1 >/dev/null 2>&1
30 - then
31 - echo "$(gettext 'Applied autostash.')" >&2
32 - else
33 - git stash store -m "autostash" -q $stash_sha1 ||
34 - die "$(eval_gettext "Cannot store \$stash_sha1")"
35 - gettext 'Applying autostash resulted in conflicts.
36 -Your changes are safe in the stash.
37 -You can run "git stash pop" or "git stash drop" at any time.
38 -' >&2
39 - fi
40 - fi
41 -}
42 -
43 -move_to_original_branch () {
44 - case "$head_name" in
45 - refs/*)
46 - message="rebase finished: $head_name onto $onto"
47 - git update-ref -m "$message" \
48 - $head_name $(git rev-parse HEAD) $orig_head &&
49 - git symbolic-ref \
50 - -m "rebase finished: returning to $head_name" \
51 - HEAD $head_name ||
52 - die "$(eval_gettext "Could not move back to \$head_name")"
53 - ;;
54 - esac
55 -}
56 -
57 -output () {
58 - case "$verbose" in
59 - '')
60 - output=$("$@" 2>&1 )
61 - status=$?
62 - test $status != 0 && printf "%s\n" "$output"
63 - return $status
64 - ;;
65 - *)
66 - "$@"
67 - ;;
68 - esac
69 -}
git-rebase--preserve-merges.sh
+55
@@ -77,6 +77,61 @@ rewritten_pending="$state_dir"/rewritten-pending
77 # and leaves CR at the end instead.
78 cr=$(printf "\015")
79
80 +resolvemsg="
81 +$(gettext 'Resolve all conflicts manually, mark them as resolved with
82 +"git add/rm <conflicted_files>", then run "git rebase --continue".
83 +You can instead skip this commit: run "git rebase --skip".
84 +To abort and get back to the state before "git rebase", run "git rebase --abort".')
85 +"
86 +
87 +write_basic_state () {
88 + echo "$head_name" > "$state_dir"/head-name &&
89 + echo "$onto" > "$state_dir"/onto &&
90 + echo "$orig_head" > "$state_dir"/orig-head &&
91 + test t = "$GIT_QUIET" && : > "$state_dir"/quiet
92 + test t = "$verbose" && : > "$state_dir"/verbose
93 + test -n "$strategy" && echo "$strategy" > "$state_dir"/strategy
94 + test -n "$strategy_opts" && echo "$strategy_opts" > \
95 + "$state_dir"/strategy_opts
96 + test -n "$allow_rerere_autoupdate" && echo "$allow_rerere_autoupdate" > \
97 + "$state_dir"/allow_rerere_autoupdate
98 + test -n "$gpg_sign_opt" && echo "$gpg_sign_opt" > "$state_dir"/gpg_sign_opt
99 + test -n "$signoff" && echo "$signoff" >"$state_dir"/signoff
100 + test -n "$reschedule_failed_exec" && : > "$state_dir"/reschedule-failed-exec
101 +}
102 +
103 +apply_autostash () {
104 + if test -f "$state_dir/autostash"
105 + then
106 + stash_sha1=$(cat "$state_dir/autostash")
107 + if git stash apply $stash_sha1 >/dev/null 2>&1
108 + then
109 + echo "$(gettext 'Applied autostash.')" >&2
110 + else
111 + git stash store -m "autostash" -q $stash_sha1 ||
112 + die "$(eval_gettext "Cannot store \$stash_sha1")"
113 + gettext 'Applying autostash resulted in conflicts.
114 +Your changes are safe in the stash.
115 +You can run "git stash pop" or "git stash drop" at any time.
116 +' >&2
117 + fi
118 + fi
119 +}
120 +
121 +output () {
122 + case "$verbose" in
123 + '')
124 + output=$("$@" 2>&1 )
125 + status=$?
126 + test $status != 0 && printf "%s\n" "$output"
127 + return $status
128 + ;;
129 + *)
130 + "$@"
131 + ;;
132 + esac
133 +}
134 +
135 strategy_args=${strategy:+--strategy=$strategy}
136 test -n "$strategy_opts" &&
137 eval '