src/merge.c


Log

Author Commit Date CI Message
Carlos Martín Nieto ca2857d8 2015-06-10T10:30:08 merge: actually increment the counts, not the pointers `merge_diff_list_count_candidates()` takes pointers to the source and target counts, but when it comes time to increase them, we're increasing the pointer, rather than the value it's pointing to. Dereference the value to increase.
Edward Thomson 885b94aa 2015-05-28T15:26:13 Rename GIT_EMERGECONFLICT to GIT_ECONFLICT We do not error on "merge conflicts"; on the contrary, merge conflicts are a normal part of merging. We only error on "checkout conflicts", where a change exists in the index or the working directory that would otherwise be overwritten by performing the checkout. This *may* happen during merge (after the production of the new index that we're going to checkout) but it could happen during any checkout.
Edward Thomson 9f545b9d 2015-05-19T11:23:59 introduce `git_index_entry_is_conflict` It's not always obvious the mapping between stage level and conflict-ness. More importantly, this can lead otherwise sane people to write constructs like `if (!git_index_entry_stage(entry))`, which (while technically correct) is unreadable. Provide a nice method to help avoid such messy thinking.
Edward Thomson 9ebb5a3f 2015-02-18T22:53:40 merge: merge iterators
Edward Thomson 89ba9f1a 2015-03-18T13:17:04 Merge pull request #2967 from jacquesg/merge-whitespace Allow merges of files (and trees) with whitespace problems/fixes
Jeff Hostetler fea24c53 2015-03-16T15:54:53 PERF: In MERGE, lazily compute is_binary
Jacques Germishuys 13de9363 2015-03-12T12:36:09 Collapse whitespace flags into git_merge_file_flags_t
Jacques Germishuys f29dde68 2015-03-12T12:29:47 Renamed git_merge_options 'flags' to 'tree_flags'
Jacques Germishuys 45a86bbf 2015-03-09T17:02:52 Allow for merges with whitespace discrepancies
Carlos Martín Nieto a291790a 2015-02-15T05:18:01 Merge pull request #2831 from ethomson/merge_lock merge: lock index during the merge (not just checkout)
Edward Thomson 41fae48d 2015-02-03T22:31:10 indexwriter: an indexwriter for repo operations Provide git_indexwriter_init_for_operation for the common locking pattern in merge, rebase, revert and cherry-pick.
Edward Thomson 8b0ddd5d 2015-01-17T23:28:53 merge: lock the index at the start of the merge Always lock the index when we begin the merge, before we write any of the metdata files. This prevents a race where another client may run a commit after we have written the MERGE_HEAD but before we have updated the index, which will produce a merge commit that is treesame to one parent. The merge will finish and update the index and the resultant commit would not be a merge at all.
Edward Thomson f1453c59 2015-02-12T12:19:37 Make our overflow check look more like gcc/clang's Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
Edward Thomson 392702ee 2015-02-09T23:41:13 allocations: test for overflow of requested size Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
Edward Thomson 85880693 2015-01-14T10:19:28 Merge branch 'pr/2740'
Pierre-Olivier Latour b3837d4d 2014-12-02T05:47:32 Always use GIT_HASHSIG_SMART_WHITESPACE when diffing for merges git_merge_tree_flag_t cannot contain any GIT_DIFF_FIND_xxx flags so there's not point in checking for them
Jacques Germishuys 6f73e026 2014-12-24T11:42:50 Plug some leaks
Edward Thomson 18b00406 2014-10-03T19:02:29 s/git_merge_head/git_annotated_commit Rename git_merge_head to git_annotated_commit, as it becomes used in more operations than just merge.
Edward Thomson 867a36f3 2014-07-14T14:35:01 Introduce git_rebase to set up a rebase session Introduce `git_rebase` to set up a rebase session that can then be continued. Immediately, only merge-type rebase is supported.
Arthur Schreiber 917f85a1 2014-10-09T14:16:10 Extract shared functionality.
Arthur Schreiber eca07bcd 2014-10-09T13:58:23 Add git_merge_bases_many.
Vicent Marti 737b5051 2014-10-01T12:03:24 hashsig: Export as a `sys` header
Jacques Germishuys dc68ee8d 2014-09-12T22:37:15 Remove local unused index_repo variable
Jacques Germishuys a565f364 2014-09-12T22:53:56 Only check for workdir conflicts if the index has merged files Passing 0 as the length of the paths to check to git_diff_index_to_workdir results in all files being treated as conflicting, that is, all untracked or modified files in the worktree is reported as conflicting
Vicent Marti 46a13f32 2014-08-29T18:19:56 Merge pull request #2481 from libgit2/cmn/oidarray merge: expose multiple merge bases
Arthur Schreiber 017c0eac 2014-08-25T22:41:07 merge base: Correctly raise an error if a non-commit object is passed.
Carlos Martín Nieto 7db0e6ee 2014-07-18T16:00:21 merge: expose multiple merge bases We always calculate multiple merge bases, but up to now we had only exposed the "best" merge base. Introduce git_oidarray which analogously to git_strarray lets us return multiple ids.
Edward Thomson 994404b5 2014-07-17T01:25:31 Don't allow conflicts by default
Edward Thomson 02bf955f 2014-07-02T15:42:15 merge: don't open COMMIT_MSG unless we need to append conflicts
Edward Thomson 967f5a76 2014-05-23T14:50:51 git_checkout_index: checkout other indexes git_checkout_index can now check out other git_index's (that are not necessarily the repository index). This allows checkout_index to use the repository's index for stat cache information instead of the index data being checked out. git_merge and friends now check out their indexes directly instead of trying to blend it into the running index.
Edward Thomson eff531e1 2014-05-27T20:58:20 Modify GIT_MERGE_CONFIG -> GIT_MERGE_PREFERENCE
Edward Thomson de3f851e 2014-05-21T09:44:05 Staticify `merge_config`
Edward Thomson 22ab8881 2014-05-20T22:07:15 Use a config snapshot
Edward Thomson a3622ba6 2014-05-16T13:54:40 Move GIT_MERGE_CONFIG_* to its own enum
Edward Thomson d362093f 2014-05-08T15:41:36 Introduce GIT_MERGE_CONFIG_* for merge.ff settings git_merge_analysis will now return GIT_MERGE_CONFIG_NO_FASTFORWARD when merge.ff=false and GIT_MERGE_CONFIG_FASTFORWARD_ONLY when merge.ff=true
Russell Belfer 702efc89 2014-04-30T10:57:42 Make init_options fns use unsigned ints and macro Use an unsigned int for the version and add a helper macro so the code is simplified (and so the error message is a common string).
Edward Thomson a4e2c36a 2014-04-23T19:40:21 merge: checkout default shouldn't clobber given
Edward Thomson 26564d80 2014-04-23T19:26:58 merge: default checkout strategy for should be SAFE
Russell Belfer 8a2834d3 2014-03-14T13:20:51 Index locking and entry allocation changes This makes the lock management on the index a little bit broader, having a number of routines hold the lock across looking up the item to be modified and actually making the modification. Still not true thread safety, but more pure index modifications are now safe which allows the simple cases (such as starting up a diff while index modifications are underway) safe enough to get the snapshot without hitting allocation problems. As part of this, I simplified the allocation of index entries to use a flex array and just put the path at the end of the index entry. This makes every entry self-contained and makes it a little easier to feel sure that pointers to strings aren't being accidentally copied and freed while other references are still being held.
Russell Belfer 3b4c401a 2014-02-10T13:20:08 Decouple index iterator sort from index This makes the index iterator honor the GIT_ITERATOR_IGNORE_CASE and GIT_ITERATOR_DONT_IGNORE_CASE flags without modifying the index data itself. To take advantage of this, I had to export a number of the internal index entry comparison functions. I also wrote some new tests to exercise the capability.
Russell Belfer c67fd4c9 2014-02-07T11:20:36 Some vector utility tweaks This is just laying some groundwork for internal index changes that I'm working on.
Jacques Germishuys 6fefb7af 2014-04-13T19:53:35 Capture conflict information in MERGE_MSG for revert and merge
Jacques Germishuys 399f2b62 2014-04-07T20:15:45 Introduce git_merge__extract_conflict_paths
Jacques Germishuys 3b4ba278 2014-04-03T15:50:21 Const correctness!
Edward Thomson 976634c4 2014-03-30T19:56:18 Introduce git_merge_head_id
Edward Thomson 9cb99e8b 2014-03-26T12:43:41 Free temporary merge index
Vicent Marti 85a41fc4 2014-03-24T18:09:13 Merge pull request #2183 from ethomson/merge_refactor Refactor the `git_merge` API
Carlos Martín Nieto 704b55cc 2014-03-20T20:24:11 revwalk: don't try to find merge bases when there can be none As a way to speed up the cases where we need to hide some commits, we find out what the merge bases are so we know to stop marking commits as uninteresting and avoid walking down a potentially very large amount of commits which we will never see. There are however two oversights in current code. The merge-base finding algorithm fails to recognize that if it is only given one commit, there can be no merge base. It instead walks down the whole ancestor chain needlessly. Make it return an empty list immediately in this situation. The revwalk does not know whether the user has asked to hide any commits at all. In situation where the user pushes multiple commits but doesn't hide any, the above fix wouldn't do the trick. Keep track of whether the user wants to hide any commits and only run the merge-base finding algorithm when it's needed.
Edward Thomson 58c2b1c4 2014-03-20T09:35:22 UNBORN implies FAST_FORWARD
Edward Thomson ac584fcf 2014-03-18T16:04:51 Introduce GIT_MERGE_ANALYSIS_UNBORN
Edward Thomson 97f3462a 2014-03-18T13:14:09 git_merge_status -> git_merge_analysis
Edward Thomson d9fdee6e 2014-03-12T09:43:53 Remove `git_merge_result` as it's now unnecessary
Edward Thomson 5aa2ac6d 2014-03-11T22:47:39 Update git_merge_tree_opts to git_merge_options
Edward Thomson 02105a27 2014-03-11T18:40:38 Change signature of `git_merge` to take merge and checkout opts
Edward Thomson 1c0b6a38 2014-03-11T17:58:10 Remove fastforward / uptodate from `git_merge`
Edward Thomson ccb30827 2014-03-11T17:19:35 Add `git_merge_status` to provide info about an upcoming merge
Edward Thomson 05d47768 2014-03-10T22:30:41 Introduce git_merge_file for consumers
Aimeast 0aee025b 2014-03-18T22:31:14 Implement git_merge_base_octopus
Matthew Bowen b9f81997 2014-03-05T21:49:23 Added function-based initializers for every options struct. The basic structure of each function is courtesy of arrbee.
Russell Belfer 72556cc6 2014-02-20T14:27:10 Address PR comments * Make GIT_INLINE an internal definition so it cannot be used in public headers * Fix language in CONTRIBUTING * Make index caps API use signed instead of unsigned values
Vicent Marti c4ee3b54 2014-02-07T18:32:06 Merge pull request #2100 from libgit2/rb/update-pqueue Replace priority queue code with implementation from hashsig
Russell Belfer 4075e060 2014-02-03T21:02:08 Replace pqueue with code from hashsig heap I accidentally wrote a separate priority queue implementation when I was working on file rename detection as part of the file hash signature calculation code. To simplify licensing terms, I just adapted that to a general purpose priority queue and replace the old priority queue implementation that was borrowed from elsewhere. This also removes parts of the COPYING document that no longer apply to libgit2.
Edward Thomson dbfd83bc 2014-02-03T19:56:13 Remove unused pointer assignment
Edward Thomson c0b10c25 2014-02-01T12:05:00 Merge wd validation tests against index not HEAD Validating the workdir should not compare HEAD to working directory - this is both inefficient (as it ignores the cache) and incorrect. If we had legitimately allowed changes in the index (identical to the merge result) then comparing HEAD to workdir would reject these changes as different. Further, this will identify files that were filtered strangely as modified, while testing with the cache would prevent this. Also, it's stupid slow.
Edward Thomson 0972c592 2014-01-29T13:14:00 Two-phase index merging When three-way merging indexes, we previously changed each path as we read them, which would lead to us adding an index entry for 'foo', then removing an index entry for 'foo/file'. With the new index requirements, this is not allowed. Removing entries in the merged index, then adding them, resolves this. In the previous example, we now remove 'foo/file' before adding 'foo'.
Carlos Martín Nieto a1bbc0ce 2014-01-25T04:14:37 merge: rename _oid() -> id() Following the rest of the series, use 'id' when refering to the value.
Carlos Martín Nieto 9950bb4e 2014-01-24T20:23:17 diff: rename the file's 'oid' to 'id' In the same vein as the previous commits in this series.
Carlos Martín Nieto d541170c 2014-01-24T11:36:41 index: rename an entry's id to 'id' This was not converted when we converted the rest, so do it now.
Edward Thomson 0ef19fe1 2014-01-20T17:13:55 Merge submodules
Edward Thomson 0e1ba46c 2014-01-19T20:03:13 Remove the "merge none" flag The "merge none" (don't automerge) flag was only to aide in merge trivial tests. We can easily determine whether merge trivial resulted in a trivial merge or an automerge by examining the REUC after automerge has completed.
Edward Thomson e651e8e2 2014-01-19T15:05:08 Introduce diff3 mode for checking out conflicts
Edward Thomson 6b92c99b 2014-01-19T01:20:25 Don't try to merge binary files
Edward Thomson c1d648c5 2014-01-08T18:29:42 merge_file should use more aggressive levels The default merge_file level was XDL_MERGE_MINIMAL, which will produce conflicts where there should not be in the case where both sides were changed identically. Change the defaults to be more aggressive (XDL_MERGE_ZEALOUS) which will more aggressively compress non-conflicts. This matches git.git's defaults. Increase testing around reverting a previously reverted commit to illustrate this problem.
Vicent Marti 79194bcd 2013-12-13T06:20:19 Merge pull request #1986 from libgit2/rb/error-handling-cleanups Clean up some error handling and change callback error behavior
Edward Thomson 86a05ef3 2013-12-12T17:40:40 Validate struct versions in merge, revert
Russell Belfer 9cfce273 2013-12-12T12:11:38 Cleanups, renames, and leak fixes This renames git_vector_free_all to the better git_vector_free_deep and also contains a couple of memory leak fixes based on valgrind checks. The fixes are specifically: failure to free global dir path variables when not compiled with threading on and failure to free filters from the filter registry that had not be initialized fully.
Russell Belfer 26c1cb91 2013-12-09T09:44:03 One more rename/cleanup for callback err functions
Russell Belfer c7b3e1b3 2013-12-06T15:42:20 Some callback error check style cleanups I find this easier to read...
Russell Belfer 25e0b157 2013-12-06T15:07:57 Remove converting user error to GIT_EUSER This changes the behavior of callbacks so that the callback error code is not converted into GIT_EUSER and instead we propagate the return value through to the caller. Instead of using the giterr_capture and giterr_restore functions, we now rely on all functions to pass back the return value from a callback. To avoid having a return value with no error message, the user can call the public giterr_set_str or some such function to set an error message. There is a new helper 'giterr_set_callback' that functions can invoke after making a callback which ensures that some error message was set in case the callback did not set one. In places where the sign of the callback return value is meaningful (e.g. positive to skip, negative to abort), only the negative values are returned back to the caller, obviously, since the other values allow for continuing the loop. The hardest parts of this were in the checkout code where positive return values were overloaded as meaningful values for checkout. I fixed this by adding an output parameter to many of the internal checkout functions and removing the overload. This added some code, but it is probably a better implementation. There is some funkiness in the network code where user provided callbacks could be returning a positive or a negative value and we want to rely on that to cancel the loop. There are still a couple places where an user error might get turned into GIT_EUSER there, I think, though none exercised by the tests.
Russell Belfer fcd324c6 2013-12-06T15:04:31 Add git_vector_free_all There are a lot of places that we call git__free on each item in a vector and then call git_vector_free on the vector itself. This just wraps that up into one convenient helper function.
Russell Belfer dab89f9b 2013-12-04T21:22:57 Further EUSER and error propagation fixes This continues auditing all the places where GIT_EUSER is being returned and making sure to clear any existing error using the new giterr_user_cancel helper. As a result, places that relied on intercepting GIT_EUSER but having the old error preserved also needed to be cleaned up to correctly stash and then retrieve the actual error. Additionally, as I encountered places where error codes were not being propagated correctly, I tried to fix them up. A number of those fixes are included in the this commit as well.
Russell Belfer 9f77b3f6 2013-11-25T14:21:34 Add config read fns with controlled error behavior This adds `git_config__lookup_entry` which will look up a key in a config and return either the entry or NULL if the key was not present. Optionally, it can either suppress all errors or can return them (although not finding the key is not an error for this function). Unlike other accessors, this does not normalize the config key string, so it must only be used when the key is known to be in normalized form (i.e. all lower-case before the first dot and after the last dot, with no invalid characters). This also adds three high-level helper functions to look up config values with no errors and a fallback value. The three functions are for string, bool, and int values, and will resort to the fallback value for any error that arises. They are: * `git_config__get_string_force` * `git_config__get_bool_force` * `git_config__get_int_force` None of them normalize the config `key` either, so they can only be used for internal cases where the key is known to be in normal format.
Edward Thomson 5588f073 2013-12-09T10:25:36 Clean up warnings
Edward Thomson eac938d9 2013-12-02T14:10:04 Bare naked merge and rebase
Edward Thomson bab0b9f2 2013-11-22T18:02:12 clean up state metadata more consistently
Edward Thomson 300d192f 2013-12-02T11:15:27 Introduce git_revert to revert a single commit
Russell Belfer 98eaf39a 2013-11-13T11:12:31 Fix warnings
nulltoken 8d22773f 2013-11-05T16:44:10 Plug git_merge() related leaks
Edward Thomson 039db728 2013-07-03T01:00:45 merge branch into current, updating workdir
Edward Thomson 1d3a8aeb 2013-11-04T18:28:57 move mode_t to filebuf_open instead of _commit
Carlos Martín Nieto 1d37da33 2013-10-30T16:25:49 merge: any non-zero return from the user is an error This fixes #1703.
Carlos Martín Nieto 07fb67f9 2013-09-22T05:55:39 merge: reverse array and length parameter order Make it pair up with the one for commits. This fixes #1691.
Rémi Duraffort c6451624 2013-07-15T16:00:07 Fix some more memory leaks in error path
Russell Belfer 114f5a6c 2013-06-10T10:10:39 Reorganize diff and add basic diff driver 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.
Russell Belfer cee695ae 2013-05-31T12:18:43 Make iterators use GIT_ITEROVER & smart advance 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.
Edward Thomson 9c06b250 2013-05-16T13:04:37 merge setup
nulltoken 1fed6b07 2013-05-13T21:57:37 Fix trailing whitespaces
Vicent Martí 03c28d92 2013-05-06T06:45:53 Merge pull request #1526 from arrbee/cleanup-error-return-without-msg Make sure error messages are set for most error returns
Edward Thomson 4e7c1560 2013-05-02T14:58:40 puns are not funny; type punning especially so
Russell Belfer de19c4a9 2013-05-01T14:00:20 Set error when no merge base is found