From e8ddd8d76c119903677b5d0c638c875023ae6784 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 17 Sep 2015 17:49:32 -0400 Subject: [PATCH] repo::reservedname: test a submodule update Test an initial submodule update, where we are trying to checkout the submodule for the first time, and placing a file within the submodule working directory with the same name as the submodule (and consequently, the same name as the repository itself). --- tests/repo/reservedname.c | 24 ++++++++++++++++++ tests/resources/sub.git/HEAD | Bin 0 -> 23 bytes tests/resources/sub.git/config | Bin 0 -> 157 bytes tests/resources/sub.git/index | Bin 0 -> 405 bytes tests/resources/sub.git/logs/HEAD | Bin 0 -> 174 bytes .../resources/sub.git/logs/refs/heads/master | Bin 0 -> 174 bytes .../10/ddd6d257e01349d514541981aeecea6b2e741d | Bin 0 -> 22 bytes .../17/6a458f94e0ea5272ce67c36bf30b6be9caf623 | Bin 0 -> 28 bytes .../94/c7d78d85c933d1d95b56bc2de01833ba8559fb | Bin 0 -> 132 bytes .../b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8 | Bin 0 -> 139 bytes .../d0/ee23c41b28746d7e822511d7838bce784ae773 | Bin 0 -> 54 bytes tests/resources/sub.git/refs/heads/master | Bin 0 -> 41 bytes tests/resources/super/.gitted/COMMIT_EDITMSG | Bin 0 -> 10 bytes tests/resources/super/.gitted/HEAD | Bin 0 -> 23 bytes tests/resources/super/.gitted/config | Bin 0 -> 193 bytes tests/resources/super/.gitted/index | Bin 0 -> 217 bytes .../51/589c218bf77a8da9e9d8dbc097d76a742726c4 | Bin 0 -> 90 bytes .../79/d0d58ca6aa1688a073d280169908454cad5b91 | Bin 0 -> 132 bytes .../d7/57768b570a83e80d02edcc1032db14573e5034 | Bin 0 -> 87 bytes .../resources/super/.gitted/refs/heads/master | Bin 0 -> 41 bytes tests/resources/super/gitmodules | Bin 0 -> 48 bytes tests/submodule/submodule_helpers.c | 16 ++++++++++++ tests/submodule/submodule_helpers.h | 1 + 23 files changed, 41 insertions(+) create mode 100644 tests/resources/sub.git/HEAD create mode 100644 tests/resources/sub.git/config create mode 100644 tests/resources/sub.git/index create mode 100644 tests/resources/sub.git/logs/HEAD create mode 100644 tests/resources/sub.git/logs/refs/heads/master create mode 100644 tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d create mode 100644 tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623 create mode 100644 tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fb create mode 100644 tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8 create mode 100644 tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773 create mode 100644 tests/resources/sub.git/refs/heads/master create mode 100644 tests/resources/super/.gitted/COMMIT_EDITMSG create mode 100644 tests/resources/super/.gitted/HEAD create mode 100644 tests/resources/super/.gitted/config create mode 100644 tests/resources/super/.gitted/index create mode 100644 tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4 create mode 100644 tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91 create mode 100644 tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034 create mode 100644 tests/resources/super/.gitted/refs/heads/master create mode 100644 tests/resources/super/gitmodules diff --git a/tests/repo/reservedname.c b/tests/repo/reservedname.c index faea0cc2b..2a5b38239 100644 --- a/tests/repo/reservedname.c +++ b/tests/repo/reservedname.c @@ -106,3 +106,27 @@ void test_repo_reservedname__submodule_pointer(void) git_repository_free(sub_repo); #endif } + +/* Like the `submodule_pointer` test (above), this ensures that we do not + * follow the gitlink to the submodule's repository location and treat that + * as a reserved name. This tests at an initial submodule update, where the + * submodule repo is being created. + */ +void test_repo_reservedname__submodule_pointer_during_create(void) +{ + git_repository *repo; + git_submodule *sm; + git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT; + git_buf url = GIT_BUF_INIT; + + repo = setup_fixture_super(); + + cl_git_pass(git_buf_joinpath(&url, clar_sandbox_path(), "sub.git")); + cl_repo_set_string(repo, "submodule.sub.url", url.ptr); + + cl_git_pass(git_submodule_lookup(&sm, repo, "sub")); + cl_git_pass(git_submodule_update(sm, 1, &update_options)); + + git_submodule_free(sm); + git_buf_free(&url); +} diff --git a/tests/resources/sub.git/HEAD b/tests/resources/sub.git/HEAD new file mode 100644 index 0000000000000000000000000000000000000000..cb089cd89a7d7686d284d8761201649346b5aa1c GIT binary patch literal 23 ecmXR)O|w!cN=+-)&qz&7Db~+TEG|hc;sO9;xClW2 literal 0 HcmV?d00001 diff --git a/tests/resources/sub.git/config b/tests/resources/sub.git/config new file mode 100644 index 0000000000000000000000000000000000000000..78387c50b472d8c0cdaeca4b56bf23c5b7f791df GIT binary patch literal 157 zcmYj~F%H5o3`OVU6g@&Oz=mM#0T6>}oMPd`mF*(s_9TLV@qN9ge_KWI9)sd8MlRa2 zXaRqt8cCf_(;P!4#v%zjWnjY?9-x23vH`PVKK2BT);-swYt{-=eU0H4(pLN73O4eu U^rVDm@k>7$ViLcSFO^&T0N7wQ1ONa4 literal 0 HcmV?d00001 diff --git a/tests/resources/sub.git/index b/tests/resources/sub.git/index new file mode 100644 index 0000000000000000000000000000000000000000..54be69e33e1917169be0a3fbaba5fd61746ea15a GIT binary patch literal 405 zcmZ?q402{*U|<4bmeAiS$AL5hkUj;X5ukAig3Z7yp5@v<<-x0SOTvLu;?`=J4eDP*<*dE;n62`k)BYy+6Fc>Nra9wz(d_-EKB)6_f kRq%Rq_qhtM=fz>Ee_l3S@LMBvbgC8SC8;G(PQUH}02WnsssI20 literal 0 HcmV?d00001 diff --git a/tests/resources/sub.git/logs/HEAD b/tests/resources/sub.git/logs/HEAD new file mode 100644 index 0000000000000000000000000000000000000000..f636268f6fd72e083ae31c48aa7ad90d6e238f08 GIT binary patch literal 174 zcma*bK?*`45P;!zonn@?DAZB(MMRqx?Yn?FN&~5&Qr9nd7wBJo{6hQ}1nbQbFze(c zhQ*oeyi9`78cQY;B1%u>;6@+c2_DZ@Myqg6bJewQ>}|9>kFk{tNUfDo3YCI`&_Zl} XxA24=SDx%&`xD$(K~HZU-0JoVU8^zE literal 0 HcmV?d00001 diff --git a/tests/resources/sub.git/logs/refs/heads/master b/tests/resources/sub.git/logs/refs/heads/master new file mode 100644 index 0000000000000000000000000000000000000000..f636268f6fd72e083ae31c48aa7ad90d6e238f08 GIT binary patch literal 174 zcma*bK?*`45P;!zonn@?DAZB(MMRqx?Yn?FN&~5&Qr9nd7wBJo{6hQ}1nbQbFze(c zhQ*oeyi9`78cQY;B1%u>;6@+c2_DZ@Myqg6bJewQ>}|9>kFk{tNUfDo3YCI`&_Zl} XxA24=SDx%&`xD$(K~HZU-0JoVU8^zE literal 0 HcmV?d00001 diff --git a/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d b/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d new file mode 100644 index 0000000000000000000000000000000000000000..a095b3fb822e3cde46d5d39ff21528c1e1fc70cf GIT binary patch literal 22 ecmb7F=sF|FfcPQQP4}zEJ-XWDauSLElDkA5YKY$pYq^UP|>;c z!`Yv?vtOS2rVLe?n3rFYky@lzQc=PnaQE7!@CU-4S4Bc38`r&gm91AI3sshunUjiB mjfnveC={0_F?TvpB(Aj# zP#zDX=M3Jai6%!5lQ)JGd5n0DNmG`}854s;^h*@sHCFC$qfh7rkCp4j4d%StA6;un toi|>_DRI4kvR0$kMr$}qE2Y@&J|6jxgt)gdN_axg@3Iwc;tNWyL3_OFJ+1%% literal 0 HcmV?d00001 diff --git a/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773 b/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773 new file mode 100644 index 0000000000000000000000000000000000000000..d9bb9c84d8053600309e1bd6393d26b61c47bd78 GIT binary patch literal 54 zcmV-60LlM&0V^p=O;s>9XD~D{Ff%bxNY2R2Nzp5*C}9w|d+k#A17XjrA|aBE>)yP| M)+><(08@Jq$s_(2XaE2J literal 0 HcmV?d00001 diff --git a/tests/resources/sub.git/refs/heads/master b/tests/resources/sub.git/refs/heads/master new file mode 100644 index 0000000000000000000000000000000000000000..0e4d6e2a7897e667e388557d25a9c64e9bf2096f GIT binary patch literal 41 ucmV~$!4Uu;2m`Rc)5z5xFb-JUe*}~EVm98HGIR!Cl+6~LE?xn!l45=I^9x=8 literal 0 HcmV?d00001 diff --git a/tests/resources/super/.gitted/COMMIT_EDITMSG b/tests/resources/super/.gitted/COMMIT_EDITMSG new file mode 100644 index 0000000000000000000000000000000000000000..e2d6b8987e3c26ce8b4444db8fe855acf8644936 GIT binary patch literal 10 RcmXReP0GzrDa}dc0st2(1KR)q literal 0 HcmV?d00001 diff --git a/tests/resources/super/.gitted/HEAD b/tests/resources/super/.gitted/HEAD new file mode 100644 index 0000000000000000000000000000000000000000..cb089cd89a7d7686d284d8761201649346b5aa1c GIT binary patch literal 23 ecmXR)O|w!cN=+-)&qz&7Db~+TEG|hc;sO9;xClW2 literal 0 HcmV?d00001 diff --git a/tests/resources/super/.gitted/config b/tests/resources/super/.gitted/config new file mode 100644 index 0000000000000000000000000000000000000000..06a8b77907e29ad26fcf19724b9c70d364c639fd GIT binary patch literal 193 zcmYk0K@NgI3`N(>DF_EZFW}DT(gP3|1Jl9AG9_(?gxg!93wQlL@8@-xSl}5Nft3}F zWzQ^2v<*a&OM7Y0p~*-50|0K8oKE=iM{R9FHCS{ySd~56Wbl_QD_f?*3rF{pzZwZ{Ld=nOy8e8_cL1f08=GFZU6uP literal 0 HcmV?d00001 diff --git a/tests/resources/super/.gitted/index b/tests/resources/super/.gitted/index new file mode 100644 index 0000000000000000000000000000000000000000..cc2ffffb980f6eade02621e7431faffc830c96e9 GIT binary patch literal 217 zcmZ?q402{*U|<5_(BFmvK$-zYgV+$zxCF)m(!qfda}>M3SM{!ZdE@qh>DRML)YXnK zaOp0i)X@;dTKg{30SZ^EfSPb1kPO Nt$y+J!W`S|A^_*II9C7w literal 0 HcmV?d00001 diff --git a/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4 b/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4 new file mode 100644 index 0000000000000000000000000000000000000000..727d3a696894fe8d07899ae0b520da02596720cd GIT binary patch literal 90 zcmV-g0HyzU0ZYosPg1ZjW{55>P0GzrDa}b$Py#ZQV!1dA5=$}^Y!!e!F3!@T93V5< wDkdg9vm_=aCo>618|fOy#FV5KmlVgu6r~pDmlh?b0+~P!dO%q&0A7+GCFlAeGXMYp literal 0 HcmV?d00001 diff --git a/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91 b/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91 new file mode 100644 index 0000000000000000000000000000000000000000..7fd889d5f1cfe79f0b769d2682e3f5a888f0fa3b GIT binary patch literal 132 zcmV-~0DJ#<0i}&e3IZ_@06pgw{Q;%3nFxb;@dth&Nw>^^u^|h7-|-FJiaJyksdXEm zV?2z;3>16_=a_xK6fH+2G)$#vw1%>FK3Mi>ol0}8(%?>?)CeA{)GlvWc(*^g)vYw? m@*Jlk^$OZKAU@$Z=Ff%bx&`ZxO$<0qG%}Fh02#lDc*!{h#cje0)w+~Fe to>ii*cEr%k00$tl#o29h3`5|2fC0kl5aFs~UyWIQVG`1<2i3UdGe literal 0 HcmV?d00001 diff --git a/tests/resources/super/gitmodules b/tests/resources/super/gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..a3d8f7f5afa24d79f145cf902746e684d1446290 GIT binary patch literal 48 ycmazpE=|hKPbtkwRZs#lm14O#3ld8*6l@iMJTA`Cq8uPoPfs7n(@W1R;Q|1ItPb)3 literal 0 HcmV?d00001 diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c index 1dc687231..cde69d92d 100644 --- a/tests/submodule/submodule_helpers.c +++ b/tests/submodule/submodule_helpers.c @@ -126,6 +126,22 @@ git_repository *setup_fixture_submod2(void) return repo; } +git_repository *setup_fixture_super(void) +{ + git_repository *repo = cl_git_sandbox_init("super"); + + cl_fixture_sandbox("sub.git"); + p_mkdir("super/sub", 0777); + + rewrite_gitmodules(git_repository_workdir(repo)); + + cl_set_cleanup(cleanup_fixture_submodules, "sub.git"); + + cl_git_pass(git_repository_reinit_filesystem(repo, 1)); + + return repo; +} + git_repository *setup_fixture_submodule_simple(void) { git_repository *repo = cl_git_sandbox_init("submodule_simple"); diff --git a/tests/submodule/submodule_helpers.h b/tests/submodule/submodule_helpers.h index 1493f245f..1191ab35b 100644 --- a/tests/submodule/submodule_helpers.h +++ b/tests/submodule/submodule_helpers.h @@ -4,6 +4,7 @@ extern void rewrite_gitmodules(const char *workdir); extern git_repository *setup_fixture_submodules(void); extern git_repository *setup_fixture_submod2(void); extern git_repository *setup_fixture_submodule_simple(void); +extern git_repository *setup_fixture_super(void); extern unsigned int get_submodule_status(git_repository *, const char *);