summaryrefslogtreecommitdiff
path: root/tests/repo
Commit message (Collapse)AuthorAgeFilesLines
* repository: do not interpret all files as gitlinks in discoveryPatrick Steinhardt2016-11-141-0/+10
| | | | | | | | | | | | | | When trying to find a discovery, we walk up the directory structure checking if there is a ".git" file or directory and, if so, check its validity. But in the case that we've got a ".git" file, we do not want to unconditionally assume that the file is in fact a ".git" file and treat it as such, as we would error out if it is not. Fix the issue by only treating a file as a gitlink file if it ends with "/.git". This allows users of the function to discover a repository by handing in any path contained inside of a git repository.
* test: discover: fix indentationPatrick Steinhardt2016-11-141-1/+1
|
* test: discover: split up monolithic test into smaller onesPatrick Steinhardt2016-11-141-49/+67
|
* test: discover: pass constants to ensure_repository_discoverPatrick Steinhardt2016-11-141-19/+26
|
* test: discover: move layout creation into test initializerPatrick Steinhardt2016-11-141-22/+35
|
* repo::open: remove dead code, free buffersEdward Thomson2016-07-242-256/+277
|
* Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment varsJosh Triplett2016-06-241-0/+258
| | | | | | | | | | | | | | | | | | | | | git_repository_open_ext provides parameters for the start path, whether to search across filesystems, and what ceiling directories to stop at. git commands have standard environment variables and defaults for each of those, as well as various other parameters of the repository. To avoid duplicate environment variable handling in users of libgit2, add a GIT_REPOSITORY_OPEN_FROM_ENV flag, which makes git_repository_open_ext automatically handle the appropriate environment variables. Commands that intend to act just like those built into git itself can use this flag to get the expected default behavior. git_repository_open_ext with the GIT_REPOSITORY_OPEN_FROM_ENV flag respects $GIT_DIR, $GIT_DISCOVERY_ACROSS_FILESYSTEM, $GIT_CEILING_DIRECTORIES, $GIT_INDEX_FILE, $GIT_NAMESPACE, $GIT_OBJECT_DIRECTORY, and $GIT_ALTERNATE_OBJECT_DIRECTORIES. In the future, when libgit2 gets worktree support, git_repository_open_env will also respect $GIT_WORK_TREE and $GIT_COMMON_DIR; until then, git_repository_open_ext with this flag will error out if either $GIT_WORK_TREE or $GIT_COMMON_DIR is set.
* Add GIT_REPOSITORY_OPEN_NO_DOTGIT flag to avoid appending /.gitJosh Triplett2016-06-241-0/+6
| | | | | | | | | | GIT_REPOSITORY_OPEN_NO_SEARCH does not search up through parent directories, but still tries the specified path both directly and with /.git appended. GIT_REPOSITORY_OPEN_BARE avoids appending /.git, but opens the repository in bare mode even if it has a working directory. To support the semantics git uses when given $GIT_DIR in the environment, provide a new GIT_REPOSITORY_OPEN_NO_DOTGIT flag to not try appending /.git.
* Fix repository discovery with ceiling_dirs at current directoryJosh Triplett2016-06-242-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git only checks ceiling directories when its search ascends to a parent directory. A ceiling directory matching the starting directory will not prevent git from finding a repository in the starting directory or a parent directory. libgit2 handled the former case correctly, but differed from git in the latter case: given a ceiling directory matching the starting directory, but no repository at the starting directory, libgit2 would stop the search at that point rather than finding a repository in a parent directory. Test case using git command-line tools: /tmp$ git init x Initialized empty Git repository in /tmp/x/.git/ /tmp$ cd x/ /tmp/x$ mkdir subdir /tmp/x$ cd subdir/ /tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x git rev-parse --git-dir fatal: Not a git repository (or any of the parent directories): .git /tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x/subdir git rev-parse --git-dir /tmp/x/.git Fix the testsuite to test this case (in one case fixing a test that depended on the current behavior), and then fix find_repo to handle this case correctly. In the process, simplify and document the logic in find_repo(): - Separate the concepts of "currently checking a .git directory" and "number of iterations left before going further counts as a search" into two separate variables, in_dot_git and min_iterations. - Move the logic to handle in_dot_git and append /.git to the top of the loop. - Only search ceiling_dirs and find ceiling_offset after running out of min_iterations; since ceiling_offset only tracks the longest matching ceiling directory, if ceiling_dirs contained both the current directory and a parent directory, this change makes find_repo stop the search at the parent directory.
* iterator: give the tests a proper hierarchyEdward Thomson2016-03-241-2327/+0
| | | | | | Iterator tests were split over repo::iterator and diff::iterator, with duplication between the two. Move them to iterator::index, iterator::tree, and iterator::workdir.
* iterator: test that we can `advance_into` empty dirsEdward Thomson2016-03-231-0/+59
| | | | | | Prior iterator implementations returned `GIT_ENOTFOUND` when trying to advance into empty directories. Ensure that we no longer do that and simply handle them gracefully.
* iterator: test pathlist handling for directoriesMarc Strapetz2016-03-231-0/+137
| | | | | | | | | | | | | tree_iterator was only working properly for a pathlist containing file paths. In case of directory paths, it didn't match children which contradicts GIT_DIFF_DISABLE_PATHSPEC_MATCH and is different from index_iterator and fs_iterator. As a consequence head-to-index status reporting for a specific directory did not work properly -- all files have been reported as added. Include additional tests.
* iterator: test `advance_over` with a pathlistEdward Thomson2016-03-231-0/+60
|
* iterator: add tests for advance_overEdward Thomson2016-03-231-0/+77
| | | | | `git_iterator_advance_over` is a gnarly bit of code with no actual tests.
* iterator: test workdir pathlist with deep pathsEdward Thomson2016-03-231-0/+159
| | | | | | | | In the workdir iterator we do some tricky things to step down into directories to look for things that are in our pathlist. Make sure that we don't confuse between folders that we're definitely going to return everything in and folders that we're only stepping down into to keep looking for matches.
* iterator: workdir tests with submodulesEdward Thomson2016-03-231-0/+80
| | | | | Ensure that when specifying start/end paths, or pathlists, that we deal correctly with submodules.
* iterator: expand workdir tests with pathlistEdward Thomson2016-03-231-62/+224
| | | | | Expand the workdir tests to validate the paths in case sensitive and insensitive tests.
* iterator: test that we're at the end of iterationEdward Thomson2016-03-231-0/+13
| | | | | | | Ensure that we have hit the end of iteration; previously we tested that we saw all the values that we expected to see. We did not then ensure that we were at the end of the iteration (and that there were subsequently values in the iteration that we did *not* expect.)
* iterator: test fs iterator w/ many nested empty dirsEdward Thomson2016-03-231-0/+30
|
* iterator: skip unreadable directories in fs iteratorEdward Thomson2016-03-231-3/+9
| | | | | Do not abort iteration in the middle when encountering an unreadable directory. Instead, skip it, as if it didn't exist.
* iterators: refactored tree iteratorEdward Thomson2016-03-231-1/+1
| | | | | | | | Refactored the tree iterator to never recurse; simply process the next entry in order in `advance`. Additionally, reduce the number of allocations and sorting as much as possible to provide a ~30% speedup on case-sensitive iteration. (The gains for case-insensitive iteration are less majestic.)
* repo::iterator: don't go out of boundsEdward Thomson2016-03-231-2/+2
|
* iterator: disambiguate reset and reset_rangeEdward Thomson2016-03-231-1/+1
| | | | | | Disambiguate the reset and reset_range functions. Now reset_range with a NULL path will clear the start or end; reset will leave the existing start and end unchanged.
* Horrible fix for #3173.Arthur Schreiber2016-02-111-25/+25
|
* git_repository_init: include dotfiles when copying templatesEdward Thomson2015-12-261-1/+12
| | | | | | Include dotfiles when copying template directory, which will handle both a template directory itself that begins with a dotfile, and any dotfiles inside the directory.
* repo::init tests: test a template dir with leading dotEdward Thomson2015-12-261-9/+37
| | | | | Ensure that we can handle template directories that begin with a leading dot.
* repo::init tests: test init.templatedir settingEdward Thomson2015-12-261-38/+93
| | | | | Ensure that `git_repository_init` honors the `init.templatedir` configuration setting.
* repository: distinguish sequencer cherry-pick and revertcmn/repository-state-sequencerCarlos Martín Nieto2015-11-201-0/+18
| | | | These are not quite like their plain counterparts and require special handling.
* Merge pull request #3434 from ethomson/reservednamesCarlos Martín Nieto2015-09-211-0/+24
|\ | | | | Win32 Reserved names: don't reserve names outside the working directory
| * repo::reservedname: test a submodule updateEdward Thomson2015-09-181-0/+24
| | | | | | | | | | | | | | 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).
* | git_futils_mkdir_*: make a relative-to-base mkdirEdward Thomson2015-09-174-16/+16
|/ | | | | | | | | | | | 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.
* iterator test: handle case (in)sensitivityEdward Thomson2015-08-311-3/+26
|
* iterator test: use new iter opts in fifo testEdward Thomson2015-08-311-2/+5
|
* iterator: saner pathlist matching for idx iteratorEdward Thomson2015-08-311-0/+70
| | | | | | | | | | | | Some nicer refactoring for index iteration walks. The index iterator doesn't binary search through the pathlist space, since it lacks directory entries, and would have to binary search each index entry and all its parents (eg, when presented with an index entry of `foo/bar/file.c`, you would have to look in the pathlist for `foo/bar/file.c`, `foo/bar` and `foo`). Since the index entries and the pathlist are both nicely sorted, we walk the index entries in lockstep with the pathlist like we do for other iteration/diff/merge walks.
* tree_iterator: use a pathlistEdward Thomson2015-08-301-0/+114
|
* diff: use new iterator pathlist handlingEdward Thomson2015-08-301-6/+11
| | | | | | | | When using literal pathspecs in diff with `GIT_DIFF_DISABLE_PATHSPEC_MATCH` turn on the faster iterator pathlist handling. Updates iterator pathspecs to include directory prefixes (eg, `foo/`) for compatibility with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`.
* iterator: sort subdirs properly with pathlistEdward Thomson2015-08-281-1/+7
| | | | | | | | | | When given a pathlist, don't assume that directories sort before files. Walk through any list of entries sorting before us to make sure that we've exhausted all entries that *aren't* directories. Eg, if we're searching for 'foo/bar', and we have a 'foo.c', keep advancing the pathlist to keep looking for an entry prefixed with 'foo/'.
* Move filelist into the iterator handling itself.Edward Thomson2015-08-281-0/+248
|
* iterator: use an options struct instead of argsEdward Thomson2015-08-281-135/+219
|
* iterator: adjust unreadable-dir test to new behaviourcmn/iterator-skip-diriterCarlos Martín Nieto2015-07-271-5/+1
| | | | | We don't want the iterator to make us stop whenever we hit an unreadable dir. We should instead move over to the next item.
* git__getenv: utf-8 aware env readerEdward Thomson2015-07-021-1/+1
| | | | | | Introduce `git__getenv` which is a UTF-8 aware `getenv` everywhere. Make `cl_getenv` use this to keep consistent memory handling around return values (free everywhere, as opposed to only some platforms).
* Fixed Xcode 6.1 build warningsPierre-Olivier Latour2015-06-231-2/+2
|
* repository: check the format versioncmn/repo-version-checkCarlos Martín Nieto2015-06-231-0/+17
| | | | | | | | This is something we do on re-init but not when opening a repository. This hasn't particularly mattered up to now as the version has been 0 ever since the first release of git, but the times, they're a-changing and we will soon see version 1 in the wild. We need to make sure we don't open those.
* Merge remote-tracking branch 'ethomson/submodule_8dot3'Carlos Martín Nieto2015-03-181-0/+108
|\
| * repository: Introduce "reserved names"Edward Thomson2015-02-271-0/+108
| | | | | | | | | | | | | | A repository can have multiple "reserved names" now, not just a single "short name" for the repository folder itself. Refactor to include a git_repository__reserved_names that returns all the reserved names for a repository.
* | Add tests for the annotated versions of ref-modifying functionsCarlos Martín Nieto2015-03-161-0/+8
| | | | | | | | | | This also brings the soft-reset tests back to life. The function name was missing an underscore, meaning they had not been running.
* | repository_new: test its barenessEdward Thomson2015-03-101-0/+27
| |
* | config: borrow refcounted referencescmn/config-borrow-entryCarlos Martín Nieto2015-03-032-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
* | repository: remove log message override for switching the active branchCarlos Martín Nieto2015-03-033-48/+34
| | | | | | | | | | | | We want to use the "checkout: moving from ..." message in order to let git know when a change of branch has happened. Make the convenience functions for this goal write this message.
* | Remove the signature from ref-modifying functionsCarlos Martín Nieto2015-03-034-37/+35
|/ | | | | | | | | | The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.