summaryrefslogtreecommitdiff
path: root/tests/checkout
Commit message (Collapse)AuthorAgeFilesLines
* references: use new names in internal usageethomson/git_refEdward Thomson2019-01-171-1/+1
| | | | Update internal usage to use the `git_reference` names for constants.
* checkout::crlf: ensure successethomson/crlfEdward Thomson2018-12-191-30/+33
| | | | | Wrap function calls in the `checkout::crlf` tests with `cl_git_pass`, `cl_assert`, etc. to ensure that they're successful.
* checkout::crlf clear the crlf workdir for checkoutEdward Thomson2018-12-031-0/+24
| | | | | | | After sandboxing the crlf directory, remove the working directory contents. This allows us to package data within the crlf directory (for simplicity, this allows us to script the to-odb and to-workdir crlf filter conversion data in a single location).
* crlf_data: move to a "to_workdir" folderEdward Thomson2018-12-031-2/+7
| | | | | | | Move the crlf_data folders reponsible for holding the state of the filters going into the working directory to "to_workdir" variations of the folder name to accommodate future growth into the "to odb" filter variation. Update the script to create these new folders as appopriate.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-016-34/+34
| | | | Use the new object_type enumeration names within the codebase.
* index: use new enum and structure namesEdward Thomson2018-12-013-7/+7
| | | | Use the new-style index names throughout our own codebase.
* symlink tests: test symbolic links on windowsethomson/win_symlinksEdward Thomson2018-10-201-31/+67
| | | | | | | | | Test updated symbolic link creation on Windows. Ensure that we emulate Git for Windows behavior. Ensure that when `core.symlinks=true` is set in a global configuration that new repositories are created without a `core.symlinks` setting, and that when `core.symlinks` is unset that `core.symlinks=false` in set in the repository. Further ensure that checkout honors the expected `core.symlinks` defaults on Windows.
* tests: provide symlink support helper functionEdward Thomson2018-10-201-22/+3
|
* checkout tests: ensure readlink succeedsEdward Thomson2018-10-201-1/+3
| | | | | | Don't try to use `link_size` as an index into a string if `p_readlink` returned <0. That will - obviously - fail and we'll write out of bounds.
* checkout tests: test symlinks based on support, not platformEdward Thomson2018-10-203-72/+121
| | | | | | | | | | | | | | When testing whether symlinks are correctly checked out, examine the `core.symlinks` configuration option to determine if symlinks are supported in a repository, don't simply assume that Windows means that symbolic links are not supported. Further, when testing the expected default behavior of `core.symlinks`, test the filesystem's support to determine if symlinks are supported. Finally, ensure that `core.symlinks=true` fails on a system where symlinks are actually not supported. This aligns with the behavior of Git for Windows.
* checkout tests: don't use GetFinalPathNameByHandleEdward Thomson2018-10-201-24/+0
| | | | | | | | | | | To determine the canonical filename for a given path, we previously looked at the directory entries on POSIX systems and used GetFinalPathNameByHandle on Windows. However, GetFinalPathNameByHandle requires a HANDLE - the results of CreateFile - and you cannot CreateFile on a symbolic link. To support finding the canonical path of a symbolic link, simply use the existing POSIX code to look at the directory entries.
* Merge pull request #4702 from tiennou/fix/coverityPatrick Steinhardt2018-07-202-18/+18
|\ | | | | Assorted Coverity fixes
| * tests: add missing cl_git_pass to testsEtienne Samson2018-07-062-18/+18
| | | | | | Reported by Coverity, CID 1393678-1393697.
* | treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-132-2/+2
|/ | | | | | | | | C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
* checkout: FORCE doesn't halt on dirty indexEdward Thomson2018-06-292-16/+0
| | | | | If the index is dirty, allow `GIT_CHECKOUT_FORCE` to obliterate unsaved changes. This is in keeping with its name and description.
* index: commit the changes to the index properlyEdward Thomson2018-06-292-4/+28
| | | | | | | Now that the index has a "dirty" state, where it has changes that have not yet been committed or rolled back, our tests need to be adapted to actually commit or rollback the changes instead of assuming that the index can be operated on in its indeterminate state.
* checkout tests: validate GIT_CHECKOUT_NO_REFRESHEdward Thomson2018-06-291-0/+64
| | | | | | Add tests that ensure that we re-read the on-disk image by default during checkout, but when the `GIT_CHECKOUT_NO_REFRESH` option is specified, we do _not_ re-read the index.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-108-29/+29
|
* checkout: change symlinked .gitmodules file test to expect failureCarlos Martín Nieto2018-05-231-1/+6
| | | | | | When dealing with `core.proectNTFS` and `core.protectHFS` we do check against `.gitmodules` but we still have a failing test as the non-filesystem codepath does not check for it.
* checkout: add a failing test for refusing a symlinked .gitmodulesCarlos Martín Nieto2018-05-221-0/+7
| | | | | We want to reject these as they cause compatibility issues and can lead to git writing to files outside of the repository.
* diff: Add missing GIT_DELTA_TYPECHANGE -> 'T' mapping.Erik van Zijst2018-04-051-0/+26
| | | | | This adds the 'T' status character to git_diff_status_char() for diff entries that change type.
* checkout test: ensure workdir mode is simplifiedEdward Thomson2018-02-231-0/+27
| | | | | | | | | | | | Ensure that when examining the working directory for checkout that the mode is correctly simplified. Git only pays attention to whether a file is executable or not. When examining a working directory, we should coalesce modes in the working directory to either `0755` (indicating that a file is executable) or `0644` (indicating that it is not). Test this by giving the file an exotic mode, and ensuring that when checkout out a branch that changes the file's contents, that we do not have a checkout conflict.
* checkout test: add core.filemode checkout testsEdward Thomson2018-02-231-0/+56
| | | | | | | | | | | | | | | | | | | | | | Add two tests for filemode. The first ensures that `core.filemode=true` is honored: if we have changed the filemode such that a file that _was_ executable (mode 0755) is now executable (mode 0644) and we go to check out a branch that has otherwise changed the contents of the file, then we should raise a checkout conflict for that file. The second ensures that `core.filemode=false` is honored: in the same situation, we set a file that was executable to be non-executable, and check out the branch that changes the contents of the file. However, since `core.filemode` is false, we do not detect the filemode change. We run these tests on both operating systems that obey `core.filemode` (eg, POSIX) and those that have no conception of filemode (eg, Win32). This ensures that `core.filemode` is always honored, as it is a cache of the underlying filesystem's settings. This ensures that we do not make assumptions based on the operating system, and honor the configuration setting even if it were misconfigured.
* checkout test: further ensure workdir perms are updatedethomson/checkout_typechange_with_index_and_wdEdward Thomson2018-02-201-0/+25
| | | | | | | When both the index _and_ the working directory has changed permissions on a file permissions on a file - but only the permissions, such that the contents of the file are identical - ensure that `git_checkout` updates the permissions to match the checkout target.
* checkout test: ensure workdir perms are updatedEdward Thomson2018-02-201-0/+20
| | | | | | | When the working directory has changed permissions on a file - but only the permissions, such that the contents of the file are identical - ensure that `git_checkout` updates the permissions to match the checkout target.
* tests: status::worktree: indicate skipped tests on Win32Patrick Steinhardt2018-01-031-0/+2
| | | | | | | | | Some function bodies of tests which are not applicable to the Win32 platform are completely #ifdef'd out instead of calling `cl_skip()`. This leaves us with no indication that these tests are not being executed at all and may thus cause decreased scrutiny when investigating skipped tests. Improve the situation by calling `cl_skip()` instead of just doing nothing.
* tests: checkout::tree: check that the status list catches mode changesPatrick Steinhardt2017-10-091-0/+2
| | | | | | | | While we verify that we have no mode changes after calling `git_checkout_tree`, we do not verify that the `p_chmod` calls actually resulted in a changed entry. While we should assume that this works due to separate tests for the status list, we should test for the change being listed to avoid programming errors in the test.
* tests: checkout::tree: extract check for status entrycountPatrick Steinhardt2017-10-091-17/+14
| | | | | | There are multiple locations where we have the same code to check whether the count of status list entries of a repository matches an expected number. Extract that into a common function.
* checkout: test force checkout when mode changesethomson/checkout_typechangeEdward Thomson2017-10-071-0/+45
| | | | | Test that we can successfully force checkout a target when the file contents are identical, but the mode has changed.
* checkout: do not delete directories with untracked entriesPatrick Steinhardt2017-06-101-0/+76
| | | | | | | | | | If the `GIT_CHECKOUT_FORCE` flag is given to any of the `git_checkout` invocations, we remove files which were previously staged. But while doing so, we unfortunately also remove unstaged files in a directory which contains at least one staged file, resulting in potential data loss. This commit adds two tests to verify behavior.
* tests: fix indentation in checkout::head::with_index_only_treePatrick Steinhardt2017-04-101-1/+1
|
* checkout::tree test: cleanup memory leakEdward Thomson2017-01-231-4/+1
|
* Fix handling of GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH flag.John Fultz2016-12-291-0/+38
| | | | | | | | | | | | | | | | | git_checkout_tree() sets up its working directory iterator to respect the pathlist if GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH is present, which is great. What's not so great is that this iterator is then used side-by-side with an iterator created by git_checkout_iterator(), which did not set up its pathlist appropriately (although the iterator mirrors all other iterator options). This could cause git_checkout_tree() to delete working tree files which were not specified in the pathlist when GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH was used, as the unsynchronized iterators causes git_checkout_tree() to think that files have been deleted between the two trees. Oops. And added a test which fails without this fix (specifically, the final check for "testrepo/README" to still be present fails).
* git_checkout_tree options fixStefan Huber2016-08-301-0/+4
| | | | | | | | According to the reference the git_checkout_tree and git_checkout_head functions should accept NULL in the opts field This was broken since the opts field was dereferenced and thus lead to a crash.
* checkout: use empty baseline when no indexethomson/checkout_no_indexEdward Thomson2016-06-151-0/+63
| | | | | When no index file exists and a baseline is not explicitly provided, use an empty baseline instead of trying to load `HEAD`.
* tests: fix memory leaks in checkout::typechangePatrick Steinhardt2016-06-071-2/+2
|
* cleanup: unused warningEdward Thomson2016-06-011-0/+3
|
* Merge pull request #3798 from mmuman/stat-test-fixEdward Thomson2016-05-261-2/+3
|\ | | | | test: Fix stat() test to mask out unwanted bits
| * test: Fix stat() test to mask out unwanted bitsFrançois Revol2016-05-241-2/+3
| | | | | | | | Haiku and Hurd both pass extra bits in struct stat::st_mode.
* | checkout: handle dirty submodules correctlyJason Haslam2016-05-261-8/+74
|/ | | | | Don't generate conflicts when checking out a modified submodule and the submodule is dirty or modified in the workdir.
* win32: introduce p_timeval that isn't stupidEdward Thomson2016-02-121-1/+1
| | | | | Windows defines `timeval` with `long`, which we cannot sanely cope with. Instead, use a custom timeval struct.
* checkout test: Apply umask to file-mode test as wellMichał Górny2015-12-011-1/+1
| | | | | | | | Fix the file-mode test to expect system umask being applied to the created file as well (it is currently applied to the directory only). This fixes the test on systems where umask != 022. Signed-off-by: Michał Górny <mgorny@gentoo.org>
* Fix some warningsJacques Germishuys2015-11-201-1/+1
|
* checkout::crlf test: don't crash when no idx entryEdward Thomson2015-11-161-4/+5
| | | | | | | | | | When there's no matching index entry (for whatever reason), don't try to dereference the null return value to get at the id. Otherwise when we break something in the index API, the checkout test crashes for confusing reasons and causes us to step through it in a debugger thinking that we had broken much more than we actually did.
* diff/index: respect USE_NSEC for racily clean file detectionAxel Rasmussen2015-09-181-5/+5
|
* git_futils_mkdir_*: make a relative-to-base mkdirEdward Thomson2015-09-171-1/+1
| | | | | | | | | | | | 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.
* checkout: overwrite files with differing modesEdward Thomson2015-09-161-1/+2
| | | | | | | | | | | When a file exists on disk and we're checking out a file that differs in executableness, remove the old file. This allows us to recreate the new file with p_open, which will take the new mode into account and handle setting the umask properly. Remove any notion of chmod'ing existing files, since it is now handled by the aforementioned removal and was incorrect, as it did not take umask into account.
* checkout::tree tests: don't use hardcoded modeEdward Thomson2015-09-161-8/+8
|
* checkout::tree tests: don't use static bufferEdward Thomson2015-09-161-6/+9
|
* Check that checkout preserves filemode in working directory.Matti Virolainen2015-09-161-0/+63
|