git-am: record full index line in the patch used while rebasing
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>
Junio C Hamano committed
Jan 31, 2013 at 19:26 UTC
4ae6d4699f4d1df7cd3ffac9dd361c86d62eca42
2 files changed
+29
-3
git-am.sh
+1
-1
@@ -664,7 +664,7 @@ do
664
sed -e '1,/^$/d' >"$dotest/msg-clean"
665
echo "$commit" >"$dotest/original-commit"
666
get_author_ident_from_commit "$commit" >"$dotest/author-script"
667
- git diff-tree --root --binary "$commit" >"$dotest/patch"
667
+ git diff-tree --root --binary --full-index "$commit" >"$dotest/patch"
668
else
669
git mailinfo $keep $no_inbody_headers $scissors $utf8 "$dotest/msg" "$dotest/patch" \
670
<"$dotest/$msgnum" >"$dotest/info" ||
t/t7402-submodule-rebase.sh
+28
-2
@@ -3,7 +3,7 @@
3
# Copyright (c) 2008 Johannes Schindelin
4
#
5
6
-test_description='Test rebasing and stashing with dirty submodules'
6
+test_description='Test rebasing, stashing, etc. with submodules'
7
8
. ./test-lib.sh
9
@@ -20,7 +20,8 @@ test_expect_success setup '
20
echo second line >> file &&
21
(cd submodule && git pull) &&
22
test_tick &&
23
- git commit -m file-and-submodule -a
23
+ git commit -m file-and-submodule -a &&
24
+ git branch added-submodule
25
26
'
27
@@ -89,4 +90,29 @@ test_expect_success 'stash with a dirty submodule' '
90
91
'
92
93
+test_expect_success 'rebasing submodule that should conflict' '
94
+ git reset --hard &&
95
+ git checkout added-submodule &&
96
+ git add submodule &&
97
+ test_tick &&
98
+ git commit -m third &&
99
+ (
100
+ cd submodule &&
101
+ git commit --allow-empty -m extra
102
+ ) &&
103
+ git add submodule &&
104
+ test_tick &&
105
+ git commit -m fourth &&
106
+
107
+ test_must_fail git rebase --onto HEAD^^ HEAD^ HEAD^0 &&
108
+ git ls-files -s submodule >actual &&
109
+ (
110
+ cd submodule &&
111
+ echo "160000 $(git rev-parse HEAD^) 1 submodule" &&
112
+ echo "160000 $(git rev-parse HEAD^^) 2 submodule" &&
113
+ echo "160000 $(git rev-parse HEAD) 3 submodule"
114
+ ) >expect &&
115
+ test_cmp expect actual
116
+'
117
+
118
test_done