Skip to content

Commit

Permalink
git-am: record full index line in the patch used while rebasing
Browse files Browse the repository at this point in the history
Earlier, a230949 (am --rebasing: get patch body from commit, not
from mailbox, 2012-06-26) learned to regenerate patch body from the
commit object while rebasing, instead of reading from the rebase-am
front-end.  While doing so, it used "git diff-tree" but without
giving it the "--full-index" option.

This does not matter for in-repository objects; during rebasing, any
abbreviated object name should uniquely identify them.

But we may be rebasing a commit that contains a change to a gitlink,
in which case we usually should not have the object (it names a
commit in the submodule).  A full object name is necessary to later
reconstruct a fake ancestor index for them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
gitster committed Feb 1, 2013
1 parent 8c7a786 commit 4ae6d46
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion git-am.sh
Expand Up @@ -664,7 +664,7 @@ do
sed -e '1,/^$/d' >"$dotest/msg-clean"
echo "$commit" >"$dotest/original-commit"
get_author_ident_from_commit "$commit" >"$dotest/author-script"
git diff-tree --root --binary "$commit" >"$dotest/patch"
git diff-tree --root --binary --full-index "$commit" >"$dotest/patch"
else
git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
<"$dotest/$msgnum" >"$dotest/info" ||
Expand Down
30 changes: 28 additions & 2 deletions t/t7402-submodule-rebase.sh
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2008 Johannes Schindelin
#

test_description='Test rebasing and stashing with dirty submodules'
test_description='Test rebasing, stashing, etc. with submodules'

. ./test-lib.sh

Expand All @@ -20,7 +20,8 @@ test_expect_success setup '
echo second line >> file &&
(cd submodule && git pull) &&
test_tick &&
git commit -m file-and-submodule -a
git commit -m file-and-submodule -a &&
git branch added-submodule
'

Expand Down Expand Up @@ -89,4 +90,29 @@ test_expect_success 'stash with a dirty submodule' '
'

test_expect_success 'rebasing submodule that should conflict' '
git reset --hard &&
git checkout added-submodule &&
git add submodule &&
test_tick &&
git commit -m third &&
(
cd submodule &&
git commit --allow-empty -m extra
) &&
git add submodule &&
test_tick &&
git commit -m fourth &&
test_must_fail git rebase --onto HEAD^^ HEAD^ HEAD^0 &&
git ls-files -s submodule >actual &&
(
cd submodule &&
echo "160000 $(git rev-parse HEAD^) 1 submodule" &&
echo "160000 $(git rev-parse HEAD^^) 2 submodule" &&
echo "160000 $(git rev-parse HEAD) 3 submodule"
) >expect &&
test_cmp expect actual
'

test_done

0 comments on commit 4ae6d46

Please sign in to comment.