From: Ben Woosley <Ben.Woosley@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] rebase: move state_dir to tmp prior to deletion
Date: Sat, 26 Jan 2019 07:41:21 +0000 [thread overview]
Message-ID: <01020168891b1a3e-140bd175-a8cb-4379-a114-de68b1cac5d6-000000@eu-west-1.amazonses.com> (raw)
From: Ben Woosley <ben.woosley@gmail.com>
To avoid partial deletion / zombie rebases.
Example behavior under partial deletion, after
Ctrl-Cing out of a standard rebase:
$ git rebase target
First, rewinding head to replay your work on top of it...
Applying: [...]
^C
$ git status
rebase in progress; onto (null)
You are currently rebasing.
(all conflicts fixed: run "git rebase --continue")
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
[...]
$ git rebase --continue
error: could not read '.git/rebase-apply/head-name': No such file or directory
$ git rebase --abort
error: could not read '.git/rebase-apply/head-name': No such file or directory
Others report this issue here:
https://stackoverflow.com/questions/3685001/git-how-to-fix-corrupted-interactive-rebase
---
git-legacy-rebase.sh | 17 ++++++++++++++---
git-rebase--preserve-merges.sh | 2 +-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/git-legacy-rebase.sh b/git-legacy-rebase.sh
index b4c7dbfa575d3..878c0e42054d7 100755
--- a/git-legacy-rebase.sh
+++ b/git-legacy-rebase.sh
@@ -128,11 +128,22 @@ read_basic_state () {
}
}
+remove_rebase_state () {
+ state_tmpdir=$(mktemp -d -t "git-rebase-state-XXXXXX")
+ if test -d state_tmpdir
+ then
+ exec mv "$state_dir" "$state_tmpdir"
+ exec rm -rf "$state_tmpdir"
+ else
+ exec rm -rf "$state_dir"
+ fi
+}
+
finish_rebase () {
rm -f "$(git rev-parse --git-path REBASE_HEAD)"
apply_autostash &&
{ git gc --auto || true; } &&
- rm -rf "$state_dir"
+ remove_rebase_state
}
run_interactive () {
@@ -194,7 +205,7 @@ run_specific_rebase () {
elif test $ret -eq 2 # special exit status for rebase -p
then
apply_autostash &&
- rm -rf "$state_dir" &&
+ remove_rebase_state &&
die "Nothing to do"
fi
exit $ret
@@ -439,7 +450,7 @@ abort)
exit
;;
quit)
- exec rm -rf "$state_dir"
+ remove_rebase_state
;;
edit-todo)
run_specific_rebase
diff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh
index afbb65765d461..146b52df14928 100644
--- a/git-rebase--preserve-merges.sh
+++ b/git-rebase--preserve-merges.sh
@@ -226,7 +226,7 @@ Once you are satisfied with your changes, run
die_abort () {
apply_autostash
- rm -rf "$state_dir"
+ remove_rebase_state
die "$1"
}
--
https://github.com/git/git/pull/569
next reply other threads:[~2019-01-26 7:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-26 7:41 Ben Woosley [this message]
2019-01-26 10:16 ` [PATCH v2] rebase: move state_dir to tmp prior to deletion Ben Woosley
2019-01-26 13:59 ` Alban Gruin
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=01020168891b1a3e-140bd175-a8cb-4379-a114-de68b1cac5d6-000000@eu-west-1.amazonses.com \
--to=ben.woosley@gmail.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.