{"thread":{"id":"45670","subject":"[PATCH] diff: recurse into nested submodules for inline diff","startedAt":"2017-04-11T21:07:42Z","lastAt":"2017-04-11T21:07:42Z","messageCount":1,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"316647","messageId":"20170411210726.29977-1-sbeller@google.com","threadId":"45670","inReplyTo":null,"subject":"[PATCH] diff: recurse into nested submodules for inline diff","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-11T21:07:26Z","receivedAt":"2017-04-11T21:07:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"When fd47ae6a5b (diff: teach diff to display submodule difference with an\ninline diff, 2016-08-31) was introduced, we did not think of recursing\ninto nested submodules.\n\nWhen showing the inline diff for submodules, automatically recurse\ninto nested submodules as well with inline submodule diffs.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n I would think this goes on top of origin/sb/show-diff-for-submodule-in-diff-fix.\n \n Thanks,\n Stefan\n\n submodule.c                                  |  3 +-\n t/t4060-diff-submodule-option-diff-format.sh | 41 ++++++++++++++++++++++++++++\n 2 files changed, 43 insertions(+), 1 deletion(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 17de8e8358..a93ec2cb66 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -453,7 +453,8 @@ void show_submodule_inline_diff(FILE *f, const char *path,\n \tcp.no_stdin = 1;\n \n \t/* TODO: other options may need to be passed here. */\n-\targv_array_push(&cp.args, \"diff\");\n+\targv_array_pushl(&cp.args, \"diff\", \"--submodule=diff\", NULL);\n+\n \targv_array_pushf(&cp.args, \"--line-prefix=%s\", line_prefix);\n \tif (DIFF_OPT_TST(o, REVERSE_DIFF)) {\n \t\targv_array_pushf(&cp.args, \"--src-prefix=%s%s/\",\ndiff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh\nindex d4a3ffa69c..33ec26d755 100755\n--- a/t/t4060-diff-submodule-option-diff-format.sh\n+++ b/t/t4060-diff-submodule-option-diff-format.sh\n@@ -775,4 +775,45 @@ test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'diff --submodule=diff recurses into nested submodules' '\n+\tcat >expected <<-EOF &&\n+\tSubmodule sm2 contains modified content\n+\tSubmodule sm2 a5a65c9..280969a:\n+\tdiff --git a/sm2/.gitmodules b/sm2/.gitmodules\n+\tnew file mode 100644\n+\tindex 0000000..3a816b8\n+\t--- /dev/null\n+\t+++ b/sm2/.gitmodules\n+\t@@ -0,0 +1,3 @@\n+\t+[submodule \"nested\"]\n+\t+\tpath = nested\n+\t+\turl = ../sm2\n+\tSubmodule nested 0000000...b55928c (new submodule)\n+\tdiff --git a/sm2/nested/file b/sm2/nested/file\n+\tnew file mode 100644\n+\tindex 0000000..ca281f5\n+\t--- /dev/null\n+\t+++ b/sm2/nested/file\n+\t@@ -0,0 +1 @@\n+\t+nested content\n+\tdiff --git a/sm2/nested/foo8 b/sm2/nested/foo8\n+\tnew file mode 100644\n+\tindex 0000000..db9916b\n+\t--- /dev/null\n+\t+++ b/sm2/nested/foo8\n+\t@@ -0,0 +1 @@\n+\t+foo8\n+\tdiff --git a/sm2/nested/foo9 b/sm2/nested/foo9\n+\tnew file mode 100644\n+\tindex 0000000..9c3b4f6\n+\t--- /dev/null\n+\t+++ b/sm2/nested/foo9\n+\t@@ -0,0 +1 @@\n+\t+foo9\n+\tEOF\n+\tgit diff --submodule=diff >actual 2>err &&\n+\ttest_must_be_empty err &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.12.2.575.gb14f27f917\n\n"}]}