rebase: extract am code to new source file
Extract the code for am-based rebase to git-rebase--am.sh. Suggested-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin von Zweigbergk committed
Feb 6, 2011 at 13:43 UTC
46df82d5fa0f83d3c1108ad70248877d6d9b56bb
4 files changed
+38
-29
.gitignore
+1
@@ -102,6 +102,7 @@
102
/git-quiltimport
103
/git-read-tree
104
/git-rebase
105
+/git-rebase--am
106
/git-rebase--interactive
107
/git-rebase--merge
108
/git-receive-pack
Makefile
+1
@@ -369,6 +369,7 @@ SCRIPT_SH += git-merge-resolve.sh
369
SCRIPT_SH += git-mergetool.sh
370
SCRIPT_SH += git-pull.sh
371
SCRIPT_SH += git-quiltimport.sh
372
+SCRIPT_SH += git-rebase--am.sh
373
SCRIPT_SH += git-rebase--interactive.sh
374
SCRIPT_SH += git-rebase--merge.sh
375
SCRIPT_SH += git-rebase.sh
git-rebase--am.sh
new
+34
@@ -0,0 +1,34 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2010 Junio C Hamano.
4
+#
5
+
6
+. git-sh-setup
7
+
8
+case "$action" in
9
+continue)
10
+ git am --resolved --3way --resolvemsg="$resolvemsg" &&
11
+ move_to_original_branch
12
+ exit
13
+ ;;
14
+skip)
15
+ git am --skip -3 --resolvemsg="$resolvemsg" &&
16
+ move_to_original_branch
17
+ exit
18
+ ;;
19
+esac
20
+
21
+test -n "$rebase_root" && root_flag=--root
22
+
23
+git format-patch -k --stdout --full-index --ignore-if-in-upstream \
24
+ --src-prefix=a/ --dst-prefix=b/ \
25
+ --no-renames $root_flag "$revisions" |
26
+git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" &&
27
+move_to_original_branch
28
+ret=$?
29
+test 0 != $ret -a -d "$state_dir" &&
30
+ echo $head_name > "$state_dir/head-name" &&
31
+ echo $onto > "$state_dir/onto" &&
32
+ echo $orig_head > "$state_dir/orig-head" &&
33
+ echo "$GIT_QUIET" > "$state_dir/quiet"
34
+exit $ret
git-rebase.sh
+2
-29
@@ -91,7 +91,7 @@ run_specific_rebase () {
91
GIT_EDITOR=:
92
export GIT_EDITOR
93
fi
94
- test "$type" != am && . git-rebase--$type
94
+ . git-rebase--$type
95
}
96
97
run_pre_rebase_hook () {
@@ -261,17 +261,11 @@ continue)
261
}
262
read_basic_state
263
run_specific_rebase
264
- git am --resolved --3way --resolvemsg="$resolvemsg" &&
265
- move_to_original_branch
266
- exit
264
;;
265
skip)
266
git reset --hard HEAD || exit $?
267
read_basic_state
268
run_specific_rebase
272
- git am -3 --skip --resolvemsg="$resolvemsg" &&
273
- move_to_original_branch
274
- exit
269
;;
270
abort)
271
git rerere clear
@@ -324,14 +318,12 @@ then
318
shift
319
upstream=`git rev-parse --verify "${upstream_name}^0"` ||
320
die "invalid upstream $upstream_name"
327
- unset root_flag
321
upstream_arg="$upstream_name"
322
else
323
test -z "$onto" && die "You must specify --onto when using --root"
324
unset upstream_name
325
unset upstream
333
- root_flag="--root"
334
- upstream_arg="$root_flag"
326
+ upstream_arg=--root
327
fi
328
329
# Make sure the branch to rebase onto is valid.
@@ -457,23 +449,4 @@ else
449
revisions="$upstream..$orig_head"
450
fi
451
460
-if test -z "$do_merge"
461
-then
462
- git format-patch -k --stdout --full-index --ignore-if-in-upstream \
463
- --src-prefix=a/ --dst-prefix=b/ \
464
- --no-renames $root_flag "$revisions" |
465
- git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" &&
466
- move_to_original_branch
467
- ret=$?
468
- test 0 != $ret -a -d "$apply_dir" &&
469
- echo $head_name > "$apply_dir/head-name" &&
470
- echo $onto > "$apply_dir/onto" &&
471
- echo $orig_head > "$apply_dir/orig-head" &&
472
- echo "$GIT_QUIET" > "$apply_dir/quiet"
473
- exit $ret
474
-fi
475
-
476
-# start doing a rebase with git-merge
477
-# this is rename-aware if the recursive (default) strategy is used
478
-
452
run_specific_rebase