aboutsummaryrefslogtreecommitdiff
path: root/git-rebase--interactive.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-09-25 16:42:36 +0100
committerJunio C Hamano <gitster@pobox.com>2007-09-25 17:46:43 -0700
commitbe6ff208d8248c3f282df14fdf3c08db57e92007 (patch)
treea3ae81af74765b69ad51beef03b3ee62ad269b27 /git-rebase--interactive.sh
parentdf3a02f6125f7ac82b6e81e3e32cd7ca3c7905ee (diff)
downloadgit-be6ff208d8248c3f282df14fdf3c08db57e92007.tar.gz
git-be6ff208d8248c3f282df14fdf3c08db57e92007.tar.xz
rebase -i: commit when continuing after "edit"
When doing an "edit" on a commit, editing and git-adding some files, "git rebase -i" complained about a missing "author-script". The idea was that the user would call "git commit --amend" herself. But we can be nice and do that for the user. Noticed by Dmitry Potapov. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase--interactive.sh')
-rwxr-xr-xgit-rebase--interactive.sh17
1 files changed, 11 insertions, 6 deletions
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 2fa53fdae..56e6f7f08 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -77,15 +77,16 @@ mark_action_done () {
}
make_patch () {
- parent_sha1=$(git rev-parse --verify "$1"^ 2> /dev/null)
+ parent_sha1=$(git rev-parse --verify "$1"^) ||
+ die "Cannot get patch for $1^"
git diff "$parent_sha1".."$1" > "$DOTEST"/patch
+ test -f "$DOTEST"/message ||
+ git cat-file commit "$1" | sed "1,/^$/d" > "$DOTEST"/message
+ test -f "$DOTEST"/author-script ||
+ get_author_ident_from_commit "$1" > "$DOTEST"/author-script
}
die_with_patch () {
- test -f "$DOTEST"/message ||
- git cat-file commit $sha1 | sed "1,/^$/d" > "$DOTEST"/message
- test -f "$DOTEST"/author-script ||
- get_author_ident_from_commit $sha1 > "$DOTEST"/author-script
make_patch "$1"
die "$2"
}
@@ -214,6 +215,7 @@ peek_next_command () {
do_next () {
test -f "$DOTEST"/message && rm "$DOTEST"/message
test -f "$DOTEST"/author-script && rm "$DOTEST"/author-script
+ test -f "$DOTEST"/amend && rm "$DOTEST"/amend
read command sha1 rest < "$TODO"
case "$command" in
\#|'')
@@ -233,6 +235,7 @@ do_next () {
pick_one $sha1 ||
die_with_patch $sha1 "Could not apply $sha1... $rest"
make_patch $sha1
+ : > "$DOTEST"/amend
warn
warn "You can amend the commit now, with"
warn
@@ -330,7 +333,9 @@ do
git update-index --refresh &&
git diff-files --quiet &&
! git diff-index --cached --quiet HEAD &&
- . "$DOTEST"/author-script &&
+ . "$DOTEST"/author-script && {
+ test ! -f "$DOTEST"/amend || git reset --soft HEAD^
+ } &&
export GIT_AUTHOR_NAME GIT_AUTHOR_NAME GIT_AUTHOR_DATE &&
git commit -F "$DOTEST"/message -e