From: Simon Sasburg <simon.sasburg@gmail.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Simon Sasburg <Simon.Sasburg@gmail.com>
Subject: [PATCH 2/3] Implement --dirty for git-rebase--interactive.
Date: Thu, 1 Nov 2007 22:30:23 +0100 [thread overview]
Message-ID: <1193952624-608-3-git-send-email-Simon.Sasburg@gmail.com> (raw)
In-Reply-To: <1193952624-608-2-git-send-email-Simon.Sasburg@gmail.com>
Signed-off-by: Simon Sasburg <Simon.Sasburg@gmail.com>
---
git-rebase--interactive.sh | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 76dc679..326076b 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -25,6 +25,7 @@ REWRITTEN="$DOTEST"/rewritten
PRESERVE_MERGES=
STRATEGY=
VERBOSE=
+FIX_DIRTY=
test -d "$REWRITTEN" && PRESERVE_MERGES=t
test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
test -f "$DOTEST"/verbose && VERBOSE=t
@@ -56,6 +57,35 @@ require_clean_work_tree () {
die "Working tree is dirty"
}
+store_dirty_state () {
+ echo "Storing dirty index/working tree"
+ diff=$(git diff --cached)
+ case "$diff" in
+ ?*) git commit -m "REBASE--dirty: store HEAD..index diff"
+ ;;
+ esac
+ diff=$(git diff)
+ case "$diff" in
+ ?*) git commit -a -m "REBASE--dirty: store index..workingtree diff"
+ ;;
+ esac
+}
+
+restore_dirty_state () {
+ lastmsg=$(git-rev-list HEAD^..HEAD --pretty=oneline | sed "s:[^ ]* ::")
+ if test "$lastmsg" = "REBASE--dirty: store index..workingtree diff"
+ then
+ echo "Restoring dirty index state"
+ git reset --mixed HEAD^
+ fi
+ lastmsg=$(git-rev-list HEAD^..HEAD --pretty=oneline | sed "s:[^ ]* ::")
+ if test "$lastmsg" = "REBASE--dirty: store HEAD..index diff"
+ then
+ echo "Restoring dirty working dir state"
+ git reset --soft HEAD^
+ fi
+}
+
ORIG_REFLOG_ACTION="$GIT_REFLOG_ACTION"
comment_for_reflog () {
@@ -329,6 +359,7 @@ do_next () {
test ! -f "$DOTEST"/verbose ||
git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
} &&
+ restore_dirty_state &&
rm -rf "$DOTEST" &&
git gc --auto &&
warn "Successfully rebased and updated $HEADNAME."
@@ -378,6 +409,7 @@ do
;;
esac &&
output git reset --hard $HEAD &&
+ restore_dirty_state &&
rm -rf "$DOTEST"
exit
;;
@@ -417,6 +449,9 @@ do
''|-h)
usage
;;
+ --dirty)
+ FIX_DIRTY=t
+ ;;
*)
test -d "$DOTEST" &&
die "Interactive rebase already started"
@@ -435,7 +470,7 @@ do
;;
esac
- require_clean_work_tree
+ test "$FIX_DIRTY" = "t" || require_clean_work_tree
if test ! -z "$2"
then
@@ -445,9 +480,12 @@ do
die "Could not checkout $2"
fi
- HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
+ test "$FIX_DIRTY" = "t" && store_dirty_state
+
+ HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
+
mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
test -z "$ONTO" && ONTO=$UPSTREAM
--
1.5.3.4.502.g37c97
next prev parent reply other threads:[~2007-11-01 21:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-01 21:30 [RFC PATCH 0/3] Starting rebase from dirty tree Simon Sasburg
2007-11-01 21:30 ` [PATCH 1/3] Introduce --dirty option to git-rebase, allowing you to start from a dirty state Simon Sasburg
2007-11-01 21:30 ` Simon Sasburg [this message]
2007-11-01 21:30 ` [PATCH 3/3] Make git-svn rebase --dirty pass along --dirty to git-rebase Simon Sasburg
2007-11-12 19:51 ` [PATCH 2/3] Implement --dirty for git-rebase--interactive Junio C Hamano
2007-11-01 22:30 ` [PATCH 1/3] Introduce --dirty option to git-rebase, allowing you to start from a dirty state Junio C Hamano
2007-11-01 22:36 ` Junio C Hamano
2007-11-02 5:08 ` Shawn O. Pearce
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=1193952624-608-3-git-send-email-Simon.Sasburg@gmail.com \
--to=simon.sasburg@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).