diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-04-16 23:29:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-04-16 23:29:32 -0700 |
commit | 1776a710d615c77e3c66be2f4a08c36663f88a07 (patch) | |
tree | f19ebe6b05a8a73dcad416b30ca547cbbf0d8c5c | |
parent | 263fd041a8cb575e18331f0af39f4481039eaf34 (diff) | |
parent | 17b254cda6dd77b1a91ac6f2946943e52698efa9 (diff) | |
download | git-1776a710d615c77e3c66be2f4a08c36663f88a07.tar.gz git-1776a710d615c77e3c66be2f4a08c36663f88a07.tar.xz |
Merge branch 'sb/show-diff-for-submodule-in-diff-fix'
"git diff --submodule=diff" learned to work better in a project
with a submodule that in turn has its own submodules.
* sb/show-diff-for-submodule-in-diff-fix:
diff: submodule inline diff to initialize env array.
-rw-r--r-- | submodule.c | 1 | ||||
-rwxr-xr-x | t/t4060-diff-submodule-option-diff-format.sh | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/submodule.c b/submodule.c index 83b13b8ff..7c3c4b17f 100644 --- a/submodule.c +++ b/submodule.c @@ -576,6 +576,7 @@ void show_submodule_inline_diff(FILE *f, const char *path, if (!(dirty_submodule & DIRTY_SUBMODULE_MODIFIED)) argv_array_push(&cp.args, oid_to_hex(new)); + prepare_submodule_repo_env(&cp.env_array); if (run_command(&cp)) fprintf(f, "(diff failed)\n"); diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh index 7e23b55ea..d4a3ffa69 100755 --- a/t/t4060-diff-submodule-option-diff-format.sh +++ b/t/t4060-diff-submodule-option-diff-format.sh @@ -746,4 +746,33 @@ 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 nested && + git -C sm2 commit -a -m "nested sub" +' + +test_expect_success 'move nested submodule HEAD' ' + echo "nested content" >sm2/nested/file && + git -C sm2/nested add file && + git -C sm2/nested commit --allow-empty -m "new HEAD" +' + +test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' ' + cat >expected <<-EOF && + Submodule nested a5a65c9..b55928c: + diff --git a/nested/file b/nested/file + new file mode 100644 + index 0000000..ca281f5 + --- /dev/null + +++ b/nested/file + @@ -0,0 +1 @@ + +nested content + EOF + git -C sm2 diff --submodule=diff >actual 2>err && + test_must_be_empty err && + test_cmp expected actual +' + test_done |