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 () {
|
||||
case "$patch_format" in
|
||||
mbox)
|
||||
if test -n "$rebasing" || test t = "$keepcr"
|
||||
if test t = "$keepcr"
|
||||
then
|
||||
keep_cr=--keep-cr
|
||||
else
|
||||
@ -413,7 +413,7 @@ do
|
||||
--abort)
|
||||
abort=t ;;
|
||||
--rebasing)
|
||||
rebasing=t threeway=t keep=t scissors=f no_inbody_headers=t ;;
|
||||
rebasing=t threeway=t ;;
|
||||
-d|--dotest)
|
||||
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.
|
||||
case "$resume" in
|
||||
'')
|
||||
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"
|
||||
if test -f "$dotest/rebasing" &&
|
||||
if test -f "$dotest/rebasing"
|
||||
then
|
||||
commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
|
||||
-e q "$dotest/$msgnum") &&
|
||||
test "$(git cat-file -t "$commit")" = commit
|
||||
then
|
||||
test "$(git cat-file -t "$commit")" = commit ||
|
||||
stop_here $this
|
||||
git cat-file commit "$commit" |
|
||||
sed -e '1,/^$/d' >"$dotest/msg-clean"
|
||||
echo "$commit" > "$dotest/original-commit"
|
||||
get_author_ident_from_commit "$commit" > "$dotest/author-script"
|
||||
echo "$commit" >"$dotest/original-commit"
|
||||
get_author_ident_from_commit "$commit" >"$dotest/author-script"
|
||||
git diff-tree --root --binary "$commit" >"$dotest/patch"
|
||||
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"
|
||||
echo
|
||||
|
@ -3,8 +3,6 @@
|
||||
# Copyright (c) 2010 Junio C Hamano.
|
||||
#
|
||||
|
||||
. git-sh-setup
|
||||
|
||||
case "$action" in
|
||||
continue)
|
||||
git am --resolved --resolvemsg="$resolvemsg" &&
|
||||
|
@ -9,9 +9,7 @@
|
||||
#
|
||||
# The original idea comes from Eric W. Biederman, in
|
||||
# http://article.gmane.org/gmane.comp.version-control.git/22407
|
||||
|
||||
. git-sh-setup
|
||||
|
||||
#
|
||||
# The file containing rebase commands, comments, and empty lines.
|
||||
# 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
|
||||
|
@ -3,8 +3,6 @@
|
||||
# Copyright (c) 2010 Junio C Hamano.
|
||||
#
|
||||
|
||||
. git-sh-setup
|
||||
|
||||
prec=4
|
||||
|
||||
read_state () {
|
||||
|
@ -414,6 +414,7 @@ else
|
||||
test -z "$onto" && die "You must specify --onto when using --root"
|
||||
unset upstream_name
|
||||
unset upstream
|
||||
test $# -gt 1 && usage
|
||||
upstream_arg=--root
|
||||
fi
|
||||
|
||||
@ -464,7 +465,7 @@ case "$#" in
|
||||
die "fatal: no such branch: $1"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
0)
|
||||
# Do not need to switch branches, we are already on it.
|
||||
if branch_name=`git symbolic-ref -q HEAD`
|
||||
then
|
||||
@ -476,6 +477,9 @@ case "$#" in
|
||||
fi
|
||||
orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
|
||||
;;
|
||||
*)
|
||||
die "BUG: unexpected number of arguments left to parse"
|
||||
;;
|
||||
esac
|
||||
|
||||
require_clean_work_tree "rebase" "Please commit or stash them."
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='rebase should not insist on git message convention'
|
||||
test_description='rebase should handle arbitrary git message'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
@ -12,6 +12,11 @@ It has two paragraphs, but its first paragraph is not friendly
|
||||
to oneline summary format.
|
||||
EOF
|
||||
|
||||
cat >G <<\EOF
|
||||
commit log message containing a diff
|
||||
EOF
|
||||
|
||||
|
||||
test_expect_success setup '
|
||||
|
||||
>file1 &&
|
||||
@ -19,8 +24,9 @@ test_expect_success setup '
|
||||
git add file1 file2 &&
|
||||
test_tick &&
|
||||
git commit -m "Initial commit" &&
|
||||
git branch diff-in-message
|
||||
|
||||
git checkout -b side &&
|
||||
git checkout -b multi-line-subject &&
|
||||
cat F >file2 &&
|
||||
git add file2 &&
|
||||
test_tick &&
|
||||
@ -28,6 +34,17 @@ test_expect_success setup '
|
||||
|
||||
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 &&
|
||||
|
||||
echo One >file1 &&
|
||||
@ -36,13 +53,20 @@ test_expect_success setup '
|
||||
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 &&
|
||||
|
||||
test_cmp F0 F1 &&
|
||||
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
|
||||
|
@ -23,9 +23,15 @@ test_expect_success 'prepare repository' '
|
||||
'
|
||||
|
||||
test_expect_success 'rebase --root expects --onto' '
|
||||
git checkout -B fail other &&
|
||||
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' '
|
||||
mkdir -p .git/hooks &&
|
||||
cat >.git/hooks/pre-rebase <<EOF &&
|
||||
@ -42,7 +48,7 @@ cat > expect <<EOF
|
||||
EOF
|
||||
|
||||
test_expect_success 'rebase --root --onto <newbase>' '
|
||||
git checkout -b work &&
|
||||
git checkout -b work other &&
|
||||
git rebase --root --onto master &&
|
||||
git log --pretty=tformat:"%s" > rebased &&
|
||||
test_cmp expect rebased
|
||||
|
Loading…
Reference in New Issue
Block a user