[PATCH 23/31] rebase: factor out sub command handling

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

 



Factor out the common parts of the handling of the sub commands
'--continue', '--skip' and '--abort'. The '--abort' handling can
handled completely in git-rebase.sh.

After this refactoring, the calls to git-rebase--am.sh,
git-rebase--merge.sh and git-rebase--interactive.sh will be better
aligned. There will only be one call to interactive rebase that will
shortcut the very last part of git-rebase.sh.

Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@xxxxxxxxx>
---
 git-rebase--interactive.sh |   34 +++-------------------------------
 git-rebase.sh              |   17 +++++++++++++++--
 2 files changed, 18 insertions(+), 33 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index acd0258..1079994 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -509,9 +509,7 @@ do_next () {
 	test -s "$TODO" && return
 
 	comment_for_reflog finish &&
-	head_name=$(cat "$state_dir"/head-name) &&
-	orig_head=$(cat "$state_dir"/head) &&
-	SHORTONTO=$(git rev-parse --short $(cat "$state_dir"/onto)) &&
+	SHORTONTO=$(git rev-parse --short $onto) &&
 	NEWHEAD=$(git rev-parse HEAD) &&
 	case $head_name in
 	refs/*)
@@ -521,7 +519,7 @@ do_next () {
 		;;
 	esac && {
 		test ! -f "$state_dir"/verbose ||
-			git diff-tree --stat $(cat "$state_dir"/head)..HEAD
+			git diff-tree --stat $orig_head..HEAD
 	} &&
 	{
 		test -s "$REWRITTEN_LIST" &&
@@ -655,14 +653,6 @@ rearrange_squash () {
 case "$action" in
 continue)
 	get_saved_options
-	comment_for_reflog continue
-
-	# Sanity check
-	git rev-parse --verify HEAD >/dev/null ||
-		die "Cannot read HEAD"
-	git update-index --ignore-submodules --refresh &&
-		git diff-files --quiet --ignore-submodules ||
-		die "Working tree is dirty"
 
 	# do we have anything to commit?
 	if git diff-index --cached --quiet --ignore-submodules HEAD --
@@ -693,30 +683,12 @@ first and then run 'git rebase --continue' again."
 	require_clean_work_tree "rebase"
 	do_rest
 	;;
-abort)
-	get_saved_options
-	comment_for_reflog abort
-
-	git rerere clear
-
-	head_name=$(cat "$state_dir"/head-name)
-	orig_head=$(cat "$state_dir"/head)
-	case $head_name in
-	refs/*)
-		git symbolic-ref HEAD $head_name
-		;;
-	esac &&
-	output git reset --hard $orig_head &&
-	rm -rf "$state_dir"
-	exit
-	;;
 skip)
 	get_saved_options
-	comment_for_reflog skip
 
 	git rerere clear
 
-	output git reset --hard && do_rest
+	do_rest
 	;;
 esac
 
diff --git a/git-rebase.sh b/git-rebase.sh
index 0322f27..7e2e978 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -70,7 +70,12 @@ test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
 read_basic_state () {
 	head_name=$(cat "$state_dir"/head-name) &&
 	onto=$(cat "$state_dir"/onto) &&
-	orig_head=$(cat "$state_dir"/orig-head) &&
+	if test "$type" = interactive
+	then
+		orig_head=$(cat "$state_dir"/head)
+	else
+		orig_head=$(cat "$state_dir"/orig-head)
+	fi &&
 	GIT_QUIET=$(cat "$state_dir"/quiet)
 }
 
@@ -267,11 +272,19 @@ test $# -gt 2 && usage
 if test -n "$action"
 then
 	test -z "$in_progress" && die "No rebase in progress?"
-	test "$type" = interactive && run_specific_rebase
+	# Only interactive rebase uses detailed reflog messages
+	if test "$type" = interactive && test "$GIT_REFLOG_ACTION" = rebase
+	then
+		GIT_REFLOG_ACTION="rebase -i ($action)"
+		export GIT_REFLOG_ACTION
+	fi
 fi
 
 case "$action" in
 continue)
+	# Sanity check
+	git rev-parse --verify HEAD >/dev/null ||
+		die "Cannot read HEAD"
 	git update-index --ignore-submodules --refresh &&
 	git diff-files --quiet --ignore-submodules || {
 		echo "You must edit all merge conflicts and then"
-- 
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]