git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: Matthieu.Moy@grenoble-inp.fr, sbeller@google.com, peff@peff.net,
	christian.couder@gmail.com, Johannes.Schindelin@gmx.de,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 2/3] rebase: move cleanup code to exit_rebase()
Date: Wed, 17 Feb 2016 20:36:40 +0700	[thread overview]
Message-ID: <1455716201-29784-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1455716201-29784-1-git-send-email-pclouds@gmail.com>

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git-rebase--lib.sh (mode +x) | 38 ++++++++++++++++++++++++++++++++++++++
 git-rebase.sh                | 37 +------------------------------------
 2 files changed, 39 insertions(+), 36 deletions(-)
 mode change 100644 => 100755 git-rebase--lib.sh

diff --git a/git-rebase--lib.sh b/git-rebase--lib.sh
old mode 100644
new mode 100755
index 8bec516..a876fc2
--- a/git-rebase--lib.sh
+++ b/git-rebase--lib.sh
@@ -39,3 +39,41 @@ move_to_original_branch () {
 		;;
 	esac
 }
+
+apply_autostash () {
+	if test -f "$state_dir/autostash"
+	then
+		stash_sha1=$(cat "$state_dir/autostash")
+		if git stash apply $stash_sha1 2>&1 >/dev/null
+		then
+			echo "$(gettext 'Applied autostash.')"
+		else
+			git stash store -m "autostash" -q $stash_sha1 ||
+			die "$(eval_gettext "Cannot store \$stash_sha1")"
+			gettext 'Applying autostash resulted in conflicts.
+Your changes are safe in the stash.
+You can run "git stash pop" or "git stash drop" at any time.
+'
+		fi
+	fi
+}
+
+finish_rebase () {
+	apply_autostash &&
+	{ git gc --auto || true; } &&
+	rm -rf "$state_dir"
+}
+
+exit_rebase () {
+	ret=$1
+	if test $ret -eq 0
+	then
+		finish_rebase
+	elif test $ret -eq 2 # special exit status for rebase -i
+	then
+		apply_autostash &&
+		rm -rf "$state_dir" &&
+		die "Nothing to do"
+	fi
+	exit $ret
+}
diff --git a/git-rebase.sh b/git-rebase.sh
index dc29474..0c70381 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -115,31 +115,6 @@ read_basic_state () {
 		gpg_sign_opt="$(cat "$state_dir"/gpg_sign_opt)"
 }
 
-
-apply_autostash () {
-	if test -f "$state_dir/autostash"
-	then
-		stash_sha1=$(cat "$state_dir/autostash")
-		if git stash apply $stash_sha1 2>&1 >/dev/null
-		then
-			echo "$(gettext 'Applied autostash.')"
-		else
-			git stash store -m "autostash" -q $stash_sha1 ||
-			die "$(eval_gettext "Cannot store \$stash_sha1")"
-			gettext 'Applying autostash resulted in conflicts.
-Your changes are safe in the stash.
-You can run "git stash pop" or "git stash drop" at any time.
-'
-		fi
-	fi
-}
-
-finish_rebase () {
-	apply_autostash &&
-	{ git gc --auto || true; } &&
-	rm -rf "$state_dir"
-}
-
 run_specific_rebase () {
 	if [ "$interactive_rebase" = implied ]; then
 		GIT_EDITOR=:
@@ -147,17 +122,7 @@ run_specific_rebase () {
 		autosquash=
 	fi
 	. git-rebase--$type
-	ret=$?
-	if test $ret -eq 0
-	then
-		finish_rebase
-	elif test $ret -eq 2 # special exit status for rebase -i
-	then
-		apply_autostash &&
-		rm -rf "$state_dir" &&
-		die "Nothing to do"
-	fi
-	exit $ret
+	exit_rebase $?
 }
 
 run_pre_rebase_hook () {
-- 
2.7.0.377.g4cd97dd

  parent reply	other threads:[~2016-02-17 13:36 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10  9:31 GSoC 2016: applications open, deadline = Fri, 19/2 Matthieu Moy
2016-02-10 11:09 ` Johannes Schindelin
2016-02-10 17:44   ` Stefan Beller
2016-02-11  8:36 ` Christian Couder
2016-02-12  7:10   ` Matthieu Moy
2016-02-12  8:29     ` Lars Schneider
2016-02-12  9:11       ` Matthieu Moy
2016-02-12 13:04     ` Jeff King
2016-02-12 13:11       ` Jeff King
2016-02-13 11:21       ` Matthieu Moy
2016-02-16 18:10         ` Stefan Beller
2016-02-17 10:34           ` Matthieu Moy
2016-02-17 10:45             ` Duy Nguyen
2016-02-17 13:36             ` [PATCH 0/3] Turn git-rebase--*.sh to external helpers Nguyễn Thái Ngọc Duy
2016-02-17 13:36               ` [PATCH 1/3] rebase: move common functions to rebase--lib.sh Nguyễn Thái Ngọc Duy
2016-02-17 13:36               ` Nguyễn Thái Ngọc Duy [this message]
2016-02-17 14:03                 ` [PATCH 2/3] rebase: move cleanup code to exit_rebase() Matthieu Moy
2016-02-17 13:36               ` [PATCH 3/3] rebase: turn git-rebase--*.sh into separate programs Nguyễn Thái Ngọc Duy
2016-02-17 14:05                 ` Matthieu Moy
2016-02-17 14:22               ` [PATCH 0/3] Turn git-rebase--*.sh to external helpers Johannes Schindelin
2016-02-17 14:40                 ` Duy Nguyen
2016-02-17 13:09           ` GSoC 2016: applications open, deadline = Fri, 19/2 Johannes Schindelin
2016-02-17 16:04             ` Christian Couder
2016-02-22  9:28         ` Duy Nguyen
2016-02-22 10:22           ` Matthieu Moy
2016-02-22 21:42             ` Jeff King
2016-02-22 21:56               ` Junio C Hamano
2016-02-22 22:02                 ` Jeff King
2016-02-23 13:13                   ` Matthieu Moy
2016-02-24 10:52                     ` Jeff King
2016-02-17 17:24 ` Thomas Gummerer
2016-02-17 18:32   ` Lars Schneider
2016-02-17 18:58     ` Matthieu Moy
2016-02-17 19:03       ` Junio C Hamano
2016-02-17 20:21         ` Matthieu Moy
2016-02-17 20:45           ` Jeff King
2016-02-17 21:33             ` Junio C Hamano
2016-02-18  9:38               ` Carlos Martín Nieto
2016-02-19  8:06                 ` GSoC 2016: applications open, libgit2 and git.git Matthieu Moy
2016-02-19  9:46                   ` Carlos Martín Nieto
2016-02-29 21:01                     ` Git has been accepted as a GSoC 2016 mentor organization! Matthieu Moy
2016-03-08 22:46                       ` Jeff King
2016-03-08 23:01                         ` Junio C Hamano
2016-03-08 23:03                           ` Jeff King
2016-03-09  9:55                         ` Matthieu Moy
2016-03-09 14:08                           ` Jeff King
2016-03-09 13:50                         ` Johannes Schindelin
2016-03-09 19:34                         ` Jeff King
2016-02-19  8:09                 ` GSoC 2016: applications open, deadline = now => submission Matthieu Moy
2016-02-19  8:18                   ` Jeff King
2016-02-19  9:10                     ` GSoC 2016: applications open, deadline = now => submitted Matthieu Moy
2016-02-19 11:37                       ` Jeff King
2016-02-18  8:41       ` GSoC 2016: applications open, deadline = Fri, 19/2 Lars Schneider
2016-02-18 18:38         ` Stefan Beller
2016-02-18 19:13           ` Junio C Hamano
2016-02-19  7:34             ` Matthieu Moy
2016-02-19 20:35               ` Junio C Hamano
2016-02-20  9:28                 ` Johannes Schindelin
2016-02-19  9:23             ` Lars Schneider
2016-02-19 12:49               ` Matthieu Moy
2016-02-19 20:37               ` Junio C Hamano
2016-02-19 11:46         ` Thomas Gummerer
2016-02-19  3:09       ` Duy Nguyen
2016-02-19  3:20         ` Junio C Hamano
2016-02-19  3:29           ` Duy Nguyen
2016-02-19  7:17         ` Matthieu Moy
2016-02-19  9:41           ` Duy Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455716201-29784-3-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).