-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Recursive Merge #3513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recursive Merge #3513
Changes from all commits
fa78782
86c8d02
75dee59
cdb6c1c
a200bcf
99d9d9a
fccad82
1b82f7b
b1eef91
3f2bb38
7730fe8
76ade3a
dcde572
651bfd6
34a5142
78859c6
5b9c63c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,29 +62,37 @@ GIT_EXTERN(int) git_merge_file_init_input( | |
unsigned int version); | ||
|
||
/** | ||
* Flags for `git_merge_tree` options. A combination of these flags can be | ||
* passed in via the `tree_flags` value in the `git_merge_options`. | ||
* Flags for `git_merge` options. A combination of these flags can be | ||
* passed in via the `flags` value in the `git_merge_options`. | ||
*/ | ||
typedef enum { | ||
/** | ||
* Detect renames that occur between the common ancestor and the "ours" | ||
* side or the common ancestor and the "theirs" side. This will enable | ||
* the ability to merge between a modified and renamed file. | ||
*/ | ||
GIT_MERGE_TREE_FIND_RENAMES = (1 << 0), | ||
GIT_MERGE_FIND_RENAMES = (1 << 0), | ||
|
||
/** | ||
* If a conflict occurs, exit immediately instead of attempting to | ||
* continue resolving conflicts. The merge operation will fail with | ||
* GIT_EMERGECONFLICT and no index will be returned. | ||
*/ | ||
GIT_MERGE_TREE_FAIL_ON_CONFLICT = (1 << 1), | ||
GIT_MERGE_FAIL_ON_CONFLICT = (1 << 1), | ||
|
||
/** | ||
* Do not write the REUC extension on the generated index | ||
*/ | ||
GIT_MERGE_TREE_SKIP_REUC = (1 << 2), | ||
} git_merge_tree_flag_t; | ||
GIT_MERGE_SKIP_REUC = (1 << 2), | ||
|
||
/** | ||
* If the commits being merged have multiple merge bases, do not build | ||
* a recursive merge base (by merging the multiple merge bases), | ||
* instead simply use the first base. This flag provides a similar | ||
* merge base to `git-merge-resolve`. | ||
*/ | ||
GIT_MERGE_NO_RECURSIVE = (1 << 3), | ||
} git_merge_flag_t; | ||
|
||
/** | ||
* Merge file favor options for `git_merge_options` instruct the file-level | ||
|
@@ -152,7 +160,7 @@ typedef enum { | |
|
||
/** Take extra time to find minimal diff */ | ||
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), | ||
} git_merge_file_flags_t; | ||
} git_merge_file_flag_t; | ||
|
||
/** | ||
* Options for merging a file | ||
|
@@ -181,8 +189,8 @@ typedef struct { | |
/** The file to favor in region conflicts. */ | ||
git_merge_file_favor_t favor; | ||
|
||
/** see `git_merge_file_flags_t` above */ | ||
unsigned int flags; | ||
/** see `git_merge_file_flag_t` above */ | ||
git_merge_file_flag_t flags; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiple options from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and this doesn't preclude that. This is to match the style in the rest of the library where enum types are named in the singular, even when they will be combined. For example: |
||
} git_merge_file_options; | ||
|
||
#define GIT_MERGE_FILE_OPTIONS_VERSION 1 | ||
|
@@ -232,11 +240,13 @@ typedef struct { | |
*/ | ||
typedef struct { | ||
unsigned int version; | ||
git_merge_tree_flag_t tree_flags; | ||
|
||
/** See `git_merge_flag_t` above */ | ||
git_merge_flag_t flags; | ||
|
||
/** | ||
* Similarity to consider a file renamed (default 50). If | ||
* `GIT_MERGE_TREE_FIND_RENAMES` is enabled, added files will be compared | ||
* `GIT_MERGE_FIND_RENAMES` is enabled, added files will be compared | ||
* with deleted files to determine their similarity. Files that are | ||
* more similar than the rename threshold (percentage-wise) will be | ||
* treated as a rename. | ||
|
@@ -255,11 +265,19 @@ typedef struct { | |
/** Pluggable similarity metric; pass NULL to use internal metric */ | ||
git_diff_similarity_metric *metric; | ||
|
||
/** | ||
* Maximum number of times to merge common ancestors to build a | ||
* virtual merge base when faced with criss-cross merges. When this | ||
* limit is reached, the next ancestor will simply be used instead of | ||
* attempting to merge it. The default is unlimited. | ||
*/ | ||
unsigned int recursion_limit; | ||
|
||
/** Flags for handling conflicting content. */ | ||
git_merge_file_favor_t file_favor; | ||
|
||
/** see `git_merge_file_flags_t` above */ | ||
unsigned int file_flags; | ||
/** see `git_merge_file_flag_t` above */ | ||
git_merge_file_flag_t file_flags; | ||
} git_merge_options; | ||
|
||
#define GIT_MERGE_OPTIONS_VERSION 1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,41 @@ | |
#ifndef INCLUDE_annotated_commit_h__ | ||
#define INCLUDE_annotated_commit_h__ | ||
|
||
#include "oidarray.h" | ||
|
||
#include "git2/oid.h" | ||
|
||
/** Internal structure for merge inputs */ | ||
typedef enum { | ||
GIT_ANNOTATED_COMMIT_REAL = 1, | ||
GIT_ANNOTATED_COMMIT_VIRTUAL = 2, | ||
} git_annotated_commit_t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering whether we should have 0 be an invalid value and have 1 and 2 as real and virtual resp. So we can detect in cleanup functions that we failed to set a value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. Updated. |
||
|
||
/** | ||
* Internal structure for merge inputs. An annotated commit is generally | ||
* "real" and backed by an actual commit in the repository, but merge will | ||
* internally create "virtual" commits that are in-memory intermediate | ||
* commits backed by an index. | ||
*/ | ||
struct git_annotated_commit { | ||
git_annotated_commit_t type; | ||
|
||
/* real commit */ | ||
git_commit *commit; | ||
git_tree *tree; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is there a new tree pointer for real annotated commits? Do we need to keep it around so the iterator can borrow the value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's correct. |
||
|
||
/* virtual commit structure */ | ||
git_index *index; | ||
git_array_oid_t parents; | ||
|
||
char *ref_name; | ||
char *remote_url; | ||
|
||
char id_str[GIT_OID_HEXSZ+1]; | ||
}; | ||
|
||
extern int git_annotated_commit_from_head(git_annotated_commit **out, | ||
git_repository *repo); | ||
extern int git_annotated_commit_from_commit(git_annotated_commit **out, | ||
git_commit *commit); | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name change should also be reflected in the CHANGELOG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.