summaryrefslogtreecommitdiff
path: root/tests/submodule
Commit message (Collapse)AuthorAgeFilesLines
* tests: submodule git lookup can be dupped test comments have been changed.Dmitry Lobanov2021-06-151-3/+3
|
* tests: submodule git lookup can be dupped test has been added.Dmitry Lobanov2021-06-031-0/+40
|
* clar: include the function nameethomson/clar_tapEdward Thomson2020-06-052-11/+11
|
* strarray: we should `dispose` instead of `free`Edward Thomson2020-06-011-1/+1
| | | | | | We _dispose_ the contents of objects; we _free_ objects (and their contents). Update `git_strarray_free` to be `git_strarray_dispose`. `git_strarray_free` remains as a deprecated proxy function.
* tests: submodule: verify setup of relative URLsPatrick Steinhardt2020-01-061-0/+21
| | | | | | | When setting up relative URLs for a submodule, then we resolve it to the actual location and write that into ".git/config" instead of writing the relative value. We do not yet have a test to nail down this behaviour, which is now being added by this commit.
* tests: submodule: test cloning edge casesPatrick Steinhardt2019-10-171-0/+37
| | | | | | Add two more tests that verify our behaviour in some edge cases, notably when cloning into a non-empty directory and when cloning the same submodule twice.
* tests: submodule: make use of sandboxes to clean reposPatrick Steinhardt2019-10-171-9/+9
| | | | | | | The test submodule::add::submodule_clone doesn't use a sandbox, and thus the created repo will not get deleted after the test has finished. Convert the test to use the empty standard repo sandbox instead to fix this.
* tests: submodule: fix tests for cloning submodulesPatrick Steinhardt2019-10-171-52/+0
| | | | | | | | | | | | | The test submodule::add::homemade_clone unfortunately doesn't test what's expected, but does instead clone the submodule to a directory that is outside of the parent repository. Fixing this by cloning to the correct location isn't possible, though, as `git_submodule_add_setup` will have pre-created a ".git" file already, which will cause `git_clone` to error out. As it's not possible to perform the clone without fiddling around with the repo's layout, let's just remove this test as that is in fact what the new `git_submodule_clone` function is for.
* submodule: provide a wrapper for simple submodule clone stepsEtienne Samson2019-10-171-0/+81
|
* fileops: rename to "futils.h" to match function signaturesPatrick Steinhardt2019-07-209-9/+9
| | | | | | | | | Our file utils functions all have a "futils" prefix, e.g. `git_futils_touch`. One would thus naturally guess that their definitions and implementation would live in files "futils.h" and "futils.c", respectively, but in fact they live in "fileops.h". Rename the files to match expectations.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-012-5/+5
| | | | Use the new object_type enumeration names within the codebase.
* submodule: add failing test for option-injection protection in url and pathCarlos Martín Nieto2018-10-051-0/+80
|
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-109-23/+23
|
* tests: submodule: do not rely on config iteration orderPatrick Steinhardt2018-06-061-22/+9
| | | | | | | | | | | | | | | | | | | | The test submodule::lookup::duplicated_path, which tries to verify that we detect submodules with duplicated paths, currently relies on the gitmodules file of "submod2_target". While this file has two gitmodules with the same path, one of these gitmodules has an empty name and thus does not pass `git_submodule_name_is_valid`. Because of this, the test is in fact dependent on the iteration order in which we process the submodules. In fact the "valid" submodule comes first, the "invalid" submodule will cause the desired error. In fact the "invalid" submodule comes first, it will be skipped due to its name being invalid, and we will not see the desired error. While this works on the master branch just right due to the refactoring of our config code, where iteration order is now deterministic, this breaks on all older maintenance branches. Fix the issue by simply using `cl_git_rewritefile` to rewrite the gitmodules file. This greatly simplifies the test and also makes the intentions of it much clearer.
* submodule: detect duplicated submodule pathsPatrick Steinhardt2018-05-301-0/+26
| | | | | | | | | | | | | When loading submodule names, we build a map of submodule paths and their respective names. While looping over the configuration keys, we do not check though whether a submodule path was seen already. This leads to a memory leak in case we have multiple submodules with the same path, as we just overwrite the old value in the map in that case. Fix the error by verifying that the path to be added is not yet part of the string map. Git does not allow to have multiple submodules for a path anyway, so we now do the same and detect this duplication, reporting it to the user.
* submodule: plug leaks from the escape detectionCarlos Martín Nieto2018-05-241-0/+2
|
* submodule: also validate Windows-separated paths for validityCarlos Martín Nieto2018-05-141-6/+37
| | | | | | | | Otherwise we would also admit `..\..\foo\bar` as a valid path and fail to protect Windows users. Ideally we would check for both separators without the need for the copied string, but this'll get us over the RCE.
* submodule: ignore submodules which include path traversal in their nameCarlos Martín Nieto2018-05-091-12/+17
| | | | | | | | | | | | | | If the we decide that the "name" of the submodule (i.e. its path inside `.git/modules/`) is trying to escape that directory or otherwise trick us, we ignore the configuration for that submodule. This leaves us with a half-configured submodule when looking it up by path, but it's the same result as if the configuration really were missing. The name check is potentially more strict than it needs to be, but it lets us re-use the check we're doing for the checkout. The function that encapsulates this logic is ready to be exported but we don't want to do that in a security release so it remains internal for now.
* submodule: add a failing test for a submodule escaping .git/modulesCarlos Martín Nieto2018-04-301-0/+60
| | | | We should pretend such submdules do not exist as it can lead to RCE.
* Merge pull request #4522 from csware/submodules-should-report-parse-errorsEdward Thomson2018-04-171-0/+16
|\ | | | | Submodules-API should report .gitmodules parse errors instead of ignoring them
| * Submodule API should report .gitmodules parse errorsSven Strickroth2018-03-271-0/+16
| | | | | | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* | submodule: add more robust error handling when a submodule path is found on addCarson Howard2018-03-281-2/+2
| |
* | tests: submodule: insert index entries directly into indexCarson Howard2018-03-271-18/+22
| |
* | submodule: update index check to check path before directory and fix testsCarson Howard2018-03-271-8/+11
| |
* | submodule: fix styling errorsCarson Howard2018-03-271-32/+14
| |
* | test: submodule: add: join path without slashesCarson Howard2018-03-271-3/+3
| |
* | test: submodule: add: use p_mkdir to create directoriesCarson Howard2018-03-271-1/+1
| |
* | submodule: check index for prefix before adding submoduleCarson Howard2018-03-271-0/+66
|/ | | | | | | submodule: check path and prefix before adding submodule submodule: fix test errors
* submodule: refuse lookup in bare repositoriesPatrick Steinhardt2017-08-251-0/+26
| | | | | | | | | | | | | | While it is technically possible to look up submodules inside of a bare repository by reading the submodule configuration of a specific commit, we do not offer this functionality right now. As such, calling both `git_submodule_lookup` and `git_submodule_foreach` should error out early when these functions encounter a bare repository. While `git_submodule_lookup` already does return an error due to not being able to parse the configuration, `git_submodule_foreach` simply returns success and never invokes the callback function. Fix the issue by having both functions check whether the repository is bare and returning an error in that case.
* tests: submodule: add explicit cleanup function in lookup testsPatrick Steinhardt2017-08-251-0/+5
|
* tests: submodule: fix declaration of testPatrick Steinhardt2017-08-251-1/+2
| | | | | | | The testcase "submodule::lookup::cached" was declared with a single underscore separating the test suide and test name, only. As the clar parser only catches tests with two underscores, it was never executed. Add in the second underscore to actually have it detected and executed.
* repository: make check if repo is a worktree more strictPatrick Steinhardt2017-05-191-0/+19
| | | | | | | | | | | | | | | | | | | To determine if a repository is a worktree or not, we currently check for the existence of a "gitdir" file inside of the repository's gitdir. While this is sufficient for non-broken repositories, we have at least one case of a subtly broken repository where there exists a gitdir file inside of a gitmodule. This will cause us to misidentify the submodule as a worktree. While this is not really a fault of ours, we can do better here by observing that a repository can only ever be a worktree iff its common directory and dotgit directory are different. This allows us to make our check whether a repo is a worktree or not more strict by doing a simple string comparison of these two directories. This will also allow us to do the right thing in the above case of a broken repository, as for submodules these directories will be the same. At the same time, this allows us to skip the `stat` check for the "gitdir" file for most repositories.
* tests: add test suite for opening submodulesPatrick Steinhardt2017-05-171-0/+71
|
* tests: provide better pass/failure error messagesEdward Thomson2017-02-171-1/+1
| | | | | | Provide more detailed messages when conditions pass or fail unexpectedly. In particular, this provides the error messages when a test fails with a different error code than was expected.
* Allow for caching of submodules.Brock Peabody2017-01-201-0/+25
| | | | | | | | | | | | | | Added `git_repository_submodule_cache_all` to initialze a cache of submodules on the repository so that operations looking up N submodules are O(N) and not O(N^2). Added a `git_repository_submodule_cache_clear` function to remove the cache. Also optimized the function that loads all submodules as it was itself O(N^2) w.r.t the number of submodules, having to loop through the `.gitmodules` file once per submodule. I changed it to process the `.gitmodules` file once, into a map. Signed-off-by: David Turner <dturner@twosigma.com>
* status: test submodules with mixed caseEdward Thomson2016-03-312-0/+27
|
* typos in commentsDmitriy Olshevskiy2015-12-211-1/+1
|
* submodule: test updating a submodule w/ a pathEdward Thomson2015-11-043-0/+64
| | | | | Test that `git_submodule_update` can handle a submodule that is freshly cloned and has a path differing from its name.
* Merge pull request #3434 from ethomson/reservednamesCarlos Martín Nieto2015-09-212-0/+17
|\ | | | | Win32 Reserved names: don't reserve names outside the working directory
| * repo::reservedname: test a submodule updateEdward Thomson2015-09-182-0/+17
| | | | | | | | | | | | | | 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).
* | Fix a couple of warningsCarlos Martín Nieto2015-09-181-1/+1
| |
* | git_futils_mkdir_*: make a relative-to-base mkdirEdward Thomson2015-09-171-5/+5
|/ | | | | | | | | | | | Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter assumes that we own everything beneath the base, as if it were being called with a base of the repository or working directory, and is tailored towards checkout and ensuring that there is no bogosity beneath the base that must be cleaned up. This is (at best) slow and (at worst) unsafe in the larger context of a filesystem where we do not own things and cannot do things like unlink symlinks that are in our way.
* submodule: add a test for a renamed submdoule dircmn/submodule-refactorCarlos Martín Nieto2015-09-101-0/+55
|
* iterator: use an options struct instead of argsEdward Thomson2015-08-281-2/+4
|
* Merge pull request #3307 from libgit2/cmn/submodule-backslashEdward Thomson2015-07-241-0/+23
|\ | | | | Normalize submodule urls before looking at them
| * submodule: add failing test for backslash in urlCarlos Martín Nieto2015-07-131-0/+23
| |
* | Merge pull request #3303 from libgit2/cmn/index-add-submoduleEdward Thomson2015-07-241-0/+1
|\ \ | | | | | | Allow adding a submodule through git_index_add_bypath
| * | blob: fail to create a blob from a dir with EDIRECTORYCarlos Martín Nieto2015-07-121-0/+1
| |/ | | | | | | | | This also affects `git_index_add_bypath()` by providing a better error message and a specific error code when a directory is passed.
* | submdule: reproduce double-reporting of a submodule in foreachCarlos Martín Nieto2015-07-111-0/+18
|/ | | | | | When we rename a submodule, we should be merging two sets of information based on whether their path is the same. We currently only deduplicate on equal name, which causes us to double-report.
* submodule: add failing test for loading the wrong submoduleCarlos Martín Nieto2015-07-011-0/+23
| | | | | When two submodules are fairly similar, we may end up loading the wrong one.