diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2015-11-20 19:01:42 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-11-25 16:25:47 -0500 |
commit | 5b9c63c3f673cbc209e53627be2a0e87c17ccb3c (patch) | |
tree | 0d65c9c37a7714ddb6d6896f14c7c925b77e1bb1 /src/merge.c | |
parent | 78859c63442bb367a4d426ec8ee31c82a28a93d7 (diff) | |
download | libgit2-5b9c63c3f673cbc209e53627be2a0e87c17ccb3c.tar.gz |
recursive merge: add a recursion limit
Diffstat (limited to 'src/merge.c')
-rw-r--r-- | src/merge.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/merge.c b/src/merge.c index f05e45c9f..9eb3b0904 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2019,17 +2019,21 @@ static int compute_base( git_repository *repo, const git_annotated_commit *one, const git_annotated_commit *two, - const git_merge_options *opts, + const git_merge_options *given_opts, size_t recursion_level) { git_array_oid_t head_ids = GIT_ARRAY_INIT; git_oidarray bases = {0}; git_annotated_commit *base = NULL, *other = NULL, *new_base = NULL; + git_merge_options opts = GIT_MERGE_OPTIONS_INIT; size_t i; int error; *out = NULL; + if (given_opts) + memcpy(&opts, given_opts, sizeof(git_merge_options)); + if ((error = insert_head_ids(&head_ids, one)) < 0 || (error = insert_head_ids(&head_ids, two)) < 0) goto done; @@ -2037,15 +2041,18 @@ static int compute_base( if ((error = git_merge_bases_many(&bases, repo, head_ids.size, head_ids.ptr)) < 0 || (error = git_annotated_commit_lookup(&base, repo, &bases.ids[0])) < 0 || - (opts && (opts->flags & GIT_MERGE_NO_RECURSIVE))) + (opts.flags & GIT_MERGE_NO_RECURSIVE)) goto done; for (i = 1; i < bases.count; i++) { recursion_level++; + if (opts.recursion_limit && recursion_level > opts.recursion_limit) + break; + if ((error = git_annotated_commit_lookup(&other, repo, &bases.ids[i])) < 0 || - (error = create_virtual_base(&new_base, repo, base, other, opts, + (error = create_virtual_base(&new_base, repo, base, other, &opts, recursion_level)) < 0) goto done; |