diff: recurse into nested submodules for inline diff
When fd47ae6a5b (diff: teach diff to display submodule difference with an inline diff, 2016-08-31) was introduced, we did not think of recursing into nested submodules. When showing the inline diff for submodules, automatically recurse into nested submodules as well with inline submodule diffs. Signed-off-by: Stefan Beller <sbeller@google.com> Acked-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
May 4, 2017 at 14:43 UTC
5a5221427cb8b78c3246ffa305900db935017c54
2 files changed
+43
-1
submodule.c
+2
-1
@@ -475,7 +475,8 @@ void show_submodule_inline_diff(FILE *f, const char *path,
475
cp.no_stdin = 1;
476
477
/* TODO: other options may need to be passed here. */
478
- argv_array_push(&cp.args, "diff");
478
+ argv_array_pushl(&cp.args, "diff", "--submodule=diff", NULL);
479
+
480
argv_array_pushf(&cp.args, "--line-prefix=%s", line_prefix);
481
if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
482
argv_array_pushf(&cp.args, "--src-prefix=%s%s/",
t/t4060-diff-submodule-option-diff-format.sh
+41
@@ -746,4 +746,45 @@ test_expect_success 'diff --submodule=diff with .git file' '
746
test_cmp expected actual
747
'
748
749
+test_expect_success 'diff --submodule=diff recurses into nested submodules' '
750
+ cat >expected <<-EOF &&
751
+ Submodule sm2 contains modified content
752
+ Submodule sm2 a5a65c9..280969a:
753
+ diff --git a/sm2/.gitmodules b/sm2/.gitmodules
754
+ new file mode 100644
755
+ index 0000000..3a816b8
756
+ --- /dev/null
757
+ +++ b/sm2/.gitmodules
758
+ @@ -0,0 +1,3 @@
759
+ +[submodule "nested"]
760
+ + path = nested
761
+ + url = ../sm2
762
+ Submodule nested 0000000...b55928c (new submodule)
763
+ diff --git a/sm2/nested/file b/sm2/nested/file
764
+ new file mode 100644
765
+ index 0000000..ca281f5
766
+ --- /dev/null
767
+ +++ b/sm2/nested/file
768
+ @@ -0,0 +1 @@
769
+ +nested content
770
+ diff --git a/sm2/nested/foo8 b/sm2/nested/foo8
771
+ new file mode 100644
772
+ index 0000000..db9916b
773
+ --- /dev/null
774
+ +++ b/sm2/nested/foo8
775
+ @@ -0,0 +1 @@
776
+ +foo8
777
+ diff --git a/sm2/nested/foo9 b/sm2/nested/foo9
778
+ new file mode 100644
779
+ index 0000000..9c3b4f6
780
+ --- /dev/null
781
+ +++ b/sm2/nested/foo9
782
+ @@ -0,0 +1 @@
783
+ +foo9
784
+ EOF
785
+ git diff --submodule=diff >actual 2>err &&
786
+ test_must_be_empty err &&
787
+ test_cmp expected actual
788
+'
789
+
790
test_done