From decff7b4c13939e5f00d51aea4176fc543d73ede Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Wed, 18 Jul 2012 14:30:15 -0700 Subject: [PATCH 1/5] New submodule test data --- tests-clar/resources/submod2/.gitted/HEAD | 1 + tests-clar/resources/submod2/.gitted/config | 20 +++ .../resources/submod2/.gitted/description | 1 + .../.gitted/hooks/applypatch-msg.sample | 15 ++ tests-clar/resources/submod2/.gitted/index | Bin 0 -> 944 bytes .../resources/submod2/.gitted/info/exclude | 6 + .../resources/submod2/.gitted/logs/HEAD | 4 + .../submod2/.gitted/logs/refs/heads/master | 4 + .../modules/sm_added_and_uncommited/HEAD | 1 + .../modules/sm_added_and_uncommited/config | 13 ++ .../sm_added_and_uncommited/description | 1 + .../hooks/applypatch-msg.sample | 15 ++ .../modules/sm_added_and_uncommited/index | Bin 0 -> 192 bytes .../sm_added_and_uncommited/info/exclude | 6 + .../modules/sm_added_and_uncommited/logs/HEAD | 1 + .../logs/refs/heads/master | 1 + .../logs/refs/remotes/origin/HEAD | 1 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../48/0095882d281ed676fe5b863569520e54a7d5c0 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../73/ba924a80437097795ae839e66e187c55d3babf | Bin 0 -> 93 bytes .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../78/9efbdadaa4a582778d4584385495559ea0994b | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../sm_added_and_uncommited/packed-refs | 2 + .../sm_added_and_uncommited/refs/heads/master | 1 + .../refs/remotes/origin/HEAD | 1 + .../.gitted/modules/sm_changed_file/HEAD | 1 + .../.gitted/modules/sm_changed_file/config | 13 ++ .../modules/sm_changed_file/description | 1 + .../hooks/applypatch-msg.sample | 15 ++ .../.gitted/modules/sm_changed_file/index | Bin 0 -> 192 bytes .../modules/sm_changed_file/info/exclude | 6 + .../.gitted/modules/sm_changed_file/logs/HEAD | 1 + .../sm_changed_file/logs/refs/heads/master | 1 + .../logs/refs/remotes/origin/HEAD | 1 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../48/0095882d281ed676fe5b863569520e54a7d5c0 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../73/ba924a80437097795ae839e66e187c55d3babf | Bin 0 -> 93 bytes .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../78/9efbdadaa4a582778d4584385495559ea0994b | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../modules/sm_changed_file/packed-refs | 2 + .../modules/sm_changed_file/refs/heads/master | 1 + .../sm_changed_file/refs/remotes/origin/HEAD | 1 + .../modules/sm_changed_head/COMMIT_EDITMSG | 1 + .../.gitted/modules/sm_changed_head/HEAD | 1 + .../.gitted/modules/sm_changed_head/config | 13 ++ .../modules/sm_changed_head/description | 1 + .../hooks/applypatch-msg.sample | 15 ++ .../.gitted/modules/sm_changed_head/index | Bin 0 -> 192 bytes .../modules/sm_changed_head/info/exclude | 6 + .../.gitted/modules/sm_changed_head/logs/HEAD | 2 + .../sm_changed_head/logs/refs/heads/master | 2 + .../logs/refs/remotes/origin/HEAD | 1 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../3d/9386c507f6b093471a3e324085657a3c2b4247 | 3 + .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../48/0095882d281ed676fe5b863569520e54a7d5c0 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../73/ba924a80437097795ae839e66e187c55d3babf | Bin 0 -> 93 bytes .../77/fb0ed3e58568d6ad362c78de08ab8649d76e29 | Bin 0 -> 93 bytes .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../78/9efbdadaa4a582778d4584385495559ea0994b | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../8e/b1e637ed9fc8e5454fa20d38f809091f9395f4 | 2 + .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../modules/sm_changed_head/packed-refs | 2 + .../modules/sm_changed_head/refs/heads/master | 1 + .../sm_changed_head/refs/remotes/origin/HEAD | 1 + .../.gitted/modules/sm_changed_index/HEAD | 1 + .../.gitted/modules/sm_changed_index/config | 13 ++ .../modules/sm_changed_index/description | 1 + .../hooks/applypatch-msg.sample | 15 ++ .../.gitted/modules/sm_changed_index/index | Bin 0 -> 192 bytes .../modules/sm_changed_index/info/exclude | 6 + .../modules/sm_changed_index/logs/HEAD | 1 + .../sm_changed_index/logs/refs/heads/master | 1 + .../logs/refs/remotes/origin/HEAD | 1 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../48/0095882d281ed676fe5b863569520e54a7d5c0 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../73/ba924a80437097795ae839e66e187c55d3babf | Bin 0 -> 93 bytes .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../78/9efbdadaa4a582778d4584385495559ea0994b | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../a0/2d31770687965547ab7a04cee199b29ee458d6 | Bin 0 -> 134 bytes .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../modules/sm_changed_index/packed-refs | 2 + .../sm_changed_index/refs/heads/master | 1 + .../sm_changed_index/refs/remotes/origin/HEAD | 1 + .../modules/sm_changed_untracked_file/HEAD | 1 + .../modules/sm_changed_untracked_file/config | 13 ++ .../sm_changed_untracked_file/description | 1 + .../hooks/applypatch-msg.sample | 15 ++ .../modules/sm_changed_untracked_file/index | Bin 0 -> 192 bytes .../sm_changed_untracked_file/info/exclude | 6 + .../sm_changed_untracked_file/logs/HEAD | 1 + .../logs/refs/heads/master | 1 + .../logs/refs/remotes/origin/HEAD | 1 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../48/0095882d281ed676fe5b863569520e54a7d5c0 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../73/ba924a80437097795ae839e66e187c55d3babf | Bin 0 -> 93 bytes .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../78/9efbdadaa4a582778d4584385495559ea0994b | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../sm_changed_untracked_file/packed-refs | 2 + .../refs/heads/master | 1 + .../refs/remotes/origin/HEAD | 1 + .../.gitted/modules/sm_missing_commits/HEAD | 1 + .../.gitted/modules/sm_missing_commits/config | 13 ++ .../modules/sm_missing_commits/description | 1 + .../hooks/applypatch-msg.sample | 15 ++ .../.gitted/modules/sm_missing_commits/index | Bin 0 -> 192 bytes .../modules/sm_missing_commits/info/exclude | 6 + .../modules/sm_missing_commits/logs/HEAD | 1 + .../sm_missing_commits/logs/refs/heads/master | 1 + .../logs/refs/remotes/origin/HEAD | 1 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../modules/sm_missing_commits/packed-refs | 2 + .../sm_missing_commits/refs/heads/master | 1 + .../refs/remotes/origin/HEAD | 1 + .../submod2/.gitted/modules/sm_unchanged/HEAD | 1 + .../.gitted/modules/sm_unchanged/config | 13 ++ .../.gitted/modules/sm_unchanged/description | 1 + .../sm_unchanged/hooks/applypatch-msg.sample | 15 ++ .../.gitted/modules/sm_unchanged/index | Bin 0 -> 192 bytes .../.gitted/modules/sm_unchanged/info/exclude | 6 + .../.gitted/modules/sm_unchanged/logs/HEAD | 1 + .../sm_unchanged/logs/refs/heads/master | 1 + .../logs/refs/remotes/origin/HEAD | 1 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../48/0095882d281ed676fe5b863569520e54a7d5c0 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../73/ba924a80437097795ae839e66e187c55d3babf | Bin 0 -> 93 bytes .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../78/9efbdadaa4a582778d4584385495559ea0994b | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../.gitted/modules/sm_unchanged/packed-refs | 2 + .../modules/sm_unchanged/refs/heads/master | 1 + .../sm_unchanged/refs/remotes/origin/HEAD | 1 + .../09/460e5b6cbcb05a3e404593c32a3aa7221eca0e | Bin 0 -> 197 bytes .../14/fe9ccf104058df25e0a08361c4494e167ef243 | 1 + .../22/ce3e0311dda73a5992d54a4a595518d3876ea7 | 4 + .../25/5546424b0efb847b1bfc91dbf7348b277f8970 | Bin 0 -> 157 bytes .../2a/30f1e6f94b20917005a21273f65b406d0f8bad | Bin 0 -> 144 bytes .../42/cfb95cd01bf9225b659b5ee3edcc78e8eeb478 | Bin 0 -> 40 bytes .../57/958699c2dc394f81cfc76950e9c3ac3025c398 | Bin 0 -> 136 bytes .../59/01da4f1c67756eeadc5121d206bec2431f253b | 2 + .../60/7d96653d4d0a4f733107f7890c2e67b55b620d | Bin 0 -> 53 bytes .../74/84482eb8db738cafa696993664607500a3f2b9 | Bin 0 -> 173 bytes .../7b/a4c5c3561daa5ab1a86215cfb0587e96d404d6 | Bin 0 -> 48 bytes .../87/3585b94bdeabccea991ea5e3ec1a277895b698 | Bin 0 -> 137 bytes .../97/4cf7c73de336b0c4e019f918f3cee367d72e84 | 2 + .../9d/bc299bc013ea253583b40bf327b5a6e4037b89 | Bin 0 -> 80 bytes .../a9/104bf89e911387244ef499413960ba472066d9 | Bin 0 -> 165 bytes .../b6/14088620bbdc1d29549d223ceba0f4419fd4cb | Bin 0 -> 110 bytes .../d4/07f19e50c1da1ff584beafe0d6dac7237c5d06 | Bin 0 -> 55 bytes .../d9/3e95571d92cceb5de28c205f1d5f3cc8b88bc8 | 2 + .../e3/b83bf274ee065eee48734cf8c6dfaf5e81471c | Bin 0 -> 246 bytes .../f5/4414c25e6d24fe39f5c3f128d7c8a17bc23833 | 2 + .../f9/90a25a74d1a8281ce2ab018ea8df66795cd60b | 1 + .../submod2/.gitted/refs/heads/master | 1 + tests-clar/resources/submod2/README.txt | 3 + tests-clar/resources/submod2/gitmodules | 21 +++ .../resources/submod2/just_a_dir/contents | 1 + tests-clar/resources/submod2/just_a_file | 1 + .../not_submodule/.gitted/COMMIT_EDITMSG | 1 + .../submod2/not_submodule/.gitted/HEAD | 1 + .../submod2/not_submodule/.gitted/config | 6 + .../submod2/not_submodule/.gitted/description | 1 + .../.gitted/hooks/applypatch-msg.sample | 15 ++ .../.gitted/hooks/commit-msg.sample | 24 +++ .../.gitted/hooks/post-update.sample | 8 + .../.gitted/hooks/pre-applypatch.sample | 14 ++ .../.gitted/hooks/pre-commit.sample | 50 ++++++ .../.gitted/hooks/pre-rebase.sample | 169 ++++++++++++++++++ .../.gitted/hooks/prepare-commit-msg.sample | 36 ++++ .../not_submodule/.gitted/hooks/update.sample | 128 +++++++++++++ .../submod2/not_submodule/.gitted/index | Bin 0 -> 112 bytes .../not_submodule/.gitted/info/exclude | 6 + .../submod2/not_submodule/.gitted/logs/HEAD | 1 + .../.gitted/logs/refs/heads/master | 1 + .../68/e92c611b80ee1ed8f38314ff9577f0d15b2444 | Bin 0 -> 132 bytes .../71/ff9927d7c8a5639e062c38a7d35c433c424627 | Bin 0 -> 52 bytes .../f0/1d56b18efd353ef2bb93a4585d590a0847195e | Bin 0 -> 55 bytes .../not_submodule/.gitted/refs/heads/master | 1 + .../submod2/not_submodule/README.txt | 1 + .../submod2/sm_added_and_uncommited/.gitted | 1 + .../sm_added_and_uncommited/README.txt | 3 + .../sm_added_and_uncommited/file_to_modify | 3 + .../resources/submod2/sm_changed_file/.gitted | 1 + .../submod2/sm_changed_file/README.txt | 3 + .../submod2/sm_changed_file/file_to_modify | 4 + .../resources/submod2/sm_changed_head/.gitted | 1 + .../submod2/sm_changed_head/README.txt | 3 + .../submod2/sm_changed_head/file_to_modify | 4 + .../submod2/sm_changed_index/.gitted | 1 + .../submod2/sm_changed_index/README.txt | 3 + .../submod2/sm_changed_index/file_to_modify | 4 + .../submod2/sm_changed_untracked_file/.gitted | 1 + .../sm_changed_untracked_file/README.txt | 3 + .../sm_changed_untracked_file/file_to_modify | 3 + .../sm_changed_untracked_file/i_am_untracked | 1 + .../submod2/sm_missing_commits/.gitted | 1 + .../submod2/sm_missing_commits/README.txt | 3 + .../submod2/sm_missing_commits/file_to_modify | 3 + .../resources/submod2/sm_unchanged/.gitted | 1 + .../resources/submod2/sm_unchanged/README.txt | 3 + .../submod2/sm_unchanged/file_to_modify | 3 + .../resources/submod2_target/.gitted/HEAD | 1 + .../resources/submod2_target/.gitted/config | 6 + .../submod2_target/.gitted/description | 1 + .../.gitted/hooks/applypatch-msg.sample | 15 ++ .../resources/submod2_target/.gitted/index | Bin 0 -> 192 bytes .../submod2_target/.gitted/info/exclude | 6 + .../submod2_target/.gitted/logs/HEAD | 4 + .../.gitted/logs/refs/heads/master | 4 + .../06/362fe2fdb7010d0e447b4fb450d405420479a1 | Bin 0 -> 55 bytes .../0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 | Bin 0 -> 53 bytes .../17/d0ece6e96460a06592d9d9d000de37ba4232c5 | Bin 0 -> 93 bytes .../41/bd4bc3df978de695f67ace64c560913da11653 | Bin 0 -> 163 bytes .../48/0095882d281ed676fe5b863569520e54a7d5c0 | Bin 0 -> 163 bytes .../5e/4963595a9774b90524d35a807169049de8ccad | Bin 0 -> 167 bytes .../6b/31c659545507c381e9cd34ec508f16c04e149e | 2 + .../73/ba924a80437097795ae839e66e187c55d3babf | Bin 0 -> 93 bytes .../78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a | 2 + .../78/9efbdadaa4a582778d4584385495559ea0994b | 2 + .../88/34b635dd468a83cb012f6feace968c1c9f5d6e | Bin 0 -> 81 bytes .../d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 | Bin 0 -> 93 bytes .../submod2_target/.gitted/refs/heads/master | 1 + .../resources/submod2_target/README.txt | 3 + .../resources/submod2_target/file_to_modify | 3 + 270 files changed, 1007 insertions(+) create mode 100644 tests-clar/resources/submod2/.gitted/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/config create mode 100644 tests-clar/resources/submod2/.gitted/description create mode 100755 tests-clar/resources/submod2/.gitted/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/index create mode 100644 tests-clar/resources/submod2/.gitted/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/config create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/description create mode 100755 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/index create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/73/ba924a80437097795ae839e66e187c55d3babf create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/9efbdadaa4a582778d4584385495559ea0994b create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/packed-refs create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/config create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/description create mode 100755 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/index create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/73/ba924a80437097795ae839e66e187c55d3babf create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/packed-refs create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/COMMIT_EDITMSG create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/config create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/description create mode 100755 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/index create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/3d/9386c507f6b093471a3e324085657a3c2b4247 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/73/ba924a80437097795ae839e66e187c55d3babf create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/77/fb0ed3e58568d6ad362c78de08ab8649d76e29 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/9efbdadaa4a582778d4584385495559ea0994b create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/8e/b1e637ed9fc8e5454fa20d38f809091f9395f4 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/packed-refs create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/config create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/description create mode 100755 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/index create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/73/ba924a80437097795ae839e66e187c55d3babf create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/9efbdadaa4a582778d4584385495559ea0994b create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/a0/2d31770687965547ab7a04cee199b29ee458d6 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/packed-refs create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/config create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/description create mode 100755 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/index create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/73/ba924a80437097795ae839e66e187c55d3babf create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/packed-refs create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/config create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/description create mode 100755 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/index create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/packed-refs create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/config create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/description create mode 100755 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/index create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/info/exclude create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/73/ba924a80437097795ae839e66e187c55d3babf create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/9efbdadaa4a582778d4584385495559ea0994b create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/packed-refs create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/heads/master create mode 100644 tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/remotes/origin/HEAD create mode 100644 tests-clar/resources/submod2/.gitted/objects/09/460e5b6cbcb05a3e404593c32a3aa7221eca0e create mode 100644 tests-clar/resources/submod2/.gitted/objects/14/fe9ccf104058df25e0a08361c4494e167ef243 create mode 100644 tests-clar/resources/submod2/.gitted/objects/22/ce3e0311dda73a5992d54a4a595518d3876ea7 create mode 100644 tests-clar/resources/submod2/.gitted/objects/25/5546424b0efb847b1bfc91dbf7348b277f8970 create mode 100644 tests-clar/resources/submod2/.gitted/objects/2a/30f1e6f94b20917005a21273f65b406d0f8bad create mode 100644 tests-clar/resources/submod2/.gitted/objects/42/cfb95cd01bf9225b659b5ee3edcc78e8eeb478 create mode 100644 tests-clar/resources/submod2/.gitted/objects/57/958699c2dc394f81cfc76950e9c3ac3025c398 create mode 100644 tests-clar/resources/submod2/.gitted/objects/59/01da4f1c67756eeadc5121d206bec2431f253b create mode 100644 tests-clar/resources/submod2/.gitted/objects/60/7d96653d4d0a4f733107f7890c2e67b55b620d create mode 100644 tests-clar/resources/submod2/.gitted/objects/74/84482eb8db738cafa696993664607500a3f2b9 create mode 100644 tests-clar/resources/submod2/.gitted/objects/7b/a4c5c3561daa5ab1a86215cfb0587e96d404d6 create mode 100644 tests-clar/resources/submod2/.gitted/objects/87/3585b94bdeabccea991ea5e3ec1a277895b698 create mode 100644 tests-clar/resources/submod2/.gitted/objects/97/4cf7c73de336b0c4e019f918f3cee367d72e84 create mode 100644 tests-clar/resources/submod2/.gitted/objects/9d/bc299bc013ea253583b40bf327b5a6e4037b89 create mode 100644 tests-clar/resources/submod2/.gitted/objects/a9/104bf89e911387244ef499413960ba472066d9 create mode 100644 tests-clar/resources/submod2/.gitted/objects/b6/14088620bbdc1d29549d223ceba0f4419fd4cb create mode 100644 tests-clar/resources/submod2/.gitted/objects/d4/07f19e50c1da1ff584beafe0d6dac7237c5d06 create mode 100644 tests-clar/resources/submod2/.gitted/objects/d9/3e95571d92cceb5de28c205f1d5f3cc8b88bc8 create mode 100644 tests-clar/resources/submod2/.gitted/objects/e3/b83bf274ee065eee48734cf8c6dfaf5e81471c create mode 100644 tests-clar/resources/submod2/.gitted/objects/f5/4414c25e6d24fe39f5c3f128d7c8a17bc23833 create mode 100644 tests-clar/resources/submod2/.gitted/objects/f9/90a25a74d1a8281ce2ab018ea8df66795cd60b create mode 100644 tests-clar/resources/submod2/.gitted/refs/heads/master create mode 100644 tests-clar/resources/submod2/README.txt create mode 100644 tests-clar/resources/submod2/gitmodules create mode 100644 tests-clar/resources/submod2/just_a_dir/contents create mode 100644 tests-clar/resources/submod2/just_a_file create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/COMMIT_EDITMSG create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/HEAD create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/config create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/description create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/applypatch-msg.sample create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/commit-msg.sample create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/post-update.sample create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-applypatch.sample create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-commit.sample create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-rebase.sample create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/prepare-commit-msg.sample create mode 100755 tests-clar/resources/submod2/not_submodule/.gitted/hooks/update.sample create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/index create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/info/exclude create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/logs/HEAD create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/objects/68/e92c611b80ee1ed8f38314ff9577f0d15b2444 create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/objects/71/ff9927d7c8a5639e062c38a7d35c433c424627 create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/objects/f0/1d56b18efd353ef2bb93a4585d590a0847195e create mode 100644 tests-clar/resources/submod2/not_submodule/.gitted/refs/heads/master create mode 100644 tests-clar/resources/submod2/not_submodule/README.txt create mode 100644 tests-clar/resources/submod2/sm_added_and_uncommited/.gitted create mode 100644 tests-clar/resources/submod2/sm_added_and_uncommited/README.txt create mode 100644 tests-clar/resources/submod2/sm_added_and_uncommited/file_to_modify create mode 100644 tests-clar/resources/submod2/sm_changed_file/.gitted create mode 100644 tests-clar/resources/submod2/sm_changed_file/README.txt create mode 100644 tests-clar/resources/submod2/sm_changed_file/file_to_modify create mode 100644 tests-clar/resources/submod2/sm_changed_head/.gitted create mode 100644 tests-clar/resources/submod2/sm_changed_head/README.txt create mode 100644 tests-clar/resources/submod2/sm_changed_head/file_to_modify create mode 100644 tests-clar/resources/submod2/sm_changed_index/.gitted create mode 100644 tests-clar/resources/submod2/sm_changed_index/README.txt create mode 100644 tests-clar/resources/submod2/sm_changed_index/file_to_modify create mode 100644 tests-clar/resources/submod2/sm_changed_untracked_file/.gitted create mode 100644 tests-clar/resources/submod2/sm_changed_untracked_file/README.txt create mode 100644 tests-clar/resources/submod2/sm_changed_untracked_file/file_to_modify create mode 100644 tests-clar/resources/submod2/sm_changed_untracked_file/i_am_untracked create mode 100644 tests-clar/resources/submod2/sm_missing_commits/.gitted create mode 100644 tests-clar/resources/submod2/sm_missing_commits/README.txt create mode 100644 tests-clar/resources/submod2/sm_missing_commits/file_to_modify create mode 100644 tests-clar/resources/submod2/sm_unchanged/.gitted create mode 100644 tests-clar/resources/submod2/sm_unchanged/README.txt create mode 100644 tests-clar/resources/submod2/sm_unchanged/file_to_modify create mode 100644 tests-clar/resources/submod2_target/.gitted/HEAD create mode 100644 tests-clar/resources/submod2_target/.gitted/config create mode 100644 tests-clar/resources/submod2_target/.gitted/description create mode 100755 tests-clar/resources/submod2_target/.gitted/hooks/applypatch-msg.sample create mode 100644 tests-clar/resources/submod2_target/.gitted/index create mode 100644 tests-clar/resources/submod2_target/.gitted/info/exclude create mode 100644 tests-clar/resources/submod2_target/.gitted/logs/HEAD create mode 100644 tests-clar/resources/submod2_target/.gitted/logs/refs/heads/master create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/41/bd4bc3df978de695f67ace64c560913da11653 create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/48/0095882d281ed676fe5b863569520e54a7d5c0 create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/5e/4963595a9774b90524d35a807169049de8ccad create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/6b/31c659545507c381e9cd34ec508f16c04e149e create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/73/ba924a80437097795ae839e66e187c55d3babf create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/78/9efbdadaa4a582778d4584385495559ea0994b create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e create mode 100644 tests-clar/resources/submod2_target/.gitted/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 create mode 100644 tests-clar/resources/submod2_target/.gitted/refs/heads/master create mode 100644 tests-clar/resources/submod2_target/README.txt create mode 100644 tests-clar/resources/submod2_target/file_to_modify diff --git a/tests-clar/resources/submod2/.gitted/HEAD b/tests-clar/resources/submod2/.gitted/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/config b/tests-clar/resources/submod2/.gitted/config new file mode 100644 index 000000000..abc420734 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/config @@ -0,0 +1,20 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true +[submodule "sm_missing_commits"] + url = ../submod2_target +[submodule "sm_unchanged"] + url = ../submod2_target +[submodule "sm_changed_file"] + url = ../submod2_target +[submodule "sm_changed_index"] + url = ../submod2_target +[submodule "sm_changed_head"] + url = ../submod2_target +[submodule "sm_changed_untracked_file"] + url = ../submod2_target +[submodule "sm_added_and_uncommited"] + url = ../submod2_target diff --git a/tests-clar/resources/submod2/.gitted/description b/tests-clar/resources/submod2/.gitted/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/index b/tests-clar/resources/submod2/.gitted/index new file mode 100644 index 0000000000000000000000000000000000000000..0c17e8629df1f457dd55db2b43f79442955e8e18 GIT binary patch literal 944 zcmZ?q402{*U|<4b?f}*sHb9yIM)NT+urS;{zk`9HaR~zh<5!@R2vBJ`ryE~%&YlfX zb`GwS4{KR1SCTu$$H1+Zo>`KcpHiBWS`0D-2m)BI0gXV=5c5v|KsApc{^x{6Q6(2w zXvjQT&Dgi%ep+SBHEss3AXi5hUst`7iV~0+AP~TM{W>xYb)Phvc`DUQjvfw^T@|%) zMUv?G4H0$IuCQEV5Y8$sE{RW!PsuFOPtMOPNzE%kxbylcsJUPoYOW}nxl&H&cg9?h z{;3q5Iy>(1+cOm}-fgL1;D(x;mYI_ZG6V=<;RmCk=4CN3JOIkV!jWN>2gB43T@ATw zW&fhvOf!S{LY7}Wz#v|n8=shxlA02qn3ob?nwOlPo10mZngTZW`dT0b3I{L^G572y zqRiz7nwy-Fn3oPT8R}M`IhfoX_&=i*5=FC#S(>b~_*^T0IJJa(eY6F_obW?o8a z1=ydvpyq*TsCiq7GEWl8ywbdqqQvBEn9qU!=75?DrXl8@5hKc6A)vXrnZ?DKdFk!nhT~O=AMlu%3L0xxxm 1342559771 -0700 commit (initial): Initial commit +14fe9ccf104058df25e0a08361c4494e167ef243 a9104bf89e911387244ef499413960ba472066d9 Russell Belfer 1342559831 -0700 commit: Adding a submodule +a9104bf89e911387244ef499413960ba472066d9 5901da4f1c67756eeadc5121d206bec2431f253b Russell Belfer 1342560036 -0700 commit: Updating submodule +5901da4f1c67756eeadc5121d206bec2431f253b 7484482eb8db738cafa696993664607500a3f2b9 Russell Belfer 1342560288 -0700 commit: Adding a bunch more test content diff --git a/tests-clar/resources/submod2/.gitted/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/logs/refs/heads/master new file mode 100644 index 000000000..2cf2ca74d --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/logs/refs/heads/master @@ -0,0 +1,4 @@ +0000000000000000000000000000000000000000 14fe9ccf104058df25e0a08361c4494e167ef243 Russell Belfer 1342559771 -0700 commit (initial): Initial commit +14fe9ccf104058df25e0a08361c4494e167ef243 a9104bf89e911387244ef499413960ba472066d9 Russell Belfer 1342559831 -0700 commit: Adding a submodule +a9104bf89e911387244ef499413960ba472066d9 5901da4f1c67756eeadc5121d206bec2431f253b Russell Belfer 1342560036 -0700 commit: Updating submodule +5901da4f1c67756eeadc5121d206bec2431f253b 7484482eb8db738cafa696993664607500a3f2b9 Russell Belfer 1342560288 -0700 commit: Adding a bunch more test content diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/config b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/config new file mode 100644 index 000000000..2d0583e99 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + worktree = ../../../sm_added_and_uncommited + ignorecase = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/description b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/index b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/index new file mode 100644 index 0000000000000000000000000000000000000000..65140a51097551874bfd47c68c0b7cd52751c7a0 GIT binary patch literal 192 zcmZ?q402{*U|<5_0M;8eK$-zY^D!{6Fx)=BnSr5k2?GP;SD=NB2J7Ek~B;>VZr z-=W*rTb(&1>aFX=z!l``=;G_DS5i>|G6Mu)=D=vEd0WuT%dD99`_`=`OPk7jU0WiXFD)}CHNGT2J~uxlGp!P29{X{_l`mH5U)hp1IZi^iI7`7`MJWKpE;#G} literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/info/exclude b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/HEAD new file mode 100644 index 000000000..53753e7dd --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560316 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/heads/master new file mode 100644 index 000000000..53753e7dd --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560316 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..53753e7dd --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560316 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG8X>-X+A`MI6N*Dz6QY4Oxv{b!#F?R3>Zey&Eh^ zLz#U_A&YRfX{+!#kAs&5Uc8K4;a=nOJGbeKx3rZ94B99}B8703PD;_&{;zfVZz|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&VW?_0N)ENv?9b#1W-nHoB8!Ax%es2L;m5j-ce literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a new file mode 100644 index 000000000..6d27af8a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a @@ -0,0 +1,2 @@ +x-10 Fa0p(N-ӡғq]>ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/9efbdadaa4a582778d4584385495559ea0994b new file mode 100644 index 000000000..17458840b --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/78/9efbdadaa4a582778d4584385495559ea0994b @@ -0,0 +1,2 @@ +x 0 )?= NlOkj8&r +qJW7B<fK8#Q1C-"e̫>'@ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/packed-refs b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/packed-refs new file mode 100644 index 000000000..5a4ebc47c --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/heads/master new file mode 100644 index 000000000..e12c44d7a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/heads/master @@ -0,0 +1 @@ +480095882d281ed676fe5b863569520e54a7d5c0 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/remotes/origin/HEAD new file mode 100644 index 000000000..6efe28fff --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_added_and_uncommited/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/config b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/config new file mode 100644 index 000000000..10cc2508e --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + worktree = ../../../sm_changed_file + ignorecase = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/description b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/index b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/index new file mode 100644 index 0000000000000000000000000000000000000000..6914a3b6edf944a819a71ecbd6b0b5c919c3a28b GIT binary patch literal 192 zcmZ?q402{*U|<5_0M_ekfiwe*=3`)BVYq$vHv>cC5(WmwuRtjgAkM1bEuQ}M#g8xL zzeBgLw>oo3)LYk!fh)+>(Z$zQucV>`WCjSp%z@ER^ZuZjmsv6I_pMt?mNu35y0%z^ zObwm4V5T<%Us`5PYJ5q4d~SY9W?Ci4yw+10^HT0^J@!F#v(di=TgsUqthNIH2lGAc literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/info/exclude b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/HEAD new file mode 100644 index 000000000..e5cb63f8d --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560173 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/heads/master new file mode 100644 index 000000000..e5cb63f8d --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560173 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..e5cb63f8d --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560173 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG8X>-X+A`MI6N*Dz6QY4Oxv{b!#F?R3>Zey&Eh^ zLz#U_A&YRfX{+!#kAs&5Uc8K4;a=nOJGbeKx3rZ94B99}B8703PD;_&{;zfVZz|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&VW?_0N)ENv?9b#1W-nHoB8!Ax%es2L;m5j-ce literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a new file mode 100644 index 000000000..6d27af8a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a @@ -0,0 +1,2 @@ +x-10 Fa0p(N-ӡғq]>ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b new file mode 100644 index 000000000..17458840b --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b @@ -0,0 +1,2 @@ +x 0 )?= NlOkj8&r +qJW7B<fK8#Q1C-"e̫>'@ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/packed-refs b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/packed-refs new file mode 100644 index 000000000..5a4ebc47c --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/heads/master new file mode 100644 index 000000000..e12c44d7a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/heads/master @@ -0,0 +1 @@ +480095882d281ed676fe5b863569520e54a7d5c0 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/remotes/origin/HEAD new file mode 100644 index 000000000..6efe28fff --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_file/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/COMMIT_EDITMSG b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/COMMIT_EDITMSG new file mode 100644 index 000000000..6b8d1e3fc --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/COMMIT_EDITMSG @@ -0,0 +1 @@ +Making a change in a submodule diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/config b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/config new file mode 100644 index 000000000..7d002536a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + worktree = ../../../sm_changed_head + ignorecase = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/description b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/index b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/index new file mode 100644 index 0000000000000000000000000000000000000000..728fa292f5c9e9a10d1d9983132120ad9034c122 GIT binary patch literal 192 zcmZ?q402{*U|<5_0M_f9fiwe*=3`)BVYq#61p`Cl5(WmwuRtjgAkM1bEuQ}M#g8xL zzeBgLw>oo3)LYk!fh)+>(Z$zQucV>`WCjQXu-;gVOhe4Opn_)Jy1tFi%-_yG@zm9S z5wFD$PEPsBQ@=3qrDf)%#+T&B=jNwmrd5K>iK}TYk-nns6nKVZqb1KYHMJMo>j7GH BIK2P> literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/info/exclude b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/HEAD new file mode 100644 index 000000000..cabdeb2b5 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560179 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target +480095882d281ed676fe5b863569520e54a7d5c0 3d9386c507f6b093471a3e324085657a3c2b4247 Russell Belfer 1342560431 -0700 commit: Making a change in a submodule diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/heads/master new file mode 100644 index 000000000..cabdeb2b5 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/heads/master @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560179 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target +480095882d281ed676fe5b863569520e54a7d5c0 3d9386c507f6b093471a3e324085657a3c2b4247 Russell Belfer 1342560431 -0700 commit: Making a change in a submodule diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..257ca21d1 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560179 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/3d/9386c507f6b093471a3e324085657a3c2b4247 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/3d/9386c507f6b093471a3e324085657a3c2b4247 new file mode 100644 index 000000000..a2c371642 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/3d/9386c507f6b093471a3e324085657a3c2b4247 @@ -0,0 +1,3 @@ +xKj!E3vj#<<@Ouq .)ql osFa#v )g#{':Tl`b40 ;fr4 + +zU-/glm\'LjrhXG_+l ʚE`;=]J \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG8X>-X+A`MI6N*Dz6QY4Oxv{b!#F?R3>Zey&Eh^ zLz#U_A&YRfX{+!#kAs&5Uc8K4;a=nOJGbeKx3rZ94B99}B8703PD;_&{;zfVZz|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&VW?_0N)ENv?9b#1W-nHoB8!Ax%es2L;m5j-ce literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/77/fb0ed3e58568d6ad362c78de08ab8649d76e29 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/77/fb0ed3e58568d6ad362c78de08ab8649d76e29 new file mode 100644 index 0000000000000000000000000000000000000000..f8a236f3d34786f432673ca244af537700adb66a GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&+oGxN9ePds(?U&L$igOgK!^3*Q?pK2pjFwQB_ literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a new file mode 100644 index 000000000..6d27af8a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a @@ -0,0 +1,2 @@ +x-10 Fa0p(N-ӡғq]>ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/9efbdadaa4a582778d4584385495559ea0994b new file mode 100644 index 000000000..17458840b --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/78/9efbdadaa4a582778d4584385495559ea0994b @@ -0,0 +1,2 @@ +x 0 )?= NlOkj8&r +qJW7B<fK8#Q1C-"e̫>'@ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/8e/b1e637ed9fc8e5454fa20d38f809091f9395f4 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/8e/b1e637ed9fc8e5454fa20d38f809091f9395f4 new file mode 100644 index 000000000..8155b3e87 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/8e/b1e637ed9fc8e5454fa20d38f809091f9395f4 @@ -0,0 +1,2 @@ +xMM; +1) ZPr3k lEnl!crz ,e +lEZxuPYx QC*fuLcfR3T0'үj~G^s1b2zVk]5<v'> \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/packed-refs b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/packed-refs new file mode 100644 index 000000000..5a4ebc47c --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/heads/master new file mode 100644 index 000000000..ae079bd79 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/heads/master @@ -0,0 +1 @@ +3d9386c507f6b093471a3e324085657a3c2b4247 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/remotes/origin/HEAD new file mode 100644 index 000000000..6efe28fff --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_head/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/config b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/config new file mode 100644 index 000000000..0274ff7e3 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + worktree = ../../../sm_changed_index + ignorecase = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/description b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/index b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/index new file mode 100644 index 0000000000000000000000000000000000000000..6fad3b43eab8d2b6b8717c1111a61c378cc37aeb GIT binary patch literal 192 zcmZ?q402{*U|<5_0M_g4fiwe*=3`)BVYq!RfPtZL2?GP;SD=NB2J7Ek~B;>VZr z-=W*rTb(&1>aFX=z!l``=;G_DS5i>|G6MtxSZ}l=(-8A62%?!ce}S%HIa~X*Q1{hU zEax81+%)e=#5D%Kw9K5;_>%ni-29Zxv`UaUS1bMog|S)uwLFq+XeS%cmaR8$7Xax* BIIREx literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/info/exclude b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/HEAD new file mode 100644 index 000000000..80eb54102 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560175 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/heads/master new file mode 100644 index 000000000..80eb54102 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560175 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..80eb54102 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560175 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG8X>-X+A`MI6N*Dz6QY4Oxv{b!#F?R3>Zey&Eh^ zLz#U_A&YRfX{+!#kAs&5Uc8K4;a=nOJGbeKx3rZ94B99}B8703PD;_&{;zfVZz|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&VW?_0N)ENv?9b#1W-nHoB8!Ax%es2L;m5j-ce literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a new file mode 100644 index 000000000..6d27af8a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a @@ -0,0 +1,2 @@ +x-10 Fa0p(N-ӡғq]>ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/9efbdadaa4a582778d4584385495559ea0994b new file mode 100644 index 000000000..17458840b --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/78/9efbdadaa4a582778d4584385495559ea0994b @@ -0,0 +1,2 @@ +x 0 )?= NlOkj8&r +qJW7B<fK8#Q1C-"e̫>'@ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/a0/2d31770687965547ab7a04cee199b29ee458d6 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/a0/2d31770687965547ab7a04cee199b29ee458d6 new file mode 100644 index 0000000000000000000000000000000000000000..cb3f5a00261e6d452d9e86c55f0adc6a41ca8c57 GIT binary patch literal 134 zcmV;10D1p-0VRz)4gxU{L#cBLpI{{l3T^;B4do;=OCquvDIY;@&nzpsv1R-DtRCmf z_4J6T!9-Y77Iej?oYsj{(1tfNvNU(^pj?G`B2q)sO<>EebuR9y1Az*N8Ce5mgh=Hj o_S#THSa@+asdgXb;281f@DAGJR9L>C!hiSC`sP&K4-wKjM3@OZ!vFvP literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/packed-refs b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/packed-refs new file mode 100644 index 000000000..5a4ebc47c --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/heads/master new file mode 100644 index 000000000..e12c44d7a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/heads/master @@ -0,0 +1 @@ +480095882d281ed676fe5b863569520e54a7d5c0 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/remotes/origin/HEAD new file mode 100644 index 000000000..6efe28fff --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_index/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/config b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/config new file mode 100644 index 000000000..7f2584476 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + worktree = ../../../sm_changed_untracked_file + ignorecase = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/description b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/index b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/index new file mode 100644 index 0000000000000000000000000000000000000000..598e30a32c0a05c68b94868c903b70e267e29b6f GIT binary patch literal 192 zcmZ?q402{*U|<5_0M_fffHVV)=3`)BVYq$n9|J?<5(WmwuRtjgAkM1bEuQ}M#g8xL zzeBgLw>oo3)LYk!fh)+>(Z$zQucV>`WCjSp%z@ER^Zuimmsv6I_pMt?mNu35y0%z^ zObwm4V5T<%Us`5PYJ5q4d~SY9W?Ci4ylltW-{u{;yzbMyE8!+zFDLJqyR!xWEx|us literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/info/exclude b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/HEAD new file mode 100644 index 000000000..d1beafbd6 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560186 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/heads/master new file mode 100644 index 000000000..d1beafbd6 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560186 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..d1beafbd6 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560186 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG8X>-X+A`MI6N*Dz6QY4Oxv{b!#F?R3>Zey&Eh^ zLz#U_A&YRfX{+!#kAs&5Uc8K4;a=nOJGbeKx3rZ94B99}B8703PD;_&{;zfVZz|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&VW?_0N)ENv?9b#1W-nHoB8!Ax%es2L;m5j-ce literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a new file mode 100644 index 000000000..6d27af8a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a @@ -0,0 +1,2 @@ +x-10 Fa0p(N-ӡғq]>ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b new file mode 100644 index 000000000..17458840b --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/78/9efbdadaa4a582778d4584385495559ea0994b @@ -0,0 +1,2 @@ +x 0 )?= NlOkj8&r +qJW7B<fK8#Q1C-"e̫>'@ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/packed-refs b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/packed-refs new file mode 100644 index 000000000..5a4ebc47c --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/heads/master new file mode 100644 index 000000000..e12c44d7a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/heads/master @@ -0,0 +1 @@ +480095882d281ed676fe5b863569520e54a7d5c0 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/remotes/origin/HEAD new file mode 100644 index 000000000..6efe28fff --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_changed_untracked_file/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/config b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/config new file mode 100644 index 000000000..45fbb30cf --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + worktree = ../../../sm_missing_commits + ignorecase = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/description b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/index b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/index new file mode 100644 index 0000000000000000000000000000000000000000..4903565245793c25c85846d2ec7f1f1f7bf86cf1 GIT binary patch literal 192 zcmZ?q402{*U|<5_0M=_JK$-zY^D!{6Fx);9#lXH5m@#9PR z@6he*t$OWah`_G4Q2j=A_1# 1342559796 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/heads/master new file mode 100644 index 000000000..ee08c9706 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559796 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..ee08c9706 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559796 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/packed-refs b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/packed-refs new file mode 100644 index 000000000..66fbf5daf --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +5e4963595a9774b90524d35a807169049de8ccad refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/heads/master new file mode 100644 index 000000000..3913aca5d --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/heads/master @@ -0,0 +1 @@ +5e4963595a9774b90524d35a807169049de8ccad diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/remotes/origin/HEAD new file mode 100644 index 000000000..6efe28fff --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_missing_commits/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/config b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/config new file mode 100644 index 000000000..fc706c9dd --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/config @@ -0,0 +1,13 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + worktree = ../../../sm_unchanged + ignorecase = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = /Users/rb/src/libgit2/tests-clar/resources/submod2_target +[branch "master"] + remote = origin + merge = refs/heads/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/description b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/hooks/applypatch-msg.sample b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/index b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/index new file mode 100644 index 0000000000000000000000000000000000000000..629c849ecfac930312db938c6c7c4484ef449aff GIT binary patch literal 192 zcmZ?q402{*U|<5_0M_d(fiwe*=3`)BVYq#E83RM(5(WmwuRtjgAkM1bEuQ}M#g8xL zzeBgLw>oo3)LYk!fh)+>(Z$zQucV>`WCjSp%z@ER^OmETmsv6I_pMt?mNu35y0%z^ zObwm4V5T<%Us`5PYJ5q4d~SY9W?Ci4JlT+i%MRAdRwr(p^x(Rr0pH6VH)a9=m{dFW literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/info/exclude b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/HEAD new file mode 100644 index 000000000..72653286a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560169 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/heads/master new file mode 100644 index 000000000..72653286a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560169 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/remotes/origin/HEAD new file mode 100644 index 000000000..72653286a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/logs/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342560169 -0700 clone: from /Users/rb/src/libgit2/tests-clar/resources/submod2_target diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG8X>-X+A`MI6N*Dz6QY4Oxv{b!#F?R3>Zey&Eh^ zLz#U_A&YRfX{+!#kAs&5Uc8K4;a=nOJGbeKx3rZ94B99}B8703PD;_&{;zfVZz|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&VW?_0N)ENv?9b#1W-nHoB8!Ax%es2L;m5j-ce literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a new file mode 100644 index 000000000..6d27af8a8 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a @@ -0,0 +1,2 @@ +x-10 Fa0p(N-ӡғq]>ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/9efbdadaa4a582778d4584385495559ea0994b new file mode 100644 index 000000000..17458840b --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/78/9efbdadaa4a582778d4584385495559ea0994b @@ -0,0 +1,2 @@ +x 0 )?= NlOkj8&r +qJW7B<fK8#Q1C-"e̫>'@ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/packed-refs b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/packed-refs new file mode 100644 index 000000000..5a4ebc47c --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/packed-refs @@ -0,0 +1,2 @@ +# pack-refs with: peeled +480095882d281ed676fe5b863569520e54a7d5c0 refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/heads/master b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/heads/master new file mode 100644 index 000000000..e12c44d7a --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/heads/master @@ -0,0 +1 @@ +480095882d281ed676fe5b863569520e54a7d5c0 diff --git a/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/remotes/origin/HEAD b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/remotes/origin/HEAD new file mode 100644 index 000000000..6efe28fff --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/modules/sm_unchanged/refs/remotes/origin/HEAD @@ -0,0 +1 @@ +ref: refs/remotes/origin/master diff --git a/tests-clar/resources/submod2/.gitted/objects/09/460e5b6cbcb05a3e404593c32a3aa7221eca0e b/tests-clar/resources/submod2/.gitted/objects/09/460e5b6cbcb05a3e404593c32a3aa7221eca0e new file mode 100644 index 0000000000000000000000000000000000000000..f1ea5f4c8ecf1fbc9730e84b202ac91d9af39b05 GIT binary patch literal 197 zcmV;$06PD80hQ8C3c@fD1z@-BDN6Smtl-XLxDpBZ8Pi~r%1izuT@(l%#KTa!{1yxwk|%7_J)cZKU#?XEzb+;!ymCd6v+%$!5b|NX4T-12G?= zDX3Zm1A54Pj%Pz}hF`3Mq4k|C=4{Y#pZ2 ^!F'!諲l_q4E޶RݏS'n>>m^\w^$X_迦xE_.9} \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/objects/22/ce3e0311dda73a5992d54a4a595518d3876ea7 b/tests-clar/resources/submod2/.gitted/objects/22/ce3e0311dda73a5992d54a4a595518d3876ea7 new file mode 100644 index 000000000..fce6a94b5 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/objects/22/ce3e0311dda73a5992d54a4a595518d3876ea7 @@ -0,0 +1,4 @@ +x +0Eݶ_Q. +. W"!1 !3 >+.9=3W(n-:;j[" W{ޕQZW,2 iviyh T/={ !@b(bJcSPrŌ +{`|%imp콡=IÿW26B@)|)g \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/objects/25/5546424b0efb847b1bfc91dbf7348b277f8970 b/tests-clar/resources/submod2/.gitted/objects/25/5546424b0efb847b1bfc91dbf7348b277f8970 new file mode 100644 index 0000000000000000000000000000000000000000..2965becf606848ee8b992a62838f0e84c4d15aba GIT binary patch literal 157 zcmV;O0Al}m0kzG$3IZ_@g<;#>rwH4-1FMCNk6|Seav8IMTx2EzA7Al?tAd5to*&Mq zL)K!sSk1Ovb7 z8C7y literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/2a/30f1e6f94b20917005a21273f65b406d0f8bad b/tests-clar/resources/submod2/.gitted/objects/2a/30f1e6f94b20917005a21273f65b406d0f8bad new file mode 100644 index 0000000000000000000000000000000000000000..08faf0fa8e69b6488d400a0e61f5875ace6ce1f6 GIT binary patch literal 144 zcmV;B0B`?z0i}(*3IZ_@0BtW{5w7MmAhz1QDTb&b-^36+XLKO3_eM4V literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/42/cfb95cd01bf9225b659b5ee3edcc78e8eeb478 b/tests-clar/resources/submod2/.gitted/objects/42/cfb95cd01bf9225b659b5ee3edcc78e8eeb478 new file mode 100644 index 0000000000000000000000000000000000000000..ee7848ae6efdac9ddaca627c926715721fafbfcf GIT binary patch literal 40 ycmV+@0N4L`0ZYosPf{>4V+hH}ELH%btkU8Vg+zsdoW#sLg|y6^R4xF(PYWStUJ-); literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/57/958699c2dc394f81cfc76950e9c3ac3025c398 b/tests-clar/resources/submod2/.gitted/objects/57/958699c2dc394f81cfc76950e9c3ac3025c398 new file mode 100644 index 0000000000000000000000000000000000000000..ca9203a6e3dc2d699dbd7ac7bb72c49d15d29ef7 GIT binary patch literal 136 zcmV;30C)d*0V^p=O;s>7GG;I|FfcPQQP4}zEXmDJDa}bOW|+H2bM^t@SE{DXTev@~ zZ(a6;xw;doEXdW-#n)A@q@sl3=Y&O3B^Os{$UIuj*tg<-T4l^NZbLHzAW$gIjnB<2 qF3!wLk5A6e&CM(+X7FH`+M%l6#=-g?,F \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/objects/60/7d96653d4d0a4f733107f7890c2e67b55b620d b/tests-clar/resources/submod2/.gitted/objects/60/7d96653d4d0a4f733107f7890c2e67b55b620d new file mode 100644 index 0000000000000000000000000000000000000000..30bee40e94f29490b006aadaec04669732ccda8c GIT binary patch literal 53 zcmbi`6I6@CB! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/74/84482eb8db738cafa696993664607500a3f2b9 b/tests-clar/resources/submod2/.gitted/objects/74/84482eb8db738cafa696993664607500a3f2b9 new file mode 100644 index 0000000000000000000000000000000000000000..79018042d905a039f8bc37fdb65726addb7d3b48 GIT binary patch literal 173 zcmV;e08;;W0hNy1O~o(}1^IRr+W^RK8|exGCD4JrKE8>R#K_t7Pg>x2G$Rd&tHnDldUHo!`8V+hH}ELH%bM1{1>oK%I(JRqweClN@eWEQ0+m*f{!asdE5 Gs1B*t@Dh;# literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/87/3585b94bdeabccea991ea5e3ec1a277895b698 b/tests-clar/resources/submod2/.gitted/objects/87/3585b94bdeabccea991ea5e3ec1a277895b698 new file mode 100644 index 0000000000000000000000000000000000000000..41af98aa9f2dec642502d9c2d2bbf3d9de10c89c GIT binary patch literal 137 zcmV;40CxX)0V^p=O;s>7GG;I|FfcPQQP4}zEXmDJDa}bOW|+H2bM^t@SE{DXTev@~ zZ(a6;xw;doEXdW-#n)A@q@sl3=Y&O3B^Os{$UIuj*tg<-T4l^NZbLHzAW$gIjnB<2 rF3!wLk5A6e&CM(+W{C4lj*OaKvXfQia#TZMCd=FxXVwA$eBLt!%4k4; literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/97/4cf7c73de336b0c4e019f918f3cee367d72e84 b/tests-clar/resources/submod2/.gitted/objects/97/4cf7c73de336b0c4e019f918f3cee367d72e84 new file mode 100644 index 000000000..160f1caf4 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/objects/97/4cf7c73de336b0c4e019f918f3cee367d72e84 @@ -0,0 +1,2 @@ +x +0Eݶ_Bqg yi IYUp!΁s|R7=)XCAG:25:<-uU_IY\Ϥ%AF f{G qTPsu(Z{RA #̉0mŲ.8b?{vʌ \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/objects/9d/bc299bc013ea253583b40bf327b5a6e4037b89 b/tests-clar/resources/submod2/.gitted/objects/9d/bc299bc013ea253583b40bf327b5a6e4037b89 new file mode 100644 index 0000000000000000000000000000000000000000..1ee52218d9f27d4c087983e47a8e2194ad3b8f93 GIT binary patch literal 80 zcmV-W0I&ae0ZYosPg1ZjWr!{=P0GzrDa}b$P%6%i&&@0@&df`XPtMQH%`7Qaisj-g mNG!=vuvNg6FGlZF^VrqEJ{x;;Q{~&2q2jMMSvUZTt zTzVq{Ym~M+I1Gt=h>^T=g1jb0QFv*LbvjJWvafHncMzD##h3+0u5HRv6ZhPzNkl}4 zBql>yqGEpZr8fAC=evERe?F8+*{_>W;*reC2e*g#eZ)<~sx@kGvW9Gey+W6WiZ QLBA|zFV@+^2Y_`jIUZm*3IG5A literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/d4/07f19e50c1da1ff584beafe0d6dac7237c5d06 b/tests-clar/resources/submod2/.gitted/objects/d4/07f19e50c1da1ff584beafe0d6dac7237c5d06 new file mode 100644 index 0000000000000000000000000000000000000000..292303eb9376601cf4d4fc319529960ea41a7220 GIT binary patch literal 55 zcmb)7U|?ckU~Cx3QB+#;vGl6;N{z%HmWhEOCy$Cs8TE%5e_Oj_ewbu& LuQWqMo1hH<9@`XQ literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/d9/3e95571d92cceb5de28c205f1d5f3cc8b88bc8 b/tests-clar/resources/submod2/.gitted/objects/d9/3e95571d92cceb5de28c205f1d5f3cc8b88bc8 new file mode 100644 index 000000000..b92c7eebd --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/objects/d9/3e95571d92cceb5de28c205f1d5f3cc8b88bc8 @@ -0,0 +1,2 @@ +x +!nק} ".zuRCx}Αہt .׫6,is&%9S#IW=aߐf2ABYsНa{c^K3gwM͠Fߥ4s'NI \ No newline at end of file diff --git a/tests-clar/resources/submod2/.gitted/objects/e3/b83bf274ee065eee48734cf8c6dfaf5e81471c b/tests-clar/resources/submod2/.gitted/objects/e3/b83bf274ee065eee48734cf8c6dfaf5e81471c new file mode 100644 index 0000000000000000000000000000000000000000..3c7750b12addc1be9c7f6824d34794b35f9d486b GIT binary patch literal 246 zcmV4GGZ_^FfcPQQP4}zEXmDJDa}bOX1HlLHC%Smnb)z8dKBVi z<84mt=sp2e7Ub&a;_IqcQc=S2bHbvil8Y-eWFD<%>|1d^tup2sw}}A|C}foum&7N= zr(_l}B-Bnzwe{ulFE(WV-pQkvzBM|D7itt#Ra$0FDudJcoiP`re=0?%&W?Nh_Dsc# zcUvk9&A^5g=f)>zB<7{3ro@AldN54w(AAK;R`xHt%``KJFJ$@E1DHxPQWH}ch*O%G wmy%jRq}tNFlA^@qY~tLKn^|0(nU@})oS&PUSyD{Eiqbr&H?gV%07{jksAL9rrvLx| literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/.gitted/objects/f5/4414c25e6d24fe39f5c3f128d7c8a17bc23833 b/tests-clar/resources/submod2/.gitted/objects/f5/4414c25e6d24fe39f5c3f128d7c8a17bc23833 new file mode 100644 index 000000000..219620b25 --- /dev/null +++ b/tests-clar/resources/submod2/.gitted/objects/f5/4414c25e6d24fe39f5c3f128d7c8a17bc23833 @@ -0,0 +1,2 @@ +xe +0aSbOz12\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/hooks/post-update.sample b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/post-update.sample new file mode 100755 index 000000000..ec17ec193 --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-applypatch.sample b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-applypatch.sample new file mode 100755 index 000000000..b1f187c2e --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-commit.sample b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-commit.sample new file mode 100755 index 000000000..18c482976 --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-commit.sample @@ -0,0 +1,50 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# If you want to allow non-ascii filenames set this variable to true. +allownonascii=$(git config hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ascii filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + echo "Error: Attempt to add a non-ascii file name." + echo + echo "This can cause problems if you want to work" + echo "with people on other platforms." + echo + echo "To be portable it is advisable to rename the file ..." + echo + echo "If you know what you are doing you can disable this" + echo "check using:" + echo + echo " git config hooks.allownonascii true" + echo + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-rebase.sample b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-rebase.sample new file mode 100755 index 000000000..9773ed4cb --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up-to-date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +exit 0 + +################################################################ + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/hooks/prepare-commit-msg.sample b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/prepare-commit-msg.sample new file mode 100755 index 000000000..f093a02ec --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/prepare-commit-msg.sample @@ -0,0 +1,36 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first comments out the +# "Conflicts:" part of a merge commit. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +case "$2,$3" in + merge,) + /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; + +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$1" ;; + + *) ;; +esac + +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/hooks/update.sample b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/update.sample new file mode 100755 index 000000000..71ab04edc --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to blocks unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/index b/tests-clar/resources/submod2/not_submodule/.gitted/index new file mode 100644 index 0000000000000000000000000000000000000000..f3fafa536b3412beae2a78051147fb34f429dcc4 GIT binary patch literal 112 zcmZ?q402{*U|<4b#sJnEu|S#uM)NT+urS;{|Av8~aS2fRD^N-Vh}8@K&s4vDVrlX` zHXV!Qmt&l5oZQqIxPn|AU3^{jN-9b~W`F?m@~ literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/info/exclude b/tests-clar/resources/submod2/not_submodule/.gitted/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/logs/HEAD b/tests-clar/resources/submod2/not_submodule/.gitted/logs/HEAD new file mode 100644 index 000000000..1749e7dff --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 68e92c611b80ee1ed8f38314ff9577f0d15b2444 Russell Belfer 1342560358 -0700 commit (initial): Initial commit diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/logs/refs/heads/master b/tests-clar/resources/submod2/not_submodule/.gitted/logs/refs/heads/master new file mode 100644 index 000000000..1749e7dff --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 68e92c611b80ee1ed8f38314ff9577f0d15b2444 Russell Belfer 1342560358 -0700 commit (initial): Initial commit diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/objects/68/e92c611b80ee1ed8f38314ff9577f0d15b2444 b/tests-clar/resources/submod2/not_submodule/.gitted/objects/68/e92c611b80ee1ed8f38314ff9577f0d15b2444 new file mode 100644 index 0000000000000000000000000000000000000000..8892531a749bf004b9dd9b802e09bc19cae75bc3 GIT binary patch literal 132 zcmV-~0DJ#<0hNtG4#FT1MO|}>xqxOUOiL4Ej61j90LoxVKoSb~m&6me{dw>Gt>hdV z$c0X=GDAS=X?D_Z@QM_N$+=ZoO@=(JXwm3JuEfIjwwDU8ejJ<)7U|?ckU~Cx3QB+#;vGl6;N{vK~KlZ_Ye|0WB`T0hP&b0Wx!fk~` L!R!nH>inw!O7<3- literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2/not_submodule/.gitted/refs/heads/master b/tests-clar/resources/submod2/not_submodule/.gitted/refs/heads/master new file mode 100644 index 000000000..0bd8514bd --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/.gitted/refs/heads/master @@ -0,0 +1 @@ +68e92c611b80ee1ed8f38314ff9577f0d15b2444 diff --git a/tests-clar/resources/submod2/not_submodule/README.txt b/tests-clar/resources/submod2/not_submodule/README.txt new file mode 100644 index 000000000..71ff9927d --- /dev/null +++ b/tests-clar/resources/submod2/not_submodule/README.txt @@ -0,0 +1 @@ +This is a git repo but not a submodule diff --git a/tests-clar/resources/submod2/sm_added_and_uncommited/.gitted b/tests-clar/resources/submod2/sm_added_and_uncommited/.gitted new file mode 100644 index 000000000..2b2a4cf90 --- /dev/null +++ b/tests-clar/resources/submod2/sm_added_and_uncommited/.gitted @@ -0,0 +1 @@ +gitdir: ../.git/modules/sm_added_and_uncommited diff --git a/tests-clar/resources/submod2/sm_added_and_uncommited/README.txt b/tests-clar/resources/submod2/sm_added_and_uncommited/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2/sm_added_and_uncommited/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2/sm_added_and_uncommited/file_to_modify b/tests-clar/resources/submod2/sm_added_and_uncommited/file_to_modify new file mode 100644 index 000000000..789efbdad --- /dev/null +++ b/tests-clar/resources/submod2/sm_added_and_uncommited/file_to_modify @@ -0,0 +1,3 @@ +This is a file to modify in submodules +It already has some history. +You can add local changes as needed. diff --git a/tests-clar/resources/submod2/sm_changed_file/.gitted b/tests-clar/resources/submod2/sm_changed_file/.gitted new file mode 100644 index 000000000..dc98b1674 --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_file/.gitted @@ -0,0 +1 @@ +gitdir: ../.git/modules/sm_changed_file diff --git a/tests-clar/resources/submod2/sm_changed_file/README.txt b/tests-clar/resources/submod2/sm_changed_file/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_file/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2/sm_changed_file/file_to_modify b/tests-clar/resources/submod2/sm_changed_file/file_to_modify new file mode 100644 index 000000000..e5ba67168 --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_file/file_to_modify @@ -0,0 +1,4 @@ +This is a file to modify in submodules +It already has some history. +You can add local changes as needed. +In this case, the file is changed in the workdir diff --git a/tests-clar/resources/submod2/sm_changed_head/.gitted b/tests-clar/resources/submod2/sm_changed_head/.gitted new file mode 100644 index 000000000..d5419b62d --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_head/.gitted @@ -0,0 +1 @@ +gitdir: ../.git/modules/sm_changed_head diff --git a/tests-clar/resources/submod2/sm_changed_head/README.txt b/tests-clar/resources/submod2/sm_changed_head/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_head/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2/sm_changed_head/file_to_modify b/tests-clar/resources/submod2/sm_changed_head/file_to_modify new file mode 100644 index 000000000..8eb1e637e --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_head/file_to_modify @@ -0,0 +1,4 @@ +This is a file to modify in submodules +It already has some history. +You can add local changes as needed. +This one has been changed and the change has been committed to HEAD. diff --git a/tests-clar/resources/submod2/sm_changed_index/.gitted b/tests-clar/resources/submod2/sm_changed_index/.gitted new file mode 100644 index 000000000..2c7a5b271 --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_index/.gitted @@ -0,0 +1 @@ +gitdir: ../.git/modules/sm_changed_index diff --git a/tests-clar/resources/submod2/sm_changed_index/README.txt b/tests-clar/resources/submod2/sm_changed_index/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_index/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2/sm_changed_index/file_to_modify b/tests-clar/resources/submod2/sm_changed_index/file_to_modify new file mode 100644 index 000000000..a02d31770 --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_index/file_to_modify @@ -0,0 +1,4 @@ +This is a file to modify in submodules +It already has some history. +You can add local changes as needed. +Here the file is changed in the index and the workdir diff --git a/tests-clar/resources/submod2/sm_changed_untracked_file/.gitted b/tests-clar/resources/submod2/sm_changed_untracked_file/.gitted new file mode 100644 index 000000000..9a1070647 --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_untracked_file/.gitted @@ -0,0 +1 @@ +gitdir: ../.git/modules/sm_changed_untracked_file diff --git a/tests-clar/resources/submod2/sm_changed_untracked_file/README.txt b/tests-clar/resources/submod2/sm_changed_untracked_file/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_untracked_file/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2/sm_changed_untracked_file/file_to_modify b/tests-clar/resources/submod2/sm_changed_untracked_file/file_to_modify new file mode 100644 index 000000000..789efbdad --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_untracked_file/file_to_modify @@ -0,0 +1,3 @@ +This is a file to modify in submodules +It already has some history. +You can add local changes as needed. diff --git a/tests-clar/resources/submod2/sm_changed_untracked_file/i_am_untracked b/tests-clar/resources/submod2/sm_changed_untracked_file/i_am_untracked new file mode 100644 index 000000000..d2bae6167 --- /dev/null +++ b/tests-clar/resources/submod2/sm_changed_untracked_file/i_am_untracked @@ -0,0 +1 @@ +This file is untracked, but in a submodule diff --git a/tests-clar/resources/submod2/sm_missing_commits/.gitted b/tests-clar/resources/submod2/sm_missing_commits/.gitted new file mode 100644 index 000000000..70193be84 --- /dev/null +++ b/tests-clar/resources/submod2/sm_missing_commits/.gitted @@ -0,0 +1 @@ +gitdir: ../.git/modules/sm_missing_commits diff --git a/tests-clar/resources/submod2/sm_missing_commits/README.txt b/tests-clar/resources/submod2/sm_missing_commits/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2/sm_missing_commits/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2/sm_missing_commits/file_to_modify b/tests-clar/resources/submod2/sm_missing_commits/file_to_modify new file mode 100644 index 000000000..8834b635d --- /dev/null +++ b/tests-clar/resources/submod2/sm_missing_commits/file_to_modify @@ -0,0 +1,3 @@ +This is a file to modify in submodules +It already has some history. + diff --git a/tests-clar/resources/submod2/sm_unchanged/.gitted b/tests-clar/resources/submod2/sm_unchanged/.gitted new file mode 100644 index 000000000..51a679c80 --- /dev/null +++ b/tests-clar/resources/submod2/sm_unchanged/.gitted @@ -0,0 +1 @@ +gitdir: ../.git/modules/sm_unchanged diff --git a/tests-clar/resources/submod2/sm_unchanged/README.txt b/tests-clar/resources/submod2/sm_unchanged/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2/sm_unchanged/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2/sm_unchanged/file_to_modify b/tests-clar/resources/submod2/sm_unchanged/file_to_modify new file mode 100644 index 000000000..789efbdad --- /dev/null +++ b/tests-clar/resources/submod2/sm_unchanged/file_to_modify @@ -0,0 +1,3 @@ +This is a file to modify in submodules +It already has some history. +You can add local changes as needed. diff --git a/tests-clar/resources/submod2_target/.gitted/HEAD b/tests-clar/resources/submod2_target/.gitted/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/tests-clar/resources/submod2_target/.gitted/config b/tests-clar/resources/submod2_target/.gitted/config new file mode 100644 index 000000000..af107929f --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/config @@ -0,0 +1,6 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true diff --git a/tests-clar/resources/submod2_target/.gitted/description b/tests-clar/resources/submod2_target/.gitted/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/tests-clar/resources/submod2_target/.gitted/hooks/applypatch-msg.sample b/tests-clar/resources/submod2_target/.gitted/hooks/applypatch-msg.sample new file mode 100755 index 000000000..8b2a2fe84 --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/tests-clar/resources/submod2_target/.gitted/index b/tests-clar/resources/submod2_target/.gitted/index new file mode 100644 index 0000000000000000000000000000000000000000..eb3ff8c101bf9689c5ec54f63dfe456d65313cea GIT binary patch literal 192 zcmZ?q402{*U|<5_0M@I^fHVV)=3`)BVYq#|l!2jf2?GP;SD=NB2J7Ek~B;>VZr z-=W*rTb(&1>aFX=z!l``=;G_DS5i>|G6MtxSg)-`rXl8?nTuv#X2rbUw{9(2+Em`_ z+F}thHFVyBncfV1X_+~x@g@23x%nxXX_X*zR@#d%xV7m{P}xn_BZc)^T+6E5`2lzM BI;;Qy literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2_target/.gitted/info/exclude b/tests-clar/resources/submod2_target/.gitted/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/tests-clar/resources/submod2_target/.gitted/logs/HEAD b/tests-clar/resources/submod2_target/.gitted/logs/HEAD new file mode 100644 index 000000000..0ecd1113f --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/logs/HEAD @@ -0,0 +1,4 @@ +0000000000000000000000000000000000000000 6b31c659545507c381e9cd34ec508f16c04e149e Russell Belfer 1342559662 -0700 commit (initial): Initial commit +6b31c659545507c381e9cd34ec508f16c04e149e 41bd4bc3df978de695f67ace64c560913da11653 Russell Belfer 1342559709 -0700 commit: Adding test file +41bd4bc3df978de695f67ace64c560913da11653 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559726 -0700 commit: Updating test file +5e4963595a9774b90524d35a807169049de8ccad 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342559925 -0700 commit: One more update diff --git a/tests-clar/resources/submod2_target/.gitted/logs/refs/heads/master b/tests-clar/resources/submod2_target/.gitted/logs/refs/heads/master new file mode 100644 index 000000000..0ecd1113f --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/logs/refs/heads/master @@ -0,0 +1,4 @@ +0000000000000000000000000000000000000000 6b31c659545507c381e9cd34ec508f16c04e149e Russell Belfer 1342559662 -0700 commit (initial): Initial commit +6b31c659545507c381e9cd34ec508f16c04e149e 41bd4bc3df978de695f67ace64c560913da11653 Russell Belfer 1342559709 -0700 commit: Adding test file +41bd4bc3df978de695f67ace64c560913da11653 5e4963595a9774b90524d35a807169049de8ccad Russell Belfer 1342559726 -0700 commit: Updating test file +5e4963595a9774b90524d35a807169049de8ccad 480095882d281ed676fe5b863569520e54a7d5c0 Russell Belfer 1342559925 -0700 commit: One more update diff --git a/tests-clar/resources/submod2_target/.gitted/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 b/tests-clar/resources/submod2_target/.gitted/objects/06/362fe2fdb7010d0e447b4fb450d405420479a1 new file mode 100644 index 0000000000000000000000000000000000000000..f4b7094c52b2b13a955016da7ed894453ab9813c GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL NNYq=`3jkt>5$jr-7%cz* literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2_target/.gitted/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 b/tests-clar/resources/submod2_target/.gitted/objects/0e/6a3ca48bd47cfe67681acf39aa0b10a0b92484 new file mode 100644 index 0000000000000000000000000000000000000000..56c845e49de66164d68d3f7439e2aedcb220c498 GIT binary patch literal 53 zcmV-50LuS(0ZYosPf{>3U`ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E Ln2QSlfR+#vlJ6KL literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2_target/.gitted/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 b/tests-clar/resources/submod2_target/.gitted/objects/17/d0ece6e96460a06592d9d9d000de37ba4232c5 new file mode 100644 index 0000000000000000000000000000000000000000..bd179b5f5406f12f948b97d871c763cc0e10b06f GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*l7TPFW=Z#znt$mTQs*sKaSJTisnP-fi0mQg3zH~C literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2_target/.gitted/objects/41/bd4bc3df978de695f67ace64c560913da11653 b/tests-clar/resources/submod2_target/.gitted/objects/41/bd4bc3df978de695f67ace64c560913da11653 new file mode 100644 index 0000000000000000000000000000000000000000..ccf49bd15cac3c2bac13fa644f20924a6928dead GIT binary patch literal 163 zcmV;U09^lg0hNx~4Z<)G1^IRr+W=^NtQ|`T0VU9Zv)&w14&*rf;}+2TJYIve6?|_sH;Eh(2DY7+$k{q!!fw!> z(TR3ZR66Ul7xvZ-v-q#0c>kLs07~zTmQMI-8)u#UYRIi-p RZG8X>-X+A`MI6N*Dz6QY4Oxv{b!#F?R3>Zey&Eh^ zLz#U_A&YRfX{+!#kAs&5Uc8K4;a=nOJGbeKx3rZ94B99}B8703PD;_&{;zfVZz|>;+Qv+EoOhlpLYZ1IW9p#9+rkUf;jILVt%D7~a-( zHi)r&*iZ%W*dq%vm(oN!T~(-~7mAT<%e|zi#OU5_=*u97N%F)=dM#H`s@SPCR?3Xz zYe>>UAWW_u_S^>i9Q&@z0(V`y4!Di!`!U<|m_B)1zaXR>5o?JA7hk-0Cq4h{RR3GL V-?ucIUk@ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA&VW?_0N)ENv?9b#1W-nHoB8!Ax%es2L;m5j-ce literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2_target/.gitted/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a b/tests-clar/resources/submod2_target/.gitted/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a new file mode 100644 index 000000000..6d27af8a8 --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/objects/78/0d7397f5e8f8f477fb55b7af3accc2154b2d4a @@ -0,0 +1,2 @@ +x-10 Fa0p(N-ӡғq]>ks*? |m“i@mV'`).-1 x +uxt(+ \ No newline at end of file diff --git a/tests-clar/resources/submod2_target/.gitted/objects/78/9efbdadaa4a582778d4584385495559ea0994b b/tests-clar/resources/submod2_target/.gitted/objects/78/9efbdadaa4a582778d4584385495559ea0994b new file mode 100644 index 000000000..17458840b --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/objects/78/9efbdadaa4a582778d4584385495559ea0994b @@ -0,0 +1,2 @@ +x 0 )?= NlOkj8&r +qJW7B<fK8#Q1C-"e̫>'@ \ No newline at end of file diff --git a/tests-clar/resources/submod2_target/.gitted/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e b/tests-clar/resources/submod2_target/.gitted/objects/88/34b635dd468a83cb012f6feace968c1c9f5d6e new file mode 100644 index 0000000000000000000000000000000000000000..83cc29fb159ab59087d724473642a0057d841358 GIT binary patch literal 81 zcmV-X0IvUd0ZYosPf{?mWC+Q~ELH%bM1{1>oK%I9e1+Wnl+3hBh0HvK;?g7_r!*(E nn9H+7Au*>YH8G`9AtSL^p*TM`RRO58B)_OqkBbWc`{EjQ6-gx7 literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2_target/.gitted/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 b/tests-clar/resources/submod2_target/.gitted/objects/d0/5f2cd5cc77addf68ed6f50d622c9a4f732e6c5 new file mode 100644 index 0000000000000000000000000000000000000000..55bda40ef277279310f6bf3122497c14602374d6 GIT binary patch literal 93 zcmV-j0HXhR0V^p=O;xZkU@$Z=Ff%bx2y%6F@paWJsVHHn;4Pm1^~H}b<-bF>ueUmL zNYq=`3#uwDGbc5^BtJekKP5A*lA*(7o9SJ*uIAH>`uVTUP3w`FADagNj^84oNOvn! literal 0 HcmV?d00001 diff --git a/tests-clar/resources/submod2_target/.gitted/refs/heads/master b/tests-clar/resources/submod2_target/.gitted/refs/heads/master new file mode 100644 index 000000000..e12c44d7a --- /dev/null +++ b/tests-clar/resources/submod2_target/.gitted/refs/heads/master @@ -0,0 +1 @@ +480095882d281ed676fe5b863569520e54a7d5c0 diff --git a/tests-clar/resources/submod2_target/README.txt b/tests-clar/resources/submod2_target/README.txt new file mode 100644 index 000000000..780d7397f --- /dev/null +++ b/tests-clar/resources/submod2_target/README.txt @@ -0,0 +1,3 @@ +This is the target for submod2 submodule links. +Don't add commits casually because you make break tests. + diff --git a/tests-clar/resources/submod2_target/file_to_modify b/tests-clar/resources/submod2_target/file_to_modify new file mode 100644 index 000000000..789efbdad --- /dev/null +++ b/tests-clar/resources/submod2_target/file_to_modify @@ -0,0 +1,3 @@ +This is a file to modify in submodules +It already has some history. +You can add local changes as needed. From aa13bf05c84f10f364ce35c5d4f989337b36e043 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 2 Aug 2012 13:00:58 -0700 Subject: [PATCH 2/5] Major submodule rewrite This replaces the old submodule API with a new extended API that supports most of the things that can be done with `git submodule`. --- include/git2/errors.h | 1 + include/git2/submodule.h | 469 ++++++- src/config_file.c | 6 + src/config_file.h | 12 + src/diff.c | 2 +- src/submodule.c | 1483 +++++++++++++++++++--- src/submodule.h | 94 ++ tests-clar/status/submodules.c | 16 +- tests-clar/submodule/lookup.c | 110 ++ tests-clar/submodule/modify.c | 256 ++++ tests-clar/submodule/status.c | 44 + tests-clar/submodule/submodule_helpers.c | 84 ++ tests-clar/submodule/submodule_helpers.h | 2 + 13 files changed, 2326 insertions(+), 253 deletions(-) create mode 100644 src/submodule.h create mode 100644 tests-clar/submodule/lookup.c create mode 100644 tests-clar/submodule/modify.c create mode 100644 tests-clar/submodule/status.c create mode 100644 tests-clar/submodule/submodule_helpers.c create mode 100644 tests-clar/submodule/submodule_helpers.h diff --git a/include/git2/errors.h b/include/git2/errors.h index 2ab1da403..b55f8c30d 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -54,6 +54,7 @@ typedef enum { GITERR_TREE, GITERR_INDEXER, GITERR_SSL, + GITERR_SUBMODULE, } git_error_t; /** diff --git a/include/git2/submodule.h b/include/git2/submodule.h index f65911a3b..6cd66465e 100644 --- a/include/git2/submodule.h +++ b/include/git2/submodule.h @@ -20,54 +20,169 @@ */ GIT_BEGIN_DECL +/** + * Opaque structure representing a submodule. + * + * Submodule support in libgit2 builds a list of known submodules and keeps + * it in the repository. The list is built from the .gitmodules file, the + * .git/config file, the index, and the HEAD tree. Items in the working + * directory that look like submodules (i.e. a git repo) but are not + * mentioned in those places won't be tracked. + */ +typedef struct git_submodule git_submodule; + +/** + * Values that could be specified for the update rule of a submodule. + * + * Use the DEFAULT value if you have altered the update value via + * `git_submodule_set_update()` and wish to reset to the original default. + */ typedef enum { + GIT_SUBMODULE_UPDATE_DEFAULT = -1, GIT_SUBMODULE_UPDATE_CHECKOUT = 0, GIT_SUBMODULE_UPDATE_REBASE = 1, - GIT_SUBMODULE_UPDATE_MERGE = 2 + GIT_SUBMODULE_UPDATE_MERGE = 2, + GIT_SUBMODULE_UPDATE_NONE = 3 } git_submodule_update_t; +/** + * Values that could be specified for how closely to examine the + * working directory when getting submodule status. + * + * Use the DEFUALT value if you have altered the ignore value via + * `git_submodule_set_ignore()` and wish to reset to the original value. + */ typedef enum { - GIT_SUBMODULE_IGNORE_ALL = 0, /* never dirty */ - GIT_SUBMODULE_IGNORE_DIRTY = 1, /* only dirty if HEAD moved */ - GIT_SUBMODULE_IGNORE_UNTRACKED = 2, /* dirty if tracked files change */ - GIT_SUBMODULE_IGNORE_NONE = 3 /* any change or untracked == dirty */ + GIT_SUBMODULE_IGNORE_DEFAULT = -1, /* reset to default */ + GIT_SUBMODULE_IGNORE_NONE = 0, /* any change or untracked == dirty */ + GIT_SUBMODULE_IGNORE_UNTRACKED = 1, /* dirty if tracked files change */ + GIT_SUBMODULE_IGNORE_DIRTY = 2, /* only dirty if HEAD moved */ + GIT_SUBMODULE_IGNORE_ALL = 3 /* never dirty */ } git_submodule_ignore_t; /** - * Description of submodule + * Status values for submodules. * - * This record describes a submodule found in a repository. There - * should be an entry for every submodule found in the HEAD and for - * every submodule described in .gitmodules. The fields are as follows: - * - * - `name` is the name of the submodule from .gitmodules. - * - `path` is the path to the submodule from the repo working directory. - * It is almost always the same as `name`. - * - `url` is the url for the submodule. - * - `oid` is the HEAD SHA1 for the submodule. - * - `update` is a value from above - see gitmodules(5) update. - * - `ignore` is a value from above - see gitmodules(5) ignore. - * - `fetch_recurse` is 0 or 1 - see gitmodules(5) fetchRecurseSubmodules. - * - `refcount` is for internal use. - * - * If the submodule has been added to .gitmodules but not yet git added, - * then the `oid` will be zero. If the submodule has been deleted, but - * the delete has not been committed yet, then the `oid` will be set, but - * the `url` will be NULL. + * One of these values will be returned for the submodule in the index + * relative to the HEAD tree, and one will be returned for the submodule in + * the working directory relative to the index. The value can be extracted + * from the actual submodule status return value using one of the macros + * below (see GIT_SUBMODULE_INDEX_STATUS and GIT_SUBMODULE_WD_STATUS). */ -typedef struct { - char *name; - char *path; - char *url; - git_oid oid; /* sha1 of submodule HEAD ref or zero if not committed */ - git_submodule_update_t update; - git_submodule_ignore_t ignore; - int fetch_recurse; - int refcount; -} git_submodule; +enum { + GIT_SUBMODULE_STATUS_CLEAN = 0, + GIT_SUBMODULE_STATUS_ADDED = 1, + GIT_SUBMODULE_STATUS_REMOVED = 2, + GIT_SUBMODULE_STATUS_REMOVED_TYPE_CHANGE = 3, + GIT_SUBMODULE_STATUS_MODIFIED = 4, + GIT_SUBMODULE_STATUS_MODIFIED_AHEAD = 5, + GIT_SUBMODULE_STATUS_MODIFIED_BEHIND = 6 +}; /** - * Iterate over all submodules of a repository. + * Return codes for submodule status. + * + * A combination of these flags (and shifted values of the + * GIT_SUBMODULE_STATUS codes above) will be returned to describe the status + * of a submodule. + * + * Submodule info is contained in 4 places: the HEAD tree, the index, config + * files (both .git/config and .gitmodules), and the working directory. Any + * or all of those places might be missing information about the submodule + * depending on what state the repo is in. + * + * When you ask for submodule status, we consider all four places and return + * a combination of the flags below. Also, we also compare HEAD to index to + * workdir, and return a relative status code (see above) for the + * comparisons. Use the GIT_SUBMODULE_INDEX_STATUS() and + * GIT_SUBMODULE_WD_STATUS() macros to extract these status codes from the + * results. As an example, if the submodule exists in the HEAD and does not + * exist in the index, then using GIT_SUBMODULE_INDEX_STATUS(st) will return + * GIT_SUBMODULE_STATUS_REMOVED. + * + * The ignore settings for the submodule will control how much status info + * you get about the working directory. For example, with ignore ALL, the + * workdir will always show as clean. With any ignore level below NONE, + * you will never get the WD_HAS_UNTRACKED value back. + * + * The other SUBMODULE_STATUS values you might see are: + * + * - IN_HEAD means submodule exists in HEAD tree + * - IN_INDEX means submodule exists in index + * - IN_CONFIG means submodule exists in config + * - IN_WD means submodule exists in workdir and looks like a submodule + * - WD_CHECKED_OUT means submodule in workdir has .git content + * - WD_HAS_UNTRACKED means workdir contains untracked files. This would + * only ever be returned for ignore value GIT_SUBMODULE_IGNORE_NONE. + * - WD_MISSING_COMMITS means workdir repo is out of date and does not + * contain the SHAs from either the index or the HEAD tree + */ +#define GIT_SUBMODULE_STATUS_IN_HEAD (1u << 0) +#define GIT_SUBMODULE_STATUS_IN_INDEX (1u << 1) +#define GIT_SUBMODULE_STATUS_IN_CONFIG (1u << 2) +#define GIT_SUBMODULE_STATUS_IN_WD (1u << 3) +#define GIT_SUBMODULE_STATUS_INDEX_DATA_OFFSET (4) +#define GIT_SUBMODULE_STATUS_WD_DATA_OFFSET (7) +#define GIT_SUBMODULE_STATUS_WD_CHECKED_OUT (1u << 10) +#define GIT_SUBMODULE_STATUS_WD_HAS_UNTRACKED (1u << 11) +#define GIT_SUBMODULE_STATUS_WD_MISSING_COMMITS (1u << 12) + +/** + * Extract submodule status value for index from status mask. + */ +#define GIT_SUBMODULE_INDEX_STATUS(s) \ + (((s) >> GIT_SUBMODULE_STATUS_INDEX_DATA_OFFSET) & 0x07) + +/** + * Extract submodule status value for working directory from status mask. + */ +#define GIT_SUBMODULE_WD_STATUS(s) \ + (((s) >> GIT_SUBMODULE_STATUS_WD_DATA_OFFSET) & 0x07) + +/** + * Lookup submodule information by name or path. + * + * Given either the submodule name or path (they are usually the same), this + * returns a structure describing the submodule. + * + * There are two expected error scenarios: + * + * - The submodule is not mentioned in the HEAD, the index, and the config, + * but does "exist" in the working directory (i.e. there is a subdirectory + * that is a valid self-contained git repo). In this case, this function + * returns GIT_EEXISTS to indicate the the submodule exists but not in a + * state where a git_submodule can be instantiated. + * - The submodule is not mentioned in the HEAD, index, or config and the + * working directory doesn't contain a value git repo at that path. + * There may or may not be anything else at that path, but nothing that + * looks like a submodule. In this case, this returns GIT_ENOTFOUND. + * + * The submodule object is owned by the containing repo and will be freed + * when the repo is freed. The caller need not free the submodule. + * + * @param submodule Pointer to submodule description object pointer.. + * @param repo The repository. + * @param name The name of the submodule. Trailing slashes will be ignored. + * @return 0 on success, GIT_ENOTFOUND if submodule does not exist, + * GIT_EEXISTS if submodule exists in working directory only, -1 on + * other errors. + */ +GIT_EXTERN(int) git_submodule_lookup( + git_submodule **submodule, + git_repository *repo, + const char *name); + +/** + * Iterate over all tracked submodules of a repository. + * + * See the note on `git_submodule` above. This iterates over the tracked + * submodules as decribed therein. + * + * If you are concerned about items in the working directory that look like + * submodules but are not tracked, the diff API will generate a diff record + * for workdir items that look like submodules but are not tracked, showing + * them as added in the workdir. Also, the status API will treat the entire + * subdirectory of a contained git repo as a single GIT_STATUS_WT_NEW item. * * @param repo The repository * @param callback Function to be called with the name of each submodule. @@ -77,26 +192,286 @@ typedef struct { */ GIT_EXTERN(int) git_submodule_foreach( git_repository *repo, - int (*callback)(const char *name, void *payload), + int (*callback)(git_submodule *sm, const char *name, void *payload), void *payload); /** - * Lookup submodule information by name or path. + * Set up a new git submodule for checkout. * - * Given either the submodule name or path (they are usually the same), - * this returns a structure describing the submodule. If the submodule - * does not exist, this will return GIT_ENOTFOUND and set the submodule - * pointer to NULL. + * This does "git submodule add" up to the fetch and checkout of the + * submodule contents. It preps a new submodule, creates an entry in + * .gitmodules and creates an empty initialized repository either at the + * given path in the working directory or in .git/modules with a gitlink + * from the working directory to the new repo. * - * @param submodule Pointer to submodule description object pointer.. - * @param repo The repository. - * @param name The name of the submodule. Trailing slashes will be ignored. - * @return 0 on success, GIT_ENOTFOUND if submodule does not exist, -1 on error + * To fully emulate "git submodule add" call this function, then open the + * submodule repo and perform the clone step as needed. Lastly, call + * `git_submodule_add_finalize` to wrap up adding the new submodule and + * .gitmodules to the index to be ready to commit. + * + * @param submodule The newly created submodule ready to open for clone + * @param repo Superproject repository to contain the new submodule + * @param url URL for the submodules remote + * @param path Path at which the submodule should be created + * @param use_gitlink Should workdir contain a gitlink to the repo in + * .git/modules vs. repo directly in workdir. + * @return 0 on success, GIT_EEXISTS if submodule already exists, + * -1 on other errors. */ -GIT_EXTERN(int) git_submodule_lookup( +GIT_EXTERN(int) git_submodule_add_setup( git_submodule **submodule, git_repository *repo, - const char *name); + const char *url, + const char *path, + int use_gitlink); + +/** + * Resolve the setup of a new git submodule. + * + * This should be called on a submodule once you have called add setup + * and done the clone of the submodule. This adds the .gitmodules file + * and the newly cloned submodule to the index to be ready to be committed + * (but doesn't actually do the commit). + */ +GIT_EXTERN(int) git_submodule_add_finalize(git_submodule *submodule); + +/** + * Add current submodule HEAD commit to index of superproject. + */ +GIT_EXTERN(int) git_submodule_add_to_index(git_submodule *submodule); + +/** + * Write submodule settings to .gitmodules file. + * + * This commits any in-memory changes to the submodule to the gitmodules + * file on disk. You may also be interested in `git_submodule_init` which + * writes submodule info to ".git/config" (which is better for local changes + * to submodule settings) and/or `git_submodule_sync` which writes settings + * about remotes to the actual submodule repository. + * + * @param submodule The submodule to write. + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_submodule_save(git_submodule *submodule); + +/** + * Get the containing repository for a submodule. + * + * This returns a pointer to the repository that contains the submodule. + * This is a just a reference to the repository that was passed to the + * original `git_submodule_lookup` call, so if that repository has been + * freed, then this may be a dangling reference. + * + * @param submodule Pointer to submodule object + * @return Pointer to `git_repository` + */ +GIT_EXTERN(git_repository *) git_submodule_owner(git_submodule *submodule); + +/** + * Get the name of submodule. + * + * @param submodule Pointer to submodule object + * @return Pointer to the submodule name + */ +GIT_EXTERN(const char *) git_submodule_name(git_submodule *submodule); + +/** + * Get the path to the submodule. + * + * The path is almost always the same as the submodule name, but the + * two are actually not required to match. + * + * @param submodule Pointer to submodule object + * @return Pointer to the submodule path + */ +GIT_EXTERN(const char *) git_submodule_path(git_submodule *submodule); + +/** + * Get the URL for the submodule. + * + * @param submodule Pointer to submodule object + * @return Pointer to the submodule url + */ +GIT_EXTERN(const char *) git_submodule_url(git_submodule *submodule); + +/** + * Set the URL for the submodule. + * + * This sets the URL in memory for the submodule. This will be used for + * any following submodule actions while this submodule data is in memory. + * + * After calling this, you may wish to call `git_submodule_save` to write + * the changes back to the ".gitmodules" file and `git_submodule_sync` to + * write the changes to the checked out submodule repository. + * + * @param submodule Pointer to the submodule object + * @param url URL that should be used for the submodule + * @return 0 on success, <0 on failure + */ +GIT_EXTERN(int) git_submodule_set_url(git_submodule *submodule, const char *url); + +/** + * Get the OID for the submodule in the index. + * + * @param submodule Pointer to submodule object + * @return Pointer to git_oid or NULL if submodule is not in index. + */ +GIT_EXTERN(const git_oid *) git_submodule_index_oid(git_submodule *submodule); + +/** + * Get the OID for the submodule in the current HEAD tree. + * + * @param submodule Pointer to submodule object + * @return Pointer to git_oid or NULL if submodule is not in the HEAD. + */ +GIT_EXTERN(const git_oid *) git_submodule_head_oid(git_submodule *submodule); + +/** + * Get the OID for the submodule in the current working directory. + * + * This returns the OID that corresponds to looking up 'HEAD' in the checked + * out submodule. If there are pending changes in the index or anything + * else, this won't notice that. You should call `git_submodule_status` for + * a more complete picture about the state of the working directory. + * + * @param submodule Pointer to submodule object + * @return Pointer to git_oid or NULL if submodule is not checked out. + */ +GIT_EXTERN(const git_oid *) git_submodule_wd_oid(git_submodule *submodule); + +/** + * Get the ignore rule for the submodule. + * + * There are four ignore values: + * + * - **GIT_SUBMODULE_IGNORE_NONE** will consider any change to the contents + * of the submodule from a clean checkout to be dirty, including the + * addition of untracked files. This is the default if unspecified. + * - **GIT_SUBMODULE_IGNORE_UNTRACKED** examines the contents of the + * working tree (i.e. call `git_status_foreach` on the submodule) but + * UNTRACKED files will not count as making the submodule dirty. + * - **GIT_SUBMODULE_IGNORE_DIRTY** means to only check if the HEAD of the + * submodule has moved for status. This is fast since it does not need to + * scan the working tree of the submodule at all. + * - **GIT_SUBMODULE_IGNORE_ALL** means not to open the submodule repo. + * The working directory will be consider clean so long as there is a + * checked out version present. + */ +GIT_EXTERN(git_submodule_ignore_t) git_submodule_ignore( + git_submodule *submodule); + +/** + * Set the ignore rule for the submodule. + * + * This sets the ignore rule in memory for the submodule. This will be used + * for any following actions (such as `git_submodule_status`) while the + * submodule is in memory. You should call `git_submodule_save` if you want + * to persist the new ignore role. + * + * Calling this again with GIT_SUBMODULE_IGNORE_DEFAULT or calling + * `git_submodule_reload` will revert the rule to the value that was in the + * original config. + * + * @return old value for ignore + */ +GIT_EXTERN(git_submodule_ignore_t) git_submodule_set_ignore( + git_submodule *submodule, + git_submodule_ignore_t ignore); + +/** + * Get the update rule for the submodule. + */ +GIT_EXTERN(git_submodule_update_t) git_submodule_update( + git_submodule *submodule); + +/** + * Set the update rule for the submodule. + * + * This sets the update rule in memory for the submodule. You should call + * `git_submodule_save` if you want to persist the new update rule. + * + * Calling this again with GIT_SUBMODULE_UPDATE_DEFAULT or calling + * `git_submodule_reload` will revert the rule to the value that was in the + * original config. + * + * @return old value for update + */ +GIT_EXTERN(git_submodule_update_t) git_submodule_set_update( + git_submodule *submodule, + git_submodule_update_t update); + +/** + * Copy submodule info into ".git/config" file. + * + * Just like "git submodule init", this copies information about the + * submodule into ".git/config". You can use the accessor functions + * above to alter the in-memory git_submodule object and control what + * is written to the config, overriding what is in .gitmodules. + * + * @param submodule The submodule to write into the superproject config + * @param overwrite By default, existing entries will not be overwritten, + * but setting this to true forces them to be updated. + * @return 0 on success, <0 on failure. + */ +GIT_EXTERN(int) git_submodule_init(git_submodule *submodule, int overwrite); + +/** + * Copy submodule remote info into submodule repo. + * + * This copies the information about the submodules URL into the checked out + * submodule config, acting like "git submodule sync". This is useful if + * you have altered the URL for the submodule (or it has been altered by a + * fetch of upstream changes) and you need to update your local repo. + */ +GIT_EXTERN(int) git_submodule_sync(git_submodule *submodule); + +/** + * Open the repository for a submodule. + * + * This is a newly opened repository object. The caller is responsible for + * calling `git_repository_free` on it when done. Multiple calls to this + * function will return distinct `git_repository` objects. This will only + * work if the submodule is checked out into the working directory. + * + * @param subrepo Pointer to the submodule repo which was opened + * @param submodule Submodule to be opened + * @return 0 on success, <0 if submodule repo could not be opened. + */ +GIT_EXTERN(int) git_submodule_open( + git_repository **repo, + git_submodule *submodule); + +/** + * Reread submodule info from config, index, and HEAD. + * + * Call this to reread cached submodule information for this submodule if + * you have reason to believe that it has changed. + */ +GIT_EXTERN(int) git_submodule_reload(git_submodule *submodule); + +/** + * Reread all submodule info. + * + * Call this to reload all cached submodule information for the repo. + */ +GIT_EXTERN(int) git_submodule_reload_all(git_repository *repo); + +/** + * Get the status for a submodule. + * + * This looks at a submodule and tries to determine the status. It + * will return a combination of the `GIT_SUBMODULE_STATUS` values above. + * How deeply it examines the working directory to do this will depend + * on the `git_submodule_ignore_t` value for the submodule (which can be + * overridden with `git_submodule_set_ignore()`). + * + * @param status Combination of GIT_SUBMODULE_STATUS values from above. + * @param submodule Submodule for which to get status + * @return 0 on success, <0 on error + */ +GIT_EXTERN(int) git_submodule_status( + unsigned int *status, + git_submodule *submodule); /** @} */ GIT_END_DECL diff --git a/src/config_file.c b/src/config_file.c index 547509b9f..aabb21f16 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -253,11 +253,17 @@ static int config_set(git_config_file *cfg, const char *name, const char *value) char *tmp = NULL; git__free(key); + if (existing->next != NULL) { giterr_set(GITERR_CONFIG, "Multivar incompatible with simple set"); return -1; } + /* don't update if old and new values already match */ + if ((!existing->value && !value) || + (existing->value && value && !strcmp(existing->value, value))) + return 0; + if (value) { tmp = git__strdup(value); GITERR_CHECK_ALLOC(tmp); diff --git a/src/config_file.h b/src/config_file.h index c31292881..bf687b516 100644 --- a/src/config_file.h +++ b/src/config_file.h @@ -19,12 +19,24 @@ GIT_INLINE(void) git_config_file_free(git_config_file *cfg) cfg->free(cfg); } +GIT_INLINE(int) git_config_file_get_string( + const char **out, git_config_file *cfg, const char *name) +{ + return cfg->get(cfg, name, out); +} + GIT_INLINE(int) git_config_file_set_string( git_config_file *cfg, const char *name, const char *value) { return cfg->set(cfg, name, value); } +GIT_INLINE(int) git_config_file_delete( + git_config_file *cfg, const char *name) +{ + return cfg->del(cfg, name); +} + GIT_INLINE(int) git_config_file_foreach( git_config_file *cfg, int (*fn)(const char *key, const char *value, void *data), diff --git a/src/diff.c b/src/diff.c index 9abf8b9f5..430f52e0a 100644 --- a/src/diff.c +++ b/src/diff.c @@ -530,7 +530,7 @@ static int maybe_modified( status = GIT_DELTA_UNMODIFIED; else if (git_submodule_lookup(&sub, diff->repo, nitem->path) < 0) return -1; - else if (sub->ignore == GIT_SUBMODULE_IGNORE_ALL) + else if (git_submodule_ignore(sub) == GIT_SUBMODULE_IGNORE_ALL) status = GIT_DELTA_UNMODIFIED; else { /* TODO: support other GIT_SUBMODULE_IGNORE values */ diff --git a/src/submodule.c b/src/submodule.c index b8537cb8c..9a852041a 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -17,18 +17,24 @@ #include "config_file.h" #include "config.h" #include "repository.h" +#include "submodule.h" +#include "tree.h" +#include "iterator.h" + +#define GIT_MODULES_FILE ".gitmodules" static git_cvar_map _sm_update_map[] = { {GIT_CVAR_STRING, "checkout", GIT_SUBMODULE_UPDATE_CHECKOUT}, {GIT_CVAR_STRING, "rebase", GIT_SUBMODULE_UPDATE_REBASE}, - {GIT_CVAR_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE} + {GIT_CVAR_STRING, "merge", GIT_SUBMODULE_UPDATE_MERGE}, + {GIT_CVAR_STRING, "none", GIT_SUBMODULE_UPDATE_NONE}, }; static git_cvar_map _sm_ignore_map[] = { - {GIT_CVAR_STRING, "all", GIT_SUBMODULE_IGNORE_ALL}, - {GIT_CVAR_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY}, + {GIT_CVAR_STRING, "none", GIT_SUBMODULE_IGNORE_NONE}, {GIT_CVAR_STRING, "untracked", GIT_SUBMODULE_IGNORE_UNTRACKED}, - {GIT_CVAR_STRING, "none", GIT_SUBMODULE_IGNORE_NONE} + {GIT_CVAR_STRING, "dirty", GIT_SUBMODULE_IGNORE_DIRTY}, + {GIT_CVAR_STRING, "all", GIT_SUBMODULE_IGNORE_ALL}, }; static kh_inline khint_t str_hash_no_trailing_slash(const char *s) @@ -55,9 +61,725 @@ static kh_inline int str_equal_no_trailing_slash(const char *a, const char *b) return (alen == blen && strncmp(a, b, alen) == 0); } -__KHASH_IMPL(str, static kh_inline, const char *, void *, 1, str_hash_no_trailing_slash, str_equal_no_trailing_slash); +__KHASH_IMPL( + str, static kh_inline, const char *, void *, 1, + str_hash_no_trailing_slash, str_equal_no_trailing_slash); -static git_submodule *submodule_alloc(const char *name) +static int load_submodule_config( + git_repository *repo, bool force); +static git_config_file *open_gitmodules( + git_repository *, bool, const git_oid *); +static int lookup_head_remote( + git_buf *url, git_repository *repo); +static git_submodule *submodule_lookup_or_create( + git_repository *repo, const char *n1, const char *n2); +static int submodule_update_map( + git_repository *repo, git_submodule *sm, const char *key); +static void submodule_release( + git_submodule *sm, int decr); +static int submodule_load_from_index( + git_repository *, const git_index_entry *); +static int submodule_load_from_head( + git_repository *, const char *, const git_oid *); +static int submodule_load_from_config( + const char *, const char *, void *); +static int submodule_update_config( + git_submodule *, const char *, const char *, bool, bool); + +static int submodule_cmp(const void *a, const void *b) +{ + return strcmp(((git_submodule *)a)->name, ((git_submodule *)b)->name); +} + +static int submodule_config_key_trunc_puts(git_buf *key, const char *suffix) +{ + ssize_t idx = git_buf_rfind(key, '.'); + git_buf_truncate(key, (size_t)(idx + 1)); + return git_buf_puts(key, suffix); +} + +/* + * PUBLIC APIS + */ + +int git_submodule_lookup( + git_submodule **sm_ptr, /* NULL if user only wants to test existence */ + git_repository *repo, + const char *name) /* trailing slash is allowed */ +{ + int error; + khiter_t pos; + + assert(repo && name); + + if ((error = load_submodule_config(repo, false)) < 0) + return error; + + pos = git_strmap_lookup_index(repo->submodules, name); + + if (!git_strmap_valid_index(repo->submodules, pos)) { + error = GIT_ENOTFOUND; + + /* check if a plausible submodule exists at path */ + if (git_repository_workdir(repo)) { + git_buf path = GIT_BUF_INIT; + + if (git_buf_joinpath(&path, git_repository_workdir(repo), name) < 0) + return -1; + + if (git_path_contains_dir(&path, DOT_GIT)) + error = GIT_EEXISTS; + + git_buf_free(&path); + } + + return error; + } + + if (sm_ptr) + *sm_ptr = git_strmap_value_at(repo->submodules, pos); + + return 0; +} + +int git_submodule_foreach( + git_repository *repo, + int (*callback)(git_submodule *sm, const char *name, void *payload), + void *payload) +{ + int error; + git_submodule *sm; + git_vector seen = GIT_VECTOR_INIT; + seen._cmp = submodule_cmp; + + assert(repo && callback); + + if ((error = load_submodule_config(repo, false)) < 0) + return error; + + git_strmap_foreach_value(repo->submodules, sm, { + /* Usually the following will not come into play - it just prevents + * us from issuing a callback twice for a submodule where the name + * and path are not the same. + */ + if (sm->refcount > 1) { + if (git_vector_bsearch(&seen, sm) != GIT_ENOTFOUND) + continue; + if ((error = git_vector_insert(&seen, sm)) < 0) + break; + } + + if ((error = callback(sm, sm->name, payload)) < 0) + break; + }); + + git_vector_free(&seen); + + return error; +} + +void git_submodule_config_free(git_repository *repo) +{ + git_strmap *smcfg; + git_submodule *sm; + + assert(repo); + + smcfg = repo->submodules; + repo->submodules = NULL; + + if (smcfg == NULL) + return; + + git_strmap_foreach_value(smcfg, sm, { + submodule_release(sm,1); + }); + git_strmap_free(smcfg); +} + +int git_submodule_add_setup( + git_submodule **submodule, + git_repository *repo, + const char *url, + const char *path, + int use_gitlink) +{ + int error = 0; + git_config_file *mods = NULL; + git_submodule *sm; + git_buf name = GIT_BUF_INIT, real_url = GIT_BUF_INIT; + git_repository_init_options initopt; + git_repository *subrepo = NULL; + + assert(repo && url && path); + + /* see if there is already an entry for this submodule */ + + if (git_submodule_lookup(&sm, repo, path) < 0) + giterr_clear(); + else { + giterr_set(GITERR_SUBMODULE, + "Attempt to add a submodule that already exists"); + return GIT_EEXISTS; + } + + /* resolve parameters */ + + if (url[0] == '.' && (url[1] == '/' || (url[1] == '.' && url[2] == '/'))) { + if (!(error = lookup_head_remote(&real_url, repo))) + error = git_path_apply_relative(&real_url, url); + } else if (strchr(url, ':') != NULL || url[0] == '/') { + error = git_buf_sets(&real_url, url); + } else { + giterr_set(GITERR_SUBMODULE, "Invalid format for submodule URL"); + error = -1; + } + if (error) + goto cleanup; + + /* validate and normalize path */ + + if (git__prefixcmp(path, git_repository_workdir(repo)) == 0) + path += strlen(git_repository_workdir(repo)); + + if (git_path_root(path) >= 0) { + giterr_set(GITERR_SUBMODULE, "Submodule path must be a relative path"); + error = -1; + goto cleanup; + } + + /* update .gitmodules */ + + if ((mods = open_gitmodules(repo, true, NULL)) == NULL) { + giterr_set(GITERR_SUBMODULE, + "Adding submodules to a bare repository is not supported (for now)"); + return -1; + } + + if ((error = git_buf_printf(&name, "submodule.%s.path", path)) < 0 || + (error = git_config_file_set_string(mods, name.ptr, path)) < 0) + goto cleanup; + + if ((error = submodule_config_key_trunc_puts(&name, "url")) < 0 || + (error = git_config_file_set_string(mods, name.ptr, real_url.ptr)) < 0) + goto cleanup; + + git_buf_clear(&name); + + /* init submodule repository and add origin remote as needed */ + + error = git_buf_joinpath(&name, git_repository_workdir(repo), path); + if (error < 0) + goto cleanup; + + /* New style: sub-repo goes in /modules// with a + * gitlink in the sub-repo workdir directory to that repository + * + * Old style: sub-repo goes directly into repo//.git/ + */ + + memset(&initopt, 0, sizeof(initopt)); + initopt.flags = GIT_REPOSITORY_INIT_MKPATH | + GIT_REPOSITORY_INIT_NO_REINIT; + initopt.origin_url = real_url.ptr; + + if (git_path_exists(name.ptr) && + git_path_contains(&name, DOT_GIT)) + { + /* repo appears to already exist - reinit? */ + } + else if (use_gitlink) { + git_buf repodir = GIT_BUF_INIT; + + error = git_buf_join_n( + &repodir, '/', 3, git_repository_path(repo), "modules", path); + if (error < 0) + goto cleanup; + + initopt.workdir_path = name.ptr; + initopt.flags |= GIT_REPOSITORY_INIT_NO_DOTGIT_DIR; + + error = git_repository_init_ext(&subrepo, repodir.ptr, &initopt); + + git_buf_free(&repodir); + } + else { + error = git_repository_init_ext(&subrepo, name.ptr, &initopt); + } + if (error < 0) + goto cleanup; + + /* add submodule to hash and "reload" it */ + + if ((sm = submodule_lookup_or_create(repo, path, NULL)) == NULL) { + error = -1; + goto cleanup; + } + + if ((error = submodule_update_map(repo, sm, sm->path)) < 0) + goto cleanup; + + if ((error = git_submodule_reload(sm)) < 0) + goto cleanup; + + error = git_submodule_init(sm, false); + +cleanup: + if (submodule != NULL) + *submodule = !error ? sm : NULL; + + if (mods != NULL) + git_config_file_free(mods); + git_repository_free(subrepo); + git_buf_free(&real_url); + git_buf_free(&name); + + return error; +} + +int git_submodule_add_finalize(git_submodule *sm) +{ + int error; + git_index *index; + + assert(sm); + + if ((error = git_repository_index__weakptr(&index, sm->owner)) < 0 || + (error = git_index_add(index, GIT_MODULES_FILE, 0)) < 0) + return error; + + return git_submodule_add_to_index(sm); +} + +int git_submodule_add_to_index(git_submodule *sm) +{ + int error; + git_repository *repo, *sm_repo; + git_index *index; + git_buf path = GIT_BUF_INIT; + git_commit *head; + git_index_entry entry; + struct stat st; + + assert(sm); + + repo = sm->owner; + + if ((error = git_repository_index__weakptr(&index, repo)) < 0 || + (error = git_buf_joinpath( + &path, git_repository_workdir(repo), sm->path)) < 0 || + (error = git_submodule_open(&sm_repo, sm)) < 0) + goto cleanup; + + /* read stat information for submodule working directory */ + if (p_stat(path.ptr, &st) < 0) { + giterr_set(GITERR_SUBMODULE, + "Cannot add submodule without working directory"); + error = -1; + goto cleanup; + } + git_index__init_entry_from_stat(&st, &entry); + + /* calling git_submodule_open will have set sm->wd_oid if possible */ + if ((sm->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) == 0) { + giterr_set(GITERR_SUBMODULE, + "Cannot add submodule without HEAD to index"); + error = -1; + goto cleanup; + } + git_oid_cpy(&entry.oid, &sm->wd_oid); + + if ((error = git_commit_lookup(&head, sm_repo, &sm->wd_oid)) < 0) + goto cleanup; + + entry.ctime.seconds = git_commit_time(head); + entry.ctime.nanoseconds = 0; + entry.mtime.seconds = git_commit_time(head); + entry.mtime.nanoseconds = 0; + + git_commit_free(head); + + /* now add it */ + error = git_index_add2(index, &entry); + +cleanup: + git_repository_free(sm_repo); + git_buf_free(&path); + return error; +} + +int git_submodule_save(git_submodule *submodule) +{ + int error = 0; + git_config_file *mods; + git_buf key = GIT_BUF_INIT; + + assert(submodule); + + mods = open_gitmodules(submodule->owner, true, NULL); + if (!mods) { + giterr_set(GITERR_SUBMODULE, + "Adding submodules to a bare repository is not supported (for now)"); + return -1; + } + + if ((error = git_buf_printf(&key, "submodule.%s.", submodule->name)) < 0) + goto cleanup; + + /* save values for path, url, update, ignore, fetchRecurseSubmodules */ + + if ((error = submodule_config_key_trunc_puts(&key, "path")) < 0 || + (error = git_config_file_set_string(mods, key.ptr, submodule->path)) < 0) + goto cleanup; + + if ((error = submodule_config_key_trunc_puts(&key, "url")) < 0 || + (error = git_config_file_set_string(mods, key.ptr, submodule->url)) < 0) + goto cleanup; + + if (!(error = submodule_config_key_trunc_puts(&key, "update")) && + submodule->update != GIT_SUBMODULE_UPDATE_DEFAULT) + { + const char *val = (submodule->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ? + NULL : _sm_update_map[submodule->update].str_match; + error = git_config_file_set_string(mods, key.ptr, val); + } + if (error < 0) + goto cleanup; + + if (!(error = submodule_config_key_trunc_puts(&key, "ignore")) && + submodule->ignore != GIT_SUBMODULE_IGNORE_DEFAULT) + { + const char *val = (submodule->ignore == GIT_SUBMODULE_IGNORE_NONE) ? + NULL : _sm_ignore_map[submodule->ignore].str_match; + error = git_config_file_set_string(mods, key.ptr, val); + } + if (error < 0) + goto cleanup; + + if ((error = submodule_config_key_trunc_puts( + &key, "fetchRecurseSubmodules")) < 0 || + (error = git_config_file_set_string( + mods, key.ptr, submodule->fetch_recurse ? "true" : "false")) < 0) + goto cleanup; + + /* update internal defaults */ + + submodule->ignore_default = submodule->ignore; + submodule->update_default = submodule->update; + submodule->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; + +cleanup: + if (mods != NULL) + git_config_file_free(mods); + git_buf_free(&key); + + return error; +} + +git_repository *git_submodule_owner(git_submodule *submodule) +{ + assert(submodule); + return submodule->owner; +} + +const char *git_submodule_name(git_submodule *submodule) +{ + assert(submodule); + return submodule->name; +} + +const char *git_submodule_path(git_submodule *submodule) +{ + assert(submodule); + return submodule->path; +} + +const char *git_submodule_url(git_submodule *submodule) +{ + assert(submodule); + return submodule->url; +} + +int git_submodule_set_url(git_submodule *submodule, const char *url) +{ + assert(submodule && url); + + git__free(submodule->url); + + submodule->url = git__strdup(url); + GITERR_CHECK_ALLOC(submodule->url); + + return 0; +} + + const git_oid *git_submodule_index_oid(git_submodule *submodule) +{ + assert(submodule); + + if (submodule->flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID) + return &submodule->index_oid; + else + return NULL; +} + +const git_oid *git_submodule_head_oid(git_submodule *submodule) +{ + assert(submodule); + + if (submodule->flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID) + return &submodule->head_oid; + else + return NULL; +} + +const git_oid *git_submodule_wd_oid(git_submodule *submodule) +{ + assert(submodule); + + if (!(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) { + git_repository *subrepo; + + /* calling submodule open grabs the HEAD OID if possible */ + if (!git_submodule_open(&subrepo, submodule)) + git_repository_free(subrepo); + } + + if (submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) + return &submodule->wd_oid; + else + return NULL; +} + +git_submodule_ignore_t git_submodule_ignore(git_submodule *submodule) +{ + assert(submodule); + return submodule->ignore; +} + +git_submodule_ignore_t git_submodule_set_ignore( + git_submodule *submodule, git_submodule_ignore_t ignore) +{ + git_submodule_ignore_t old; + + assert(submodule); + + if (ignore == GIT_SUBMODULE_IGNORE_DEFAULT) + ignore = submodule->ignore_default; + + old = submodule->ignore; + submodule->ignore = ignore; + return old; +} + +git_submodule_update_t git_submodule_update(git_submodule *submodule) +{ + assert(submodule); + return submodule->update; +} + +git_submodule_update_t git_submodule_set_update( + git_submodule *submodule, git_submodule_update_t update) +{ + git_submodule_update_t old; + + assert(submodule); + + if (update == GIT_SUBMODULE_UPDATE_DEFAULT) + update = submodule->update_default; + + old = submodule->update; + submodule->update = update; + return old; +} + +int git_submodule_init(git_submodule *submodule, int overwrite) +{ + int error; + + /* write "submodule.NAME.url" */ + + if (!submodule->url) { + giterr_set(GITERR_SUBMODULE, + "No URL configured for submodule '%s'", submodule->name); + return -1; + } + + error = submodule_update_config( + submodule, "url", submodule->url, overwrite != 0, false); + if (error < 0) + return error; + + /* write "submodule.NAME.update" if not default */ + + if (submodule->update == GIT_SUBMODULE_UPDATE_CHECKOUT) + error = submodule_update_config( + submodule, "update", NULL, (overwrite != 0), false); + else if (submodule->update != GIT_SUBMODULE_UPDATE_DEFAULT) + error = submodule_update_config( + submodule, "update", + _sm_update_map[submodule->update].str_match, + (overwrite != 0), false); + + return error; +} + +int git_submodule_sync(git_submodule *submodule) +{ + if (!submodule->url) { + giterr_set(GITERR_SUBMODULE, + "No URL configured for submodule '%s'", submodule->name); + return -1; + } + + /* copy URL over to config only if it already exists */ + + return submodule_update_config( + submodule, "url", submodule->url, true, true); +} + +int git_submodule_open( + git_repository **subrepo, + git_submodule *submodule) +{ + int error; + git_buf path = GIT_BUF_INIT; + git_repository *repo; + const char *workdir; + + assert(submodule && subrepo); + + repo = submodule->owner; + workdir = git_repository_workdir(repo); + + if (!workdir) { + giterr_set(GITERR_REPOSITORY, + "Cannot open submodule repository in a bare repo"); + return GIT_ENOTFOUND; + } + + if ((submodule->flags & GIT_SUBMODULE_STATUS_IN_WD) == 0) { + giterr_set(GITERR_REPOSITORY, + "Cannot open submodule repository that is not checked out"); + return GIT_ENOTFOUND; + } + + if (git_buf_joinpath(&path, workdir, submodule->path) < 0) + return -1; + + error = git_repository_open(subrepo, path.ptr); + + git_buf_free(&path); + + /* if we have opened the submodule successfully, let's grab the HEAD OID */ + if (!error && !(submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID)) { + if (!git_reference_name_to_oid( + &submodule->wd_oid, *subrepo, GIT_HEAD_FILE)) + submodule->flags |= GIT_SUBMODULE_STATUS__WD_OID_VALID; + else + giterr_clear(); + } + + return error; +} + +int git_submodule_reload_all(git_repository *repo) +{ + assert(repo); + return load_submodule_config(repo, true); +} + +int git_submodule_reload(git_submodule *submodule) +{ + git_repository *repo; + git_index *index; + int pos, error; + git_tree *head; + git_config_file *mods; + + assert(submodule); + + /* refresh index data */ + + repo = submodule->owner; + if (git_repository_index__weakptr(&index, repo) < 0) + return -1; + + pos = git_index_find(index, submodule->path); + if (pos >= 0) { + git_index_entry *entry = git_index_get(index, pos); + + submodule->flags = submodule->flags & + ~(GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS__INDEX_OID_VALID); + + if ((error = submodule_load_from_index(repo, entry)) < 0) + return error; + } + + /* refresh HEAD tree data */ + + if (!(error = git_repository_head_tree(&head, repo))) { + git_tree_entry *te; + + submodule->flags = submodule->flags & + ~(GIT_SUBMODULE_STATUS_IN_HEAD | + GIT_SUBMODULE_STATUS__HEAD_OID_VALID); + + if (!(error = git_tree_entry_bypath(&te, head, submodule->path))) { + error = submodule_load_from_head(repo, submodule->path, &te->oid); + + git_tree_entry_free(te); + } + else if (error == GIT_ENOTFOUND) { + giterr_clear(); + error = 0; + } + + git_tree_free(head); + } + + if (error < 0) + return error; + + /* refresh config data */ + + if ((mods = open_gitmodules(repo, false, NULL)) != NULL) { + git_buf path = GIT_BUF_INIT; + + git_buf_sets(&path, "submodule\\."); + git_buf_puts_escape_regex(&path, submodule->name); + git_buf_puts(&path, ".*"); + + if (git_buf_oom(&path)) + error = -1; + else + error = git_config_file_foreach_match( + mods, path.ptr, submodule_load_from_config, repo); + + git_buf_free(&path); + } + + return error; +} + +int git_submodule_status( + unsigned int *status, + git_submodule *submodule) +{ + assert(status && submodule); + + /* TODO: move status code from below and update */ + + *status = 0; + + return 0; +} + +/* + * INTERNAL FUNCTIONS + */ + +static git_submodule *submodule_alloc(git_repository *repo, const char *name) { git_submodule *sm = git__calloc(1, sizeof(git_submodule)); if (sm == NULL) @@ -69,6 +791,8 @@ static git_submodule *submodule_alloc(const char *name) return NULL; } + sm->owner = repo; + return sm; } @@ -80,69 +804,113 @@ static void submodule_release(git_submodule *sm, int decr) sm->refcount -= decr; if (sm->refcount == 0) { - if (sm->name != sm->path) + if (sm->name != sm->path) { git__free(sm->path); + sm->path = NULL; + } + git__free(sm->name); + sm->name = NULL; + git__free(sm->url); + sm->url = NULL; + + sm->owner = NULL; + git__free(sm); } } -static int submodule_from_entry( - git_strmap *smcfg, git_index_entry *entry) +static git_submodule *submodule_lookup_or_create( + git_repository *repo, const char *n1, const char *n2) { - git_submodule *sm; - void *old_sm; + git_strmap *smcfg = repo->submodules; khiter_t pos; - int error; + git_submodule *sm; - pos = git_strmap_lookup_index(smcfg, entry->path); + assert(n1); - if (git_strmap_valid_index(smcfg, pos)) - sm = git_strmap_value_at(smcfg, pos); + pos = git_strmap_lookup_index(smcfg, n1); + + if (!git_strmap_valid_index(smcfg, pos) && n2) + pos = git_strmap_lookup_index(smcfg, n2); + + if (!git_strmap_valid_index(smcfg, pos)) + sm = submodule_alloc(repo, n1); else - sm = submodule_alloc(entry->path); + sm = git_strmap_value_at(smcfg, pos); - git_oid_cpy(&sm->oid, &entry->oid); - - if (strcmp(sm->path, entry->path) != 0) { - if (sm->path != sm->name) { - git__free(sm->path); - sm->path = sm->name; - } - sm->path = git__strdup(entry->path); - if (!sm->path) - goto fail; - } - - git_strmap_insert2(smcfg, sm->path, sm, old_sm, error); - if (error < 0) - goto fail; - sm->refcount++; - - if (old_sm && ((git_submodule *)old_sm) != sm) { - /* TODO: log warning about multiple entrys for same submodule path */ - submodule_release(old_sm, 1); - } - - return 0; - -fail: - submodule_release(sm, 0); - return -1; + return sm; } -static int submodule_from_config( +static int submodule_update_map( + git_repository *repo, git_submodule *sm, const char *key) +{ + void *old_sm; + int error; + + git_strmap_insert2(repo->submodules, key, sm, old_sm, error); + if (error < 0) { + submodule_release(sm, 0); + return -1; + } + + sm->refcount++; + + if (old_sm && ((git_submodule *)old_sm) != sm) + submodule_release(old_sm, 1); + + return 0; +} + +static int submodule_load_from_index( + git_repository *repo, const git_index_entry *entry) +{ + git_submodule *sm = submodule_lookup_or_create(repo, entry->path, NULL); + + if (!sm) + return -1; + + if (sm->flags & GIT_SUBMODULE_STATUS_IN_INDEX) { + sm->flags |= GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES; + return 0; + } + + sm->flags |= GIT_SUBMODULE_STATUS_IN_INDEX; + + git_oid_cpy(&sm->index_oid, &entry->oid); + sm->flags |= GIT_SUBMODULE_STATUS__INDEX_OID_VALID; + + return submodule_update_map(repo, sm, sm->path); +} + +static int submodule_load_from_head( + git_repository *repo, const char *path, const git_oid *oid) +{ + git_submodule *sm = submodule_lookup_or_create(repo, path, NULL); + + if (!sm) + return -1; + + sm->flags |= GIT_SUBMODULE_STATUS_IN_HEAD; + + git_oid_cpy(&sm->head_oid, oid); + sm->flags |= GIT_SUBMODULE_STATUS__HEAD_OID_VALID; + + return submodule_update_map(repo, sm, sm->path); +} + +static int submodule_load_from_config( const char *key, const char *value, void *data) { - git_strmap *smcfg = data; + git_repository *repo = data; + git_strmap *smcfg = repo->submodules; const char *namestart; const char *property; git_buf name = GIT_BUF_INIT; git_submodule *sm; void *old_sm = NULL; bool is_path; - khiter_t pos; int error; if (git__prefixcmp(key, "submodule.") != 0) @@ -153,21 +921,17 @@ static int submodule_from_config( if (property == NULL) return 0; property++; - is_path = (strcmp(property, "path") == 0); + is_path = (strcasecmp(property, "path") == 0); if (git_buf_set(&name, namestart, property - namestart - 1) < 0) return -1; - pos = git_strmap_lookup_index(smcfg, name.ptr); - if (!git_strmap_valid_index(smcfg, pos) && is_path) - pos = git_strmap_lookup_index(smcfg, value); - if (!git_strmap_valid_index(smcfg, pos)) - sm = submodule_alloc(name.ptr); - else - sm = git_strmap_value_at(smcfg, pos); + sm = submodule_lookup_or_create(repo, name.ptr, is_path ? value : NULL); if (!sm) goto fail; + sm->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; + if (strcmp(sm->name, name.ptr) != 0) { assert(sm->path == sm->name); sm->name = git_buf_detach(&name); @@ -177,7 +941,7 @@ static int submodule_from_config( goto fail; sm->refcount++; } - else if (is_path && strcmp(sm->path, value) != 0) { + else if (is_path && value && strcmp(sm->path, value) != 0) { assert(sm->path == sm->name); sm->path = git__strdup(value); if (sm->path == NULL) @@ -195,19 +959,23 @@ static int submodule_from_config( submodule_release(old_sm, 1); } + /* TODO: Look up path in index and if it is present but not a GITLINK + * then this should be deleted (at least to match git's behavior) + */ + if (is_path) return 0; /* copy other properties into submodule entry */ - if (strcmp(property, "url") == 0) { + if (strcasecmp(property, "url") == 0) { if (sm->url) { git__free(sm->url); sm->url = NULL; } - if ((sm->url = git__strdup(value)) == NULL) + if (value != NULL && (sm->url = git__strdup(value)) == NULL) goto fail; } - else if (strcmp(property, "update") == 0) { + else if (strcasecmp(property, "update") == 0) { int val; if (git_config_lookup_map_value( _sm_update_map, ARRAY_SIZE(_sm_update_map), value, &val) < 0) { @@ -215,16 +983,16 @@ static int submodule_from_config( "Invalid value for submodule update property: '%s'", value); goto fail; } - sm->update = (git_submodule_update_t)val; + sm->update_default = sm->update = (git_submodule_update_t)val; } - else if (strcmp(property, "fetchRecurseSubmodules") == 0) { + else if (strcasecmp(property, "fetchRecurseSubmodules") == 0) { if (git__parse_bool(&sm->fetch_recurse, value) < 0) { giterr_set(GITERR_INVALID, "Invalid value for submodule 'fetchRecurseSubmodules' property: '%s'", value); goto fail; } } - else if (strcmp(property, "ignore") == 0) { + else if (strcasecmp(property, "ignore") == 0) { int val; if (git_config_lookup_map_value( _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), value, &val) < 0) { @@ -232,7 +1000,7 @@ static int submodule_from_config( "Invalid value for submodule ignore property: '%s'", value); goto fail; } - sm->ignore = (git_submodule_ignore_t)val; + sm->ignore_default = sm->ignore = (git_submodule_ignore_t)val; } /* ignore other unknown submodule properties */ @@ -244,144 +1012,471 @@ fail: return -1; } -static int load_submodule_config(git_repository *repo) +static int submodule_load_from_wd_lite( + git_submodule *sm, const char *name, void *payload) { - int error; - git_index *index; - unsigned int i, max_i; - git_oid gitmodules_oid; - git_strmap *smcfg; - struct git_config_file *mods = NULL; + git_repository *repo = git_submodule_owner(sm); + git_buf path = GIT_BUF_INIT; - if (repo->submodules) - return 0; + GIT_UNUSED(name); + GIT_UNUSED(payload); - /* submodule data is kept in a hashtable with each submodule stored - * under both its name and its path. These are usually the same, but - * that is not guaranteed. - */ - smcfg = git_strmap_alloc(); - GITERR_CHECK_ALLOC(smcfg); - - /* scan index for gitmodules (and .gitmodules entry) */ - if ((error = git_repository_index__weakptr(&index, repo)) < 0) - goto cleanup; - memset(&gitmodules_oid, 0, sizeof(gitmodules_oid)); - max_i = git_index_entrycount(index); - - for (i = 0; i < max_i; i++) { - git_index_entry *entry = git_index_get(index, i); - if (S_ISGITLINK(entry->mode)) { - if ((error = submodule_from_entry(smcfg, entry)) < 0) - goto cleanup; - } - else if (strcmp(entry->path, ".gitmodules") == 0) - git_oid_cpy(&gitmodules_oid, &entry->oid); - } - - /* load .gitmodules from workdir if it exists */ - if (git_repository_workdir(repo) != NULL) { - /* look in workdir for .gitmodules */ - git_buf path = GIT_BUF_INIT; - if (!git_buf_joinpath( - &path, git_repository_workdir(repo), ".gitmodules") && - git_path_isfile(path.ptr)) - { - if (!(error = git_config_file__ondisk(&mods, path.ptr))) - error = git_config_file_open(mods); - } - git_buf_free(&path); - } - - /* load .gitmodules from object cache if not in workdir */ - if (!error && mods == NULL && !git_oid_iszero(&gitmodules_oid)) { - /* TODO: is it worth loading gitmodules from object cache? */ - } - - /* process .gitmodules info */ - if (!error && mods != NULL) - error = git_config_file_foreach(mods, submodule_from_config, smcfg); - - /* store submodule config in repo */ - if (!error) - repo->submodules = smcfg; - -cleanup: - if (mods != NULL) - git_config_file_free(mods); - if (error) - git_strmap_free(smcfg); - return error; -} - -void git_submodule_config_free(git_repository *repo) -{ - git_strmap *smcfg = repo->submodules; - git_submodule *sm; - - repo->submodules = NULL; - - if (smcfg == NULL) - return; - - git_strmap_foreach_value(smcfg, sm, { - submodule_release(sm,1); - }); - git_strmap_free(smcfg); -} - -static int submodule_cmp(const void *a, const void *b) -{ - return strcmp(((git_submodule *)a)->name, ((git_submodule *)b)->name); -} - -int git_submodule_foreach( - git_repository *repo, - int (*callback)(const char *name, void *payload), - void *payload) -{ - int error; - git_submodule *sm; - git_vector seen = GIT_VECTOR_INIT; - seen._cmp = submodule_cmp; - - if ((error = load_submodule_config(repo)) < 0) - return error; - - git_strmap_foreach_value(repo->submodules, sm, { - /* usually the following will not come into play */ - if (sm->refcount > 1) { - if (git_vector_bsearch(&seen, sm) != GIT_ENOTFOUND) - continue; - if ((error = git_vector_insert(&seen, sm)) < 0) - break; - } - - if ((error = callback(sm->name, payload)) < 0) - break; - }); - - git_vector_free(&seen); - - return error; -} - -int git_submodule_lookup( - git_submodule **sm_ptr, /* NULL allowed if user only wants to test */ - git_repository *repo, - const char *name) /* trailing slash is allowed */ -{ - khiter_t pos; - - if (load_submodule_config(repo) < 0) + if (git_buf_joinpath(&path, git_repository_workdir(repo), sm->path) < 0) return -1; - pos = git_strmap_lookup_index(repo->submodules, name); - if (!git_strmap_valid_index(repo->submodules, pos)) - return GIT_ENOTFOUND; + if (git_path_isdir(path.ptr)) + sm->flags |= GIT_SUBMODULE_STATUS__WD_SCANNED; - if (sm_ptr) - *sm_ptr = git_strmap_value_at(repo->submodules, pos); + if (git_path_contains(&path, DOT_GIT)) + sm->flags |= GIT_SUBMODULE_STATUS_IN_WD; + + git_buf_free(&path); return 0; } + +static int load_submodule_config_from_index( + git_repository *repo, git_oid *gitmodules_oid) +{ + int error; + git_iterator *i; + const git_index_entry *entry; + + if ((error = git_iterator_for_index(&i, repo)) < 0) + return error; + + error = git_iterator_current(i, &entry); + + while (!error && entry != NULL) { + + if (S_ISGITLINK(entry->mode)) { + error = submodule_load_from_index(repo, entry); + if (error < 0) + break; + } else if (strcmp(entry->path, GIT_MODULES_FILE) == 0) + git_oid_cpy(gitmodules_oid, &entry->oid); + + error = git_iterator_advance(i, &entry); + } + + git_iterator_free(i); + + return error; +} + +static int load_submodule_config_from_head( + git_repository *repo, git_oid *gitmodules_oid) +{ + int error; + git_tree *head; + git_iterator *i; + const git_index_entry *entry; + + if ((error = git_repository_head_tree(&head, repo)) < 0) + return error; + + if ((error = git_iterator_for_tree(&i, repo, head)) < 0) { + git_tree_free(head); + return error; + } + + error = git_iterator_current(i, &entry); + + while (!error && entry != NULL) { + + if (S_ISGITLINK(entry->mode)) { + error = submodule_load_from_head(repo, entry->path, &entry->oid); + if (error < 0) + break; + } else if (strcmp(entry->path, GIT_MODULES_FILE) == 0 && + git_oid_iszero(gitmodules_oid)) + git_oid_cpy(gitmodules_oid, &entry->oid); + + error = git_iterator_advance(i, &entry); + } + + git_iterator_free(i); + git_tree_free(head); + + return error; +} + +static git_config_file *open_gitmodules( + git_repository *repo, + bool okay_to_create, + const git_oid *gitmodules_oid) +{ + const char *workdir = git_repository_workdir(repo); + git_buf path = GIT_BUF_INIT; + git_config_file *mods = NULL; + + if (workdir != NULL) { + if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0) + return NULL; + + if (okay_to_create || git_path_isfile(path.ptr)) { + /* git_config_file__ondisk should only fail if OOM */ + if (git_config_file__ondisk(&mods, path.ptr) < 0) + return NULL; + + /* open should only fail here if the file is malformed */ + if (git_config_file_open(mods) < 0) { + git_config_file_free(mods); + mods = NULL; + } + } + } + + if (!mods && gitmodules_oid && !git_oid_iszero(gitmodules_oid)) { + /* TODO: Retrieve .gitmodules content from ODB */ + + /* Should we actually do this? Core git does not, but it means you + * can't really get much information about submodules on bare repos. + */ + } + + return mods; +} + +static int load_submodule_config(git_repository *repo, bool force) +{ + int error; + git_oid gitmodules_oid; + git_buf path = GIT_BUF_INIT; + git_config_file *mods = NULL; + + if (repo->submodules && !force) + return 0; + + memset(&gitmodules_oid, 0, sizeof(gitmodules_oid)); + + /* Submodule data is kept in a hashtable keyed by both name and path. + * These are usually the same, but that is not guaranteed. + */ + if (!repo->submodules) { + repo->submodules = git_strmap_alloc(); + GITERR_CHECK_ALLOC(repo->submodules); + } + + /* add submodule information from index */ + + if ((error = load_submodule_config_from_index(repo, &gitmodules_oid)) < 0) + goto cleanup; + + /* add submodule information from HEAD */ + + if ((error = load_submodule_config_from_head(repo, &gitmodules_oid)) < 0) + goto cleanup; + + /* add submodule information from .gitmodules */ + + if ((mods = open_gitmodules(repo, false, &gitmodules_oid)) != NULL) + error = git_config_file_foreach(mods, submodule_load_from_config, repo); + + if (error != 0) + goto cleanup; + + /* shallow scan submodules in work tree */ + + if (!git_repository_is_bare(repo)) + error = git_submodule_foreach(repo, submodule_load_from_wd_lite, NULL); + +cleanup: + git_buf_free(&path); + + if (mods != NULL) + git_config_file_free(mods); + + if (error) + git_submodule_config_free(repo); + + return error; +} + +static int lookup_head_remote(git_buf *url, git_repository *repo) +{ + int error; + git_config *cfg; + git_reference *head = NULL, *remote = NULL; + const char *tgt, *scan; + git_buf key = GIT_BUF_INIT; + + /* 1. resolve HEAD -> refs/heads/BRANCH + * 2. lookup config branch.BRANCH.remote -> ORIGIN + * 3. lookup remote.ORIGIN.url + */ + + if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) + return error; + + if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0) { + giterr_set(GITERR_SUBMODULE, + "Cannot resolve relative URL when HEAD cannot be resolved"); + error = GIT_ENOTFOUND; + goto cleanup; + } + + if (git_reference_type(head) != GIT_REF_SYMBOLIC) { + giterr_set(GITERR_SUBMODULE, + "Cannot resolve relative URL when HEAD is not symbolic"); + error = GIT_ENOTFOUND; + goto cleanup; + } + + if ((error = git_branch_tracking(&remote, head)) < 0) + goto cleanup; + + /* remote should refer to something like refs/remotes/ORIGIN/BRANCH */ + + if (git_reference_type(remote) != GIT_REF_SYMBOLIC || + git__prefixcmp(git_reference_target(remote), "refs/remotes/") != 0) + { + giterr_set(GITERR_SUBMODULE, + "Cannot resolve relative URL when HEAD is not symbolic"); + error = GIT_ENOTFOUND; + goto cleanup; + } + + scan = tgt = git_reference_target(remote) + strlen("refs/remotes/"); + while (*scan && (*scan != '/' || (scan > tgt && scan[-1] != '\\'))) + scan++; /* find non-escaped slash to end ORIGIN name */ + + error = git_buf_printf(&key, "remote.%.*s.url", (int)(scan - tgt), tgt); + if (error < 0) + goto cleanup; + + if ((error = git_config_get_string(&tgt, cfg, key.ptr)) < 0) + goto cleanup; + + error = git_buf_sets(url, tgt); + +cleanup: + git_buf_free(&key); + git_reference_free(head); + git_reference_free(remote); + + return error; +} + +static int submodule_update_config( + git_submodule *submodule, + const char *attr, + const char *value, + bool overwrite, + bool only_existing) +{ + int error; + git_config *config; + git_buf key = GIT_BUF_INIT; + const char *old = NULL; + + assert(submodule); + + error = git_repository_config__weakptr(&config, submodule->owner); + if (error < 0) + return error; + + error = git_buf_printf(&key, "submodule.%s.%s", submodule->name, attr); + if (error < 0) + goto cleanup; + + if (git_config_get_string(&old, config, key.ptr) < 0) + giterr_clear(); + + if (!old && only_existing) + goto cleanup; + if (old && !overwrite) + goto cleanup; + if ((!old && !value) || (old && value && strcmp(old, value) == 0)) + goto cleanup; + + if (!value) + error = git_config_delete(config, key.ptr); + else + error = git_config_set_string(config, key.ptr, value); + +cleanup: + git_buf_free(&key); + return error; +} + +#if 0 + +static int head_oid_for_submodule( + git_oid *oid, + git_repository *owner, + const char *path) +{ + int error = 0; + git_oid head_oid; + git_tree *head_tree = NULL, *container_tree = NULL; + unsigned int pos; + const git_tree_entry *entry; + + if (git_reference_name_to_oid(&head_oid, owner, GIT_HEAD_FILE) < 0 || + git_tree_lookup(&head_tree, owner, &head_oid) < 0 || + git_tree_resolve_path(&container_tree, &pos, head_tree, path) < 0 || + (entry = git_tree_entry_byindex(container_tree, pos)) == NULL) + { + memset(oid, 0, sizeof(*oid)); + error = GIT_ENOTFOUND; + } + else { + git_oid_cpy(oid, &entry->oid); + } + + git_tree_free(head_tree); + git_tree_free(container_tree); + + return error; +} + +int git_submodule_status( + unsigned int *status, + git_oid *head, + git_submodule *sm, + git_submodule_ignore_t ignore) +{ + int error; + const char *workdir; + git_repository *owner, *sm_repo = NULL; + git_oid owner_head, sm_head; + + assert(submodule && status); + + if (head == NULL) + head = &sm_head; + + owner = submodule->owner; + workdir = git_repository_workdir(owner); + + if (ignore == GIT_SUBMODULE_IGNORE_DEFAULT) + ignore = sm->ignore; + + /* if this is a bare repo or the submodule dir has no .git yet, + * then it is not checked out and we'll just return index data. + */ + if (!workdir || (sm->flags & GIT_SUBMODULE_FLAG__HAS_DOTGIT) == 0) { + *status = GIT_SUBMODULE_STATUS_NOT_CHECKED_OUT; + + if (sm->index_oid_valid) + git_oid_cpy(head, &sm->index_oid); + else + memset(head, 0, sizeof(git_oid)); + + if (git_oid_iszero(head)) { + if (sm->url) + *status = GIT_SUBMODULE_STATUS_NEW_SUBMODULE; + } else if (!sm->url) { + *status = GIT_SUBMODULE_STATUS_DELETED_SUBMODULE; + } + + return 0; + } + + /* look up submodule path in repo head to find if new or deleted */ + if ((error = head_oid_for_submodule(&owner_head, owner, sm->path)) < 0) { + *status = GIT_SUBMODULE_STATUS_NEW_SUBMODULE; + /* ??? */ + } + + if (ignore == GIT_SUBMODULE_IGNORE_ALL) { + *status = GIT_SUBMODULE_STATUS_CLEAN; + git_oid_cpy(head, &sm->oid); + return 0; + } + + if ((error = git_submodule_open(&sm_repo, sm)) < 0) + return error; + + if ((error = git_reference_name_to_oid(head, sm_repo, GIT_HEAD_FILE)) < 0) + goto cleanup; + + if (ignore == GIT_SUBMODULE_IGNORE_DIRTY && + git_oid_cmp(head, &sm->oid) == 0) + { + *status = GIT_SUBMODULE_STATUS_CLEAN; + return 0; + } + + /* look up submodule oid from index in repo to find if new commits or missing commits */ + + /* run a short status to find if modified or untracked content */ + +#define GIT_SUBMODULE_STATUS_NEW_SUBMODULE (1u << 2) +#define GIT_SUBMODULE_STATUS_DELETED_SUBMODULE (1u << 3) +#define GIT_SUBMODULE_STATUS_NOT_CHECKED_OUT (1u << 4) +#define GIT_SUBMODULE_STATUS_NEW_COMMITS (1u << 5) +#define GIT_SUBMODULE_STATUS_MISSING_COMMITS (1u << 6) +#define GIT_SUBMODULE_STATUS_MODIFIED_CONTENT (1u << 7) +#define GIT_SUBMODULE_STATUS_UNTRACKED_CONTENT (1u << 8) + +cleanup: + git_repository_free(sm_repo); + git_tree_free(owner_tree); + + return error; +} + +int git_submodule_status_for_path( + unsigned int *status, + git_oid *head, + git_repository *repo, + const char *submodule_path, + git_submodule_ignore_t ignore) +{ + int error; + git_submodule *sm; + const char *workdir; + git_buf path = GIT_BUF_INIT; + git_oid owner_head; + + assert(repo && submodule_path && status); + + if ((error = git_submodule_lookup(&sm, repo, submodule_path)) == 0) + return git_submodule_status(status, head, sm, ignore); + + /* if submodule still exists in HEAD, then it is DELETED */ + if (!(error = head_oid_for_submodule(&owner_head, repo, submodule_path))) { + *status = GIT_SUBMODULE_STATUS_DELETED_SUBMODULE; + if (head) + git_oid_cmp(head, &owner_head); + return 0; + } + + /* submodule was not found - let's see what we can determine about it */ + workdir = git_repository_workdir(repo); + + if (error != GIT_ENOTFOUND || !workdir) { + *status = GIT_SUBMODULE_STATUS_NOT_A_SUBMODULE; + return error; + } + + giterr_clear(); + error = 0; + + /* figure out if this is NEW, NOT_CHECKED_OUT, or what */ + if (git_buf_joinpath(&path, workdir, submodule_path) < 0) + return -1; + + if (git_path_contains(&path, DOT_GIT)) { + git_repository *sm_repo; + + *status = GIT_SUBMODULE_STATUS_UNTRACKED_SUBMODULE; + + /* only bother look up head if it was non-NULL */ + if (head != NULL && + !(error = git_repository_open(&sm_repo, path.ptr))) + { + error = git_reference_name_to_oid(head, sm_repo, GIT_HEAD_FILE); + git_repository_free(sm_repo); + } + } else + *status = GIT_SUBMODULE_STATUS_NOT_A_SUBMODULE; + + git_buf_free(&path); + + return error; +} + +#endif diff --git a/src/submodule.h b/src/submodule.h new file mode 100644 index 000000000..83bc7dfe9 --- /dev/null +++ b/src/submodule.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2012 the libgit2 contributors + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_submodule_h__ +#define INCLUDE_submodule_h__ + +/* Notes: + * + * Submodule information can be in four places: the index, the config files + * (both .git/config and .gitmodules), the HEAD tree, and the working + * directory. + * + * In the index: + * - submodule is found by path + * - may be missing, present, or of the wrong type + * - will have an oid if present + * + * In the HEAD tree: + * - submodule is found by path + * - may be missing, present, or of the wrong type + * - will have an oid if present + * + * In the config files: + * - submodule is found by submodule "name" which is usually the path + * - may be missing or present + * - will have a name, path, url, and other properties + * + * In the working directory: + * - submodule is found by path + * - may be missing, an empty directory, a checked out directory, + * or of the wrong type + * - if checked out, will have a HEAD oid + * - if checked out, will have git history that can be used to compare oids + * - if checked out, may have modified files and/or untracked files + */ + +/** + * Description of submodule + * + * This record describes a submodule found in a repository. There should be + * an entry for every submodule found in the HEAD and index, and for every + * submodule described in .gitmodules. The fields are as follows: + * + * - `owner` is the git_repository containing this submodule + * - `name` is the name of the submodule from .gitmodules. + * - `path` is the path to the submodule from the repo root. It is almost + * always the same as `name`. + * - `url` is the url for the submodule. + * - `tree_oid` is the SHA1 for the submodule path in the repo HEAD. + * - `index_oid` is the SHA1 for the submodule recorded in the index. + * - `workdir_oid` is the SHA1 for the HEAD of the checked out submodule. + * - `update` is a git_submodule_update_t value - see gitmodules(5) update. + * - `ignore` is a git_submodule_ignore_t value - see gitmodules(5) ignore. + * - `fetch_recurse` is 0 or 1 - see gitmodules(5) fetchRecurseSubmodules. + * - `refcount` tracks how many hashmap entries there are for this submodule. + * It only comes into play if the name and path of the submodule differ. + * - `flags` is for internal use, tracking where this submodule has been + * found (head, index, config, workdir) and other misc info about it. + * + * If the submodule has been added to .gitmodules but not yet git added, + * then the `index_oid` will be valid and zero. If the submodule has been + * deleted, but the delete has not been committed yet, then the `index_oid` + * will be set, but the `url` will be NULL. + */ +struct git_submodule { + git_repository *owner; + char *name; + char *path; /* important: may point to same string data as "name" */ + char *url; + uint32_t flags; + git_oid head_oid; + git_oid index_oid; + git_oid wd_oid; + /* information from config */ + git_submodule_update_t update; + git_submodule_update_t update_default; + git_submodule_ignore_t ignore; + git_submodule_ignore_t ignore_default; + int fetch_recurse; + /* internal information */ + int refcount; +}; + +/* Additional flags on top of public GIT_SUBMODULE_STATUS values */ +#define GIT_SUBMODULE_STATUS__WD_SCANNED (1u << 15) +#define GIT_SUBMODULE_STATUS__HEAD_OID_VALID (1u << 16) +#define GIT_SUBMODULE_STATUS__INDEX_OID_VALID (1u << 17) +#define GIT_SUBMODULE_STATUS__WD_OID_VALID (1u << 18) +#define GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES (1u << 19) + +#endif diff --git a/tests-clar/status/submodules.c b/tests-clar/status/submodules.c index 9423e8490..3a69e0c47 100644 --- a/tests-clar/status/submodules.c +++ b/tests-clar/status/submodules.c @@ -3,24 +3,17 @@ #include "path.h" #include "posix.h" #include "status_helpers.h" +#include "../submodule/submodule_helpers.h" static git_repository *g_repo = NULL; void test_status_submodules__initialize(void) { - git_buf modpath = GIT_BUF_INIT; - g_repo = cl_git_sandbox_init("submodules"); cl_fixture_sandbox("testrepo.git"); - cl_git_pass(git_buf_sets(&modpath, git_repository_workdir(g_repo))); - cl_assert(git_path_dirname_r(&modpath, modpath.ptr) >= 0); - cl_git_pass(git_buf_joinpath(&modpath, modpath.ptr, "testrepo.git\n")); - - p_rename("submodules/gitmodules", "submodules/.gitmodules"); - cl_git_append2file("submodules/.gitmodules", modpath.ptr); - git_buf_free(&modpath); + rewrite_gitmodules(git_repository_workdir(g_repo)); p_rename("submodules/testrepo/.gitted", "submodules/testrepo/.git"); } @@ -28,6 +21,7 @@ void test_status_submodules__initialize(void) void test_status_submodules__cleanup(void) { cl_git_sandbox_cleanup(); + cl_fixture_cleanup("testrepo.git"); } void test_status_submodules__api(void) @@ -40,8 +34,8 @@ void test_status_submodules__api(void) cl_git_pass(git_submodule_lookup(&sm, g_repo, "testrepo")); cl_assert(sm != NULL); - cl_assert_equal_s("testrepo", sm->name); - cl_assert_equal_s("testrepo", sm->path); + cl_assert_equal_s("testrepo", git_submodule_name(sm)); + cl_assert_equal_s("testrepo", git_submodule_path(sm)); } void test_status_submodules__0(void) diff --git a/tests-clar/submodule/lookup.c b/tests-clar/submodule/lookup.c new file mode 100644 index 000000000..669338f1c --- /dev/null +++ b/tests-clar/submodule/lookup.c @@ -0,0 +1,110 @@ +#include "clar_libgit2.h" +#include "submodule_helpers.h" +#include "posix.h" + +static git_repository *g_repo = NULL; + +void test_submodule_lookup__initialize(void) +{ + g_repo = cl_git_sandbox_init("submod2"); + + cl_fixture_sandbox("submod2_target"); + p_rename("submod2_target/.gitted", "submod2_target/.git"); + + /* must create submod2_target before rewrite so prettify will work */ + rewrite_gitmodules(git_repository_workdir(g_repo)); + p_rename("submod2/not_submodule/.gitted", "submod2/not_submodule/.git"); +} + +void test_submodule_lookup__cleanup(void) +{ + cl_git_sandbox_cleanup(); + cl_fixture_cleanup("submod2_target"); +} + +void test_submodule_lookup__simple_lookup(void) +{ + git_submodule *sm; + + /* lookup existing */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_assert(sm); + + /* lookup pending change in .gitmodules that is not in HEAD */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited")); + cl_assert(sm); + + /* lookup git repo subdir that is not added as submodule */ + cl_assert(git_submodule_lookup(&sm, g_repo, "not_submodule") == GIT_EEXISTS); + + /* lookup existing directory that is not a submodule */ + cl_assert(git_submodule_lookup(&sm, g_repo, "just_a_dir") == GIT_ENOTFOUND); + + /* lookup existing file that is not a submodule */ + cl_assert(git_submodule_lookup(&sm, g_repo, "just_a_file") == GIT_ENOTFOUND); + + /* lookup non-existent item */ + cl_assert(git_submodule_lookup(&sm, g_repo, "no_such_file") == GIT_ENOTFOUND); +} + +void test_submodule_lookup__accessors(void) +{ + git_submodule *sm; + const char *oid = "480095882d281ed676fe5b863569520e54a7d5c0"; + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_assert(git_submodule_owner(sm) == g_repo); + cl_assert_equal_s("sm_unchanged", git_submodule_name(sm)); + cl_assert(git__suffixcmp(git_submodule_path(sm), "sm_unchanged") == 0); + cl_assert(git__suffixcmp(git_submodule_url(sm), "/submod2_target") == 0); + + cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0); + cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0); + cl_assert(git_oid_streq(git_submodule_wd_oid(sm), oid) == 0); + + cl_assert(git_submodule_ignore(sm) == GIT_SUBMODULE_IGNORE_NONE); + cl_assert(git_submodule_update(sm) == GIT_SUBMODULE_UPDATE_CHECKOUT); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_assert_equal_s("sm_changed_head", git_submodule_name(sm)); + + cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0); + cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0); + cl_assert(git_oid_streq(git_submodule_wd_oid(sm), + "3d9386c507f6b093471a3e324085657a3c2b4247") == 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited")); + cl_assert_equal_s("sm_added_and_uncommited", git_submodule_name(sm)); + + cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0); + cl_assert(git_submodule_head_oid(sm) == NULL); + cl_assert(git_oid_streq(git_submodule_wd_oid(sm), oid) == 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits")); + cl_assert_equal_s("sm_missing_commits", git_submodule_name(sm)); + + cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0); + cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0); + cl_assert(git_oid_streq(git_submodule_wd_oid(sm), + "5e4963595a9774b90524d35a807169049de8ccad") == 0); +} + +typedef struct { + int count; +} sm_lookup_data; + +static int sm_lookup_cb(git_submodule *sm, const char *name, void *payload) +{ + sm_lookup_data *data = payload; + data->count += 1; + cl_assert_equal_s(git_submodule_name(sm), name); + return 0; +} + +void test_submodule_lookup__foreach(void) +{ + sm_lookup_data data; + memset(&data, 0, sizeof(data)); + cl_git_pass(git_submodule_foreach(g_repo, sm_lookup_cb, &data)); + cl_assert_equal_i(7, data.count); +} diff --git a/tests-clar/submodule/modify.c b/tests-clar/submodule/modify.c new file mode 100644 index 000000000..7f04ce0f5 --- /dev/null +++ b/tests-clar/submodule/modify.c @@ -0,0 +1,256 @@ +#include "clar_libgit2.h" +#include "posix.h" +#include "path.h" +#include "submodule_helpers.h" + +static git_repository *g_repo = NULL; + +#define SM_LIBGIT2_URL "https://github.com/libgit2/libgit2.git" +#define SM_LIBGIT2 "sm_libgit2" +#define SM_LIBGIT2B "sm_libgit2b" + +void test_submodule_modify__initialize(void) +{ + g_repo = cl_git_sandbox_init("submod2"); + + cl_fixture_sandbox("submod2_target"); + p_rename("submod2_target/.gitted", "submod2_target/.git"); + + /* must create submod2_target before rewrite so prettify will work */ + rewrite_gitmodules(git_repository_workdir(g_repo)); + p_rename("submod2/not_submodule/.gitted", "submod2/not_submodule/.git"); +} + +void test_submodule_modify__cleanup(void) +{ + cl_git_sandbox_cleanup(); + cl_fixture_cleanup("submod2_target"); +} + +void test_submodule_modify__add(void) +{ + git_submodule *sm; + git_config *cfg; + const char *s; + + /* re-add existing submodule */ + cl_assert( + git_submodule_add_setup(NULL, g_repo, "whatever", "sm_unchanged", 1) == + GIT_EEXISTS ); + + /* add a submodule using a gitlink */ + + cl_git_pass( + git_submodule_add_setup(&sm, g_repo, SM_LIBGIT2_URL, SM_LIBGIT2, 1) + ); + + cl_assert(git_path_isfile("submod2/" SM_LIBGIT2 "/.git")); + + cl_assert(git_path_isdir("submod2/.git/modules")); + cl_assert(git_path_isdir("submod2/.git/modules/" SM_LIBGIT2)); + cl_assert(git_path_isfile("submod2/.git/modules/" SM_LIBGIT2 "/HEAD")); + + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_pass( + git_config_get_string(&s, cfg, "submodule." SM_LIBGIT2 ".url")); + cl_assert_equal_s(s, SM_LIBGIT2_URL); + git_config_free(cfg); + + /* add a submodule not using a gitlink */ + + cl_git_pass( + git_submodule_add_setup(&sm, g_repo, SM_LIBGIT2_URL, SM_LIBGIT2B, 0) + ); + + cl_assert(git_path_isdir("submod2/" SM_LIBGIT2B "/.git")); + cl_assert(git_path_isfile("submod2/" SM_LIBGIT2B "/.git/HEAD")); + cl_assert(!git_path_exists("submod2/.git/modules/" SM_LIBGIT2B)); + + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_pass( + git_config_get_string(&s, cfg, "submodule." SM_LIBGIT2B ".url")); + cl_assert_equal_s(s, SM_LIBGIT2_URL); + git_config_free(cfg); +} + +static int delete_one_config( + const char *var_name, const char *value, void *payload) +{ + git_config *cfg = payload; + GIT_UNUSED(value); + return git_config_delete(cfg, var_name); +} + +static int init_one_submodule( + git_submodule *sm, const char *name, void *payload) +{ + GIT_UNUSED(name); + GIT_UNUSED(payload); + return git_submodule_init(sm, false); +} + +void test_submodule_modify__init(void) +{ + git_config *cfg; + const char *str; + + /* erase submodule data from .git/config */ + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_pass( + git_config_foreach_match(cfg, "submodule\\..*", delete_one_config, cfg)); + git_config_free(cfg); + + /* confirm no submodule data in config */ + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_fail(git_config_get_string(&str, cfg, "submodule.sm_unchanged.url")); + cl_git_fail(git_config_get_string(&str, cfg, "submodule.sm_changed_head.url")); + cl_git_fail(git_config_get_string(&str, cfg, "submodule.sm_added_and_uncommited.url")); + git_config_free(cfg); + + /* call init and see that settings are copied */ + cl_git_pass(git_submodule_foreach(g_repo, init_one_submodule, NULL)); + + git_submodule_reload_all(g_repo); + + /* confirm submodule data in config */ + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_pass(git_config_get_string(&str, cfg, "submodule.sm_unchanged.url")); + cl_assert(git__suffixcmp(str, "/submod2_target") == 0); + cl_git_pass(git_config_get_string(&str, cfg, "submodule.sm_changed_head.url")); + cl_assert(git__suffixcmp(str, "/submod2_target") == 0); + cl_git_pass(git_config_get_string(&str, cfg, "submodule.sm_added_and_uncommited.url")); + cl_assert(git__suffixcmp(str, "/submod2_target") == 0); + git_config_free(cfg); +} + +static int sync_one_submodule( + git_submodule *sm, const char *name, void *payload) +{ + GIT_UNUSED(name); + GIT_UNUSED(payload); + return git_submodule_sync(sm); +} + +void test_submodule_modify__sync(void) +{ + git_submodule *sm1, *sm2, *sm3; + git_config *cfg; + const char *str; + +#define SM1 "sm_unchanged" +#define SM2 "sm_changed_head" +#define SM3 "sm_added_and_uncommited" + + /* look up some submodules */ + cl_git_pass(git_submodule_lookup(&sm1, g_repo, SM1)); + cl_git_pass(git_submodule_lookup(&sm2, g_repo, SM2)); + cl_git_pass(git_submodule_lookup(&sm3, g_repo, SM3)); + + /* At this point, the .git/config URLs for the submodules have + * not be rewritten with the absolute paths (although the + * .gitmodules have. Let's confirm that they DO NOT match + * yet, then we can do a sync to make them match... + */ + + /* check submodule info does not match before sync */ + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM1".url")); + cl_assert(strcmp(git_submodule_url(sm1), str) != 0); + cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM2".url")); + cl_assert(strcmp(git_submodule_url(sm2), str) != 0); + cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM3".url")); + cl_assert(strcmp(git_submodule_url(sm3), str) != 0); + git_config_free(cfg); + + /* sync all the submodules */ + cl_git_pass(git_submodule_foreach(g_repo, sync_one_submodule, NULL)); + + /* check that submodule config is updated */ + cl_git_pass(git_repository_config(&cfg, g_repo)); + cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM1".url")); + cl_assert_equal_s(git_submodule_url(sm1), str); + cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM2".url")); + cl_assert_equal_s(git_submodule_url(sm2), str); + cl_git_pass(git_config_get_string(&str, cfg, "submodule."SM3".url")); + cl_assert_equal_s(git_submodule_url(sm3), str); + git_config_free(cfg); +} + +void test_submodule_modify__edit_and_save(void) +{ + git_submodule *sm1, *sm2; + char *old_url; + git_submodule_ignore_t old_ignore; + git_submodule_update_t old_update; + git_repository *r2; + + cl_git_pass(git_submodule_lookup(&sm1, g_repo, "sm_changed_head")); + + old_url = git__strdup(git_submodule_url(sm1)); + + /* modify properties of submodule */ + cl_git_pass(git_submodule_set_url(sm1, SM_LIBGIT2_URL)); + old_ignore = git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_UNTRACKED); + old_update = git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_REBASE); + + cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm1)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm1)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm1)); + + /* revert without saving (and confirm setters return old value) */ + cl_git_pass(git_submodule_set_url(sm1, old_url)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_IGNORE_UNTRACKED, + (int)git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_DEFAULT)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_UPDATE_REBASE, + (int)git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_DEFAULT)); + + /* check that revert was successful */ + cl_assert_equal_s(old_url, git_submodule_url(sm1)); + cl_assert_equal_i((int)old_ignore, (int)git_submodule_ignore(sm1)); + cl_assert_equal_i((int)old_update, (int)git_submodule_update(sm1)); + + /* modify properties of submodule (again) */ + cl_git_pass(git_submodule_set_url(sm1, SM_LIBGIT2_URL)); + git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_UNTRACKED); + git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_REBASE); + + /* call save */ + cl_git_pass(git_submodule_save(sm1)); + + /* attempt to "revert" values */ + git_submodule_set_ignore(sm1, GIT_SUBMODULE_IGNORE_DEFAULT); + git_submodule_set_update(sm1, GIT_SUBMODULE_UPDATE_DEFAULT); + + /* but ignore and update should NOT revert because the DEFAULT + * should now be the newly saved value... + */ + cl_assert_equal_i( + (int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm1)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm1)); + + /* call reload and check that the new values are loaded */ + cl_git_pass(git_submodule_reload(sm1)); + + cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm1)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm1)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm1)); + + /* open a second copy of the repo and compare submodule */ + cl_git_pass(git_repository_open(&r2, "submod2")); + cl_git_pass(git_submodule_lookup(&sm2, r2, "sm_changed_head")); + + cl_assert_equal_s(SM_LIBGIT2_URL, git_submodule_url(sm2)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_IGNORE_UNTRACKED, (int)git_submodule_ignore(sm2)); + cl_assert_equal_i( + (int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm2)); + + git_repository_free(r2); +} diff --git a/tests-clar/submodule/status.c b/tests-clar/submodule/status.c new file mode 100644 index 000000000..e0c1e4c7a --- /dev/null +++ b/tests-clar/submodule/status.c @@ -0,0 +1,44 @@ +#include "clar_libgit2.h" +#include "posix.h" +#include "path.h" +#include "submodule_helpers.h" + +static git_repository *g_repo = NULL; + +void test_submodule_status__initialize(void) +{ + g_repo = cl_git_sandbox_init("submod2"); + + cl_fixture_sandbox("submod2_target"); + p_rename("submod2_target/.gitted", "submod2_target/.git"); + + /* must create submod2_target before rewrite so prettify will work */ + rewrite_gitmodules(git_repository_workdir(g_repo)); + p_rename("submod2/not_submodule/.gitted", "submod2/not_submodule/.git"); +} + +void test_submodule_status__cleanup(void) +{ + cl_git_sandbox_cleanup(); + cl_fixture_cleanup("submod2_target"); +} + +void test_submodule_status__unchanged(void) +{ + /* make sure it really looks unchanged */ +} + +void test_submodule_status__changed(void) +{ + /* 4 values of GIT_SUBMODULE_IGNORE to check */ + + /* 6 states of change: + * - none, (handled in __unchanged above) + * - dirty workdir file, + * - dirty index, + * - moved head, + * - untracked file, + * - missing commits (i.e. superproject commit is ahead of submodule) + */ +} + diff --git a/tests-clar/submodule/submodule_helpers.c b/tests-clar/submodule/submodule_helpers.c new file mode 100644 index 000000000..0c3e79f71 --- /dev/null +++ b/tests-clar/submodule/submodule_helpers.c @@ -0,0 +1,84 @@ +#include "clar_libgit2.h" +#include "buffer.h" +#include "path.h" +#include "util.h" +#include "posix.h" +#include "submodule_helpers.h" + +/* rewrite gitmodules -> .gitmodules + * rewrite the empty or relative urls inside each module + * rename the .gitted directory inside any submodule to .git + */ +void rewrite_gitmodules(const char *workdir) +{ + git_buf in_f = GIT_BUF_INIT, out_f = GIT_BUF_INIT, path = GIT_BUF_INIT; + FILE *in, *out; + char line[256]; + + cl_git_pass(git_buf_joinpath(&in_f, workdir, "gitmodules")); + cl_git_pass(git_buf_joinpath(&out_f, workdir, ".gitmodules")); + + cl_assert((in = fopen(in_f.ptr, "r")) != NULL); + cl_assert((out = fopen(out_f.ptr, "w")) != NULL); + + while (fgets(line, sizeof(line), in) != NULL) { + char *scan = line; + + while (*scan == ' ' || *scan == '\t') scan++; + + /* rename .gitted -> .git in submodule directories */ + if (git__prefixcmp(scan, "path =") == 0) { + scan += strlen("path ="); + while (*scan == ' ') scan++; + + git_buf_joinpath(&path, workdir, scan); + git_buf_rtrim(&path); + git_buf_joinpath(&path, path.ptr, ".gitted"); + + if (!git_buf_oom(&path) && p_access(path.ptr, F_OK) == 0) { + git_buf_joinpath(&out_f, workdir, scan); + git_buf_rtrim(&out_f); + git_buf_joinpath(&out_f, out_f.ptr, ".git"); + + if (!git_buf_oom(&out_f)) + p_rename(path.ptr, out_f.ptr); + } + } + + /* copy non-"url =" lines verbatim */ + if (git__prefixcmp(scan, "url =") != 0) { + fputs(line, out); + continue; + } + + /* convert relative URLs in "url =" lines */ + scan += strlen("url ="); + while (*scan == ' ') scan++; + + if (*scan == '.') { + git_buf_joinpath(&path, workdir, scan); + git_buf_rtrim(&path); + } else if (!*scan || *scan == '\n') { + git_buf_joinpath(&path, workdir, "../testrepo.git"); + } else { + fputs(line, out); + continue; + } + + git_path_prettify(&path, path.ptr, NULL); + git_buf_putc(&path, '\n'); + cl_assert(!git_buf_oom(&path)); + + fwrite(line, scan - line, sizeof(char), out); + fputs(path.ptr, out); + } + + fclose(in); + fclose(out); + + cl_must_pass(p_unlink(in_f.ptr)); + + git_buf_free(&in_f); + git_buf_free(&out_f); + git_buf_free(&path); +} diff --git a/tests-clar/submodule/submodule_helpers.h b/tests-clar/submodule/submodule_helpers.h new file mode 100644 index 000000000..6b76a832e --- /dev/null +++ b/tests-clar/submodule/submodule_helpers.h @@ -0,0 +1,2 @@ +extern void rewrite_gitmodules(const char *workdir); + From 0c8858de8c82bae3fd88513724689a07d231da7e Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 3 Aug 2012 14:28:07 -0700 Subject: [PATCH 3/5] Fix valgrind issues and leaks This fixes up a number of problems flagged by valgrind and also cleans up the internal `git_submodule` allocation handling overall with a simpler model. --- src/buffer.c | 37 +++-- src/config_file.c | 6 +- src/fileops.c | 1 + src/submodule.c | 233 ++++++++++++++++--------------- tests-clar/submodule/modify.c | 1 + tests-clar/valgrind-supp-mac.txt | 82 +++++++++++ 6 files changed, 229 insertions(+), 131 deletions(-) create mode 100644 tests-clar/valgrind-supp-mac.txt diff --git a/src/buffer.c b/src/buffer.c index b57998e1b..61cfaf9e2 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -144,31 +144,40 @@ int git_buf_puts(git_buf *buf, const char *string) int git_buf_puts_escaped( git_buf *buf, const char *string, const char *esc_chars, const char *esc_with) { - const char *scan = string; - size_t total = 0, esc_with_len = strlen(esc_with); + const char *scan; + size_t total = 0, esc_len = strlen(esc_with), count; - while (*scan) { - size_t count = strcspn(scan, esc_chars); - total += count + 1 + esc_with_len; - scan += count + 1; + if (!string) + return 0; + + for (scan = string; *scan; ) { + /* count run of non-escaped characters */ + count = strcspn(scan, esc_chars); + total += count; + scan += count; + /* count run of escaped characters */ + count = strspn(scan, esc_chars); + total += count * (esc_len + 1); + scan += count; } ENSURE_SIZE(buf, buf->size + total + 1); for (scan = string; *scan; ) { - size_t count = strcspn(scan, esc_chars); + count = strcspn(scan, esc_chars); memmove(buf->ptr + buf->size, scan, count); scan += count; buf->size += count; - if (*scan) { - memmove(buf->ptr + buf->size, esc_with, esc_with_len); - buf->size += esc_with_len; - - memmove(buf->ptr + buf->size, scan, 1); - scan += 1; - buf->size += 1; + for (count = strspn(scan, esc_chars); count > 0; --count) { + /* copy escape sequence */ + memmove(buf->ptr + buf->size, esc_with, esc_len); + buf->size += esc_len; + /* copy character to be escaped */ + buf->ptr[buf->size] = *scan; + buf->size++; + scan++; } } diff --git a/src/config_file.c b/src/config_file.c index aabb21f16..d3fb56aaa 100644 --- a/src/config_file.c +++ b/src/config_file.c @@ -195,7 +195,7 @@ static int file_foreach( void *data) { diskfile_backend *b = (diskfile_backend *)backend; - cvar_t *var; + cvar_t *var, *next_var; const char *key; regex_t regex; int result = 0; @@ -212,7 +212,9 @@ static int file_foreach( } git_strmap_foreach(b->values, key, var, - for (; var != NULL; var = CVAR_LIST_NEXT(var)) { + for (; var != NULL; var = next_var) { + next_var = CVAR_LIST_NEXT(var); + /* skip non-matching keys if regexp was provided */ if (regexp && regexec(®ex, key, 0, NULL, 0) != 0) continue; diff --git a/src/fileops.c b/src/fileops.c index eecfc2847..76ef8c910 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -700,6 +700,7 @@ int git_futils_cp_r( error = _cp_r_callback(&info, &path); git_buf_free(&path); + git_buf_free(&info.to); return error; } diff --git a/src/submodule.c b/src/submodule.c index 9a852041a..3ebb362a4 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -71,10 +71,8 @@ static git_config_file *open_gitmodules( git_repository *, bool, const git_oid *); static int lookup_head_remote( git_buf *url, git_repository *repo); -static git_submodule *submodule_lookup_or_create( - git_repository *repo, const char *n1, const char *n2); -static int submodule_update_map( - git_repository *repo, git_submodule *sm, const char *key); +static int submodule_get( + git_submodule **, git_repository *, const char *, const char *); static void submodule_release( git_submodule *sm, int decr); static int submodule_load_from_index( @@ -311,18 +309,9 @@ int git_submodule_add_setup( /* add submodule to hash and "reload" it */ - if ((sm = submodule_lookup_or_create(repo, path, NULL)) == NULL) { - error = -1; - goto cleanup; - } - - if ((error = submodule_update_map(repo, sm, sm->path)) < 0) - goto cleanup; - - if ((error = git_submodule_reload(sm)) < 0) - goto cleanup; - - error = git_submodule_init(sm, false); + if (!(error = submodule_get(&sm, repo, path, NULL)) && + !(error = git_submodule_reload(sm))) + error = git_submodule_init(sm, false); cleanup: if (submodule != NULL) @@ -757,6 +746,7 @@ int git_submodule_reload(git_submodule *submodule) mods, path.ptr, submodule_load_from_config, repo); git_buf_free(&path); + git_config_file_free(mods); } return error; @@ -768,6 +758,9 @@ int git_submodule_status( { assert(status && submodule); + GIT_UNUSED(status); + GIT_UNUSED(submodule); + /* TODO: move status code from below and update */ *status = 0; @@ -781,19 +774,29 @@ int git_submodule_status( static git_submodule *submodule_alloc(git_repository *repo, const char *name) { - git_submodule *sm = git__calloc(1, sizeof(git_submodule)); - if (sm == NULL) - return sm; + git_submodule *sm; - sm->path = sm->name = git__strdup(name); - if (!sm->name) { - git__free(sm); + if (!name || !strlen(name)) { + giterr_set(GITERR_SUBMODULE, "Invalid submodule name"); return NULL; } + sm = git__calloc(1, sizeof(git_submodule)); + if (sm == NULL) + goto fail; + + sm->path = sm->name = git__strdup(name); + if (!sm->name) + goto fail; + sm->owner = repo; + sm->refcount = 1; return sm; + +fail: + submodule_release(sm, 0); + return NULL; } static void submodule_release(git_submodule *sm, int decr) @@ -821,54 +824,56 @@ static void submodule_release(git_submodule *sm, int decr) } } -static git_submodule *submodule_lookup_or_create( - git_repository *repo, const char *n1, const char *n2) +static int submodule_get( + git_submodule **sm_ptr, + git_repository *repo, + const char *name, + const char *alternate) { git_strmap *smcfg = repo->submodules; khiter_t pos; git_submodule *sm; - - assert(n1); - - pos = git_strmap_lookup_index(smcfg, n1); - - if (!git_strmap_valid_index(smcfg, pos) && n2) - pos = git_strmap_lookup_index(smcfg, n2); - - if (!git_strmap_valid_index(smcfg, pos)) - sm = submodule_alloc(repo, n1); - else - sm = git_strmap_value_at(smcfg, pos); - - return sm; -} - -static int submodule_update_map( - git_repository *repo, git_submodule *sm, const char *key) -{ - void *old_sm; int error; - git_strmap_insert2(repo->submodules, key, sm, old_sm, error); - if (error < 0) { - submodule_release(sm, 0); - return -1; + assert(repo && name); + + pos = git_strmap_lookup_index(smcfg, name); + + if (!git_strmap_valid_index(smcfg, pos) && alternate) + pos = git_strmap_lookup_index(smcfg, alternate); + + if (!git_strmap_valid_index(smcfg, pos)) { + sm = submodule_alloc(repo, name); + + /* insert value at name - if another thread beats us to it, then use + * their record and release our own. + */ + pos = kh_put(str, smcfg, name, &error); + + if (error < 0) { + submodule_release(sm, 1); + sm = NULL; + } else if (error == 0) { + submodule_release(sm, 1); + sm = git_strmap_value_at(smcfg, pos); + } else { + git_strmap_set_value_at(smcfg, pos, sm); + } + } else { + sm = git_strmap_value_at(smcfg, pos); } - sm->refcount++; + *sm_ptr = sm; - if (old_sm && ((git_submodule *)old_sm) != sm) - submodule_release(old_sm, 1); - - return 0; + return (sm != NULL) ? 0 : -1; } static int submodule_load_from_index( git_repository *repo, const git_index_entry *entry) { - git_submodule *sm = submodule_lookup_or_create(repo, entry->path, NULL); + git_submodule *sm; - if (!sm) + if (submodule_get(&sm, repo, entry->path, NULL) < 0) return -1; if (sm->flags & GIT_SUBMODULE_STATUS_IN_INDEX) { @@ -881,15 +886,15 @@ static int submodule_load_from_index( git_oid_cpy(&sm->index_oid, &entry->oid); sm->flags |= GIT_SUBMODULE_STATUS__INDEX_OID_VALID; - return submodule_update_map(repo, sm, sm->path); + return 0; } static int submodule_load_from_head( git_repository *repo, const char *path, const git_oid *oid) { - git_submodule *sm = submodule_lookup_or_create(repo, path, NULL); + git_submodule *sm; - if (!sm) + if (submodule_get(&sm, repo, path, NULL) < 0) return -1; sm->flags |= GIT_SUBMODULE_STATUS_IN_HEAD; @@ -897,7 +902,14 @@ static int submodule_load_from_head( git_oid_cpy(&sm->head_oid, oid); sm->flags |= GIT_SUBMODULE_STATUS__HEAD_OID_VALID; - return submodule_update_map(repo, sm, sm->path); + return 0; +} + +static int submodule_config_error(const char *property, const char *value) +{ + giterr_set(GITERR_INVALID, + "Invalid value for submodule '%s' property: '%s'", property, value); + return -1; } static int submodule_load_from_config( @@ -905,13 +917,11 @@ static int submodule_load_from_config( { git_repository *repo = data; git_strmap *smcfg = repo->submodules; - const char *namestart; - const char *property; + const char *namestart, *property, *alternate = NULL; git_buf name = GIT_BUF_INIT; git_submodule *sm; - void *old_sm = NULL; bool is_path; - int error; + int error = 0; if (git__prefixcmp(key, "submodule.") != 0) return 0; @@ -926,38 +936,45 @@ static int submodule_load_from_config( if (git_buf_set(&name, namestart, property - namestart - 1) < 0) return -1; - sm = submodule_lookup_or_create(repo, name.ptr, is_path ? value : NULL); - if (!sm) - goto fail; + if (submodule_get(&sm, repo, name.ptr, is_path ? value : NULL) < 0) { + git_buf_free(&name); + return -1; + } sm->flags |= GIT_SUBMODULE_STATUS_IN_CONFIG; + /* Only from config might we get differing names & paths. If so, then + * update the submodule and insert under the alternative key. + */ + + /* TODO: if case insensitive filesystem, then the following strcmps + * should be strcasecmp + */ + if (strcmp(sm->name, name.ptr) != 0) { - assert(sm->path == sm->name); - sm->name = git_buf_detach(&name); - - git_strmap_insert2(smcfg, sm->name, sm, old_sm, error); - if (error < 0) - goto fail; - sm->refcount++; + alternate = sm->name = git_buf_detach(&name); + } else if (is_path && value && strcmp(sm->path, value) != 0) { + alternate = sm->path = git__strdup(value); + if (!sm->path) + error = -1; } - else if (is_path && value && strcmp(sm->path, value) != 0) { - assert(sm->path == sm->name); - sm->path = git__strdup(value); - if (sm->path == NULL) - goto fail; + if (alternate) { + void *old_sm = NULL; + git_strmap_insert2(smcfg, alternate, sm, old_sm, error); - git_strmap_insert2(smcfg, sm->path, sm, old_sm, error); - if (error < 0) - goto fail; - sm->refcount++; + if (error >= 0) + sm->refcount++; /* inserted under a new key */ + + /* if we replaced an old module under this key, release the old one */ + if (old_sm && ((git_submodule *)old_sm) != sm) { + submodule_release(old_sm, 1); + /* TODO: log warning about multiple submodules with same path */ + } } + git_buf_free(&name); - - if (old_sm && ((git_submodule *)old_sm) != sm) { - /* TODO: log warning about multiple submodules with same path */ - submodule_release(old_sm, 1); - } + if (error < 0) + return error; /* TODO: Look up path in index and if it is present but not a GITLINK * then this should be deleted (at least to match git's behavior) @@ -968,48 +985,33 @@ static int submodule_load_from_config( /* copy other properties into submodule entry */ if (strcasecmp(property, "url") == 0) { - if (sm->url) { - git__free(sm->url); - sm->url = NULL; - } + git__free(sm->url); + sm->url = NULL; + if (value != NULL && (sm->url = git__strdup(value)) == NULL) - goto fail; + return -1; } else if (strcasecmp(property, "update") == 0) { int val; if (git_config_lookup_map_value( - _sm_update_map, ARRAY_SIZE(_sm_update_map), value, &val) < 0) { - giterr_set(GITERR_INVALID, - "Invalid value for submodule update property: '%s'", value); - goto fail; - } + _sm_update_map, ARRAY_SIZE(_sm_update_map), value, &val) < 0) + return submodule_config_error("update", value); sm->update_default = sm->update = (git_submodule_update_t)val; } else if (strcasecmp(property, "fetchRecurseSubmodules") == 0) { - if (git__parse_bool(&sm->fetch_recurse, value) < 0) { - giterr_set(GITERR_INVALID, - "Invalid value for submodule 'fetchRecurseSubmodules' property: '%s'", value); - goto fail; - } + if (git__parse_bool(&sm->fetch_recurse, value) < 0) + return submodule_config_error("fetchRecurseSubmodules", value); } else if (strcasecmp(property, "ignore") == 0) { int val; if (git_config_lookup_map_value( - _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), value, &val) < 0) { - giterr_set(GITERR_INVALID, - "Invalid value for submodule ignore property: '%s'", value); - goto fail; - } + _sm_ignore_map, ARRAY_SIZE(_sm_ignore_map), value, &val) < 0) + return submodule_config_error("ignore", value); sm->ignore_default = sm->ignore = (git_submodule_ignore_t)val; } /* ignore other unknown submodule properties */ return 0; - -fail: - submodule_release(sm, 0); - git_buf_free(&name); - return -1; } static int submodule_load_from_wd_lite( @@ -1117,10 +1119,9 @@ static git_config_file *open_gitmodules( if (okay_to_create || git_path_isfile(path.ptr)) { /* git_config_file__ondisk should only fail if OOM */ if (git_config_file__ondisk(&mods, path.ptr) < 0) - return NULL; - + mods = NULL; /* open should only fail here if the file is malformed */ - if (git_config_file_open(mods) < 0) { + else if (git_config_file_open(mods) < 0) { git_config_file_free(mods); mods = NULL; } @@ -1135,6 +1136,8 @@ static git_config_file *open_gitmodules( */ } + git_buf_free(&path); + return mods; } diff --git a/tests-clar/submodule/modify.c b/tests-clar/submodule/modify.c index 7f04ce0f5..ffbbe891c 100644 --- a/tests-clar/submodule/modify.c +++ b/tests-clar/submodule/modify.c @@ -253,4 +253,5 @@ void test_submodule_modify__edit_and_save(void) (int)GIT_SUBMODULE_UPDATE_REBASE, (int)git_submodule_update(sm2)); git_repository_free(r2); + git__free(old_url); } diff --git a/tests-clar/valgrind-supp-mac.txt b/tests-clar/valgrind-supp-mac.txt new file mode 100644 index 000000000..03e60dcd7 --- /dev/null +++ b/tests-clar/valgrind-supp-mac.txt @@ -0,0 +1,82 @@ +{ + libgit2-giterr-set-buffer + Memcheck:Leak + ... + fun:git__realloc + fun:git_buf_try_grow + fun:git_buf_grow + fun:git_buf_vprintf + fun:giterr_set +} +{ + mac-setenv-leak-1 + Memcheck:Leak + fun:malloc_zone_malloc + fun:__setenv + fun:setenv +} +{ + mac-setenv-leak-2 + Memcheck:Leak + fun:malloc_zone_malloc + fun:malloc_set_zone_name + ... + fun:init__zone0 + fun:setenv +} +{ + mac-dyld-initializer-leak + Memcheck:Leak + fun:malloc + ... + fun:dyld_register_image_state_change_handler + fun:_dyld_initializer +} +{ + mac-tz-leak-1 + Memcheck:Leak + ... + fun:token_table_add + fun:notify_register_check + fun:notify_register_tz +} +{ + mac-tz-leak-2 + Memcheck:Leak + fun:malloc + fun:tzload +} +{ + mac-tz-leak-3 + Memcheck:Leak + fun:malloc + fun:tzsetwall_basic +} +{ + mac-tz-leak-4 + Memcheck:Leak + fun:malloc + fun:gmtsub +} +{ + mac-system-init-leak-1 + Memcheck:Leak + ... + fun:_libxpc_initializer + fun:libSystem_initializer +} +{ + mac-system-init-leak-2 + Memcheck:Leak + ... + fun:__keymgr_initializer + fun:libSystem_initializer +} +{ + mac-puts-leak + Memcheck:Leak + fun:malloc + fun:__smakebuf + ... + fun:puts +} From 5f4a61aea834fe25ce1596bc9c0e0b5e563aa98b Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 9 Aug 2012 19:43:25 -0700 Subject: [PATCH 4/5] Working implementation of git_submodule_status This is a big redesign of the git_submodule_status API and the implementation of the redesigned API. It also fixes a number of bugs that I found in other parts of the submodule API while writing the tests for the status part. This also fixes a couple of bugs in the iterators that had not been noticed before - one with iterating when there is a gitlink (i.e. separate-work-dir) and one where I was treating anything even vaguely submodule-like as a submodule, more aggressively than core git does. --- include/git2/diff.h | 15 ++ include/git2/oid.h | 2 + include/git2/submodule.h | 167 +++++++------- src/diff_output.c | 19 ++ src/iterator.c | 21 +- src/repository.c | 9 +- src/submodule.c | 401 ++++++++++++++++----------------- src/submodule.h | 18 +- tests-clar/status/submodules.c | 8 +- tests-clar/submodule/status.c | 286 ++++++++++++++++++++++- 10 files changed, 618 insertions(+), 328 deletions(-) diff --git a/include/git2/diff.h b/include/git2/diff.h index 79ef7a49b..088e1ecfa 100644 --- a/include/git2/diff.h +++ b/include/git2/diff.h @@ -391,6 +391,21 @@ GIT_EXTERN(int) git_diff_print_patch( void *cb_data, git_diff_data_fn print_cb); +/** + * Query how many diff records are there in a diff list. + * + * You can optionally pass in a `git_delta_t` value if you want a count + * of just entries that match that delta type, or pass -1 for all delta + * records. + * + * @param diff A git_diff_list generated by one of the above functions + * @param delta_t A git_delta_t value to filter the count, or -1 for all records + * @return Count of number of deltas matching delta_t type + */ +GIT_EXTERN(int) git_diff_entrycount( + git_diff_list *diff, + int delta_t); + /**@}*/ diff --git a/include/git2/oid.h b/include/git2/oid.h index 887b33e50..9e54a9f96 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -185,6 +185,8 @@ GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str); /** * Check is an oid is all zeros. + * + * @return 1 if all zeros, 0 otherwise. */ GIT_EXTERN(int) git_oid_iszero(const git_oid *a); diff --git a/include/git2/submodule.h b/include/git2/submodule.h index 6cd66465e..fe7f26cfe 100644 --- a/include/git2/submodule.h +++ b/include/git2/submodule.h @@ -60,84 +60,68 @@ typedef enum { GIT_SUBMODULE_IGNORE_ALL = 3 /* never dirty */ } git_submodule_ignore_t; -/** - * Status values for submodules. - * - * One of these values will be returned for the submodule in the index - * relative to the HEAD tree, and one will be returned for the submodule in - * the working directory relative to the index. The value can be extracted - * from the actual submodule status return value using one of the macros - * below (see GIT_SUBMODULE_INDEX_STATUS and GIT_SUBMODULE_WD_STATUS). - */ -enum { - GIT_SUBMODULE_STATUS_CLEAN = 0, - GIT_SUBMODULE_STATUS_ADDED = 1, - GIT_SUBMODULE_STATUS_REMOVED = 2, - GIT_SUBMODULE_STATUS_REMOVED_TYPE_CHANGE = 3, - GIT_SUBMODULE_STATUS_MODIFIED = 4, - GIT_SUBMODULE_STATUS_MODIFIED_AHEAD = 5, - GIT_SUBMODULE_STATUS_MODIFIED_BEHIND = 6 -}; - /** * Return codes for submodule status. * - * A combination of these flags (and shifted values of the - * GIT_SUBMODULE_STATUS codes above) will be returned to describe the status - * of a submodule. + * A combination of these flags will be returned to describe the status of a + * submodule. Depending on the "ignore" property of the submodule, some of + * the flags may never be returned because they indicate changes that are + * supposed to be ignored. * * Submodule info is contained in 4 places: the HEAD tree, the index, config * files (both .git/config and .gitmodules), and the working directory. Any * or all of those places might be missing information about the submodule - * depending on what state the repo is in. + * depending on what state the repo is in. We consider all four places to + * build the combination of status flags. * - * When you ask for submodule status, we consider all four places and return - * a combination of the flags below. Also, we also compare HEAD to index to - * workdir, and return a relative status code (see above) for the - * comparisons. Use the GIT_SUBMODULE_INDEX_STATUS() and - * GIT_SUBMODULE_WD_STATUS() macros to extract these status codes from the - * results. As an example, if the submodule exists in the HEAD and does not - * exist in the index, then using GIT_SUBMODULE_INDEX_STATUS(st) will return - * GIT_SUBMODULE_STATUS_REMOVED. + * There are four values that are not really status, but give basic info + * about what sources of submodule data are available. These will be + * returned even if ignore is set to "ALL". * - * The ignore settings for the submodule will control how much status info - * you get about the working directory. For example, with ignore ALL, the - * workdir will always show as clean. With any ignore level below NONE, - * you will never get the WD_HAS_UNTRACKED value back. + * * IN_HEAD - superproject head contains submodule + * * IN_INDEX - superproject index contains submodule + * * IN_CONFIG - superproject gitmodules has submodule + * * IN_WD - superproject workdir has submodule * - * The other SUBMODULE_STATUS values you might see are: + * The following values will be returned so long as ignore is not "ALL". * - * - IN_HEAD means submodule exists in HEAD tree - * - IN_INDEX means submodule exists in index - * - IN_CONFIG means submodule exists in config - * - IN_WD means submodule exists in workdir and looks like a submodule - * - WD_CHECKED_OUT means submodule in workdir has .git content - * - WD_HAS_UNTRACKED means workdir contains untracked files. This would - * only ever be returned for ignore value GIT_SUBMODULE_IGNORE_NONE. - * - WD_MISSING_COMMITS means workdir repo is out of date and does not - * contain the SHAs from either the index or the HEAD tree + * * INDEX_ADDED - in index, not in head + * * INDEX_DELETED - in head, not in index + * * INDEX_MODIFIED - index and head don't match + * * WD_UNINITIALIZED - workdir contains empty directory + * * WD_ADDED - in workdir, not index + * * WD_DELETED - in index, not workdir + * * WD_MODIFIED - index and workdir head don't match + * + * The following can only be returned if ignore is "NONE" or "UNTRACKED". + * + * * WD_INDEX_MODIFIED - submodule workdir index is dirty + * * WD_WD_MODIFIED - submodule workdir has modified files + * + * Lastly, the following will only be returned for ignore "NONE". + * + * * WD_UNTRACKED - wd contains untracked files */ -#define GIT_SUBMODULE_STATUS_IN_HEAD (1u << 0) -#define GIT_SUBMODULE_STATUS_IN_INDEX (1u << 1) -#define GIT_SUBMODULE_STATUS_IN_CONFIG (1u << 2) -#define GIT_SUBMODULE_STATUS_IN_WD (1u << 3) -#define GIT_SUBMODULE_STATUS_INDEX_DATA_OFFSET (4) -#define GIT_SUBMODULE_STATUS_WD_DATA_OFFSET (7) -#define GIT_SUBMODULE_STATUS_WD_CHECKED_OUT (1u << 10) -#define GIT_SUBMODULE_STATUS_WD_HAS_UNTRACKED (1u << 11) -#define GIT_SUBMODULE_STATUS_WD_MISSING_COMMITS (1u << 12) +typedef enum { + GIT_SUBMODULE_STATUS_IN_HEAD = (1u << 0), + GIT_SUBMODULE_STATUS_IN_INDEX = (1u << 1), + GIT_SUBMODULE_STATUS_IN_CONFIG = (1u << 2), + GIT_SUBMODULE_STATUS_IN_WD = (1u << 3), + GIT_SUBMODULE_STATUS_INDEX_ADDED = (1u << 4), + GIT_SUBMODULE_STATUS_INDEX_DELETED = (1u << 5), + GIT_SUBMODULE_STATUS_INDEX_MODIFIED = (1u << 6), + GIT_SUBMODULE_STATUS_WD_UNINITIALIZED = (1u << 7), + GIT_SUBMODULE_STATUS_WD_ADDED = (1u << 8), + GIT_SUBMODULE_STATUS_WD_DELETED = (1u << 9), + GIT_SUBMODULE_STATUS_WD_MODIFIED = (1u << 10), + GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = (1u << 11), + GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = (1u << 12), + GIT_SUBMODULE_STATUS_WD_UNTRACKED = (1u << 13), +} git_submodule_status_t; -/** - * Extract submodule status value for index from status mask. - */ -#define GIT_SUBMODULE_INDEX_STATUS(s) \ - (((s) >> GIT_SUBMODULE_STATUS_INDEX_DATA_OFFSET) & 0x07) - -/** - * Extract submodule status value for working directory from status mask. - */ -#define GIT_SUBMODULE_WD_STATUS(s) \ - (((s) >> GIT_SUBMODULE_STATUS_WD_DATA_OFFSET) & 0x07) +#define GIT_SUBMODULE_STATUS_IS_UNMODIFIED(S) \ + (((S) & ~(GIT_SUBMODULE_STATUS_IN_HEAD | GIT_SUBMODULE_STATUS_IN_INDEX | \ + GIT_SUBMODULE_STATUS_IN_CONFIG | GIT_SUBMODULE_STATUS_IN_WD)) == 0) /** * Lookup submodule information by name or path. @@ -206,7 +190,7 @@ GIT_EXTERN(int) git_submodule_foreach( * * To fully emulate "git submodule add" call this function, then open the * submodule repo and perform the clone step as needed. Lastly, call - * `git_submodule_add_finalize` to wrap up adding the new submodule and + * `git_submodule_add_finalize()` to wrap up adding the new submodule and * .gitmodules to the index to be ready to commit. * * @param submodule The newly created submodule ready to open for clone @@ -232,22 +216,33 @@ GIT_EXTERN(int) git_submodule_add_setup( * and done the clone of the submodule. This adds the .gitmodules file * and the newly cloned submodule to the index to be ready to be committed * (but doesn't actually do the commit). + * + * @param submodule The submodule to finish adding. */ GIT_EXTERN(int) git_submodule_add_finalize(git_submodule *submodule); /** * Add current submodule HEAD commit to index of superproject. + * + * @param submodule The submodule to add to the index + * @param write_index Boolean if this should immediately write the index + * file. If you pass this as false, you will have to get the + * git_index and explicitly call `git_index_write()` on it to + * save the change. + * @return 0 on success, <0 on failure */ -GIT_EXTERN(int) git_submodule_add_to_index(git_submodule *submodule); +GIT_EXTERN(int) git_submodule_add_to_index( + git_submodule *submodule, + int write_index); /** * Write submodule settings to .gitmodules file. * * This commits any in-memory changes to the submodule to the gitmodules - * file on disk. You may also be interested in `git_submodule_init` which + * file on disk. You may also be interested in `git_submodule_init()` which * writes submodule info to ".git/config" (which is better for local changes - * to submodule settings) and/or `git_submodule_sync` which writes settings - * about remotes to the actual submodule repository. + * to submodule settings) and/or `git_submodule_sync()` which writes + * settings about remotes to the actual submodule repository. * * @param submodule The submodule to write. * @return 0 on success, <0 on failure. @@ -259,7 +254,7 @@ GIT_EXTERN(int) git_submodule_save(git_submodule *submodule); * * This returns a pointer to the repository that contains the submodule. * This is a just a reference to the repository that was passed to the - * original `git_submodule_lookup` call, so if that repository has been + * original `git_submodule_lookup()` call, so if that repository has been * freed, then this may be a dangling reference. * * @param submodule Pointer to submodule object @@ -300,8 +295,8 @@ GIT_EXTERN(const char *) git_submodule_url(git_submodule *submodule); * This sets the URL in memory for the submodule. This will be used for * any following submodule actions while this submodule data is in memory. * - * After calling this, you may wish to call `git_submodule_save` to write - * the changes back to the ".gitmodules" file and `git_submodule_sync` to + * After calling this, you may wish to call `git_submodule_save()` to write + * the changes back to the ".gitmodules" file and `git_submodule_sync()` to * write the changes to the checked out submodule repository. * * @param submodule Pointer to the submodule object @@ -331,8 +326,8 @@ GIT_EXTERN(const git_oid *) git_submodule_head_oid(git_submodule *submodule); * * This returns the OID that corresponds to looking up 'HEAD' in the checked * out submodule. If there are pending changes in the index or anything - * else, this won't notice that. You should call `git_submodule_status` for - * a more complete picture about the state of the working directory. + * else, this won't notice that. You should call `git_submodule_status()` + * for a more complete picture about the state of the working directory. * * @param submodule Pointer to submodule object * @return Pointer to git_oid or NULL if submodule is not checked out. @@ -348,7 +343,7 @@ GIT_EXTERN(const git_oid *) git_submodule_wd_oid(git_submodule *submodule); * of the submodule from a clean checkout to be dirty, including the * addition of untracked files. This is the default if unspecified. * - **GIT_SUBMODULE_IGNORE_UNTRACKED** examines the contents of the - * working tree (i.e. call `git_status_foreach` on the submodule) but + * working tree (i.e. call `git_status_foreach()` on the submodule) but * UNTRACKED files will not count as making the submodule dirty. * - **GIT_SUBMODULE_IGNORE_DIRTY** means to only check if the HEAD of the * submodule has moved for status. This is fast since it does not need to @@ -364,12 +359,12 @@ GIT_EXTERN(git_submodule_ignore_t) git_submodule_ignore( * Set the ignore rule for the submodule. * * This sets the ignore rule in memory for the submodule. This will be used - * for any following actions (such as `git_submodule_status`) while the - * submodule is in memory. You should call `git_submodule_save` if you want - * to persist the new ignore role. + * for any following actions (such as `git_submodule_status()`) while the + * submodule is in memory. You should call `git_submodule_save()` if you + * want to persist the new ignore role. * * Calling this again with GIT_SUBMODULE_IGNORE_DEFAULT or calling - * `git_submodule_reload` will revert the rule to the value that was in the + * `git_submodule_reload()` will revert the rule to the value that was in the * original config. * * @return old value for ignore @@ -388,10 +383,10 @@ GIT_EXTERN(git_submodule_update_t) git_submodule_update( * Set the update rule for the submodule. * * This sets the update rule in memory for the submodule. You should call - * `git_submodule_save` if you want to persist the new update rule. + * `git_submodule_save()` if you want to persist the new update rule. * * Calling this again with GIT_SUBMODULE_UPDATE_DEFAULT or calling - * `git_submodule_reload` will revert the rule to the value that was in the + * `git_submodule_reload()` will revert the rule to the value that was in the * original config. * * @return old value for update @@ -429,7 +424,7 @@ GIT_EXTERN(int) git_submodule_sync(git_submodule *submodule); * Open the repository for a submodule. * * This is a newly opened repository object. The caller is responsible for - * calling `git_repository_free` on it when done. Multiple calls to this + * calling `git_repository_free()` on it when done. Multiple calls to this * function will return distinct `git_repository` objects. This will only * work if the submodule is checked out into the working directory. * @@ -462,10 +457,10 @@ GIT_EXTERN(int) git_submodule_reload_all(git_repository *repo); * This looks at a submodule and tries to determine the status. It * will return a combination of the `GIT_SUBMODULE_STATUS` values above. * How deeply it examines the working directory to do this will depend - * on the `git_submodule_ignore_t` value for the submodule (which can be - * overridden with `git_submodule_set_ignore()`). + * on the `git_submodule_ignore_t` value for the submodule - which can be + * set either temporarily or permanently with `git_submodule_set_ignore()`. * - * @param status Combination of GIT_SUBMODULE_STATUS values from above. + * @param status Combination of `GIT_SUBMODULE_STATUS` flags * @param submodule Submodule for which to get status * @return 0 on success, <0 on error */ diff --git a/src/diff_output.c b/src/diff_output.c index d269a4cee..2bf939f33 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -718,6 +718,25 @@ int git_diff_print_patch( return error; } +int git_diff_entrycount(git_diff_list *diff, int delta_t) +{ + int count = 0; + unsigned int i; + git_diff_delta *delta; + + assert(diff); + + if (delta_t < 0) + return diff->deltas.length; + + git_vector_foreach(&diff->deltas, i, delta) { + if (delta->status == (git_delta_t)delta_t) + count++; + } + + return count; +} + int git_diff_blobs( git_blob *old_blob, git_blob *new_blob, diff --git a/src/iterator.c b/src/iterator.c index 819b0e22a..92fe67134 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -525,7 +525,9 @@ static int workdir_iterator__advance( while ((wf = wi->stack) != NULL) { next = git_vector_get(&wf->entries, ++wf->index); if (next != NULL) { - if (strcmp(next->path, DOT_GIT "/") == 0) + /* match git's behavior of ignoring anything named ".git" */ + if (strcmp(next->path, DOT_GIT "/") == 0 || + strcmp(next->path, DOT_GIT) == 0) continue; /* else found a good entry */ break; @@ -607,8 +609,8 @@ static int workdir_iterator__update_entry(workdir_iterator *wi) wi->entry.path = ps->path; - /* skip over .git directory */ - if (strcmp(ps->path, DOT_GIT "/") == 0) + /* skip over .git entry */ + if (strcmp(ps->path, DOT_GIT "/") == 0 || strcmp(ps->path, DOT_GIT) == 0) return workdir_iterator__advance((git_iterator *)wi, NULL); /* if there is an error processing the entry, treat as ignored */ @@ -629,15 +631,10 @@ static int workdir_iterator__update_entry(workdir_iterator *wi) /* detect submodules */ if (S_ISDIR(wi->entry.mode)) { - bool is_submodule = git_path_contains(&wi->path, DOT_GIT); - - /* if there is no .git, still check submodules data */ - if (!is_submodule) { - int res = git_submodule_lookup(NULL, wi->repo, wi->entry.path); - is_submodule = (res == 0); - if (res == GIT_ENOTFOUND) - giterr_clear(); - } + int res = git_submodule_lookup(NULL, wi->repo, wi->entry.path); + bool is_submodule = (res == 0); + if (res == GIT_ENOTFOUND) + giterr_clear(); /* if submodule, mark as GITLINK and remove trailing slash */ if (is_submodule) { diff --git a/src/repository.c b/src/repository.c index 18788d187..c12df25c3 100644 --- a/src/repository.c +++ b/src/repository.c @@ -146,8 +146,13 @@ static int load_workdir(git_repository *repo, git_buf *parent_path) return -1; error = git_config_get_string(&worktree, config, "core.worktree"); - if (!error && worktree != NULL) - repo->workdir = git__strdup(worktree); + if (!error && worktree != NULL) { + error = git_path_prettify_dir( + &worktree_buf, worktree, repo->path_repository); + if (error < 0) + return error; + repo->workdir = git_buf_detach(&worktree_buf); + } else if (error != GIT_ENOTFOUND) return error; else { diff --git a/src/submodule.c b/src/submodule.c index 3ebb362a4..15501a1dd 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -42,7 +42,7 @@ static kh_inline khint_t str_hash_no_trailing_slash(const char *s) khint_t h; for (h = 0; *s; ++s) - if (s[1] || *s != '/') + if (s[1] != '\0' || *s != '/') h = (h << 5) - h + *s; return h; @@ -53,9 +53,9 @@ static kh_inline int str_equal_no_trailing_slash(const char *a, const char *b) size_t alen = a ? strlen(a) : 0; size_t blen = b ? strlen(b) : 0; - if (alen && a[alen] == '/') + if (alen > 0 && a[alen - 1] == '/') alen--; - if (blen && b[blen] == '/') + if (blen > 0 && b[blen - 1] == '/') blen--; return (alen == blen && strncmp(a, b, alen) == 0); @@ -65,24 +65,19 @@ __KHASH_IMPL( str, static kh_inline, const char *, void *, 1, str_hash_no_trailing_slash, str_equal_no_trailing_slash); -static int load_submodule_config( - git_repository *repo, bool force); -static git_config_file *open_gitmodules( - git_repository *, bool, const git_oid *); -static int lookup_head_remote( - git_buf *url, git_repository *repo); -static int submodule_get( - git_submodule **, git_repository *, const char *, const char *); -static void submodule_release( - git_submodule *sm, int decr); -static int submodule_load_from_index( - git_repository *, const git_index_entry *); -static int submodule_load_from_head( - git_repository *, const char *, const git_oid *); -static int submodule_load_from_config( - const char *, const char *, void *); -static int submodule_update_config( - git_submodule *, const char *, const char *, bool, bool); +static int load_submodule_config(git_repository *repo, bool force); +static git_config_file *open_gitmodules(git_repository *, bool, const git_oid *); +static int lookup_head_remote(git_buf *url, git_repository *repo); +static int submodule_get(git_submodule **, git_repository *, const char *, const char *); +static void submodule_release(git_submodule *sm, int decr); +static int submodule_load_from_index(git_repository *, const git_index_entry *); +static int submodule_load_from_head(git_repository*, const char*, const git_oid*); +static int submodule_load_from_config(const char *, const char *, void *); +static int submodule_load_from_wd_lite(git_submodule *, const char *, void *); +static int submodule_update_config(git_submodule *, const char *, const char *, bool, bool); +static void submodule_mode_mismatch(git_repository *, const char *, unsigned int); +static int submodule_index_status(unsigned int *status, git_submodule *sm); +static int submodule_wd_status(unsigned int *status, git_submodule *sm); static int submodule_cmp(const void *a, const void *b) { @@ -167,8 +162,10 @@ int git_submodule_foreach( break; } - if ((error = callback(sm, sm->name, payload)) < 0) + if (callback(sm, sm->name, payload)) { + error = GIT_EUSER; break; + } }); git_vector_free(&seen); @@ -337,10 +334,10 @@ int git_submodule_add_finalize(git_submodule *sm) (error = git_index_add(index, GIT_MODULES_FILE, 0)) < 0) return error; - return git_submodule_add_to_index(sm); + return git_submodule_add_to_index(sm, true); } -int git_submodule_add_to_index(git_submodule *sm) +int git_submodule_add_to_index(git_submodule *sm, int write_index) { int error; git_repository *repo, *sm_repo; @@ -354,6 +351,9 @@ int git_submodule_add_to_index(git_submodule *sm) repo = sm->owner; + /* force reload of wd OID by git_submodule_open */ + sm->flags = sm->flags & ~GIT_SUBMODULE_STATUS__WD_OID_VALID; + if ((error = git_repository_index__weakptr(&index, repo)) < 0 || (error = git_buf_joinpath( &path, git_repository_workdir(repo), sm->path)) < 0 || @@ -367,6 +367,7 @@ int git_submodule_add_to_index(git_submodule *sm) error = -1; goto cleanup; } + entry.path = sm->path; git_index__init_entry_from_stat(&st, &entry); /* calling git_submodule_open will have set sm->wd_oid if possible */ @@ -388,9 +389,17 @@ int git_submodule_add_to_index(git_submodule *sm) git_commit_free(head); - /* now add it */ + /* add it */ error = git_index_add2(index, &entry); + /* write it, if requested */ + if (!error && write_index) { + error = git_index_write(index); + + if (!error) + git_oid_cpy(&sm->index_oid, &sm->wd_oid); + } + cleanup: git_repository_free(sm_repo); git_buf_free(&path); @@ -501,7 +510,7 @@ int git_submodule_set_url(git_submodule *submodule, const char *url) return 0; } - const git_oid *git_submodule_index_oid(git_submodule *submodule) +const git_oid *git_submodule_index_oid(git_submodule *submodule) { assert(submodule); @@ -531,6 +540,8 @@ const git_oid *git_submodule_wd_oid(git_submodule *submodule) /* calling submodule open grabs the HEAD OID if possible */ if (!git_submodule_open(&subrepo, submodule)) git_repository_free(subrepo); + else + giterr_clear(); } if (submodule->flags & GIT_SUBMODULE_STATUS__WD_OID_VALID) @@ -693,16 +704,21 @@ int git_submodule_reload(git_submodule *submodule) if (git_repository_index__weakptr(&index, repo) < 0) return -1; + submodule->flags = submodule->flags & + ~(GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS__INDEX_OID_VALID); + pos = git_index_find(index, submodule->path); if (pos >= 0) { git_index_entry *entry = git_index_get(index, pos); - submodule->flags = submodule->flags & - ~(GIT_SUBMODULE_STATUS_IN_INDEX | - GIT_SUBMODULE_STATUS__INDEX_OID_VALID); - - if ((error = submodule_load_from_index(repo, entry)) < 0) - return error; + if (S_ISGITLINK(entry->mode)) { + if ((error = submodule_load_from_index(repo, entry)) < 0) + return error; + } else { + submodule_mode_mismatch( + repo, entry->path, GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE); + } } /* refresh HEAD tree data */ @@ -715,7 +731,14 @@ int git_submodule_reload(git_submodule *submodule) GIT_SUBMODULE_STATUS__HEAD_OID_VALID); if (!(error = git_tree_entry_bypath(&te, head, submodule->path))) { - error = submodule_load_from_head(repo, submodule->path, &te->oid); + + if (S_ISGITLINK(te->attr)) { + error = submodule_load_from_head(repo, submodule->path, &te->oid); + } else { + submodule_mode_mismatch( + repo, submodule->path, + GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE); + } git_tree_entry_free(te); } @@ -749,6 +772,16 @@ int git_submodule_reload(git_submodule *submodule) git_config_file_free(mods); } + if (error < 0) + return error; + + /* refresh wd data */ + + submodule->flags = submodule->flags & + ~(GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_OID_VALID); + + error = submodule_load_from_wd_lite(submodule, submodule->path, NULL); + return error; } @@ -756,16 +789,21 @@ int git_submodule_status( unsigned int *status, git_submodule *submodule) { + int error = 0; + unsigned int status_val; + assert(status && submodule); - GIT_UNUSED(status); - GIT_UNUSED(submodule); + status_val = GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(submodule->flags); - /* TODO: move status code from below and update */ + if (submodule->ignore != GIT_SUBMODULE_IGNORE_ALL) { + if (!(error = submodule_index_status(&status_val, submodule))) + error = submodule_wd_status(&status_val, submodule); + } - *status = 0; + *status = status_val; - return 0; + return error; } /* @@ -848,7 +886,7 @@ static int submodule_get( /* insert value at name - if another thread beats us to it, then use * their record and release our own. */ - pos = kh_put(str, smcfg, name, &error); + pos = kh_put(str, smcfg, sm->name, &error); if (error < 0) { submodule_release(sm, 1); @@ -1037,6 +1075,18 @@ static int submodule_load_from_wd_lite( return 0; } +static void submodule_mode_mismatch( + git_repository *repo, const char *path, unsigned int flag) +{ + khiter_t pos = git_strmap_lookup_index(repo->submodules, path); + + if (git_strmap_valid_index(repo->submodules, pos)) { + git_submodule *sm = git_strmap_value_at(repo->submodules, pos); + + sm->flags |= flag; + } +} + static int load_submodule_config_from_index( git_repository *repo, git_oid *gitmodules_oid) { @@ -1055,8 +1105,13 @@ static int load_submodule_config_from_index( error = submodule_load_from_index(repo, entry); if (error < 0) break; - } else if (strcmp(entry->path, GIT_MODULES_FILE) == 0) - git_oid_cpy(gitmodules_oid, &entry->oid); + } else { + submodule_mode_mismatch( + repo, entry->path, GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE); + + if (strcmp(entry->path, GIT_MODULES_FILE) == 0) + git_oid_cpy(gitmodules_oid, &entry->oid); + } error = git_iterator_advance(i, &entry); } @@ -1090,9 +1145,14 @@ static int load_submodule_config_from_head( error = submodule_load_from_head(repo, entry->path, &entry->oid); if (error < 0) break; - } else if (strcmp(entry->path, GIT_MODULES_FILE) == 0 && - git_oid_iszero(gitmodules_oid)) - git_oid_cpy(gitmodules_oid, &entry->oid); + } else { + submodule_mode_mismatch( + repo, entry->path, GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE); + + if (strcmp(entry->path, GIT_MODULES_FILE) == 0 && + git_oid_iszero(gitmodules_oid)) + git_oid_cpy(gitmodules_oid, &entry->oid); + } error = git_iterator_advance(i, &entry); } @@ -1303,183 +1363,108 @@ cleanup: return error; } -#if 0 +static int submodule_index_status(unsigned int *status, git_submodule *sm) +{ + const git_oid *head_oid = git_submodule_head_oid(sm); + const git_oid *index_oid = git_submodule_index_oid(sm); -static int head_oid_for_submodule( - git_oid *oid, - git_repository *owner, - const char *path) + if (!head_oid) { + if (index_oid) + *status |= GIT_SUBMODULE_STATUS_INDEX_ADDED; + } + else if (!index_oid) + *status |= GIT_SUBMODULE_STATUS_INDEX_DELETED; + else if (!git_oid_equal(head_oid, index_oid)) + *status |= GIT_SUBMODULE_STATUS_INDEX_MODIFIED; + + return 0; +} + +static int submodule_wd_status(unsigned int *status, git_submodule *sm) { int error = 0; - git_oid head_oid; - git_tree *head_tree = NULL, *container_tree = NULL; - unsigned int pos; - const git_tree_entry *entry; + const git_oid *wd_oid, *index_oid; + git_repository *sm_repo = NULL; - if (git_reference_name_to_oid(&head_oid, owner, GIT_HEAD_FILE) < 0 || - git_tree_lookup(&head_tree, owner, &head_oid) < 0 || - git_tree_resolve_path(&container_tree, &pos, head_tree, path) < 0 || - (entry = git_tree_entry_byindex(container_tree, pos)) == NULL) + /* open repo now if we need it (so wd_oid() call won't reopen) */ + if ((sm->ignore == GIT_SUBMODULE_IGNORE_NONE || + sm->ignore == GIT_SUBMODULE_IGNORE_UNTRACKED) && + (sm->flags & GIT_SUBMODULE_STATUS_IN_WD) != 0) { - memset(oid, 0, sizeof(*oid)); - error = GIT_ENOTFOUND; - } - else { - git_oid_cpy(oid, &entry->oid); + if ((error = git_submodule_open(&sm_repo, sm)) < 0) + return error; } - git_tree_free(head_tree); - git_tree_free(container_tree); + index_oid = git_submodule_index_oid(sm); + wd_oid = git_submodule_wd_oid(sm); - return error; -} - -int git_submodule_status( - unsigned int *status, - git_oid *head, - git_submodule *sm, - git_submodule_ignore_t ignore) -{ - int error; - const char *workdir; - git_repository *owner, *sm_repo = NULL; - git_oid owner_head, sm_head; - - assert(submodule && status); - - if (head == NULL) - head = &sm_head; - - owner = submodule->owner; - workdir = git_repository_workdir(owner); - - if (ignore == GIT_SUBMODULE_IGNORE_DEFAULT) - ignore = sm->ignore; - - /* if this is a bare repo or the submodule dir has no .git yet, - * then it is not checked out and we'll just return index data. - */ - if (!workdir || (sm->flags & GIT_SUBMODULE_FLAG__HAS_DOTGIT) == 0) { - *status = GIT_SUBMODULE_STATUS_NOT_CHECKED_OUT; - - if (sm->index_oid_valid) - git_oid_cpy(head, &sm->index_oid); + if (!index_oid) { + if (wd_oid) + *status |= GIT_SUBMODULE_STATUS_WD_ADDED; + } + else if (!wd_oid) { + if ((sm->flags & GIT_SUBMODULE_STATUS__WD_SCANNED) != 0 && + (sm->flags & GIT_SUBMODULE_STATUS_IN_WD) == 0) + *status |= GIT_SUBMODULE_STATUS_WD_UNINITIALIZED; else - memset(head, 0, sizeof(git_oid)); + *status |= GIT_SUBMODULE_STATUS_WD_DELETED; + } + else if (!git_oid_equal(index_oid, wd_oid)) + *status |= GIT_SUBMODULE_STATUS_WD_MODIFIED; - if (git_oid_iszero(head)) { - if (sm->url) - *status = GIT_SUBMODULE_STATUS_NEW_SUBMODULE; - } else if (!sm->url) { - *status = GIT_SUBMODULE_STATUS_DELETED_SUBMODULE; + if (sm_repo != NULL) { + git_tree *sm_head; + git_diff_options opt; + git_diff_list *diff; + + /* the diffs below could be optimized with an early termination + * option to the git_diff functions, but for now this is sufficient + * (and certainly no worse that what core git does). + */ + + /* perform head-to-index diff on submodule */ + + if ((error = git_repository_head_tree(&sm_head, sm_repo)) < 0) + return error; + + memset(&opt, 0, sizeof(opt)); + if (sm->ignore == GIT_SUBMODULE_IGNORE_NONE) + opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED; + + error = git_diff_index_to_tree(sm_repo, &opt, sm_head, &diff); + + if (!error) { + if (git_diff_entrycount(diff, -1) > 0) + *status |= GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED; + + git_diff_list_free(diff); + diff = NULL; } - return 0; + git_tree_free(sm_head); + + if (error < 0) + return error; + + /* perform index-to-workdir diff on submodule */ + + error = git_diff_workdir_to_index(sm_repo, &opt, &diff); + + if (!error) { + int untracked = git_diff_entrycount(diff, GIT_DELTA_UNTRACKED); + + if (untracked > 0) + *status |= GIT_SUBMODULE_STATUS_WD_UNTRACKED; + + if (git_diff_entrycount(diff, -1) - untracked > 0) + *status |= GIT_SUBMODULE_STATUS_WD_WD_MODIFIED; + + git_diff_list_free(diff); + diff = NULL; + } + + git_repository_free(sm_repo); } - /* look up submodule path in repo head to find if new or deleted */ - if ((error = head_oid_for_submodule(&owner_head, owner, sm->path)) < 0) { - *status = GIT_SUBMODULE_STATUS_NEW_SUBMODULE; - /* ??? */ - } - - if (ignore == GIT_SUBMODULE_IGNORE_ALL) { - *status = GIT_SUBMODULE_STATUS_CLEAN; - git_oid_cpy(head, &sm->oid); - return 0; - } - - if ((error = git_submodule_open(&sm_repo, sm)) < 0) - return error; - - if ((error = git_reference_name_to_oid(head, sm_repo, GIT_HEAD_FILE)) < 0) - goto cleanup; - - if (ignore == GIT_SUBMODULE_IGNORE_DIRTY && - git_oid_cmp(head, &sm->oid) == 0) - { - *status = GIT_SUBMODULE_STATUS_CLEAN; - return 0; - } - - /* look up submodule oid from index in repo to find if new commits or missing commits */ - - /* run a short status to find if modified or untracked content */ - -#define GIT_SUBMODULE_STATUS_NEW_SUBMODULE (1u << 2) -#define GIT_SUBMODULE_STATUS_DELETED_SUBMODULE (1u << 3) -#define GIT_SUBMODULE_STATUS_NOT_CHECKED_OUT (1u << 4) -#define GIT_SUBMODULE_STATUS_NEW_COMMITS (1u << 5) -#define GIT_SUBMODULE_STATUS_MISSING_COMMITS (1u << 6) -#define GIT_SUBMODULE_STATUS_MODIFIED_CONTENT (1u << 7) -#define GIT_SUBMODULE_STATUS_UNTRACKED_CONTENT (1u << 8) - -cleanup: - git_repository_free(sm_repo); - git_tree_free(owner_tree); - return error; } - -int git_submodule_status_for_path( - unsigned int *status, - git_oid *head, - git_repository *repo, - const char *submodule_path, - git_submodule_ignore_t ignore) -{ - int error; - git_submodule *sm; - const char *workdir; - git_buf path = GIT_BUF_INIT; - git_oid owner_head; - - assert(repo && submodule_path && status); - - if ((error = git_submodule_lookup(&sm, repo, submodule_path)) == 0) - return git_submodule_status(status, head, sm, ignore); - - /* if submodule still exists in HEAD, then it is DELETED */ - if (!(error = head_oid_for_submodule(&owner_head, repo, submodule_path))) { - *status = GIT_SUBMODULE_STATUS_DELETED_SUBMODULE; - if (head) - git_oid_cmp(head, &owner_head); - return 0; - } - - /* submodule was not found - let's see what we can determine about it */ - workdir = git_repository_workdir(repo); - - if (error != GIT_ENOTFOUND || !workdir) { - *status = GIT_SUBMODULE_STATUS_NOT_A_SUBMODULE; - return error; - } - - giterr_clear(); - error = 0; - - /* figure out if this is NEW, NOT_CHECKED_OUT, or what */ - if (git_buf_joinpath(&path, workdir, submodule_path) < 0) - return -1; - - if (git_path_contains(&path, DOT_GIT)) { - git_repository *sm_repo; - - *status = GIT_SUBMODULE_STATUS_UNTRACKED_SUBMODULE; - - /* only bother look up head if it was non-NULL */ - if (head != NULL && - !(error = git_repository_open(&sm_repo, path.ptr))) - { - error = git_reference_name_to_oid(head, sm_repo, GIT_HEAD_FILE); - git_repository_free(sm_repo); - } - } else - *status = GIT_SUBMODULE_STATUS_NOT_A_SUBMODULE; - - git_buf_free(&path); - - return error; -} - -#endif diff --git a/src/submodule.h b/src/submodule.h index 83bc7dfe9..c7a6aaf76 100644 --- a/src/submodule.h +++ b/src/submodule.h @@ -85,10 +85,18 @@ struct git_submodule { }; /* Additional flags on top of public GIT_SUBMODULE_STATUS values */ -#define GIT_SUBMODULE_STATUS__WD_SCANNED (1u << 15) -#define GIT_SUBMODULE_STATUS__HEAD_OID_VALID (1u << 16) -#define GIT_SUBMODULE_STATUS__INDEX_OID_VALID (1u << 17) -#define GIT_SUBMODULE_STATUS__WD_OID_VALID (1u << 18) -#define GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES (1u << 19) +enum { + GIT_SUBMODULE_STATUS__WD_SCANNED = (1u << 20), + GIT_SUBMODULE_STATUS__HEAD_OID_VALID = (1u << 21), + GIT_SUBMODULE_STATUS__INDEX_OID_VALID = (1u << 22), + GIT_SUBMODULE_STATUS__WD_OID_VALID = (1u << 23), + GIT_SUBMODULE_STATUS__HEAD_NOT_SUBMODULE = (1u << 24), + GIT_SUBMODULE_STATUS__INDEX_NOT_SUBMODULE = (1u << 25), + GIT_SUBMODULE_STATUS__WD_NOT_SUBMODULE = (1u << 26), + GIT_SUBMODULE_STATUS__INDEX_MULTIPLE_ENTRIES = (1u << 27), +}; + +#define GIT_SUBMODULE_STATUS__CLEAR_INTERNAL(S) \ + ((S) & ~(0xFFFFFFFFu << 20)) #endif diff --git a/tests-clar/status/submodules.c b/tests-clar/status/submodules.c index 3a69e0c47..24dd660ab 100644 --- a/tests-clar/status/submodules.c +++ b/tests-clar/status/submodules.c @@ -50,7 +50,7 @@ void test_status_submodules__0(void) git_status_foreach(g_repo, cb_status__count, &counts) ); - cl_assert(counts == 6); + cl_assert_equal_i(6, counts); } static const char *expected_files[] = { @@ -95,12 +95,12 @@ void test_status_submodules__1(void) git_status_foreach(g_repo, cb_status__match, &index) ); - cl_assert(index == 6); + cl_assert_equal_i(6, index); } void test_status_submodules__single_file(void) { - unsigned int status; + unsigned int status = 0; cl_git_pass( git_status_file(&status, g_repo, "testrepo") ); - cl_assert(status == 0); + cl_assert(!status); } diff --git a/tests-clar/submodule/status.c b/tests-clar/submodule/status.c index e0c1e4c7a..d3a39235a 100644 --- a/tests-clar/submodule/status.c +++ b/tests-clar/submodule/status.c @@ -2,6 +2,7 @@ #include "posix.h" #include "path.h" #include "submodule_helpers.h" +#include "fileops.h" static git_repository *g_repo = NULL; @@ -25,20 +26,283 @@ void test_submodule_status__cleanup(void) void test_submodule_status__unchanged(void) { - /* make sure it really looks unchanged */ + unsigned int status, expected; + git_submodule *sm; + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + expected = GIT_SUBMODULE_STATUS_IN_HEAD | + GIT_SUBMODULE_STATUS_IN_INDEX | + GIT_SUBMODULE_STATUS_IN_CONFIG | + GIT_SUBMODULE_STATUS_IN_WD; + + cl_assert(status == expected); } -void test_submodule_status__changed(void) +/* 4 values of GIT_SUBMODULE_IGNORE to check */ + +void test_submodule_status__ignore_none(void) { - /* 4 values of GIT_SUBMODULE_IGNORE to check */ + unsigned int status; + git_submodule *sm; + git_buf path = GIT_BUF_INIT; - /* 6 states of change: - * - none, (handled in __unchanged above) - * - dirty workdir file, - * - dirty index, - * - moved head, - * - untracked file, - * - missing commits (i.e. superproject commit is ahead of submodule) - */ + cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "sm_unchanged")); + cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), GIT_DIRREMOVAL_FILES_AND_DIRS)); + + cl_git_fail(git_submodule_lookup(&sm, g_repo, "not_submodule")); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_index")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_untracked_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_UNTRACKED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_INDEX_ADDED) != 0); + + /* removed sm_unchanged for deleted workdir */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_DELETED) != 0); + + /* now mkdir sm_unchanged to test uninitialized */ + cl_git_pass(git_futils_mkdir(git_buf_cstr(&path), NULL, 0755, 0)); + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_reload(sm)); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_UNINITIALIZED) != 0); + + /* update sm_changed_head in index */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_add_to_index(sm, true)); + /* reload is not needed because add_to_index updates the submodule data */ + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_INDEX_MODIFIED) != 0); + + /* remove sm_changed_head from index */ + { + git_index *index; + int pos; + + cl_git_pass(git_repository_index(&index, g_repo)); + pos = git_index_find(index, "sm_changed_head"); + cl_assert(pos >= 0); + cl_git_pass(git_index_remove(index, pos)); + cl_git_pass(git_index_write(index)); + + git_index_free(index); + } + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_reload(sm)); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_INDEX_DELETED) != 0); + + git_buf_free(&path); } +static int set_sm_ignore(git_submodule *sm, const char *name, void *payload) +{ + git_submodule_ignore_t ignore = *(git_submodule_ignore_t *)payload; + GIT_UNUSED(name); + git_submodule_set_ignore(sm, ignore); + return 0; +} + +void test_submodule_status__ignore_untracked(void) +{ + unsigned int status; + git_submodule *sm; + git_buf path = GIT_BUF_INIT; + git_submodule_ignore_t ign = GIT_SUBMODULE_IGNORE_UNTRACKED; + + cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "sm_unchanged")); + cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), GIT_DIRREMOVAL_FILES_AND_DIRS)); + + cl_git_pass(git_submodule_foreach(g_repo, set_sm_ignore, &ign)); + + cl_git_fail(git_submodule_lookup(&sm, g_repo, "not_submodule")); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_index")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_untracked_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_INDEX_ADDED) != 0); + + /* removed sm_unchanged for deleted workdir */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_DELETED) != 0); + + /* now mkdir sm_unchanged to test uninitialized */ + cl_git_pass(git_futils_mkdir(git_buf_cstr(&path), NULL, 0755, 0)); + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_reload(sm)); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_UNINITIALIZED) != 0); + + /* update sm_changed_head in index */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_add_to_index(sm, true)); + /* reload is not needed because add_to_index updates the submodule data */ + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_INDEX_MODIFIED) != 0); + + git_buf_free(&path); +} + +void test_submodule_status__ignore_dirty(void) +{ + unsigned int status; + git_submodule *sm; + git_buf path = GIT_BUF_INIT; + git_submodule_ignore_t ign = GIT_SUBMODULE_IGNORE_DIRTY; + + cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "sm_unchanged")); + cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), GIT_DIRREMOVAL_FILES_AND_DIRS)); + + cl_git_pass(git_submodule_foreach(g_repo, set_sm_ignore, &ign)); + + cl_git_fail(git_submodule_lookup(&sm, g_repo, "not_submodule")); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_index")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_untracked_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_MODIFIED) != 0); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_INDEX_ADDED) != 0); + + /* removed sm_unchanged for deleted workdir */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_DELETED) != 0); + + /* now mkdir sm_unchanged to test uninitialized */ + cl_git_pass(git_futils_mkdir(git_buf_cstr(&path), NULL, 0755, 0)); + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_reload(sm)); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_WD_UNINITIALIZED) != 0); + + /* update sm_changed_head in index */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_add_to_index(sm, true)); + /* reload is not needed because add_to_index updates the submodule data */ + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert((status & GIT_SUBMODULE_STATUS_INDEX_MODIFIED) != 0); + + git_buf_free(&path); +} + +void test_submodule_status__ignore_all(void) +{ + unsigned int status; + git_submodule *sm; + git_buf path = GIT_BUF_INIT; + git_submodule_ignore_t ign = GIT_SUBMODULE_IGNORE_ALL; + + cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "sm_unchanged")); + cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), GIT_DIRREMOVAL_FILES_AND_DIRS)); + + cl_git_pass(git_submodule_foreach(g_repo, set_sm_ignore, &ign)); + + cl_git_fail(git_submodule_lookup(&sm, g_repo, "not_submodule")); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_index")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_untracked_file")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + /* removed sm_unchanged for deleted workdir */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + /* now mkdir sm_unchanged to test uninitialized */ + cl_git_pass(git_futils_mkdir(git_buf_cstr(&path), NULL, 0755, 0)); + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged")); + cl_git_pass(git_submodule_reload(sm)); + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + /* update sm_changed_head in index */ + cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head")); + cl_git_pass(git_submodule_add_to_index(sm, true)); + /* reload is not needed because add_to_index updates the submodule data */ + cl_git_pass(git_submodule_status(&status, sm)); + cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status)); + + git_buf_free(&path); +} From 97a17e4e9fa5cafa531ff79cb88a9ee5c224a613 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 24 Aug 2012 12:19:22 -0700 Subject: [PATCH 5/5] Fix valgrind warnings and spurious error messages Just clean up valgrind warnings about uninitialized memory and also clear out errno in some cases where it results in a false error message being generated at a later point. --- src/checkout.c | 15 ++++++++------- src/errors.c | 5 +++++ src/filebuf.c | 1 + src/submodule.c | 2 ++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/checkout.c b/src/checkout.c index ac540391e..88df2128d 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -31,7 +31,7 @@ typedef struct tree_walk_data git_checkout_opts *opts; git_repository *repo; git_odb *odb; - bool do_symlinks; + bool no_symlinks; } tree_walk_data; @@ -48,9 +48,9 @@ static int blob_contents_to_link(tree_walk_data *data, git_buf *fnbuf, /* Create the link */ const char *new = git_buf_cstr(&linktarget), *old = git_buf_cstr(fnbuf); - retcode = data->do_symlinks - ? p_symlink(new, old) - : git_futils_fake_symlink(new, old); + retcode = data->no_symlinks + ? git_futils_fake_symlink(new, old) + : p_symlink(new, old); } git_buf_free(&linktarget); git_blob_free(blob); @@ -176,13 +176,14 @@ int git_checkout_head(git_repository *repo, git_checkout_opts *opts, git_indexer return GIT_ERROR; } + memset(&payload, 0, sizeof(payload)); + /* Determine if symlinks should be handled */ - if (!git_repository_config(&cfg, repo)) { + if (!git_repository_config__weakptr(&cfg, repo)) { int temp = true; if (!git_config_get_bool(&temp, cfg, "core.symlinks")) { - payload.do_symlinks = !!temp; + payload.no_symlinks = !temp; } - git_config_free(cfg); } stats->total = stats->processed = 0; diff --git a/src/errors.c b/src/errors.c index d43d7d9b5..802ad3647 100644 --- a/src/errors.c +++ b/src/errors.c @@ -110,6 +110,11 @@ void giterr_set_regex(const regex_t *regex, int error_code) void giterr_clear(void) { GIT_GLOBAL->last_error = NULL; + + errno = 0; +#ifdef GIT_WIN32 + SetLastError(0); +#endif } const git_error *giterr_last(void) diff --git a/src/filebuf.c b/src/filebuf.c index 8b3ebb3e2..cfc8528e6 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -50,6 +50,7 @@ static int lock_file(git_filebuf *file, int flags) if (flags & GIT_FILEBUF_FORCE) p_unlink(file->path_lock); else { + giterr_clear(); /* actual OS error code just confuses */ giterr_set(GITERR_OS, "Failed to lock file '%s' for writing", file->path_lock); return -1; diff --git a/src/submodule.c b/src/submodule.c index 15501a1dd..a9de9ee6e 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -367,6 +367,8 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index) error = -1; goto cleanup; } + + memset(&entry, 0, sizeof(entry)); entry.path = sm->path; git_index__init_entry_from_stat(&st, &entry);