Merge branch 'mz/rebase-no-mbox'
Teach "am --rebasing" codepath to grab authorship, log message and the patch text directly out of existing commits. This will help rebasing commits that have confusing "diff" output in their log messages. * mz/rebase-no-mbox: am: don't call mailinfo if $rebasing am --rebasing: get patch body from commit, not from mailbox rebase --root: print usage on too many args rebase: don't source git-sh-setup twice
This commit is contained in:
commit
a1204bd7c3
48
git-am.sh
48
git-am.sh
@ -260,7 +260,7 @@ check_patch_format () {
|
|||||||
split_patches () {
|
split_patches () {
|
||||||
case "$patch_format" in
|
case "$patch_format" in
|
||||||
mbox)
|
mbox)
|
||||||
if test -n "$rebasing" || test t = "$keepcr"
|
if test t = "$keepcr"
|
||||||
then
|
then
|
||||||
keep_cr=--keep-cr
|
keep_cr=--keep-cr
|
||||||
else
|
else
|
||||||
@ -413,7 +413,7 @@ do
|
|||||||
--abort)
|
--abort)
|
||||||
abort=t ;;
|
abort=t ;;
|
||||||
--rebasing)
|
--rebasing)
|
||||||
rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;;
|
rebasing=t threeway=t ;;
|
||||||
-d|--dotest)
|
-d|--dotest)
|
||||||
die "$(gettext "-d option is no longer supported. Do not use.")"
|
die "$(gettext "-d option is no longer supported. Do not use.")"
|
||||||
;;
|
;;
|
||||||
@ -658,32 +658,34 @@ do
|
|||||||
# by the user, or the user can tell us to do so by --resolved flag.
|
# by the user, or the user can tell us to do so by --resolved flag.
|
||||||
case "$resume" in
|
case "$resume" in
|
||||||
'')
|
'')
|
||||||
git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
|
if test -f "$dotest/rebasing"
|
||||||
<"$dotest/$msgnum" >"$dotest/info" ||
|
then
|
||||||
stop_here $this
|
|
||||||
|
|
||||||
# skip pine's internal folder data
|
|
||||||
sane_grep '^Author: Mail System Internal Data$' \
|
|
||||||
<"$dotest"/info >/dev/null &&
|
|
||||||
go_next && continue
|
|
||||||
|
|
||||||
test -s "$dotest/patch" || {
|
|
||||||
eval_gettextln "Patch is empty. Was it split wrong?
|
|
||||||
If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
|
|
||||||
To restore the original branch and stop patching run \"\$cmdline --abort\"."
|
|
||||||
stop_here $this
|
|
||||||
}
|
|
||||||
rm -f "$dotest/original-commit" "$dotest/author-script"
|
|
||||||
if test -f "$dotest/rebasing" &&
|
|
||||||
commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
|
commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
|
||||||
-e q "$dotest/$msgnum") &&
|
-e q "$dotest/$msgnum") &&
|
||||||
test "$(git cat-file -t "$commit")" = commit
|
test "$(git cat-file -t "$commit")" = commit ||
|
||||||
then
|
stop_here $this
|
||||||
git cat-file commit "$commit" |
|
git cat-file commit "$commit" |
|
||||||
sed -e '1,/^$/d' >"$dotest/msg-clean"
|
sed -e '1,/^$/d' >"$dotest/msg-clean"
|
||||||
echo "$commit" > "$dotest/original-commit"
|
echo "$commit" >"$dotest/original-commit"
|
||||||
get_author_ident_from_commit "$commit" > "$dotest/author-script"
|
get_author_ident_from_commit "$commit" >"$dotest/author-script"
|
||||||
|
git diff-tree --root --binary "$commit" >"$dotest/patch"
|
||||||
else
|
else
|
||||||
|
git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
|
||||||
|
<"$dotest/$msgnum" >"$dotest/info" ||
|
||||||
|
stop_here $this
|
||||||
|
|
||||||
|
# skip pine's internal folder data
|
||||||
|
sane_grep '^Author: Mail System Internal Data$' \
|
||||||
|
<"$dotest"/info >/dev/null &&
|
||||||
|
go_next && continue
|
||||||
|
|
||||||
|
test -s "$dotest/patch" || {
|
||||||
|
eval_gettextln "Patch is empty. Was it split wrong?
|
||||||
|
If you would prefer to skip this patch, instead run \"\$cmdline --skip\".
|
||||||
|
To restore the original branch and stop patching run \"\$cmdline --abort\"."
|
||||||
|
stop_here $this
|
||||||
|
}
|
||||||
|
rm -f "$dotest/original-commit" "$dotest/author-script"
|
||||||
{
|
{
|
||||||
sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
|
sed -n '/^Subject/ s/Subject: //p' "$dotest/info"
|
||||||
echo
|
echo
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
# Copyright (c) 2010 Junio C Hamano.
|
# Copyright (c) 2010 Junio C Hamano.
|
||||||
#
|
#
|
||||||
|
|
||||||
. git-sh-setup
|
|
||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
continue)
|
continue)
|
||||||
git am --resolved --resolvemsg="$resolvemsg" &&
|
git am --resolved --resolvemsg="$resolvemsg" &&
|
||||||
|
@ -9,9 +9,7 @@
|
|||||||
#
|
#
|
||||||
# The original idea comes from Eric W. Biederman, in
|
# The original idea comes from Eric W. Biederman, in
|
||||||
# http://article.gmane.org/gmane.comp.version-control.git/22407
|
# http://article.gmane.org/gmane.comp.version-control.git/22407
|
||||||
|
#
|
||||||
. git-sh-setup
|
|
||||||
|
|
||||||
# The file containing rebase commands, comments, and empty lines.
|
# The file containing rebase commands, comments, and empty lines.
|
||||||
# This file is created by "git rebase -i" then edited by the user. As
|
# This file is created by "git rebase -i" then edited by the user. As
|
||||||
# the lines are processed, they are removed from the front of this
|
# the lines are processed, they are removed from the front of this
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
# Copyright (c) 2010 Junio C Hamano.
|
# Copyright (c) 2010 Junio C Hamano.
|
||||||
#
|
#
|
||||||
|
|
||||||
. git-sh-setup
|
|
||||||
|
|
||||||
prec=4
|
prec=4
|
||||||
|
|
||||||
read_state () {
|
read_state () {
|
||||||
|
@ -414,6 +414,7 @@ else
|
|||||||
test -z "$onto" && die "You must specify --onto when using --root"
|
test -z "$onto" && die "You must specify --onto when using --root"
|
||||||
unset upstream_name
|
unset upstream_name
|
||||||
unset upstream
|
unset upstream
|
||||||
|
test $# -gt 1 && usage
|
||||||
upstream_arg=--root
|
upstream_arg=--root
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -464,7 +465,7 @@ case "$#" in
|
|||||||
die "fatal: no such branch: $1"
|
die "fatal: no such branch: $1"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
0)
|
||||||
# Do not need to switch branches, we are already on it.
|
# Do not need to switch branches, we are already on it.
|
||||||
if branch_name=`git symbolic-ref -q HEAD`
|
if branch_name=`git symbolic-ref -q HEAD`
|
||||||
then
|
then
|
||||||
@ -476,6 +477,9 @@ case "$#" in
|
|||||||
fi
|
fi
|
||||||
orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
|
orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
die "BUG: unexpected number of arguments left to parse"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
require_clean_work_tree "rebase" "Please commit or stash them."
|
require_clean_work_tree "rebase" "Please commit or stash them."
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test_description='rebase should not insist on git message convention'
|
test_description='rebase should handle arbitrary git message'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
@ -12,6 +12,11 @@ It has two paragraphs, but its first paragraph is not friendly
|
|||||||
to oneline summary format.
|
to oneline summary format.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
cat >G <<\EOF
|
||||||
|
commit log message containing a diff
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
|
|
||||||
>file1 &&
|
>file1 &&
|
||||||
@ -19,8 +24,9 @@ test_expect_success setup '
|
|||||||
git add file1 file2 &&
|
git add file1 file2 &&
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -m "Initial commit" &&
|
git commit -m "Initial commit" &&
|
||||||
|
git branch diff-in-message
|
||||||
|
|
||||||
git checkout -b side &&
|
git checkout -b multi-line-subject &&
|
||||||
cat F >file2 &&
|
cat F >file2 &&
|
||||||
git add file2 &&
|
git add file2 &&
|
||||||
test_tick &&
|
test_tick &&
|
||||||
@ -28,6 +34,17 @@ test_expect_success setup '
|
|||||||
|
|
||||||
git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 &&
|
git cat-file commit HEAD | sed -e "1,/^\$/d" >F0 &&
|
||||||
|
|
||||||
|
git checkout diff-in-message &&
|
||||||
|
echo "commit log message containing a diff" >G &&
|
||||||
|
echo "" >>G
|
||||||
|
cat G >file2 &&
|
||||||
|
git add file2 &&
|
||||||
|
git diff --cached >>G &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -F G &&
|
||||||
|
|
||||||
|
git cat-file commit HEAD | sed -e "1,/^\$/d" >G0 &&
|
||||||
|
|
||||||
git checkout master &&
|
git checkout master &&
|
||||||
|
|
||||||
echo One >file1 &&
|
echo One >file1 &&
|
||||||
@ -36,13 +53,20 @@ test_expect_success setup '
|
|||||||
git commit -m "Second commit"
|
git commit -m "Second commit"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success rebase '
|
test_expect_success 'rebase commit with multi-line subject' '
|
||||||
|
|
||||||
git rebase master side &&
|
git rebase master multi-line-subject &&
|
||||||
git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
|
git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
|
||||||
|
|
||||||
test_cmp F0 F1 &&
|
test_cmp F0 F1 &&
|
||||||
test_cmp F F0
|
test_cmp F F0
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rebase commit with diff in message' '
|
||||||
|
git rebase master diff-in-message &&
|
||||||
|
git cat-file commit HEAD | sed -e "1,/^$/d" >G1 &&
|
||||||
|
test_cmp G0 G1 &&
|
||||||
|
test_cmp G G0
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -23,9 +23,15 @@ test_expect_success 'prepare repository' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'rebase --root expects --onto' '
|
test_expect_success 'rebase --root expects --onto' '
|
||||||
|
git checkout -B fail other &&
|
||||||
test_must_fail git rebase --root
|
test_must_fail git rebase --root
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rebase --root fails with too many args' '
|
||||||
|
git checkout -B fail other &&
|
||||||
|
test_must_fail git rebase --onto master --root fail fail
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup pre-rebase hook' '
|
test_expect_success 'setup pre-rebase hook' '
|
||||||
mkdir -p .git/hooks &&
|
mkdir -p .git/hooks &&
|
||||||
cat >.git/hooks/pre-rebase <<EOF &&
|
cat >.git/hooks/pre-rebase <<EOF &&
|
||||||
@ -42,7 +48,7 @@ cat > expect <<EOF
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'rebase --root --onto <newbase>' '
|
test_expect_success 'rebase --root --onto <newbase>' '
|
||||||
git checkout -b work &&
|
git checkout -b work other &&
|
||||||
git rebase --root --onto master &&
|
git rebase --root --onto master &&
|
||||||
git log --pretty=tformat:"%s" > rebased &&
|
git log --pretty=tformat:"%s" > rebased &&
|
||||||
test_cmp expect rebased
|
test_cmp expect rebased
|
||||||
|
Loading…
Reference in New Issue
Block a user