src/checkout.c


Log

Author Commit Date CI Message
Russell Belfer eac76c23 2013-04-22T14:27:36 Use config cache where possible 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).
Russell Belfer badd85a6 2013-04-10T17:10:17 Use git_odb_object_data/_size whereever possible This uses the odb object accessors so we can change the internals more easily...
Vicent Marti 8842c75f 2013-04-03T22:30:07 What has science done.
Edward Thomson 0da62c5c 2013-04-17T10:52:49 checkout: use cache when possible to determine if workdir item is dirty 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.
Edward Thomson 54a1a042 2013-03-29T11:26:12 remove unmerged files during reset hard
Edward Thomson d828f118 2013-03-25T18:16:02 don't stat until the file is written
Russell Belfer 3658e81e 2013-03-25T14:20:07 Move crlf conversion into buf_text 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.
Russell Belfer d85296ab 2013-03-14T13:50:54 Fix valgrind issues (and mmap fallback for diff) 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).
Russell Belfer 9bea03ce 2013-03-06T15:16:34 Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flags 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.
Russell Belfer cc216a01 2013-03-05T16:29:04 Retire spoolandsort iterator Since the case sensitivity is moved into the respective iterators, this removes the spoolandsort iterator code.
Russell Belfer 169dc616 2013-03-05T16:10:05 Make iterator APIs consistent with standards 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.
Edward Thomson 5bddabcc 2013-03-04T17:40:48 clear REUC on checkout
Vicent Martí e68e33f3 2013-02-27T14:50:32 Merge pull request #1233 from arrbee/file-similarity-metric Add file similarity scoring to diff rename/copy detection
Edward Thomson 395509ff 2013-02-27T14:47:39 don't dereference at the end of the workdir iterator
Russell Belfer 71a3d27e 2013-02-08T10:06:47 Replace diff delta binary with flags 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.
Russell Belfer 56543a60 2013-02-15T16:02:45 Clear up warnings from cppcheck 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.
yorah 943700ec 2013-01-18T16:37:13 Return the matched pathspec pattern in `git_pathspec_match_path` 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.
Edward Thomson 6e959708 2013-01-17T13:11:57 cache should contain on-disk (filtered) file size
Russell Belfer 134d8c91 2013-01-08T15:53:13 Update iterator API with flags for ignore_case 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.
nulltoken 2a3b3e03 2013-01-12T19:27:31 checkout: Teach checkout to cope with orphaned Head Fix #1236
Philip Kelley 359316b5 2013-01-11T17:16:55 Merge pull request #1215 from phkelley/binaryunicode Add a failing test for CRLF filters
Russell Belfer ad10db2a 2013-01-10T15:59:36 Check for binary blobs in checkout This adds a git_buf_text_is_binary check to blobs before applying filters when the blob data is being written to disk.
nulltoken 4a0ac175 2013-01-10T23:27:13 checkout: Deploy EMERGECONFLICT usage
Russell Belfer 40342bd2 2013-01-10T15:15:37 Add GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH 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.
Edward Thomson 359fc2d2 2013-01-08T17:07:25 update copyrights
Russell Belfer 817d6251 2013-01-03T16:56:27 Fix checkout of index-only dirs and prefixed paths 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.
Russell Belfer d8889d2b 2013-01-03T14:08:53 Fix checkout bug rmv untracked trees from index 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.
Russell Belfer dde7602a 2013-01-03T13:22:34 Fix memory leak with checkout tree iterator
Russell Belfer 0d70f650 2013-01-03T10:51:18 Fixing checkout UPDATE_ONLY and adding tests 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.
Russell Belfer 77cffa31 2013-01-02T17:14:00 Simplify checkout documentation 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.
Russell Belfer e0548c0e 2013-01-02T17:09:07 Fix some submodule and typechange checkout cases 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.
Russell Belfer 16a666d3 2013-01-02T17:05:54 Fix workdir notifications and removals 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.
Russell Belfer 546d65a8 2013-01-02T17:01:34 Fix up spoolandsort iterator usage The spoolandsort iterator changes got sort-of cherry picked out of this branch and so I dropped the commit when rebasing; however, there were a few small changes that got dropped as well (since the version merged upstream wasn't quite the same as what I dropped).
Russell Belfer 5cf9875a 2012-12-18T15:19:24 Add index updating to checkout Make checkout update entries in the index for all files that are updated and/or removed, unless flag GIT_CHECKOUT_DONT_UPDATE_INDEX is given. To do this, iterators were extended to allow a little more introspection into the index being iterated over, etc.
Russell Belfer 7e5c8a5b 2012-12-10T15:31:43 More checkout improvements This flips checkout back to be driven off the changes between the baseline and the target trees. This reinstates the complex code for tracking the contents of the working directory, but overall, I think the resulting logic is easier to follow.
Russell Belfer cf208031 2012-12-06T13:36:17 Rework checkout internals (again) I've tried to map out the detailed behaviors of checkout and make sure that we're handling the various cases correctly, along with providing options to allow us to emulate "git checkout" and "git checkout-index" with the various flags. I've thrown away flags in the checkout API that seemed like clutter and added some new ones. Also, I've converted the conflict callback to a general notification callback so we can emulate "git checkout" output and display "dirty" files. As of this commit, the new behavior is not working 100% but some of that is probably baked into tests that are not testing the right thing. This is a decent snapshot point, I think, along the way to getting the update done.
Russell Belfer f616a36b 2012-12-27T22:25:52 Make spoolandsort a pushable iterator behavior An earlier change to `git_diff_from_iterators` introduced a memory leak where the allocated spoolandsort iterator was not returned to the caller and thus not freed. One proposal changes all iterator APIs to use git_iterator** so we can reallocate the iterator at will, but that seems unexpected. This commit makes it so that an iterator can be changed in place. The callbacks are isolated in a separate structure and a pointer to that structure can be reassigned by the spoolandsort extension. This means that spoolandsort doesn't create a new iterator; it just allocates a new block of callbacks (along with space for its own extra data) and swaps that into the iterator. Additionally, since spoolandsort is only needed to switch the case sensitivity of an iterator, this simplifies the API to only take the ignore_case boolean and to be a no-op if the iterator already matches the requested case sensitivity.
Russell Belfer 56c72b75 2012-12-17T11:00:53 Fix diff constructor name order confusion The diff constructor functions had some confusing names, where the "old" side of the diff was coming after the "new" side. This reverses the order in the function name to make it less confusing. Specifically... * git_diff_index_to_tree becomes git_diff_tree_to_index * git_diff_workdir_to_index becomes git_diff_index_to_workdir * git_diff_workdir_to_tree becomes git_diff_tree_to_workdir
Russell Belfer 9950d27a 2012-12-06T13:26:58 Clean up iterator APIs This removes the need to explicitly pass the repo into iterators where the repo is implied by the other parameters. This moves the repo to be owned by the parent struct. Also, this has some iterator related updates to the internal diff API to lay the groundwork for checkout improvements.
Vicent Martí e05ca13f 2012-12-05T11:47:19 Merge pull request #1115 from ben/struct-versions Version info for public structs
Edward Thomson 05fc823f 2012-12-04T16:59:34 indentation fix
Edward Thomson aab8f5af 2012-12-04T16:40:09 hey don't stomp on my memory!
Ben Straub 0ab3a2ab 2012-11-30T20:34:50 Deploy GIT_INIT_STRUCTURE
Ben Straub c7231c45 2012-11-30T16:31:42 Deploy GITERR_CHECK_VERSION
Ben Straub 2f8d30be 2012-11-29T15:05:04 Deploy GIT_DIFF_OPTIONS_INIT
Ben Straub b81aa2f1 2012-11-29T14:06:40 Deploy GIT_CHECKOUT_OPTS_INIT
Vicent Marti cfbe4be3 2012-11-17T19:54:47 More external API cleanup Conflicts: src/branch.c tests-clar/refs/branches/create.c
nulltoken 5cec896a 2012-11-22T18:51:06 repo: Make git_repository_head_tree() return error codes
Scott J. Goldman 0cd063fd 2012-11-15T23:28:52 Merge pull request #1071 from arrbee/alternate-fix-strcmp Win32 fixes for diff/checkout/reset
Russell Belfer bbe6dbec 2012-11-14T23:29:48 Add explicit git_index ptr to diff and checkout A number of diff APIs and the `git_checkout_index` API take a `git_repository` object an operate on the index. This updates them to take a `git_index` pointer explicitly and only fall back on the `git_repository` index if the index input is NULL. This makes it easier to operate on a temporary index.
Russell Belfer 5735bf5e 2012-11-13T13:58:29 Fix diff API to better parameter order The diff API is not in the parameter order one would expect from other libgit2 APIs. This fixes that.
Russell Belfer cccacac5 2012-11-14T22:41:51 Add POSIX compat lstat() variant for win32 The existing p_lstat implementation on win32 is not quite POSIX compliant when setting errno to ENOTDIR. This adds an option to make is be compliant so that code (such as checkout) that cares to have separate behavior for ENOTDIR can use it portably. This also contains a couple of other minor cleanups in the posix_w32.c implementations to avoid unnecessary work.
Russell Belfer 757b4065 2012-11-09T14:01:44 Fix warnings and valgrind issues This fixes some various warnings that showed up in Travis and a couple uses of uninitialized memory and one memory leak.
Russell Belfer 0f3def71 2012-11-09T11:19:46 Fix various cross-platform build issues This fixes a number of warnings and problems with cross-platform builds. Among other things, it's not safe to name a member of a structure "strcmp" because that may be #defined.
Russell Belfer ad9a921b 2012-11-08T17:05:07 Rework checkout with new strategy options This is a major reworking of checkout strategy options. The checkout code is now sensitive to the contents of the HEAD tree and the new options allow you to update the working tree so that it will match the index content only when it previously matched the contents of the HEAD. This allows you to, for example, to distinguish between removing files that are in the HEAD but not in the index, vs just removing all untracked files. Because of various corner cases that arise, etc., this required some additional capabilities in rmdir and other utility functions. This includes the beginnings of an implementation of code to read a partial tree into the index based on a pathspec, but that is not enabled because of the possibility of creating conflicting index entries.
Russell Belfer 32def5af 2012-10-24T17:37:07 Fix checkout behavior when its hands are tied So, @nulltoken created a failing test case for checkout that proved to be particularly daunting. If checkout is given only a very limited strategy mask (e.g. just GIT_CHECKOUT_CREATE_MISSING) then it is possible for typechange/rename modifications to leave it unable to complete the request. That's okay, but the existing code did not have enough information not to generate an error (at least for tree/blob conflicts). This led me to a significant reorganization of the code to handle the failing case, but it has three benefits: 1. The test case is handled correctly (I think) 2. The new code should actually be much faster than the old code since I decided to make checkout aware of diff list internals. 3. The progress value accuracy is hugely increased since I added a fourth pass which calculates exactly what work needs to be done before doing anything.
Russell Belfer 331e7de9 2012-10-24T17:32:50 Extensions to rmdir and mkdir utilities * Rework GIT_DIRREMOVAL values to GIT_RMDIR flags, allowing combinations of flags * Add GIT_RMDIR_EMPTY_PARENTS flag to remove parent dirs that are left empty after removal * Add GIT_MKDIR_VERIFY_DIR to give an error if item is a file, not a dir (previously an EEXISTS error was ignored, even for files) and enable this flag for git_futils_mkpath2file call * Improve accuracy of error messages from git_futils_mkdir
Ben Straub a9db123b 2012-10-31T10:14:13 Checkout: remove duplicate 100% progress report
Ben Straub 2dae54a9 2012-10-19T20:24:15 Improve clone sample's formatting
Ben Straub 9c05c17b 2012-10-19T20:05:18 Checkout progress now reports completed/total steps
Ben Straub 63afb005 2012-10-19T19:33:23 Remove third stage from checkout progress reporting Also, now only reporting checkout progress for files that are actually being added or removed.
Ben Straub 45b60d7b 2012-10-18T15:17:12 Correct progress reporting from checkout
Ben Straub 30a46ab1 2012-10-18T14:04:14 Adjust for rebase
nulltoken 0ae81fc4 2012-10-17T15:30:22 index: remove read_tree() progress indicator git_index_read_tree() was exposing a parameter to provide the user with a progress indicator. Unfortunately, due to the recursive nature of the tree walk, the maximum number of items to process was unknown. Thus, the indicator was only counting processed entries, without providing any information how the number of remaining items.
Ben Straub 1f7c7418 2012-10-17T10:15:07 Remove dead code
Ben Straub 80642656 2012-10-16T20:23:10 Convert checkout_* to use progress callback
Ben Straub 2c8bbb27 2012-10-16T20:16:21 Convert checkout_index to use progress callback
nulltoken 8b05bea8 2012-10-19T17:07:39 errors: deploy GIT_EORPHANEDHEAD usage
Russell Belfer 52a61bb8 2012-10-17T14:10:23 Fix minor bugs Fixed no-submodule speedup of new checkout code. Fixed missing final update to progress (which may go away, I realize). Fixed unused structure in header and incorrect comment.
Russell Belfer e48bb71b 2012-10-17T10:44:38 Skip submodule checkout pass if no submodules Skip the third pass of checkout (where submodules are checked out) if the earlier passes found no submodules to be checked out.
Russell Belfer 0d64bef9 2012-10-05T15:56:57 Add complex checkout test and then fix checkout This started as a complex new test for checkout going through the "typechanges" test repository, but that revealed numerous issues with checkout, including: * complete failure with submodules * failure to create blobs with exec bits * problems when replacing a tree with a blob because the tree "example/" sorts after the blob "example" so the delete was being processed after the single file blob was created This fixes most of those problems and includes a number of other minor changes that made it easier to do that, including improving the TYPECHANGE support in diff/status, etc.
Russell Belfer 95f5f1e6 2012-10-02T13:57:15 Cleanup TYPECHANGE support This is just some cleanup code, rearranging some of the checkout code where TYPECHANGE support was added and adding some comments to the diff header regarding the constants.
Russell Belfer fbec2fb9 2012-09-28T14:32:33 Fix checkout to know about TYPECHANGE diffs
Russell Belfer fade21db 2012-09-28T13:39:34 Improve error propogation in checkout
Russell Belfer bae957b9 2012-09-25T16:31:46 Add const to all shared pointers in diff API There are a lot of places where the diff API gives the user access to internal data structures and many of these were being exposed through non-const pointers. This replaces them all with const pointers for any object that the user can access but is still owned internally to the git_diff_list or git_diff_patch objects. This will probably break some bindings... Sorry!
Michael Schubert d75074f4 2012-09-22T12:29:16 Fix -Wmaybe-uninitialized warning
nulltoken 9e592583 2012-09-19T12:23:47 checkout: add notification callback for skipped files
nulltoken 9ac8b113 2012-09-20T14:06:49 Fix MSVC amd64 compilation warnings
nulltoken 28abf3db 2012-09-20T11:41:49 checkout: prefer mode_t type usage over int
nulltoken 39783719 2012-09-17T20:27:28 checkout: Mimic git_diff_options storage of paths
nulltoken 5e4cb4f4 2012-09-17T10:38:57 checkout : reduce memory usage when not filtering
nulltoken 5af61863 2012-09-14T11:15:49 checkout: drop git_checkout_reference()
nulltoken c214fa1c 2012-09-06T15:15:46 checkout: segregate checkout strategies
nulltoken e93af304 2012-08-24T10:40:17 checkout: introduce git_checkout_index()
nulltoken 3aa443a9 2012-08-20T16:56:45 checkout: introduce git_checkout_tree()
nulltoken 35d2e449 2012-08-20T11:26:02 checkout: cleanup misplaced declaration
Russell Belfer 97a17e4e 2012-08-24T12:19:22 Fix valgrind warnings and spurious error messages Just clean up valgrind warnings about uninitialized memory and also clear out errno in some cases where it results in a false error message being generated at a later point.
nulltoken 9d7ac675 2012-08-21T11:45:16 tree entry: rename git_tree_entry_attributes() into git_tree_entry_filemode()
Ben Straub 5f4d2f9f 2012-07-31T19:49:19 Checkout: fix problem with detached HEAD.
Ben Straub 8e4aae1a 2012-07-31T10:44:42 Checkout: handle file modes properly. Global file mode override now works properly with the file mode stored in the tree node.
Ben Straub 7e02c7c5 2012-07-31T08:45:42 Checkout: save index on checkout.
Ben Straub 4bf51156 2012-07-30T14:52:46 Enable stats on git_index_read_tree. Replace with the contents of git_index_read_tree_with_stats() and improve documentation comments.
Ben Straub f1587b97 2012-07-30T14:37:40 Checkout: use git_index_read_tree_with_stats. New variant of git_index_read_tree that fills in the 'total' field of a git_indexer_stats struct as it's walking the tree.
Ben Straub b31667fb 2012-07-27T20:29:06 Checkout: add head- and ref-centric checkouts. Renamed git_checkout_index to what it really was, and removed duplicate code from clone.c. Added git_checkout_ref, which updates HEAD and hands off to git_checkout_head. Added tests for the options the caller can pass to git_checkout_*.
Ben Straub b494cdbd 2012-07-27T11:50:32 Checkout: handle deeply-nested submodules better. Now creating intermediate directories where the submodule is deep, like "src/deps/foosubmodule".
Ben Straub 6eb240b0 2012-07-26T19:09:37 Checkout: use caller's flags for open()
Ben Straub 095ccc01 2012-07-26T16:31:49 Checkout: implementation of most options
Ben Straub b401bace 2012-07-26T13:12:21 Restructure for better checkout options * Removed the #define for defaults * Promoted progress structure to top-level API call argument
Ben Straub ef9905c9 2012-07-26T12:58:44 checkout: introduce git_checkout_opts Refactor checkout into several more-sensible entry points, which consolidates common options into a single structure that may be passed around.
Ben Straub dc03369c 2012-07-21T20:12:28 checkout: create submodule dirs