summaryrefslogtreecommitdiff
path: root/src/checkout.c
Commit message (Collapse)AuthorAgeFilesLines
...
* No such thing as an orphan branchCarlos Martín Nieto2013-09-171-1/+1
| | | | | | | | | | | Unfortunately git-core uses the term "unborn branch" and "orphan branch" interchangeably. However, "orphan" is only really there for the checkout command, which has the `--orphan` option so it doesn't actually create the branch. Branches never have parents, so the distinction of a branch with no parents is odd to begin with. Crucially, the error messages deal with unborn branches, so let's use that.
* Better macro name for is-exec-bit-set testRussell Belfer2013-09-051-1/+1
|
* Add more file mode permissions macrosRussell Belfer2013-09-051-8/+5
| | | | | | This adds some more macros for some standard operations on file modes, particularly related to permissions, and then updates a number of places around the code base to use the new macros.
* Add public API for pathspec matchingRussell Belfer2013-07-101-5/+5
| | | | | | | | | | | | | | | This adds a new public API for compiling pathspecs and matching them against the working directory, the index, or a tree from the repository. This also reworks the pathspec internals to allow the sharing of code between the existing internal usage of pathspec matching and the new external API. While this is working and the new API is ready for discussion, I think there is still an incorrect behavior in which patterns are always matched against the full path of an entry without taking the subdirectories into account (so "s*" will match "subdir/file" even though it wouldn't with core Git). Further enhancements are coming, but this was a good place to take a functional snapshot.
* Loosen ensure_not_bare rules in checkoutRussell Belfer2013-06-211-6/+27
| | | | | | | | | | | | | With the new target directory option to checkout, the non-bareness of the repository should be checked much later in the parameter validation process - actually that check was already in place, but I was doing it redundantly in the checkout APIs. This removes the now unnecessary early check for bare repos. It also adds some other parameter validation and makes it so that implied parameters can actually be passed as NULL (i.e. if you pass a git_index, you don't have to pass the git_repository - we can get it from index).
* Add target directory to checkoutRussell Belfer2013-06-211-7/+18
| | | | | | | | | | | | | | | | This adds the ability for checkout to write to a target directory instead of having to use the working directory of the repository. This makes it easier to do exports of repository data and the like. This is similar to, but not quite the same as, the --prefix option to `git checkout-index` (this will always be treated as a directory name, not just as a simple text prefix). As part of this, the workdir iterator was extended to take the path to the working directory as a parameter and fallback on the git_repository_workdir result only if it's not specified. Fixes #1332
* Fix checkout of modified file when missing from wdRussell Belfer2013-06-211-1/+3
| | | | | | | | | | This fixes the checkout case when a file is modified between the baseline and the target and yet missing in the working directory. The logic for that case appears to have been wrong. This also adds a useful checkout notify callback to the checkout test helpers that will count notifications and also has a debug mode to visualize what checkout thinks that it's doing.
* Reorganize diff and add basic diff driverRussell Belfer2013-06-101-0/+1
| | | | | | | | | | | | | | | | | | This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
* Make iterators use GIT_ITEROVER & smart advanceRussell Belfer2013-05-311-13/+18
| | | | | | | | | | | | | | | 1. internal iterators now return GIT_ITEROVER when you go past the last item in the iteration. 2. git_iterator_advance will "advance" to the first item in the iteration if it is called immediately after creating the iterator, which allows a simpler idiom for basic iteration. 3. if git_iterator_advance encounters an error reading data (e.g. a missing tree or an unreadable file), it returns the error but also attempts to advance past the invalid data to prevent an infinite loop. Updated all tests and internal usage of iterators to account for these new behaviors.
* Add more diff rename detection testsRussell Belfer2013-05-201-18/+11
| | | | | | | | | | This adds a bunch more rename detection tests including checks vs the working directory, the new exact match options, some more whitespace variants, etc. This also adds a git_futils_writebuffer helper function and uses it in checkout. This is mainly added because I wanted an easy way to write out a git_buf to disk inside my test code.
* Fix checkout of submodules with no .gitmodulesRussell Belfer2013-05-151-21/+36
| | | | | | | | | It is possible for there to be a submodule in a repository with no .gitmodules file (for example, if the user forgot to commit the .gitmodules file). In this case, core Git will just create an empty directory as a placeholder for the submodule but otherwise ignore it. We were generating an error and stopping the checkout. This makes our behavior match that of core git.
* Remove old symlinks before updatingRussell Belfer2013-05-151-3/+11
| | | | | | | Unlike blob updates, symlink updates cannot be done "in place" writing over an old symlink. This means that in checkout when we realize that we can safely update a symlink, we still need to remove the old one before writing the new.
* Unify whitespaces to tabsLinquize2013-05-151-1/+1
|
* Create directory for symlink before creating symlinkBrad Morgan2013-05-141-2/+5
|
* allow checkout to proceed when a dir to be removed is in use (win32)Edward Thomson2013-05-031-0/+3
|
* allow empty dirs to exist when doing checkoutEdward Thomson2013-05-011-2/+6
|
* merge: Warning noiseVicent Marti2013-05-011-0/+1
|
* Make git_oid_cmp public and add git_oid__cmpRussell Belfer2013-04-291-3/+3
|
* Use config cache where possibleRussell Belfer2013-04-231-15/+8
| | | | | | This converts many of the config lookups that are done around the library to use the repository config cache. This was everything I could find that wasn't part of diff (which requires a larger fix).
* Use git_odb_object_data/_size whereever possibleRussell Belfer2013-04-221-2/+2
| | | | | This uses the odb object accessors so we can change the internals more easily...
* What has science done.Vicent Marti2013-04-221-2/+2
|
* checkout: use cache when possible to determine if workdir item is dirtyEdward Thomson2013-04-171-0/+12
| | | | | | | | | | | If the on-disk file has been staged (it's stat data matches the stat data in the cache) then we need not hash the file to determine whether it differs from the checkout target; instead we can simply use the oid in the index. This prevents recomputing a file's hash unnecessarily, prevents loading the file (when filtering) and prevents edge cases where filters suggest that a file is dirty immediately after git writes the file.
* remove unmerged files during reset hardEdward Thomson2013-03-291-2/+5
|
* don't stat until the file is writtenEdward Thomson2013-03-251-3/+3
|
* Move crlf conversion into buf_textautocrlf-fixesRussell Belfer2013-03-251-0/+1
| | | | | | | | | | | | | | This adds crlf/lf conversion functions into buf_text with more efficient implementations that bypass the high level buffer functions. They attempt to minimize the number of reallocations done and they directly write the buffer data as needed if they know that there is enough memory allocated to memcpy data. Tests are added for these new functions. The crlf.c code is updated to use the new functions. Removed the include of buf_text.h from filter.h and just include it more narrowly in the places that need it.
* Fix valgrind issues (and mmap fallback for diff)Russell Belfer2013-03-141-1/+1
| | | | | | | | | | This fixes a number of issues identified by valgrind - mostly missed free calls. Inside valgrind, mmap() may fail which causes some of the diff tests to fail. This adds a fallback code path to diff_output.c:get_workdir_content() where is the mmap() fails the code will now try to read the file data directly into allocated memory (which is what it would do if the data needed to be filtered anyhow).
* Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flagsRussell Belfer2013-03-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This standardizes iterator behavior across all three iterators (index, tree, and working directory). Previously the working directory iterator behaved differently from the other two. Each iterator can now operate in one of three modes: 1. *No tree results, auto expand trees* means that only non- tree items will be returned and when a tree/directory is encountered, we will automatically descend into it. 2. *Tree results, auto expand trees* means that results will be given for every item found, including trees, but you only need to call normal git_iterator_advance to yield every item (i.e. trees returned with pre-order iteration). 3. *Tree results, no auto expand* means that calling the normal git_iterator_advance when looking at a tree will not descend into the tree, but will skip over it to the next entry in the parent. Previously, behavior 1 was the only option for index and tree iterators, and behavior 3 was the only option for workdir. The main public API implications of this are that the `git_iterator_advance_into()` call is now valid for all iterators, not just working directory iterators, and all the existing uses of working directory iterators explicitly use the GIT_ITERATOR_DONT_AUTOEXPAND (for now). Interestingly, the majority of the implementation was in the index iterator, since there are no tree entries there and now have to fake them. The tree and working directory iterators only required small modifications.
* Retire spoolandsort iteratorRussell Belfer2013-03-061-4/+2
| | | | | Since the case sensitivity is moved into the respective iterators, this removes the spoolandsort iterator code.
* Make iterator APIs consistent with standardsRussell Belfer2013-03-061-19/+20
| | | | | | | | | | | | The iterator APIs are not currently consistent with the parameter ordering of the rest of the codebase. This rearranges the order of parameters, simplifies the naming of a number of functions, and makes somewhat better use of macros internally to clean up the iterator code. This also expands the test coverage of iterator functionality, making sure that case sensitive range-limited iteration works correctly.
* clear REUC on checkoutEdward Thomson2013-03-041-0/+3
|
* Merge pull request #1233 from arrbee/file-similarity-metricVicent Martí2013-02-271-1/+1
|\ | | | | Add file similarity scoring to diff rename/copy detection
| * Replace diff delta binary with flagsRussell Belfer2013-02-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the git_diff_delta recorded if the delta was binary. This replaces that (with no net change in structure size) with a full set of flags. The flag values that were already in use for individual git_diff_file objects are reused for the delta flags, too (along with renaming those flags to make it clear that they are used more generally). This (a) makes things somewhat more consistent (because I was using a -1 value in the "boolean" binary field to indicate unset, whereas now I can just use the flags that are easier to understand), and (b) will make it easier for me to add some additional flags to the delta object in the future, such as marking the results of a copy/rename detection or other deltas that might want a special indicator. While making this change, I officially moved some of the flags that were internal only into the private diff header. This also allowed me to remove a gross hack in rename/copy detect code where I was overwriting the status field with an internal value.
* | don't dereference at the end of the workdir iteratorEdward Thomson2013-02-271-2/+4
|/
* Clear up warnings from cppcheckRussell Belfer2013-02-151-3/+7
| | | | | | | | | | | | The cppcheck static analyzer generates warnings for a bunch of places in the libgit2 code base. All the ones fixed in this commit are actually false positives, but I've reorganized the code to hopefully make it easier for static analysis tools to correctly understand the structure. I wouldn't do this if I felt like it was making the code harder to read or worse for humans, but in this case, these fixes don't seem too bad and will hopefully make it easier for better analysis tools to get at any real issues.
* Return the matched pathspec pattern in `git_pathspec_match_path`yorah2013-02-071-1/+1
| | | | | | | Instead of returning directly the pattern as the return value, I used an out parameter, because the function also tests if the passed pathspecs vector is empty. If yes, it considers that the path "matches", but in that case there is no matched pattern per se.
* cache should contain on-disk (filtered) file sizeEdward Thomson2013-01-171-3/+1
|
* Update iterator API with flags for ignore_caseRussell Belfer2013-01-151-6/+10
| | | | | | | | | | | | This changes the iterator API so that flags can be passed in to the constructor functions to control the ignore_case behavior. At this point, the flags are not supported on tree iterators (i.e. there is no functional change over the old API), but the API changes are all made to accomodate this. By the way, I went with a flags parameter because in the future I have a couple of other ideas for iterator flags that will make it easier to fix some diff/status/checkout bugs.
* checkout: Teach checkout to cope with orphaned Headnulltoken2013-01-131-1/+8
| | | | Fix #1236
* Merge pull request #1215 from phkelley/binaryunicodePhilip Kelley2013-01-111-9/+13
|\ | | | | Add a failing test for CRLF filters
| * Check for binary blobs in checkoutRussell Belfer2013-01-111-9/+13
| | | | | | | | | | This adds a git_buf_text_is_binary check to blobs before applying filters when the blob data is being written to disk.
* | checkout: Deploy EMERGECONFLICT usagenulltoken2013-01-111-1/+1
| |
* | Add GIT_CHECKOUT_DISABLE_PATHSPEC_MATCHRussell Belfer2013-01-101-1/+5
|/ | | | | | | This adds an option to checkout a la the diff option to turn off fnmatch evaluation for pathspec entries. This can be useful to make sure your "pattern" in really interpretted as an exact file match only.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Fix checkout of index-only dirs and prefixed pathsRussell Belfer2013-01-041-28/+41
| | | | | | | | | | | There are a couple of checkout bugs fixed here. One is with untracked working directory entries that are prefixes of tree entries but not in a meaningful way (i.e. "read" is a prefix of "readme.txt" but doesn't interfere in any way). The second bug is actually a redo of 07edfa0fc640f85f95507c3101e77accd7d2bf0d where directory entries in the index that are not in the diff were not being removed correctly. That fix remedied one case but broke another.
* Fix checkout bug rmv untracked trees from indexRussell Belfer2013-01-041-14/+33
| | | | | | | | | When checking out with the GIT_CHECKOUT_REMOVE_UNTRACKED option and there was an entire tree in the working directory and in the index that is not in the baseline nor target commit, the tree was correctly(?) removed from the working directory but was not successfully removed from the index. This fixes that and adds a test of the functionality.
* Fix memory leak with checkout tree iteratorRussell Belfer2013-01-041-2/+1
|
* Fixing checkout UPDATE_ONLY and adding testsRussell Belfer2013-01-041-0/+28
| | | | | This adds a bunch of new checkout tests and in the process I found a bug in the GIT_CHECKOUT_UPDATE_ONLY flag which I fixed.
* Simplify checkout documentationRussell Belfer2013-01-041-176/+8
| | | | | | This moves a lot of the detailed checkout documentation into a new file (docs/checkout-internals.md) and simplifies the public docs for the checkout API.
* Fix some submodule and typechange checkout casesRussell Belfer2013-01-041-24/+109
| | | | | | | | | There were a bunch of small bugs in the checkout code where I was assuming that a typechange was always from a tree to a blob or vice versa. This fixes up most of those cases. Also, there were circumstances where the submodule definitions were changed by the checkout and the submodule data was not getting reloaded properly before the new submodules were checked out.
* Fix workdir notifications and removalsRussell Belfer2013-01-041-20/+25
| | | | | | | The notifications were broken from the various iterations over this code and were not returning working dir item data correctly. Also, workdir items that were alphabetically after the last item in diff were not being processed.