Skip to contentSkip to conversation

git diff --submodule=diff fails with submodules in a submodule

PATCH In review David Parrish 4 participants 5 messages Mar 31, 2017

lore
Share & tools
lore
#0 lore raw

When I try to run git diff --submodule=diff in a submodule which has it's own submodules that have changes I get the error: fatal: bad object

Let me know if you need an example reproduce the issue.

David

#1 lore raw

+cc Jacob, who implemented --submodule=diff

Quoted 3 lines · David Parrish

When I try to run git diff --submodule=diff in a submodule which has it's own submodules that have changes I get the error: fatal: bad object

Thanks for the bug report!

Quoted 1 line

Let me know if you need an example reproduce the issue.

I could reproduce it when playing around locally with a submodule in submodules. I think sub-submodule needs to have its HEAD moved from the recorded commit.

Thanks,
Stefan

#2 lore raw
Quoted 9 lines · Stefan Beller

+cc Jacob, who implemented --submodule=diff

Quoted 3 lines · David Parrish

When I try to run git diff --submodule=diff in a submodule which has it's own submodules that have changes I get the error: fatal: bad object

Thanks for the bug report!

Quoted 8 lines
Quoted 1 line

Let me know if you need an example reproduce the issue.

I could reproduce it when playing around locally with a submodule in submodules. I think sub-submodule needs to have its HEAD moved from the recorded commit.

Thanks,
Stefan

Hmm. An example reproduction would be helpful. Ideally in the form of a test ;) But otherwise whatever helps. I will try to look at this, but I'm busy for a few days.

Thanks,
Jake

#3 lore raw

PATCH 1/1 failure with diff --submodule=diff with moved nested submodule HEAD

This fails reliable for me.

---
 t/t4060-diff-submodule-option-diff-format.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
t/t4060-diff-submodule-option-diff-format.sh +16 -0
index 7e23b55ea4..89bced3484 100755
@@ -746,4 +746,20 @@ test_expect_success 'diff --submodule=diff with .git file' '
 	test_cmp expected actual
 '
 
+test_expect_success 'setup nested submodule' '
+	git submodule add -f ./sm2 &&
+	git commit -a -m "add sm2" &&
+	git -C sm2 submodule add ../sm2 &&
+	git -C sm2 commit -a -m "nested sub"
+'
+
+test_expect_success 'move nested submodule HEAD' '
+	git -C sm2/sm2 commit --allow-empty -m "new HEAD"
+'
+
+test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' '
+	git -C sm2 diff --submodule=diff >actual 2>err &&
+	test_must_be_empty err
+'
+
 test_done
Signature · 1 line
2.12.2.511.g2abb8caf66
#4 lore raw

Re: [PATCH] failure with diff --submodule=diff with moved nested submodule HEAD

Quoted 4 lines · Stefan Beller

This fails reliable for me.

---

I take it that this is a WIP for the testing half of the patch you are working on (i.e. you are not just throwing a patch to document known breakage to be fixed later, in which case these would have been _expect_failure).

Thanks.

Quoted 28 lines
 t/t4060-diff-submodule-option-diff-format.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
t/t4060-diff-submodule-option-diff-format.sh +16 -0
index 7e23b55ea4..89bced3484 100755
@@ -746,4 +746,20 @@ test_expect_success 'diff --submodule=diff with .git file' '
 	test_cmp expected actual
 '
 
+test_expect_success 'setup nested submodule' '
+	git submodule add -f ./sm2 &&
+	git commit -a -m "add sm2" &&
+	git -C sm2 submodule add ../sm2 &&
+	git -C sm2 commit -a -m "nested sub"
+'
+
+test_expect_success 'move nested submodule HEAD' '
+	git -C sm2/sm2 commit --allow-empty -m "new HEAD"
+'
+
+test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' '
+	git -C sm2 diff --submodule=diff >actual 2>err &&
+	test_must_be_empty err
+'
+
 test_done