summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 73e18e3)
raw | patch | inline | side by side (parent: 73e18e3)
author | Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> | |
Tue, 28 Dec 2010 09:30:19 +0000 (10:30 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 28 Dec 2010 22:58:51 +0000 (14:58 -0800) |
The code reading the state saved in $merge_dir or $rebase_dir is
currently spread out in many places, making it harder to read and to
introduce additional state. Extract this code into one method that reads
the state.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
currently spread out in many places, making it harder to read and to
introduce additional state. Extract this code into one method that reads
the state.
Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-rebase.sh | patch | blob | history |
diff --git a/git-rebase.sh b/git-rebase.sh
index 79f8008dde1f892518e5d02b5a55a1ab0bd5edd7..bf144dcd5884160db88b8ca4851159f52d7e13c7 100755 (executable)
--- a/git-rebase.sh
+++ b/git-rebase.sh
force_rebase=
allow_rerere_autoupdate=
+read_state () {
+ if test -d "$merge_dir"
+ then
+ state_dir="$merge_dir"
+ prev_head=$(cat "$merge_dir"/prev_head) &&
+ end=$(cat "$merge_dir"/end) &&
+ msgnum=$(cat "$merge_dir"/msgnum)
+ else
+ state_dir="$apply_dir"
+ fi &&
+ head_name=$(cat "$state_dir"/head-name) &&
+ onto=$(cat "$state_dir"/onto) &&
+ orig_head=$(cat "$state_dir"/orig-head) &&
+ GIT_QUIET=$(cat "$state_dir"/quiet)
+}
+
continue_merge () {
test -n "$prev_head" || die "prev_head must be defined"
test -d "$merge_dir" || die "$merge_dir directory does not exist"
}
move_to_original_branch () {
- test -z "$head_name" &&
- head_name="$(cat "$merge_dir"/head-name)" &&
- onto="$(cat "$merge_dir"/onto)" &&
- orig_head="$(cat "$merge_dir"/orig-head)"
case "$head_name" in
refs/*)
message="rebase finished: $head_name onto $onto"
echo "mark them as resolved using git add"
exit 1
}
+ read_state
if test -d "$merge_dir"
then
- prev_head=$(cat "$merge_dir/prev_head")
- end=$(cat "$merge_dir/end")
- msgnum=$(cat "$merge_dir/msgnum")
- onto=$(cat "$merge_dir/onto")
- GIT_QUIET=$(cat "$merge_dir/quiet")
continue_merge
while test "$msgnum" -le "$end"
do
finish_rb_merge
exit
fi
- head_name=$(cat "$apply_dir"/head-name) &&
- onto=$(cat "$apply_dir"/onto) &&
- orig_head=$(cat "$apply_dir"/orig-head) &&
- GIT_QUIET=$(cat "$apply_dir"/quiet)
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
die "No rebase in progress?"
git reset --hard HEAD || exit $?
+ read_state
if test -d "$merge_dir"
then
git rerere clear
- prev_head=$(cat "$merge_dir/prev_head")
- end=$(cat "$merge_dir/end")
- msgnum=$(cat "$merge_dir/msgnum")
msgnum=$(($msgnum + 1))
- onto=$(cat "$merge_dir/onto")
- GIT_QUIET=$(cat "$merge_dir/quiet")
while test "$msgnum" -le "$end"
do
call_merge "$msgnum"
finish_rb_merge
exit
fi
- head_name=$(cat "$apply_dir"/head-name) &&
- onto=$(cat "$apply_dir"/onto) &&
- orig_head=$(cat "$apply_dir"/orig-head) &&
- GIT_QUIET=$(cat "$apply_dir"/quiet)
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
die "No rebase in progress?"
git rerere clear
-
- test -d "$merge_dir" || merge_dir="$apply_dir"
-
- head_name="$(cat "$merge_dir"/head-name)" &&
+ read_state
case "$head_name" in
refs/*)
git symbolic-ref HEAD $head_name ||
die "Could not move back to $head_name"
;;
esac
- git reset --hard $(cat "$merge_dir/orig-head")
- rm -r "$merge_dir"
+ git reset --hard $orig_head
+ rm -r "$state_dir"
exit
;;
--onto)
# this is rename-aware if the recursive (default) strategy is used
mkdir -p "$merge_dir"
-echo "$onto" > "$merge_dir/onto"
echo "$onto_name" > "$merge_dir/onto_name"
prev_head=$orig_head
echo "$prev_head" > "$merge_dir/prev_head"
-echo "$orig_head" > "$merge_dir/orig-head"
echo "$head_name" > "$merge_dir/head-name"
+echo "$onto" > "$merge_dir/onto"
+echo "$orig_head" > "$merge_dir/orig-head"
echo "$GIT_QUIET" > "$merge_dir/quiet"
msgnum=0