diff options
author | Stan Hu <stanhu@gmail.com> | 2015-10-31 18:50:13 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2016-03-17 11:02:26 -0400 |
commit | f8787098fbc8944afd684ed0e26221e36da2d6f8 (patch) | |
tree | 8c69bb8b22c361a3a3525a6bb0e122f3fe461151 | |
parent | ba3493228cd16136620757b03a4df01f8caf5057 (diff) | |
download | libgit2-f8787098fbc8944afd684ed0e26221e36da2d6f8.tar.gz |
Support union merges via .gitattributes file
-rw-r--r-- | src/merge.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/merge.c b/src/merge.c index d2f92ccce..767564bf0 100644 --- a/src/merge.c +++ b/src/merge.c @@ -1819,6 +1819,28 @@ static git_iterator *iterator_given_or_empty(git_iterator **empty, git_iterator return *empty; } +static int lookup_file_favor( + git_merge_file_favor_t *file_favor, + git_repository *repo, + const char *path) +{ + int error = 0; + const char *value = NULL; + + if (path) { + if ((error = git_attr_get(&value, repo, 0, path, "merge")) < 0) + goto done; + + if (*file_favor == GIT_MERGE_FILE_FAVOR_NORMAL && + value && strcmp(value, "union") == 0) { + *file_favor |= GIT_MERGE_FILE_FAVOR_UNION; + } + } + +done: + return error; +} + int git_merge__iterators( git_index **out, git_repository *repo, @@ -1877,6 +1899,10 @@ int git_merge__iterators( git_vector_foreach(&changes, i, conflict) { int resolved = 0; + /* Check for merge options in .gitattributes */ + if ((error = lookup_file_favor(&opts.file_favor, repo, conflict->our_entry.path) < 0)) + goto done; + if ((error = merge_conflict_resolve( &resolved, diff_list, conflict, &file_opts)) < 0) goto done; |