Skip to content

Commit a531ecf

Browse files
committed
Merge branch 'jk/diff-submodule-diff-inline'
"git diff --submodule=diff" now recurses into nested submodules. * jk/diff-submodule-diff-inline: diff: recurse into nested submodules for inline diff
2 parents 4eeed27 + 5a52214 commit a531ecf

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

submodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ void show_submodule_inline_diff(FILE *f, const char *path,
554554
cp.no_stdin = 1;
555555

556556
/* TODO: other options may need to be passed here. */
557-
argv_array_push(&cp.args, "diff");
557+
argv_array_pushl(&cp.args, "diff", "--submodule=diff", NULL);
558+
558559
argv_array_pushf(&cp.args, "--line-prefix=%s", line_prefix);
559560
if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
560561
argv_array_pushf(&cp.args, "--src-prefix=%s%s/",

t/t4060-diff-submodule-option-diff-format.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,4 +775,45 @@ test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' '
775775
test_cmp expected actual
776776
'
777777

778+
test_expect_success 'diff --submodule=diff recurses into nested submodules' '
779+
cat >expected <<-EOF &&
780+
Submodule sm2 contains modified content
781+
Submodule sm2 a5a65c9..280969a:
782+
diff --git a/sm2/.gitmodules b/sm2/.gitmodules
783+
new file mode 100644
784+
index 0000000..3a816b8
785+
--- /dev/null
786+
+++ b/sm2/.gitmodules
787+
@@ -0,0 +1,3 @@
788+
+[submodule "nested"]
789+
+ path = nested
790+
+ url = ../sm2
791+
Submodule nested 0000000...b55928c (new submodule)
792+
diff --git a/sm2/nested/file b/sm2/nested/file
793+
new file mode 100644
794+
index 0000000..ca281f5
795+
--- /dev/null
796+
+++ b/sm2/nested/file
797+
@@ -0,0 +1 @@
798+
+nested content
799+
diff --git a/sm2/nested/foo8 b/sm2/nested/foo8
800+
new file mode 100644
801+
index 0000000..db9916b
802+
--- /dev/null
803+
+++ b/sm2/nested/foo8
804+
@@ -0,0 +1 @@
805+
+foo8
806+
diff --git a/sm2/nested/foo9 b/sm2/nested/foo9
807+
new file mode 100644
808+
index 0000000..9c3b4f6
809+
--- /dev/null
810+
+++ b/sm2/nested/foo9
811+
@@ -0,0 +1 @@
812+
+foo9
813+
EOF
814+
git diff --submodule=diff >actual 2>err &&
815+
test_must_be_empty err &&
816+
test_cmp expected actual
817+
'
818+
778819
test_done

0 commit comments

Comments
 (0)