From 553184a76245617556373af4cb5343e7fe58f41f Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Thu, 3 Apr 2014 10:53:42 +0200 Subject: [PATCH 1/5] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index f3a03ee74..6854ed016 100644 --- a/AUTHORS +++ b/AUTHORS @@ -25,6 +25,7 @@ Florian Forster Holger Weiss Ingmar Vanhassel J. David Ibáñez +Jacques Germishuys Jakob Pfender Jason Penny Jason R. McNeil From 399f2b6294963b8a7a154ffd0103484d018c4e27 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Mon, 7 Apr 2014 20:15:45 +0200 Subject: [PATCH 2/5] Introduce git_merge__extract_conflict_paths --- src/merge.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/merge.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/src/merge.c b/src/merge.c index dd6a39f37..371fad776 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2469,6 +2469,47 @@ done: return error; } +int git_merge__append_conflicts_to_merge_msg( + git_repository *repo, + git_index *index) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + const char *last = NULL; + size_t i; + int error; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_APPEND, GIT_MERGE_FILE_MODE)) < 0) + goto cleanup; + + if (git_index_has_conflicts(index)) + git_filebuf_printf(&file, "\nConflicts:\n"); + + for (i = 0; i < git_index_entrycount(index); i++) { + const git_index_entry *e = git_index_get_byindex(index, i); + + if (git_index_entry_stage(e) == 0) + continue; + + if (last == NULL || strcmp(e->path, last) != 0) + git_filebuf_printf(&file, "\t%s\n", e->path); + + last = e->path; + } + + error = git_filebuf_commit(&file); + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + + static int merge_state_cleanup(git_repository *repo) { const char *state_files[] = { diff --git a/src/merge.h b/src/merge.h index 2362da04d..00f6197bf 100644 --- a/src/merge.h +++ b/src/merge.h @@ -151,4 +151,6 @@ int git_merge__setup( int git_merge__indexes(git_repository *repo, git_index *index_new); +int git_merge__append_conflicts_to_merge_msg(git_repository *repo, git_index *index); + #endif From 4d7b993904008001ad995d6b27af0e8c71277c55 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Tue, 1 Apr 2014 22:18:19 +0200 Subject: [PATCH 3/5] Added cherry-pick support --- include/git2.h | 1 + include/git2/cherrypick.h | 88 +++++++++++++++ include/git2/errors.h | 1 + src/cherrypick.c | 230 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 320 insertions(+) create mode 100644 include/git2/cherrypick.h create mode 100644 src/cherrypick.c diff --git a/include/git2.h b/include/git2.h index 704fb585a..f74976061 100644 --- a/include/git2.h +++ b/include/git2.h @@ -14,6 +14,7 @@ #include "git2/branch.h" #include "git2/buffer.h" #include "git2/checkout.h" +#include "git2/cherrypick.h" #include "git2/clone.h" #include "git2/commit.h" #include "git2/common.h" diff --git a/include/git2/cherrypick.h b/include/git2/cherrypick.h new file mode 100644 index 000000000..7c48e6659 --- /dev/null +++ b/include/git2/cherrypick.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_cherrypick_h__ +#define INCLUDE_git_cherrypick_h__ + +#include "common.h" +#include "types.h" +#include "merge.h" + +/** + * @file git2/cherrypick.h + * @brief Git cherry-pick routines + * @defgroup git_cherrypick Git cherry-pick routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +typedef struct { + unsigned int version; + + /** For merge commits, the "mainline" is treated as the parent. */ + unsigned int mainline; + + git_merge_options merge_opts; + git_checkout_options checkout_opts; +} git_cherry_pick_options; + +#define GIT_CHERRY_PICK_OPTIONS_VERSION 1 +#define GIT_CHERRY_PICK_OPTIONS_INIT {GIT_CHERRY_PICK_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT} + +/** + * Initializes a `git_cherry_pick_options` with default values. Equivalent to + * creating an instance with GIT_CHERRY_PICK_OPTIONS_INIT. + * + * @param opts the `git_cherry_pick_options` instance to initialize. + * @param version the version of the struct; you should pass + * `GIT_CHERRY_PICK_OPTIONS_VERSION` here. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_cherry_pick_init_opts( + git_cherry_pick_options* opts, + int version); + +/** + * Cherry-picks the given commit against the given "our" commit, producing an + * index that reflects the result of the cherry-pick. + * + * The returned index must be freed explicitly with `git_index_free`. + * + * @param out pointer to store the index result in + * @param repo the repository that contains the given commits + * @param cherry_pick_commit the commit to cherry-pick + * @param our_commit the commit to revert against (eg, HEAD) + * @param mainline the parent of the revert commit, if it is a merge + * @param merge_tree_opts the merge tree options (or null for defaults) + * @return zero on success, -1 on failure. + */ +GIT_EXTERN(int) git_cherry_pick_commit( + git_index **out, + git_repository *repo, + git_commit *cherry_pick_commit, + git_commit *our_commit, + unsigned int mainline, + const git_merge_options *merge_options); + +/** + * Cherry-pick the given commit, producing changes in the index and working directory. + * + * @param repo the repository to cherry-pick + * @param commit the commit to cherry-pick + * @param cherry_pick_options the cherry-pick options (or null for defaults) + * @return zero on success, -1 on failure. + */ +GIT_EXTERN(int) git_cherry_pick( + git_repository *repo, + git_commit *commit, + const git_cherry_pick_options *cherry_pick_options); + +/** @} */ +GIT_END_DECL + +#endif + diff --git a/include/git2/errors.h b/include/git2/errors.h index bcf2f80ab..e22f0d86d 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -86,6 +86,7 @@ typedef enum { GITERR_FILTER, GITERR_REVERT, GITERR_CALLBACK, + GITERR_CHERRYPICK, } git_error_t; /** diff --git a/src/cherrypick.c b/src/cherrypick.c new file mode 100644 index 000000000..67a2c6af3 --- /dev/null +++ b/src/cherrypick.c @@ -0,0 +1,230 @@ +/* +* Copyright (C) the libgit2 contributors. All rights reserved. +* +* This file is part of libgit2, distributed under the GNU GPL v2 with +* a Linking Exception. For full terms see the included COPYING file. +*/ + +#include "common.h" +#include "repository.h" +#include "filebuf.h" +#include "merge.h" +#include "vector.h" + +#include "git2/types.h" +#include "git2/merge.h" +#include "git2/cherrypick.h" +#include "git2/commit.h" +#include "git2/sys/commit.h" + +#define GIT_CHERRY_PICK_FILE_MODE 0666 + +static int write_cherry_pick_head( + git_repository *repo, + const char *commit_oidstr) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + int error = 0; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_CHERRY_PICK_HEAD_FILE)) >= 0 && + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRY_PICK_FILE_MODE)) >= 0 && + (error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0) + error = git_filebuf_commit(&file); + + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int write_merge_msg( + git_repository *repo, + const char *commit_msg) +{ + git_filebuf file = GIT_FILEBUF_INIT; + git_buf file_path = GIT_BUF_INIT; + int error = 0; + + if ((error = git_buf_joinpath(&file_path, repo->path_repository, GIT_MERGE_MSG_FILE)) < 0 || + (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRY_PICK_FILE_MODE)) < 0 || + (error = git_filebuf_printf(&file, "%s", commit_msg)) < 0) + goto cleanup; + + error = git_filebuf_commit(&file); + +cleanup: + if (error < 0) + git_filebuf_cleanup(&file); + + git_buf_free(&file_path); + + return error; +} + +static int cherry_pick_normalize_opts( + git_repository *repo, + git_cherry_pick_options *opts, + const git_cherry_pick_options *given, + const char *their_label) +{ + int error = 0; + unsigned int default_checkout_strategy = GIT_CHECKOUT_SAFE_CREATE | + GIT_CHECKOUT_ALLOW_CONFLICTS; + + GIT_UNUSED(repo); + + if (given != NULL) + memcpy(opts, given, sizeof(git_cherry_pick_options)); + else { + git_cherry_pick_options default_opts = GIT_CHERRY_PICK_OPTIONS_INIT; + memcpy(opts, &default_opts, sizeof(git_cherry_pick_options)); + } + + if (!opts->checkout_opts.checkout_strategy) + opts->checkout_opts.checkout_strategy = default_checkout_strategy; + + if (!opts->checkout_opts.our_label) + opts->checkout_opts.our_label = "HEAD"; + + if (!opts->checkout_opts.their_label) + opts->checkout_opts.their_label = their_label; + + return error; +} + +static int cherry_pick_state_cleanup(git_repository *repo) +{ + const char *state_files[] = { GIT_CHERRY_PICK_HEAD_FILE, GIT_MERGE_MSG_FILE }; + + return git_repository__cleanup_files(repo, state_files, ARRAY_SIZE(state_files)); +} + +static int cherry_pick_seterr(git_commit *commit, const char *fmt) +{ + char commit_oidstr[GIT_OID_HEXSZ + 1]; + + giterr_set(GITERR_CHERRYPICK, fmt, + git_oid_tostr(commit_oidstr, GIT_OID_HEXSZ + 1, git_commit_id(commit))); + + return -1; +} + +int git_cherry_pick_commit( + git_index **out, + git_repository *repo, + git_commit *cherry_pick_commit, + git_commit *our_commit, + unsigned int mainline, + const git_merge_options *merge_opts) +{ + git_commit *parent_commit = NULL; + git_tree *parent_tree = NULL, *our_tree = NULL, *cherry_pick_tree = NULL; + int parent = 0, error = 0; + + assert(out && repo && cherry_pick_commit && our_commit); + + if (git_commit_parentcount(cherry_pick_commit) > 1) { + if (!mainline) + return cherry_pick_seterr(cherry_pick_commit, + "Mainline branch is not specified but %s is a merge commit"); + + parent = mainline; + } else { + if (mainline) + return cherry_pick_seterr(cherry_pick_commit, + "Mainline branch specified but %s is not a merge commit"); + + parent = git_commit_parentcount(cherry_pick_commit); + } + + if (parent && + ((error = git_commit_parent(&parent_commit, cherry_pick_commit, (parent - 1))) < 0 || + (error = git_commit_tree(&parent_tree, parent_commit)) < 0)) + goto done; + + if ((error = git_commit_tree(&cherry_pick_tree, cherry_pick_commit)) < 0 || + (error = git_commit_tree(&our_tree, our_commit)) < 0) + goto done; + + error = git_merge_trees(out, repo, parent_tree, our_tree, cherry_pick_tree, merge_opts); + +done: + git_tree_free(parent_tree); + git_tree_free(our_tree); + git_tree_free(cherry_pick_tree); + git_commit_free(parent_commit); + + return error; +} + +int git_cherry_pick( + git_repository *repo, + git_commit *commit, + const git_cherry_pick_options *given_opts) +{ + git_cherry_pick_options opts; + git_reference *our_ref = NULL; + git_commit *our_commit = NULL; + char commit_oidstr[GIT_OID_HEXSZ + 1]; + const char *commit_msg, *commit_summary; + git_buf their_label = GIT_BUF_INIT; + git_index *index_new = NULL, *index_repo = NULL; + int error = 0; + + assert(repo && commit); + + GITERR_CHECK_VERSION(given_opts, GIT_CHERRY_PICK_OPTIONS_VERSION, "git_cherry_pick_options"); + + if ((error = git_repository__ensure_not_bare(repo, "cherry-pick")) < 0) + return error; + + if ((commit_msg = git_commit_message(commit)) == NULL || + (commit_summary = git_commit_summary(commit)) == NULL) { + error = -1; + goto on_error; + } + + git_oid_fmt(commit_oidstr, git_commit_id(commit)); + + if ((error = write_merge_msg(repo, commit_msg)) < 0 || + (error = git_buf_printf(&their_label, "%.7s... %s", commit_oidstr, commit_summary)) < 0 || + (error = cherry_pick_normalize_opts(repo, &opts, given_opts, git_buf_cstr(&their_label))) < 0 || + (error = write_cherry_pick_head(repo, commit_oidstr)) < 0 || + (error = git_repository_head(&our_ref, repo)) < 0 || + (error = git_reference_peel((git_object **)&our_commit, our_ref, GIT_OBJ_COMMIT)) < 0 || + (error = git_cherry_pick_commit(&index_new, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 || + (error = git_merge__indexes(repo, index_new)) < 0 || + (error = git_repository_index(&index_repo, repo)) < 0 || + (error = git_merge__append_conflicts_to_merge_msg(repo, index_repo)) < 0 || + (error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0) + goto on_error; + + goto done; + +on_error: + cherry_pick_state_cleanup(repo); + +done: + git_index_free(index_new); + git_index_free(index_repo); + git_commit_free(our_commit); + git_reference_free(our_ref); + git_buf_free(&their_label); + + return error; +} + +int git_cherry_pick_init_opts(git_cherry_pick_options* opts, int version) +{ + if (version != GIT_CHERRY_PICK_OPTIONS_VERSION) { + giterr_set(GITERR_INVALID, "Invalid version %d for git_cherry_pick_options", version); + return -1; + } else { + git_cherry_pick_options o = GIT_CHERRY_PICK_OPTIONS_INIT; + memcpy(opts, &o, sizeof(o)); + return 0; + } +} From 103b7d21226e43192cf138ecf0b98b51796ae0ed Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Wed, 2 Apr 2014 13:57:11 +0200 Subject: [PATCH 4/5] Added cherry pick tests --- tests/cherrypick/bare.c | 106 +++++ tests/cherrypick/workdir.c | 429 ++++++++++++++++++ tests/resources/cherrypick/.gitted/HEAD | Bin 0 -> 33 bytes tests/resources/cherrypick/.gitted/config | Bin 0 -> 137 bytes tests/resources/cherrypick/.gitted/index | Bin 0 -> 248 bytes .../resources/cherrypick/.gitted/info/exclude | Bin 0 -> 240 bytes .../01/a2b453c2647c71ccfefc285f2266d1f00b8253 | Bin 0 -> 30 bytes .../02/67838e09bbc5969bba035be2d27c8a6de694d8 | Bin 0 -> 38 bytes .../06/3fc9f01e6e9ec2a8d8f749885e931875e50d37 | Bin 0 -> 141 bytes .../08/9ac03f76058b5ba0b44bb268f317f9242481e9 | Bin 0 -> 170 bytes .../0d/447a6c2528b06616cde3b209a4b4ea3dcb8d65 | Bin 0 -> 107 bytes .../11/24c2c1ae07b26fded662d6c3f3631d9dc16f88 | Bin 0 -> 31 bytes .../12/905f4ea5b76f9d3fdcfe73e462201c06ae632a | Bin 0 -> 108 bytes .../19/c5c7207054604b69c84d08a7571ef9672bb5c2 | Bin 0 -> 28 bytes .../1c/2116845780455ecf916538c1cc27c4222452af | Bin 0 -> 116 bytes .../1c/c85eb4ff0a8438fde1b14274c6f87f891b36a0 | Bin 0 -> 117 bytes .../1e/1cb7391d25dcd8daba88f1f627f3045982286c | Bin 0 -> 32 bytes .../20/fc1a4c9d994021f43d33ab75e4252e27ca661d | Bin 0 -> 126 bytes .../28/d9eb4208074ad1cc84e71ccc908b34573f05d2 | Bin 0 -> 28 bytes .../2a/26c7e88b285613b302ba76712bc998863f3cbc | Bin 0 -> 186 bytes .../2a/c3b376093de405b0a951bff578655b1c2b7fa1 | Bin 0 -> 191 bytes .../2c/acbcaabf785f1ac231e8519849d4ad38692f2c | Bin 0 -> 26 bytes .../35/cb210149022c7379b0a67b0dec13cc628ff87d | Bin 0 -> 137 bytes .../38/c05a857e831a7e759d83778bfc85d003e21c45 | Bin 0 -> 27 bytes .../3f/9eed8946df9e2c737d3b8dc0b8e78959aacd92 | Bin 0 -> 188 bytes .../40/9a1bec58bf35348e8b62b72bb9c1f45cf5a587 | Bin 0 -> 33 bytes .../44/cd2ed2052c9c68f9a439d208e9614dc2a55c70 | Bin 0 -> 195 bytes .../48/7434cace79238a7091e2220611d4f20a765690 | Bin 0 -> 33 bytes .../49/20ad2f17162dcc8823ad491444dcb87f5899c9 | Bin 0 -> 36 bytes .../4b/825dc642cb6eb9a060e54bf8d69288fbee4904 | Bin 0 -> 15 bytes .../4c/532774cc1fea37f6efc2256763a64d38c8cdde | Bin 0 -> 26 bytes .../51/145af30d411a50195b66517d825e69bf57ed22 | Bin 0 -> 107 bytes .../54/61de53ffadbf15be4dd6345997c15689573209 | Bin 0 -> 187 bytes .../54/784f10955e92ab27e4fa832e40cb2baf1edbdc | Bin 0 -> 74 bytes .../56/3f6473a3858f99b80e5f93c660512ed38e1e6f | Bin 0 -> 31 bytes .../58/a957ef0061c1a8ef995c855dfab4f5da8d6617 | Bin 0 -> 32 bytes .../5d/c7e1f440ce74d5503a0dfbc6c30e091475f774 | Bin 0 -> 31 bytes .../5e/2206cda1c56430ad107a6866a829c159e0b9ea | Bin 0 -> 107 bytes .../5f/77a2a13935ac62a629553f8944ad57b1ed8b4a | Bin 0 -> 106 bytes .../63/c0d92b95253c4a40d3883f423a54be47d2c4c8 | Bin 0 -> 30 bytes .../6c/e83eb5f0fd34a10c3d25c6b36d2ed7ec0d6ce7 | Bin 0 -> 108 bytes .../6d/1c2afe5eeb9e497528e2780ac468a5465cbc96 | Bin 0 -> 169 bytes .../74/f06b5bfec6d33d7264f73606b57a7c0b963819 | Bin 0 -> 141 bytes .../82/8b08c52d2cba30952e0e008f60b25b5ba0d41a | Bin 0 -> 107 bytes .../85/36dd6f0ec3ddecb9f9b6c8c64c6d322cd01211 | Bin 0 -> 36 bytes .../85/a4a1d791973644f24c72f5e89420d3064cc452 | Bin 0 -> 27 bytes .../8b/5c30499a71001189b647f4d5b57fa8f04897ce | Bin 0 -> 107 bytes .../96/4ea3da044d9083181a88ba6701de9e35778bf4 | Bin 0 -> 181 bytes .../9c/c39fca3765a2facbe31157f7d60c2602193f36 | Bin 0 -> 107 bytes .../9c/cb9bf50c011fd58dcbaa65df917bf79539717f | Bin 0 -> 30 bytes .../a1/0b59f4280491afe6e430c30654a7acc67d4a33 | Bin 0 -> 30 bytes .../a2/1b4bfe7a04ab18024fb57f4ae9a52a1acef394 | Bin 0 -> 173 bytes .../a4/3a050c588d4e92f11a6b139680923e9728477d | Bin 0 -> 180 bytes .../a5/8ca3fee5eb68b11adc2703e5843f968c9dad1e | Bin 0 -> 28 bytes .../a6/61b5dec1004e2c62654ded3762370c27cf266b | Bin 0 -> 27 bytes .../a6/9ef8fcbb9a2c509a7dbf4f23d257eb551d5610 | Bin 0 -> 172 bytes .../a8/3c6f70297b805dedc549e6583582966f6ebcab | Bin 0 -> 138 bytes .../a9/020cd240774e4d672732bcb82d516d9685da76 | Bin 0 -> 26 bytes .../ab/4115f808bc585b60f822da7020af86d20f62c8 | Bin 0 -> 213 bytes .../ab/e4603bc7cd5b8167a267e0e2418fd2348f8cff | Bin 0 -> 214 bytes .../b8/26e9b36e22e949ec885e7a1f3db496bbab6cd0 | Bin 0 -> 108 bytes .../ba/fbf6912c09505ac60575cd43d3f2aba3bd84d8 | Bin 0 -> 175 bytes .../bb/14296ffa9dfbf935ec9ce2f9ed7808d952226b | Bin 0 -> 38 bytes .../bc/4dd0744364d1db380a9811bd264c101065231e | Bin 0 -> 55 bytes .../bd/65d4083845ed5ed4e1fe5feb85ac395d0760c8 | Bin 0 -> 127 bytes .../bd/6ffc8c6c41f0f85ff9e3d61c9479516bac0024 | Bin 0 -> 31 bytes .../bd/a51965cb36c0c5731c8cb50b80a36cac81018e | Bin 0 -> 107 bytes .../ce/d8fb81b6ec534d5deaf2a48b4b96c799712507 | Bin 0 -> 184 bytes .../cf/c4f0999a8367568e049af4f72e452d40828a15 | Bin 0 -> 180 bytes .../d0/f21e17beb5b9d953b1d8349049818a4f2edd1e | Bin 0 -> 185 bytes .../d3/d77487660ee3c0194ee01dc5eaf478782b1c7e | Bin 0 -> 184 bytes .../e2/33b9ed408a95e9d4b65fec7fc34943a556deb2 | Bin 0 -> 31 bytes .../e5/183bfd18e3a0a691fadde2f0d5610b73282d31 | Bin 0 -> 33 bytes .../e6/ae8889c40c77d7be02758235b5b3f7a4f2a129 | Bin 0 -> 107 bytes .../e7/811a2bc55635f182750f0420da5ad232c1af91 | Bin 0 -> 107 bytes .../e9/b63f3655b2ad80c0ff587389b5a9589a3a7110 | Bin 0 -> 174 bytes .../eb/da71fe44dcb60c53b8fbd53208a1204d32e959 | Bin 0 -> 36 bytes .../f0/5ed049854c1596a7cc0e957fab34961077f3ae | Bin 0 -> 36 bytes .../f0/a4e1c66bb548cd2b22eebefda703872e969775 | Bin 0 -> 191 bytes .../f2/ec8c8cf1a9fb7aa047a25a4308bfe860237ad4 | Bin 0 -> 32 bytes .../f5/684c96bf40c709877b56404cd8a5dd2d2a7978 | Bin 0 -> 106 bytes .../f9/0f9dcbdac2cce5cc166346160e19cb693ef4e8 | Bin 0 -> 31 bytes .../.gitted/refs/heads/automerge-branch | Bin 0 -> 41 bytes .../cherrypick/.gitted/refs/heads/master | Bin 0 -> 41 bytes .../.gitted/refs/heads/merge-branch | Bin 0 -> 41 bytes .../.gitted/refs/heads/merge-conflicts | Bin 0 -> 41 bytes .../.gitted/refs/heads/merge-mainline | Bin 0 -> 41 bytes .../cherrypick/.gitted/refs/heads/orphan | Bin 0 -> 41 bytes .../cherrypick/.gitted/refs/heads/renames | Bin 0 -> 41 bytes tests/resources/cherrypick/file1.txt | Bin 0 -> 106 bytes tests/resources/cherrypick/file2.txt | Bin 0 -> 106 bytes tests/resources/cherrypick/file3.txt | Bin 0 -> 106 bytes 92 files changed, 535 insertions(+) create mode 100644 tests/cherrypick/bare.c create mode 100644 tests/cherrypick/workdir.c create mode 100644 tests/resources/cherrypick/.gitted/HEAD create mode 100644 tests/resources/cherrypick/.gitted/config create mode 100644 tests/resources/cherrypick/.gitted/index create mode 100644 tests/resources/cherrypick/.gitted/info/exclude create mode 100644 tests/resources/cherrypick/.gitted/objects/01/a2b453c2647c71ccfefc285f2266d1f00b8253 create mode 100644 tests/resources/cherrypick/.gitted/objects/02/67838e09bbc5969bba035be2d27c8a6de694d8 create mode 100644 tests/resources/cherrypick/.gitted/objects/06/3fc9f01e6e9ec2a8d8f749885e931875e50d37 create mode 100644 tests/resources/cherrypick/.gitted/objects/08/9ac03f76058b5ba0b44bb268f317f9242481e9 create mode 100644 tests/resources/cherrypick/.gitted/objects/0d/447a6c2528b06616cde3b209a4b4ea3dcb8d65 create mode 100644 tests/resources/cherrypick/.gitted/objects/11/24c2c1ae07b26fded662d6c3f3631d9dc16f88 create mode 100644 tests/resources/cherrypick/.gitted/objects/12/905f4ea5b76f9d3fdcfe73e462201c06ae632a create mode 100644 tests/resources/cherrypick/.gitted/objects/19/c5c7207054604b69c84d08a7571ef9672bb5c2 create mode 100644 tests/resources/cherrypick/.gitted/objects/1c/2116845780455ecf916538c1cc27c4222452af create mode 100644 tests/resources/cherrypick/.gitted/objects/1c/c85eb4ff0a8438fde1b14274c6f87f891b36a0 create mode 100644 tests/resources/cherrypick/.gitted/objects/1e/1cb7391d25dcd8daba88f1f627f3045982286c create mode 100644 tests/resources/cherrypick/.gitted/objects/20/fc1a4c9d994021f43d33ab75e4252e27ca661d create mode 100644 tests/resources/cherrypick/.gitted/objects/28/d9eb4208074ad1cc84e71ccc908b34573f05d2 create mode 100644 tests/resources/cherrypick/.gitted/objects/2a/26c7e88b285613b302ba76712bc998863f3cbc create mode 100644 tests/resources/cherrypick/.gitted/objects/2a/c3b376093de405b0a951bff578655b1c2b7fa1 create mode 100644 tests/resources/cherrypick/.gitted/objects/2c/acbcaabf785f1ac231e8519849d4ad38692f2c create mode 100644 tests/resources/cherrypick/.gitted/objects/35/cb210149022c7379b0a67b0dec13cc628ff87d create mode 100644 tests/resources/cherrypick/.gitted/objects/38/c05a857e831a7e759d83778bfc85d003e21c45 create mode 100644 tests/resources/cherrypick/.gitted/objects/3f/9eed8946df9e2c737d3b8dc0b8e78959aacd92 create mode 100644 tests/resources/cherrypick/.gitted/objects/40/9a1bec58bf35348e8b62b72bb9c1f45cf5a587 create mode 100644 tests/resources/cherrypick/.gitted/objects/44/cd2ed2052c9c68f9a439d208e9614dc2a55c70 create mode 100644 tests/resources/cherrypick/.gitted/objects/48/7434cace79238a7091e2220611d4f20a765690 create mode 100644 tests/resources/cherrypick/.gitted/objects/49/20ad2f17162dcc8823ad491444dcb87f5899c9 create mode 100644 tests/resources/cherrypick/.gitted/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 create mode 100644 tests/resources/cherrypick/.gitted/objects/4c/532774cc1fea37f6efc2256763a64d38c8cdde create mode 100644 tests/resources/cherrypick/.gitted/objects/51/145af30d411a50195b66517d825e69bf57ed22 create mode 100644 tests/resources/cherrypick/.gitted/objects/54/61de53ffadbf15be4dd6345997c15689573209 create mode 100644 tests/resources/cherrypick/.gitted/objects/54/784f10955e92ab27e4fa832e40cb2baf1edbdc create mode 100644 tests/resources/cherrypick/.gitted/objects/56/3f6473a3858f99b80e5f93c660512ed38e1e6f create mode 100644 tests/resources/cherrypick/.gitted/objects/58/a957ef0061c1a8ef995c855dfab4f5da8d6617 create mode 100644 tests/resources/cherrypick/.gitted/objects/5d/c7e1f440ce74d5503a0dfbc6c30e091475f774 create mode 100644 tests/resources/cherrypick/.gitted/objects/5e/2206cda1c56430ad107a6866a829c159e0b9ea create mode 100644 tests/resources/cherrypick/.gitted/objects/5f/77a2a13935ac62a629553f8944ad57b1ed8b4a create mode 100644 tests/resources/cherrypick/.gitted/objects/63/c0d92b95253c4a40d3883f423a54be47d2c4c8 create mode 100644 tests/resources/cherrypick/.gitted/objects/6c/e83eb5f0fd34a10c3d25c6b36d2ed7ec0d6ce7 create mode 100644 tests/resources/cherrypick/.gitted/objects/6d/1c2afe5eeb9e497528e2780ac468a5465cbc96 create mode 100644 tests/resources/cherrypick/.gitted/objects/74/f06b5bfec6d33d7264f73606b57a7c0b963819 create mode 100644 tests/resources/cherrypick/.gitted/objects/82/8b08c52d2cba30952e0e008f60b25b5ba0d41a create mode 100644 tests/resources/cherrypick/.gitted/objects/85/36dd6f0ec3ddecb9f9b6c8c64c6d322cd01211 create mode 100644 tests/resources/cherrypick/.gitted/objects/85/a4a1d791973644f24c72f5e89420d3064cc452 create mode 100644 tests/resources/cherrypick/.gitted/objects/8b/5c30499a71001189b647f4d5b57fa8f04897ce create mode 100644 tests/resources/cherrypick/.gitted/objects/96/4ea3da044d9083181a88ba6701de9e35778bf4 create mode 100644 tests/resources/cherrypick/.gitted/objects/9c/c39fca3765a2facbe31157f7d60c2602193f36 create mode 100644 tests/resources/cherrypick/.gitted/objects/9c/cb9bf50c011fd58dcbaa65df917bf79539717f create mode 100644 tests/resources/cherrypick/.gitted/objects/a1/0b59f4280491afe6e430c30654a7acc67d4a33 create mode 100644 tests/resources/cherrypick/.gitted/objects/a2/1b4bfe7a04ab18024fb57f4ae9a52a1acef394 create mode 100644 tests/resources/cherrypick/.gitted/objects/a4/3a050c588d4e92f11a6b139680923e9728477d create mode 100644 tests/resources/cherrypick/.gitted/objects/a5/8ca3fee5eb68b11adc2703e5843f968c9dad1e create mode 100644 tests/resources/cherrypick/.gitted/objects/a6/61b5dec1004e2c62654ded3762370c27cf266b create mode 100644 tests/resources/cherrypick/.gitted/objects/a6/9ef8fcbb9a2c509a7dbf4f23d257eb551d5610 create mode 100644 tests/resources/cherrypick/.gitted/objects/a8/3c6f70297b805dedc549e6583582966f6ebcab create mode 100644 tests/resources/cherrypick/.gitted/objects/a9/020cd240774e4d672732bcb82d516d9685da76 create mode 100644 tests/resources/cherrypick/.gitted/objects/ab/4115f808bc585b60f822da7020af86d20f62c8 create mode 100644 tests/resources/cherrypick/.gitted/objects/ab/e4603bc7cd5b8167a267e0e2418fd2348f8cff create mode 100644 tests/resources/cherrypick/.gitted/objects/b8/26e9b36e22e949ec885e7a1f3db496bbab6cd0 create mode 100644 tests/resources/cherrypick/.gitted/objects/ba/fbf6912c09505ac60575cd43d3f2aba3bd84d8 create mode 100644 tests/resources/cherrypick/.gitted/objects/bb/14296ffa9dfbf935ec9ce2f9ed7808d952226b create mode 100644 tests/resources/cherrypick/.gitted/objects/bc/4dd0744364d1db380a9811bd264c101065231e create mode 100644 tests/resources/cherrypick/.gitted/objects/bd/65d4083845ed5ed4e1fe5feb85ac395d0760c8 create mode 100644 tests/resources/cherrypick/.gitted/objects/bd/6ffc8c6c41f0f85ff9e3d61c9479516bac0024 create mode 100644 tests/resources/cherrypick/.gitted/objects/bd/a51965cb36c0c5731c8cb50b80a36cac81018e create mode 100644 tests/resources/cherrypick/.gitted/objects/ce/d8fb81b6ec534d5deaf2a48b4b96c799712507 create mode 100644 tests/resources/cherrypick/.gitted/objects/cf/c4f0999a8367568e049af4f72e452d40828a15 create mode 100644 tests/resources/cherrypick/.gitted/objects/d0/f21e17beb5b9d953b1d8349049818a4f2edd1e create mode 100644 tests/resources/cherrypick/.gitted/objects/d3/d77487660ee3c0194ee01dc5eaf478782b1c7e create mode 100644 tests/resources/cherrypick/.gitted/objects/e2/33b9ed408a95e9d4b65fec7fc34943a556deb2 create mode 100644 tests/resources/cherrypick/.gitted/objects/e5/183bfd18e3a0a691fadde2f0d5610b73282d31 create mode 100644 tests/resources/cherrypick/.gitted/objects/e6/ae8889c40c77d7be02758235b5b3f7a4f2a129 create mode 100644 tests/resources/cherrypick/.gitted/objects/e7/811a2bc55635f182750f0420da5ad232c1af91 create mode 100644 tests/resources/cherrypick/.gitted/objects/e9/b63f3655b2ad80c0ff587389b5a9589a3a7110 create mode 100644 tests/resources/cherrypick/.gitted/objects/eb/da71fe44dcb60c53b8fbd53208a1204d32e959 create mode 100644 tests/resources/cherrypick/.gitted/objects/f0/5ed049854c1596a7cc0e957fab34961077f3ae create mode 100644 tests/resources/cherrypick/.gitted/objects/f0/a4e1c66bb548cd2b22eebefda703872e969775 create mode 100644 tests/resources/cherrypick/.gitted/objects/f2/ec8c8cf1a9fb7aa047a25a4308bfe860237ad4 create mode 100644 tests/resources/cherrypick/.gitted/objects/f5/684c96bf40c709877b56404cd8a5dd2d2a7978 create mode 100644 tests/resources/cherrypick/.gitted/objects/f9/0f9dcbdac2cce5cc166346160e19cb693ef4e8 create mode 100644 tests/resources/cherrypick/.gitted/refs/heads/automerge-branch create mode 100644 tests/resources/cherrypick/.gitted/refs/heads/master create mode 100644 tests/resources/cherrypick/.gitted/refs/heads/merge-branch create mode 100644 tests/resources/cherrypick/.gitted/refs/heads/merge-conflicts create mode 100644 tests/resources/cherrypick/.gitted/refs/heads/merge-mainline create mode 100644 tests/resources/cherrypick/.gitted/refs/heads/orphan create mode 100644 tests/resources/cherrypick/.gitted/refs/heads/renames create mode 100644 tests/resources/cherrypick/file1.txt create mode 100644 tests/resources/cherrypick/file2.txt create mode 100644 tests/resources/cherrypick/file3.txt diff --git a/tests/cherrypick/bare.c b/tests/cherrypick/bare.c new file mode 100644 index 000000000..7ac1054a1 --- /dev/null +++ b/tests/cherrypick/bare.c @@ -0,0 +1,106 @@ +#include "clar.h" +#include "clar_libgit2.h" + +#include "buffer.h" +#include "fileops.h" +#include "git2/cherrypick.h" + +#include "../merge/merge_helpers.h" + +#define TEST_REPO_PATH "cherrypick" + +static git_repository *repo; + +void test_cherrypick_bare__initialize(void) +{ + repo = cl_git_sandbox_init(TEST_REPO_PATH); +} + +void test_cherrypick_bare__cleanup(void) +{ + cl_git_sandbox_cleanup(); +} + +void test_cherrypick_bare__automerge(void) +{ + git_commit *head = NULL, *commit = NULL; + git_index *index = NULL; + git_oid head_oid, cherry_oid; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "38c05a857e831a7e759d83778bfc85d003e21c45", 0, "file1.txt" }, + { 0100644, "a661b5dec1004e2c62654ded3762370c27cf266b", 0, "file2.txt" }, + { 0100644, "df6b290e0bd6a89b01d69f66687e8abf385283ca", 0, "file3.txt" }, + }; + + git_oid_fromstr(&head_oid, "d3d77487660ee3c0194ee01dc5eaf478782b1c7e"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + + git_oid_fromstr(&cherry_oid, "cfc4f0999a8367568e049af4f72e452d40828a15"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + + cl_git_pass(git_cherry_pick_commit(&index, repo, commit, head, 0, NULL)); + cl_assert(merge_test_index(index, merge_index_entries, 3)); + + git_index_free(index); + git_commit_free(head); + git_commit_free(commit); +} + +void test_cherrypick_bare__conflicts(void) +{ + git_commit *head = NULL, *commit = NULL; + git_index *index = NULL; + git_oid head_oid, cherry_oid; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "242e7977ba73637822ffb265b46004b9b0e5153b", 0, "file1.txt" }, + { 0100644, "a58ca3fee5eb68b11adc2703e5843f968c9dad1e", 1, "file2.txt" }, + { 0100644, "bd6ffc8c6c41f0f85ff9e3d61c9479516bac0024", 2, "file2.txt" }, + { 0100644, "563f6473a3858f99b80e5f93c660512ed38e1e6f", 3, "file2.txt" }, + { 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 1, "file3.txt" }, + { 0100644, "1124c2c1ae07b26fded662d6c3f3631d9dc16f88", 2, "file3.txt" }, + { 0100644, "e233b9ed408a95e9d4b65fec7fc34943a556deb2", 3, "file3.txt" }, + }; + + git_oid_fromstr(&head_oid, "bafbf6912c09505ac60575cd43d3f2aba3bd84d8"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + + git_oid_fromstr(&cherry_oid, "e9b63f3655b2ad80c0ff587389b5a9589a3a7110"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + + cl_git_pass(git_cherry_pick_commit(&index, repo, commit, head, 0, NULL)); + cl_assert(merge_test_index(index, merge_index_entries, 7)); + + git_index_free(index); + git_commit_free(head); + git_commit_free(commit); +} + +void test_cherrypick_bare__orphan(void) +{ + git_commit *head = NULL, *commit = NULL; + git_index *index = NULL; + git_oid head_oid, cherry_oid; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "38c05a857e831a7e759d83778bfc85d003e21c45", 0, "file1.txt" }, + { 0100644, "a661b5dec1004e2c62654ded3762370c27cf266b", 0, "file2.txt" }, + { 0100644, "85a4a1d791973644f24c72f5e89420d3064cc452", 0, "file3.txt" }, + { 0100644, "9ccb9bf50c011fd58dcbaa65df917bf79539717f", 0, "orphan.txt" }, + }; + + git_oid_fromstr(&head_oid, "d3d77487660ee3c0194ee01dc5eaf478782b1c7e"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + + git_oid_fromstr(&cherry_oid, "74f06b5bfec6d33d7264f73606b57a7c0b963819"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + + cl_git_pass(git_cherry_pick_commit(&index, repo, commit, head, 0, NULL)); + cl_assert(merge_test_index(index, merge_index_entries, 4)); + + git_index_free(index); + git_commit_free(head); + git_commit_free(commit); +} + diff --git a/tests/cherrypick/workdir.c b/tests/cherrypick/workdir.c new file mode 100644 index 000000000..581a5f997 --- /dev/null +++ b/tests/cherrypick/workdir.c @@ -0,0 +1,429 @@ +#include "clar.h" +#include "clar_libgit2.h" + +#include "buffer.h" +#include "fileops.h" +#include "git2/cherrypick.h" + +#include "../merge/merge_helpers.h" + +#define TEST_REPO_PATH "cherrypick" + +static git_repository *repo; +static git_index *repo_index; + +// Fixture setup and teardown +void test_cherrypick_workdir__initialize(void) +{ + repo = cl_git_sandbox_init(TEST_REPO_PATH); + git_repository_index(&repo_index, repo); +} + +void test_cherrypick_workdir__cleanup(void) +{ + git_index_free(repo_index); + cl_git_sandbox_cleanup(); +} + +/* git reset --hard d3d77487660ee3c0194ee01dc5eaf478782b1c7e + * git cherry-pick cfc4f0999a8367568e049af4f72e452d40828a15 + * git cherry-pick 964ea3da044d9083181a88ba6701de9e35778bf4 + * git cherry-pick a43a050c588d4e92f11a6b139680923e9728477d + */ +void test_cherrypick_workdir__automerge(void) +{ + git_oid head_oid; + git_signature *signature = NULL; + size_t i; + + const char *cherry_pick_oids[] = { + "cfc4f0999a8367568e049af4f72e452d40828a15", + "964ea3da044d9083181a88ba6701de9e35778bf4", + "a43a050c588d4e92f11a6b139680923e9728477d", + }; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "38c05a857e831a7e759d83778bfc85d003e21c45", 0, "file1.txt" }, + { 0100644, "a661b5dec1004e2c62654ded3762370c27cf266b", 0, "file2.txt" }, + { 0100644, "df6b290e0bd6a89b01d69f66687e8abf385283ca", 0, "file3.txt" }, + + { 0100644, "38c05a857e831a7e759d83778bfc85d003e21c45", 0, "file1.txt" }, + { 0100644, "bd8fc3c59fb52d3c8b5907ace7defa5803f82419", 0, "file2.txt" }, + { 0100644, "df6b290e0bd6a89b01d69f66687e8abf385283ca", 0, "file3.txt" }, + + { 0100644, "f06427bee380364bc7e0cb26a9245158e4726ce0", 0, "file1.txt" }, + { 0100644, "bd8fc3c59fb52d3c8b5907ace7defa5803f82419", 0, "file2.txt" }, + { 0100644, "df6b290e0bd6a89b01d69f66687e8abf385283ca", 0, "file3.txt" }, + }; + + cl_git_pass(git_signature_new(&signature, "Picker", "picker@example.org", time(NULL), 0)); + + git_oid_fromstr(&head_oid, "d3d77487660ee3c0194ee01dc5eaf478782b1c7e"); + + for (i = 0; i < 3; ++i) { + git_commit *head = NULL, *commit = NULL; + git_oid cherry_oid, cherry_picked_oid, cherry_picked_tree_oid; + git_tree *cherry_picked_tree = NULL; + + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, cherry_pick_oids[i]); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + cl_git_pass(git_cherry_pick(repo, commit, NULL)); + + cl_assert(git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD")); + cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG")); + + cl_git_pass(git_index_write_tree(&cherry_picked_tree_oid, repo_index)); + cl_git_pass(git_tree_lookup(&cherry_picked_tree, repo, &cherry_picked_tree_oid)); + cl_git_pass(git_commit_create(&cherry_picked_oid, repo, "HEAD", signature, signature, NULL, + "Cherry picked!", cherry_picked_tree, 1, (const git_commit **)&head)); + + cl_assert(merge_test_index(repo_index, merge_index_entries + i * 3, 3)); + + git_oid_cpy(&head_oid, &cherry_picked_oid); + + git_tree_free(cherry_picked_tree); + git_commit_free(head); + git_commit_free(commit); + } + + git_signature_free(signature); +} + +/* git reset --hard bafbf6912c09505ac60575cd43d3f2aba3bd84d8 + * git cherry-pick e9b63f3655b2ad80c0ff587389b5a9589a3a7110 + */ +void test_cherrypick_workdir__conflicts(void) +{ + git_commit *head = NULL, *commit = NULL; + git_oid head_oid, cherry_oid; + git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "242e7977ba73637822ffb265b46004b9b0e5153b", 0, "file1.txt" }, + { 0100644, "a58ca3fee5eb68b11adc2703e5843f968c9dad1e", 1, "file2.txt" }, + { 0100644, "bd6ffc8c6c41f0f85ff9e3d61c9479516bac0024", 2, "file2.txt" }, + { 0100644, "563f6473a3858f99b80e5f93c660512ed38e1e6f", 3, "file2.txt" }, + { 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 1, "file3.txt" }, + { 0100644, "1124c2c1ae07b26fded662d6c3f3631d9dc16f88", 2, "file3.txt" }, + { 0100644, "e233b9ed408a95e9d4b65fec7fc34943a556deb2", 3, "file3.txt" }, + }; + + git_oid_fromstr(&head_oid, "bafbf6912c09505ac60575cd43d3f2aba3bd84d8"); + + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, "e9b63f3655b2ad80c0ff587389b5a9589a3a7110"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + cl_git_pass(git_cherry_pick(repo, commit, NULL)); + + cl_assert(git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD")); + cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG")); + + cl_assert(merge_test_index(repo_index, merge_index_entries, 7)); + + cl_git_pass(git_futils_readbuffer(&mergemsg_buf, + TEST_REPO_PATH "/.git/MERGE_MSG")); + cl_assert(strcmp(git_buf_cstr(&mergemsg_buf), + "Change all files\n" \ + "\n" \ + "Conflicts:\n" \ + "\tfile2.txt\n" \ + "\tfile3.txt\n") == 0); + + cl_git_pass(git_futils_readbuffer(&conflicting_buf, + TEST_REPO_PATH "/file2.txt")); + + cl_assert(strcmp(git_buf_cstr(&conflicting_buf), + "!File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2!!\n" \ + "File 2\n" \ + "File 2\n" \ + "File 2\n" \ + "<<<<<<< HEAD\n" \ + "File 2\n" \ + "=======\n" \ + "File 2!\n" \ + "File 2\n" \ + "File 2!\n" \ + ">>>>>>> e9b63f3... Change all files\n") == 0); + + cl_git_pass(git_futils_readbuffer(&conflicting_buf, + TEST_REPO_PATH "/file3.txt")); + + cl_assert(strcmp(git_buf_cstr(&conflicting_buf), + "!File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3!!\n" \ + "File 3\n" \ + "File 3\n" \ + "File 3\n" \ + "<<<<<<< HEAD\n" \ + "=======\n" \ + "File 3!\n" \ + "File 3!\n" \ + ">>>>>>> e9b63f3... Change all files\n") == 0); + + git_commit_free(commit); + git_commit_free(head); + git_buf_free(&mergemsg_buf); + git_buf_free(&conflicting_buf); +} + +/* git reset --hard bafbf6912c09505ac60575cd43d3f2aba3bd84d8 + * git cherry-pick -X ours e9b63f3655b2ad80c0ff587389b5a9589a3a7110 + */ +void test_cherrypick_workdir__conflict_use_ours(void) +{ + git_commit *head = NULL, *commit = NULL; + git_oid head_oid, cherry_oid; + git_cherry_pick_options opts = GIT_CHERRY_PICK_OPTIONS_INIT; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "242e7977ba73637822ffb265b46004b9b0e5153b", 0, "file1.txt" }, + { 0100644, "a58ca3fee5eb68b11adc2703e5843f968c9dad1e", 1, "file2.txt" }, + { 0100644, "bd6ffc8c6c41f0f85ff9e3d61c9479516bac0024", 2, "file2.txt" }, + { 0100644, "563f6473a3858f99b80e5f93c660512ed38e1e6f", 3, "file2.txt" }, + { 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 1, "file3.txt" }, + { 0100644, "1124c2c1ae07b26fded662d6c3f3631d9dc16f88", 2, "file3.txt" }, + { 0100644, "e233b9ed408a95e9d4b65fec7fc34943a556deb2", 3, "file3.txt" }, + }; + + struct merge_index_entry merge_filesystem_entries[] = { + { 0100644, "242e7977ba73637822ffb265b46004b9b0e5153b", 0, "file1.txt" }, + { 0100644, "bd6ffc8c6c41f0f85ff9e3d61c9479516bac0024", 0, "file2.txt" }, + { 0100644, "1124c2c1ae07b26fded662d6c3f3631d9dc16f88", 0, "file3.txt" }, + }; + + /* leave the index in a conflicted state, but checkout "ours" to the workdir */ + opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS; + + git_oid_fromstr(&head_oid, "bafbf6912c09505ac60575cd43d3f2aba3bd84d8"); + + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, "e9b63f3655b2ad80c0ff587389b5a9589a3a7110"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + cl_git_pass(git_cherry_pick(repo, commit, &opts)); + + cl_assert(merge_test_index(repo_index, merge_index_entries, 7)); + cl_assert(merge_test_workdir(repo, merge_filesystem_entries, 3)); + + /* resolve conflicts in the index by taking "ours" */ + opts.merge_opts.file_favor = GIT_MERGE_FILE_FAVOR_OURS; + + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + cl_git_pass(git_cherry_pick(repo, commit, &opts)); + + cl_assert(merge_test_index(repo_index, merge_filesystem_entries, 3)); + cl_assert(merge_test_workdir(repo, merge_filesystem_entries, 3)); + + git_commit_free(commit); + git_commit_free(head); +} + +/* git reset --hard cfc4f0999a8367568e049af4f72e452d40828a15 + * git cherry-pick 2a26c7e88b285613b302ba76712bc998863f3cbc + */ +void test_cherrypick_workdir__rename(void) +{ + git_commit *head, *commit; + git_oid head_oid, cherry_oid; + git_cherry_pick_options opts = GIT_CHERRY_PICK_OPTIONS_INIT; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "19c5c7207054604b69c84d08a7571ef9672bb5c2", 0, "file1.txt" }, + { 0100644, "a58ca3fee5eb68b11adc2703e5843f968c9dad1e", 0, "file2.txt" }, + { 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 0, "file3.txt.renamed" }, + }; + + opts.merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES; + opts.merge_opts.rename_threshold = 50; + + git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, "2a26c7e88b285613b302ba76712bc998863f3cbc"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + cl_git_pass(git_cherry_pick(repo, commit, &opts)); + + cl_assert(merge_test_index(repo_index, merge_index_entries, 3)); + + git_commit_free(commit); + git_commit_free(head); +} + +/* git reset --hard 44cd2ed2052c9c68f9a439d208e9614dc2a55c70 + * git cherry-pick 2a26c7e88b285613b302ba76712bc998863f3cbc + */ +void test_cherrypick_workdir__both_renamed(void) +{ + git_commit *head, *commit; + git_oid head_oid, cherry_oid; + git_buf mergemsg_buf = GIT_BUF_INIT; + git_cherry_pick_options opts = GIT_CHERRY_PICK_OPTIONS_INIT; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "19c5c7207054604b69c84d08a7571ef9672bb5c2", 0, "file1.txt" }, + { 0100644, "a58ca3fee5eb68b11adc2703e5843f968c9dad1e", 0, "file2.txt" }, + { 0100644, "e233b9ed408a95e9d4b65fec7fc34943a556deb2", 1, "file3.txt" }, + { 0100644, "e233b9ed408a95e9d4b65fec7fc34943a556deb2", 3, "file3.txt.renamed" }, + { 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 2, "file3.txt.renamed_on_branch" }, + }; + + opts.merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES; + opts.merge_opts.rename_threshold = 50; + + git_oid_fromstr(&head_oid, "44cd2ed2052c9c68f9a439d208e9614dc2a55c70"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, "2a26c7e88b285613b302ba76712bc998863f3cbc"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + cl_git_pass(git_cherry_pick(repo, commit, &opts)); + + cl_assert(merge_test_index(repo_index, merge_index_entries, 5)); + + cl_git_pass(git_futils_readbuffer(&mergemsg_buf, + TEST_REPO_PATH "/.git/MERGE_MSG")); + cl_assert(strcmp(git_buf_cstr(&mergemsg_buf), + "Renamed file3.txt -> file3.txt.renamed\n" \ + "\n" \ + "Conflicts:\n" \ + "\tfile3.txt\n" \ + "\tfile3.txt.renamed\n" \ + "\tfile3.txt.renamed_on_branch\n") == 0); + + git_buf_free(&mergemsg_buf); + git_commit_free(commit); + git_commit_free(head); +} + +void test_cherrypick_workdir__nonmerge_fails_mainline_specified(void) +{ + git_reference *head; + git_commit *commit; + git_cherry_pick_options opts = GIT_CHERRY_PICK_OPTIONS_INIT; + + cl_git_pass(git_repository_head(&head, repo)); + cl_git_pass(git_reference_peel((git_object **)&commit, head, GIT_OBJ_COMMIT)); + + opts.mainline = 1; + cl_must_fail(git_cherry_pick(repo, commit, &opts)); + cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD")); + cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG")); + + git_reference_free(head); + git_commit_free(commit); +} + +/* git reset --hard cfc4f0999a8367568e049af4f72e452d40828a15 + * git cherry-pick abe4603bc7cd5b8167a267e0e2418fd2348f8cff + */ +void test_cherrypick_workdir__merge_fails_without_mainline_specified(void) +{ + git_commit *head, *commit; + git_oid head_oid, cherry_oid; + + git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, "abe4603bc7cd5b8167a267e0e2418fd2348f8cff"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + + cl_must_fail(git_cherry_pick(repo, commit, NULL)); + cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD")); + cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG")); + + git_commit_free(commit); + git_commit_free(head); +} + +/* git reset --hard cfc4f0999a8367568e049af4f72e452d40828a15 + * git cherry-pick -m1 abe4603bc7cd5b8167a267e0e2418fd2348f8cff + */ +void test_cherrypick_workdir__merge_first_parent(void) +{ + git_commit *head, *commit; + git_oid head_oid, cherry_oid; + git_cherry_pick_options opts = GIT_CHERRY_PICK_OPTIONS_INIT; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "f90f9dcbdac2cce5cc166346160e19cb693ef4e8", 0, "file1.txt" }, + { 0100644, "563f6473a3858f99b80e5f93c660512ed38e1e6f", 0, "file2.txt" }, + { 0100644, "e233b9ed408a95e9d4b65fec7fc34943a556deb2", 0, "file3.txt" }, + }; + + opts.mainline = 1; + + git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, "abe4603bc7cd5b8167a267e0e2418fd2348f8cff"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + + cl_git_pass(git_cherry_pick(repo, commit, &opts)); + + cl_assert(merge_test_index(repo_index, merge_index_entries, 3)); + + git_commit_free(commit); + git_commit_free(head); +} + +/* git reset --hard cfc4f0999a8367568e049af4f72e452d40828a15 + * git cherry-pick -m2 abe4603bc7cd5b8167a267e0e2418fd2348f8cff + */ +void test_cherrypick_workdir__merge_second_parent(void) +{ + git_commit *head, *commit; + git_oid head_oid, cherry_oid; + git_cherry_pick_options opts = GIT_CHERRY_PICK_OPTIONS_INIT; + + struct merge_index_entry merge_index_entries[] = { + { 0100644, "487434cace79238a7091e2220611d4f20a765690", 0, "file1.txt" }, + { 0100644, "e5183bfd18e3a0a691fadde2f0d5610b73282d31", 0, "file2.txt" }, + { 0100644, "409a1bec58bf35348e8b62b72bb9c1f45cf5a587", 0, "file3.txt" }, + }; + + opts.mainline = 2; + + git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15"); + cl_git_pass(git_commit_lookup(&head, repo, &head_oid)); + cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL)); + + git_oid_fromstr(&cherry_oid, "abe4603bc7cd5b8167a267e0e2418fd2348f8cff"); + cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid)); + + cl_git_pass(git_cherry_pick(repo, commit, &opts)); + + cl_assert(merge_test_index(repo_index, merge_index_entries, 3)); + + git_commit_free(commit); + git_commit_free(head); +} + diff --git a/tests/resources/cherrypick/.gitted/HEAD b/tests/resources/cherrypick/.gitted/HEAD new file mode 100644 index 0000000000000000000000000000000000000000..656ac0e0a80bd78ae334807bb75abc79c41bd173 GIT binary patch literal 33 ocmXR)O|w!cN=+-)&qz&7Db`OcEy>SKElN+-O)5&vOU~c|0M57!82|tP literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/config b/tests/resources/cherrypick/.gitted/config new file mode 100644 index 0000000000000000000000000000000000000000..6c9406b7d9320db083eca69b3f8bee9a6c7b50d4 GIT binary patch literal 137 zcmYk#%?-jZ3KJaaM(b)IThRcka) zn6vinzTI-FENHqTG;JZL7ug4u#6zM7i5Th{J5BgE#z&9!LjG%xu(tTZ>RkRd-|~Df A#{d8T literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/index b/tests/resources/cherrypick/.gitted/index new file mode 100644 index 0000000000000000000000000000000000000000..7291006c88cac48740211d1a74f551eafbb14eef GIT binary patch literal 248 zcmZ?q402{*U|<4b=3rZ~nLwHWMl%A%IqvVC!@$tEgn@zaD^N-Vh_fsXM77p6OVyRm zZ7%Qr(|UpVk&G(?XIf@Xs-a#)v_Vx z7~wN#9=bWLOBPxv646rPp@ Hn=SYjD=rRaaJf=~^$e>puw*UY{^AEQG literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/06/3fc9f01e6e9ec2a8d8f749885e931875e50d37 b/tests/resources/cherrypick/.gitted/objects/06/3fc9f01e6e9ec2a8d8f749885e931875e50d37 new file mode 100644 index 0000000000000000000000000000000000000000..48fa6efcdd3718cb912f879dd32bc4281e468273 GIT binary patch literal 141 zcmV;80CN9$0iDe;4gw(%Kv8Q>F};Zy*nvP|jGc*%X8?9qFu_$|3vcfx>j`Xs@qV03 z$sMFKyIz@rf>nBqhExoOgY#&RHHFEJ#wly3z)TKF_@$@0!qvz3!VNB5OKxfTG&nxC vc0adXv+w>8=W+r$IHRQ+9KjwHqFC#??)(QrsD6mJ)mQRQ*f8-0&j~^HUf@Er literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/08/9ac03f76058b5ba0b44bb268f317f9242481e9 b/tests/resources/cherrypick/.gitted/objects/08/9ac03f76058b5ba0b44bb268f317f9242481e9 new file mode 100644 index 0000000000000000000000000000000000000000..06d1c694e5456010b2301d491cf3f960af2da47f GIT binary patch literal 170 zcmV;b09F5Z0j17C3c@fDKvCB@#q0%{q?2g^BJKp2-e63pwL+{-(}lOU;1S%u#pkCf z=dpq#-qoTCUY$cuo!I1=8kEjrD;$_5xR|Vuiub5u-cs~cA@zxRj4?`Rxb++qDN0X$ z>y*6f2!jh^y^*y(rUF+<^QsG6wB&Jlte*vr&z}wFrIt~u9MY6eV4KK9%{Bphbcklt YZMEuO5p&ad9gBiM)-tI10w^L+Eo|UZ*#H0l literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/0d/447a6c2528b06616cde3b209a4b4ea3dcb8d65 b/tests/resources/cherrypick/.gitted/objects/0d/447a6c2528b06616cde3b209a4b4ea3dcb8d65 new file mode 100644 index 0000000000000000000000000000000000000000..9a3ea32097ec5ac637f6f9b9b3b660a07e55e009 GIT binary patch literal 107 zcmV-x0F?iD0V^p=O;s>7G-NO|FfcPQQAo?oNj20fsVHHvI1trZ*DO_6I=8vJ`%miy z=0`HFNQ#WWik2mAy?2noPbVqW_pN!7Igk2zwQM9s#$ZLQOBP literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/12/905f4ea5b76f9d3fdcfe73e462201c06ae632a b/tests/resources/cherrypick/.gitted/objects/12/905f4ea5b76f9d3fdcfe73e462201c06ae632a new file mode 100644 index 0000000000000000000000000000000000000000..162844a70bfa51f94939622c78dfd1c91515c984 GIT binary patch literal 108 zcmV-y0F(cC0V^p=O;s>7G-NO|FfcPQQAo?oNj20fsVHHHJ^t{E!?}{H0am=fj~(XY z6e;~)f~3d@tY~lkpPn4Y4?p66KE5V1r7|#k4TB1jB4e;3L6t)X*RgNPzjrO^+TqX1 OvU3mScK`siFfjX{R4`Kj literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/19/c5c7207054604b69c84d08a7571ef9672bb5c2 b/tests/resources/cherrypick/.gitted/objects/19/c5c7207054604b69c84d08a7571ef9672bb5c2 new file mode 100644 index 0000000000000000000000000000000000000000..d5cd6d3f2dd607cea68b2f9862e4827f5e81b64f GIT binary patch literal 28 kcmb40V^p=O;s>7v}7DpTlAt^EfD_YvK_}|ml85^bUs53upv7gp6cdZm>kzn=qR_fHZah literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/1c/c85eb4ff0a8438fde1b14274c6f87f891b36a0 b/tests/resources/cherrypick/.gitted/objects/1c/c85eb4ff0a8438fde1b14274c6f87f891b36a0 new file mode 100644 index 0000000000000000000000000000000000000000..98b792b644a89aa176b6fa2ee60e3657eb1c79a4 GIT binary patch literal 117 zcmV-*0E+*30V^p=O;s>7v}7twU#?o)JrS6XTOS zooV;w1(G5ou%a;gl;Xv${WEv)#ZNw#5U6*#Pc9!xkugY-UQudZVs2^*!z1IJZyma( XzPz$6{!RU1Pv@m!_cj3l=?628#`-me literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/1e/1cb7391d25dcd8daba88f1f627f3045982286c b/tests/resources/cherrypick/.gitted/objects/1e/1cb7391d25dcd8daba88f1f627f3045982286c new file mode 100644 index 0000000000000000000000000000000000000000..10a5be6fe1fe89fdf9a213932741f802967b028f GIT binary patch literal 32 ocmbOpD`K)fiR@$$w34d>0Nv#c9RL6T literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/20/fc1a4c9d994021f43d33ab75e4252e27ca661d b/tests/resources/cherrypick/.gitted/objects/20/fc1a4c9d994021f43d33ab75e4252e27ca661d new file mode 100644 index 0000000000000000000000000000000000000000..c8b26cd011248b10185873a57774bb1afea4ef59 GIT binary patch literal 126 zcmV-^0D=E_0V^p=O;s>7vSctcFfcPQQAo?oNj20fsVHHPJbGNAASA&%^Mo(Q@^HDI z>DpTlAt^EfD_YvK_}|ml85^bUs53upv7gp6cdZLzhjn6;jklvOvEo=Und~BIb)(K#0Zuu(>S74l(uBI` zS_6&_Qx22@CUP_yqZMs(SvtH?xo^C}EB7|9m+gCn!^basKdsVd5*o_Vj$mAh-Un+f oJZr19+UY)3_+Jur<|{Rxpw6G{2Kf?rIsS!VKlP~94>y=sg_*)y761SM literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/2a/c3b376093de405b0a951bff578655b1c2b7fa1 b/tests/resources/cherrypick/.gitted/objects/2a/c3b376093de405b0a951bff578655b1c2b7fa1 new file mode 100644 index 0000000000000000000000000000000000000000..a3294d764449fe672096b8763ebfe1ed992b0fcb GIT binary patch literal 191 zcmV;w06_nE0hN!zO2se`MP27BX7?7Nq?1XS0TFkC;73f-$!mqQnx+f?-pca_+@1r6 zd-GQ7(g8<%*PAM&h(S5Ipoq%Enq%}j%23>th(k(}LY}Pol%{KkTrw5Q%o1G~eTZs_ zrBE4B$>T&eVwAxfIr_Xcc$55f=nk*i>ax$r_YO}VH+Fs5dt0Q-W8UgB42}bli=N=# tqP6Cv=hUwMj}RmNMa;Xl>v^-unrFCF+0WnwmbGtCf7QcHnIFwBSeWSoW##|? literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/2c/acbcaabf785f1ac231e8519849d4ad38692f2c b/tests/resources/cherrypick/.gitted/objects/2c/acbcaabf785f1ac231e8519849d4ad38692f2c new file mode 100644 index 0000000000000000000000000000000000000000..74b48dd6b62c069cfe443c4362051e0ec1423f4c GIT binary patch literal 26 icmbUMG471sVx-h!L?TQV-rgoXg4@4%Ka`x4 z0D8BR8Y4tEATr&9wY{+u4&I$dgCKi_E3Mjl*Y&4KA_f)aK>e;P~9y r8_ry-H3l_%VtT!AS@a$s=d;!BuY!BnxGmQsOv<$%m+x z5@*U2YA>G2MvUyd;jLYk3a>2pO;$Do(s|s$DS*5(;v?0Mla&Bme*a literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/44/cd2ed2052c9c68f9a439d208e9614dc2a55c70 b/tests/resources/cherrypick/.gitted/objects/44/cd2ed2052c9c68f9a439d208e9614dc2a55c70 new file mode 100644 index 0000000000000000000000000000000000000000..8697c4e66089a35b14a151a3a95a9c9f0ccc7121 GIT binary patch literal 195 zcmV;!06hPA0i}<@PQ)+}LpkRw=8mY6$s|oAwBm-uksnyiCKK8fX(3G|_w z$+FX0>)ZjyaMzm%pf1TUrI=$Rji!*z*79X^Lg-L%OzgeM>Vums9a2eDbc~UM^`rAa zG(|2{Mig?GNe2vUoZ`JtYl9a~pSx`EEUnJlw102#c>QB+TOXDR?>Ic?8TG$g>VMG7` literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/48/7434cace79238a7091e2220611d4f20a765690 b/tests/resources/cherrypick/.gitted/objects/48/7434cace79238a7091e2220611d4f20a765690 new file mode 100644 index 0000000000000000000000000000000000000000..a1fa599e18092197d595a607bf818fd91ece0f8e GIT binary patch literal 33 ocmbiRGfItRJ#HWi|%AFi7G-NO|FfcPQQAo?oNj20fsVHHPJbGNAASA&%^Mo(Q@^HDI z>DpTlAt^EfD_YvK_}|ml85^bUs53upv7gp6cdZfd`Ib80rcd`oE N=YHwP2>=NtEy_Z5FYW*U literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/54/61de53ffadbf15be4dd6345997c15689573209 b/tests/resources/cherrypick/.gitted/objects/54/61de53ffadbf15be4dd6345997c15689573209 new file mode 100644 index 0000000000000000000000000000000000000000..7d2b233a65fc36a02f1526c7f78bdda5095367ed GIT binary patch literal 187 zcmV;s07U8_ry-H3l_%VtT!AS@a$s=d;!BuY!BnxGmQsOv<$%m+x z5@*U2YA>G2MvUyd;jLYk3a>2pO;6w`5Rs%gjktFy^8mWdi{U9P`kZPG^ gW}IfMr>CdjoROH9o~n?TlcSIZbZape04%04V46fA8vpz>% literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/5d/c7e1f440ce74d5503a0dfbc6c30e091475f774 b/tests/resources/cherrypick/.gitted/objects/5d/c7e1f440ce74d5503a0dfbc6c30e091475f774 new file mode 100644 index 0000000000000000000000000000000000000000..77deeaf0bde08841c53ecc3ae4578f8d3c38418c GIT binary patch literal 31 ncmb7G-NO|FfcPQQAo?oNj20fsVHIi^rolhiGCg{WD8slSU4bB4e7G-NO|FfcPQQAo?oNj20fsVHHvI1trZ*DO_6I=8vJ`%miy z=0`HFNQ#WWik2mAy?2noPbVqW_pN!7Igk2zwQM9s#$ZJ{Yxb<#UlA{L$nZtr49_cT MEi(0W0MvLZz#$$lYybcN literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/63/c0d92b95253c4a40d3883f423a54be47d2c4c8 b/tests/resources/cherrypick/.gitted/objects/63/c0d92b95253c4a40d3883f423a54be47d2c4c8 new file mode 100644 index 0000000000000000000000000000000000000000..eafe2c30af02ad41e99c5e26d510d143c9c82c36 GIT binary patch literal 30 mcmb7G-NO|FfcPQQAo?oNj20fsVHICEuxwKYwqu#rf=pv`uVnk z<7SXjHj*MEup*}P=048dN2kr+#T@e OHPX2tBnSZbx-o{GOf{hZ literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/6d/1c2afe5eeb9e497528e2780ac468a5465cbc96 b/tests/resources/cherrypick/.gitted/objects/6d/1c2afe5eeb9e497528e2780ac468a5465cbc96 new file mode 100644 index 0000000000000000000000000000000000000000..a98378a70cbec3d973b9a17a7a0513d59d15fa74 GIT binary patch literal 169 zcmV;a09OBa0j178YQsPfK;hJTis=nzcJ?1kaA$CnGt7=gmIAVz)vECAZSWD&zT)G_ zx-4@C^8TwgRp9I-jtQxxnlTJINbp5t$S!0mF^*BIa5WEZdhg(ZRI+G&K_W>mm5Llw z#X-e7kw|$Qa~cfqeOen_S^jq2;G%7rw`qTFaQgkU+j;A4=FUf1mv6AH#9+x44+kVf X^RDmJuKz;JPkT&!hYx06?C8rwur^4yE vwa2Bll5DdFx8yUBGI}7X48tBJqFC#?Zs8AvQT`BdFRy54*f8-0ImJN=j}=3c literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/82/8b08c52d2cba30952e0e008f60b25b5ba0d41a b/tests/resources/cherrypick/.gitted/objects/82/8b08c52d2cba30952e0e008f60b25b5ba0d41a new file mode 100644 index 0000000000000000000000000000000000000000..302014bffc0867e2c5fc5203c29b47ee9e84faac GIT binary patch literal 107 zcmV-x0F?iD0V^p=O;s>7G-NO|FfcPQQAo?oNj20fsVHHPJbGNAASA&%^Mo(Q@^HDI z>DpTlAt^EfD_YvK_}|ml85^bUs53upv7gp6cdZ)aLEr}$|Ev*0m literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/85/36dd6f0ec3ddecb9f9b6c8c64c6d322cd01211 b/tests/resources/cherrypick/.gitted/objects/85/36dd6f0ec3ddecb9f9b6c8c64c6d322cd01211 new file mode 100644 index 0000000000000000000000000000000000000000..db6faa9e2186ba8b1e720431de915d32c4c8d631 GIT binary patch literal 36 scmbZ9OAhNJcyNHp&s8wz~04U-QfdBvi literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/85/a4a1d791973644f24c72f5e89420d3064cc452 b/tests/resources/cherrypick/.gitted/objects/85/a4a1d791973644f24c72f5e89420d3064cc452 new file mode 100644 index 0000000000000000000000000000000000000000..7fe69b6f837115d80c433bbeba2d15205f775543 GIT binary patch literal 27 jcmb7G-NO|FfcPQQAo?oNj20fsVHHPJbGNAASA&%^Mo(Q@^HDI z>DpTlAt^EfD_YvK_}|ml85^bUs53upv7gp6cdZ*RGe=>%yH+X)9-V8qUN(7GBXH js-qsOUH*lr_nFtLOpupvF{l31VOybaJ6!buZ&y;-W-wmN literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/9c/c39fca3765a2facbe31157f7d60c2602193f36 b/tests/resources/cherrypick/.gitted/objects/9c/c39fca3765a2facbe31157f7d60c2602193f36 new file mode 100644 index 0000000000000000000000000000000000000000..00314454f7963adc1b554ae83228f74ed85ce284 GIT binary patch literal 107 zcmV-x0F?iD0V^p=O;s>7G-NO|FfcPQQAo?oNj20fsVHIi5O=||)kk#N@-uu>>sOmh z6Da?@4oQ&_SkdcSh5uacY~u;u@%yR~$3g{PqnD9Lij2XEJQddJi;L-==}=zlDdKWx NM}5T1lK@iqEo8;;GWP%g literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/9c/cb9bf50c011fd58dcbaa65df917bf79539717f b/tests/resources/cherrypick/.gitted/objects/9c/cb9bf50c011fd58dcbaa65df917bf79539717f new file mode 100644 index 0000000000000000000000000000000000000000..1266aff36c892a0454156b622baa9d45cb57c5b7 GIT binary patch literal 30 mcmb(agC-k*Wc$|66#Nf4uZ7~4LwhbNt literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/a1/0b59f4280491afe6e430c30654a7acc67d4a33 b/tests/resources/cherrypick/.gitted/objects/a1/0b59f4280491afe6e430c30654a7acc67d4a33 new file mode 100644 index 0000000000000000000000000000000000000000..7aa0a5dcdd07c2f776f15bf181d60abf0a746607 GIT binary patch literal 30 mcmbU(mXfDsT;Ge{-+%0OTxyxP@-EK#prH#6u`PSOHP#r_ bXiKf~mqeXLe%x9Br?07f;4JC`JaJH-!YWbg literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/a4/3a050c588d4e92f11a6b139680923e9728477d b/tests/resources/cherrypick/.gitted/objects/a4/3a050c588d4e92f11a6b139680923e9728477d new file mode 100644 index 0000000000000000000000000000000000000000..4713fb2db2bcc52a103e2054ead6937f8221d6ad GIT binary patch literal 180 zcmV;l089UP0j17OYQr!PhT*PtirELkNQ(ZTltLGQ++s8y$1aiGN;0&!kDy2B_Tl5@ zx8hDC&!SFToge+^N)#$6119s3rhgrB$y97gN!W$x1FNMZ zg-S#vj}uu&mcbj@`h96|mHgavg^RX2ulMb>!uRjL-Og)ovvfJ;rJi7LDG)jK4h|Nr aHM{PsT|bJLAAN3fQxK@yZff2~P)|%V98{tJ literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/a8/3c6f70297b805dedc549e6583582966f6ebcab b/tests/resources/cherrypick/.gitted/objects/a8/3c6f70297b805dedc549e6583582966f6ebcab new file mode 100644 index 0000000000000000000000000000000000000000..5a6db508e817dfd53f595a9318147b29532fd384 GIT binary patch literal 138 zcmV;50CoR(0V^p=O;s>7v1BkbFfcPQQAo?oNj20fsVHIa305yTBmc_$+xtVR>B-A{ zEl!-hhor~|tY{?@&n1U)Ki_n9qdhxx19PXf-YP>Dga-80D|_o?exDe`59bsg{NH0L2wOH+8Z=fdBvi literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/a9/020cd240774e4d672732bcb82d516d9685da76 b/tests/resources/cherrypick/.gitted/objects/a9/020cd240774e4d672732bcb82d516d9685da76 new file mode 100644 index 0000000000000000000000000000000000000000..61741aff9f8cea6cf5cf8e78cf20ef4ff0c97db3 GIT binary patch literal 26 icmb22BP z<9mmvj~lzb?4vI{_%Uzo85Bil3^^0v9yQ{0((~Goe?_Ku=~sc&dCfCi8t-TD0?Rr! PXus3LZJK@nIM`+;ML207 literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/ab/e4603bc7cd5b8167a267e0e2418fd2348f8cff b/tests/resources/cherrypick/.gitted/objects/ab/e4603bc7cd5b8167a267e0e2418fd2348f8cff new file mode 100644 index 0000000000000000000000000000000000000000..4e4fe6f12efd5f1fb3c27afdf5640b00c93e838e GIT binary patch literal 214 zcmV;{04e`?0i};iPQ)+}L|Nw)y_*FB+3vJI5<={dkT^uU)1JvlPQY;%+@6d^oPh1C zswb7Kway*T#)sZiA&For!WcZUD=b;jS_&mh-iY(Y*@OlC@WoA+4(yYbSS07fPRJw< zQ!Zn1I5`TMiR?t)n!moL>~DLb?0AYsOequt#*~Q@#l*-sOr@Tu*rkQ*;@fm7w}5T0OO Q`U>?HJ>8?>7g)Y#S`l1s0ssI2 literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/b8/26e9b36e22e949ec885e7a1f3db496bbab6cd0 b/tests/resources/cherrypick/.gitted/objects/b8/26e9b36e22e949ec885e7a1f3db496bbab6cd0 new file mode 100644 index 0000000000000000000000000000000000000000..e3bf3a01792dba130f6e8e3cf42cbbd464dda045 GIT binary patch literal 108 zcmV-y0F(cC0V^p=O;s>7G-NO|FfcPQQAo?oNj20fsVHIi$v^k>twU#?o)JrS6XTOS zooV;w1(G5ou%a;gl;Xv${WEv)#ZNw#5U6*#Pc9!xkug}&BjcTK9lEBzys|C+P5og{ O=cQryHUR*2`!Iay^D;vK literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/ba/fbf6912c09505ac60575cd43d3f2aba3bd84d8 b/tests/resources/cherrypick/.gitted/objects/ba/fbf6912c09505ac60575cd43d3f2aba3bd84d8 new file mode 100644 index 0000000000000000000000000000000000000000..956da8b71ca61f3604dc70fab9e9f761eff72946 GIT binary patch literal 175 zcmV;g08syU0j178Zo@DPK;g_f1@{02^<&8ff}mT_+=8K~#zAbQ5T-pb{RYl_@Z6J$e@)fHxU3uvk&k9 literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/bc/4dd0744364d1db380a9811bd264c101065231e b/tests/resources/cherrypick/.gitted/objects/bc/4dd0744364d1db380a9811bd264c101065231e new file mode 100644 index 0000000000000000000000000000000000000000..01d88a283d1f7ae6df24aef5d3e0d79533e0b9ec GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bx$S*3$NX*kKsVHHXb9(ky9!B}Ay{A{D-k(_g NeX3<)Jpgb!5}-}h7dZd` literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/bd/65d4083845ed5ed4e1fe5feb85ac395d0760c8 b/tests/resources/cherrypick/.gitted/objects/bd/65d4083845ed5ed4e1fe5feb85ac395d0760c8 new file mode 100644 index 0000000000000000000000000000000000000000..6a0eccb5ee2d78dc485202688c75d577fba665d6 GIT binary patch literal 127 zcmV-_0D%8^0j14B3PK?efZ^7jV)j9dHi|+-yP#XBZ(h$pBpnysz6Twl?YH><+-fZX z+M9!PW}xJaU9uySlj9U3I%G>}^@|I}`!z9BKvHqa);c_5eor27=U&U$=4Zg=^|R+~ hNH0<1DYtqBeGblQLx^xhgQ#}h*TR2A)E7&;JjgC9K3)I- literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/bd/6ffc8c6c41f0f85ff9e3d61c9479516bac0024 b/tests/resources/cherrypick/.gitted/objects/bd/6ffc8c6c41f0f85ff9e3d61c9479516bac0024 new file mode 100644 index 0000000000000000000000000000000000000000..56f83677969b898a35bfdd71d7133544472827b9 GIT binary patch literal 31 ncmb7G-NO|FfcPQQAo?oNj20fsVHHPJbGNAASA&%^Mo(Q@^HDI z>DpTlAt^EfD_Y6KbIGCH&o^D&XwMGaz}#uAx5|(d8G{w+tl6__e?`31A;TAeGd!=X NwaC=h0RV)BD<)fqFmC_= literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/ce/d8fb81b6ec534d5deaf2a48b4b96c799712507 b/tests/resources/cherrypick/.gitted/objects/ce/d8fb81b6ec534d5deaf2a48b4b96c799712507 new file mode 100644 index 0000000000000000000000000000000000000000..569ee0c99a758a8cba4bb0c2453b40b472b1f7c5 GIT binary patch literal 184 zcmV;p07w6L0j18(O2se`Kw;N;itL5U mrPu1@e?`RWIeX)=Fy=c;T5(^loxaPu-C5n{_Y}W$Gggq|Azz^Y literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/cf/c4f0999a8367568e049af4f72e452d40828a15 b/tests/resources/cherrypick/.gitted/objects/cf/c4f0999a8367568e049af4f72e452d40828a15 new file mode 100644 index 0000000000000000000000000000000000000000..d7deb0bff1a0edb85ea5556fa508b7ca3b1d4c97 GIT binary patch literal 180 zcmV;l089UP0j17OYQr!PK;f=+irELk=+7QODS<2ky~Rix$1aiGN;0&!uOUas_ANeM z+DchE7*B7#iU1jkNXeUQQe=z48$m&&X~1ZF^pP<;&FY)0tR2GOgl%SYE(av5Ni$L8 zVMLuJi1p)0adL|HK5rF1IsNR?;3l;!ZQlPHynj90{nC0}xbrz}>rtNsBbv{SVElvafR literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/d0/f21e17beb5b9d953b1d8349049818a4f2edd1e b/tests/resources/cherrypick/.gitted/objects/d0/f21e17beb5b9d953b1d8349049818a4f2edd1e new file mode 100644 index 0000000000000000000000000000000000000000..65c846fa4c0e9309e8dac3222882c75ede392651 GIT binary patch literal 185 zcmV;q07n0K0i}*XYQr!PMZ4B1W?u-lq>(HLp$0oShwTiy<78wp)fEjQ>1&KkrC;dRi% npgQfT!cR%m`zf_>TbSaVA+5A8J*V!Fw>#^L{EGSqCh1pM%;Q^6 literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/d3/d77487660ee3c0194ee01dc5eaf478782b1c7e b/tests/resources/cherrypick/.gitted/objects/d3/d77487660ee3c0194ee01dc5eaf478782b1c7e new file mode 100644 index 0000000000000000000000000000000000000000..b42df7e50973d08a7216ffdf9cd5a237e5be9297 GIT binary patch literal 184 zcmV;p07w6L0j17MN(3 z+UH~v`pI&wh7}&N^a1Z!z7F2ujYnJe<@nj*<>Sxh+b&~8!At4w6^zT#yAZO4XKl4s mr=F|A|B9&lA-(aK8R@}L7To4@r*AN=4|W&%7WE4%99Lw4&R#$O literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/e2/33b9ed408a95e9d4b65fec7fc34943a556deb2 b/tests/resources/cherrypick/.gitted/objects/e2/33b9ed408a95e9d4b65fec7fc34943a556deb2 new file mode 100644 index 0000000000000000000000000000000000000000..b344c9cc8a2251f512f3324e4085fc06792bbd05 GIT binary patch literal 31 ncmb7G-NO|FfcPQQAo?oNj20fsVHIaC^0#8u2Q+HVB#YsHo+^O zxXQvNASp5eD|#wn{a51gf@Kqb-F@`oY9e>BhOQx!B4e;3hgs5ZBKDh_^mQj~*WP*X NOU&1$?Eo1oF8cCFFR%ar literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/e7/811a2bc55635f182750f0420da5ad232c1af91 b/tests/resources/cherrypick/.gitted/objects/e7/811a2bc55635f182750f0420da5ad232c1af91 new file mode 100644 index 0000000000000000000000000000000000000000..2388730252b02727e7edf3e4a0e4fb35ac4e3f8a GIT binary patch literal 107 zcmV-x0F?iD0V^p=O;s>7G-NO|FfcPQQAo?oNj20fsVHIa305yTBmc_$+xtVR>B-A{ zEl!-hhor~|tY{?@&n1U)Ki_n9qdhxx19PXf-YP>xqu9kii6k#_`viJ~ZokFj zrF~uJ21vt4E2|>PZ(`e0Iif#>3PLwS(OK^VZeNam* zneu>2J&t4p2I+buN1OHnKaw7YR`}Mk&UHGT6;8i@cDvM8W@+-3_Vo;%V^7XIi|}dD cTJzTTYSVv3%yp9OrXb4#d0w=d7cH1jKo^Eo!2kdN literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/eb/da71fe44dcb60c53b8fbd53208a1204d32e959 b/tests/resources/cherrypick/.gitted/objects/eb/da71fe44dcb60c53b8fbd53208a1204d32e959 new file mode 100644 index 0000000000000000000000000000000000000000..19d0c52880ee769658a556518c99452e0e5208e3 GIT binary patch literal 36 scmb{MRzh7dB`mQ00?Xi8vp@A1VvX)jaD5bYRARn<-R&6>oi7E1Wp}Zqnc=wajhWZVf)ZpX~b8dY!rRds@pU3?@1v6D+|i tYDBfueYMN~BNpB87g1-aSAntek|sD5ZhPJA>fSJHwnSib-O literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/f2/ec8c8cf1a9fb7aa047a25a4308bfe860237ad4 b/tests/resources/cherrypick/.gitted/objects/f2/ec8c8cf1a9fb7aa047a25a4308bfe860237ad4 new file mode 100644 index 0000000000000000000000000000000000000000..a0117515ce7c973c3b64f74e5cd741c8d45b2a59 GIT binary patch literal 32 ocmb7G-NO|FfcPQQAo?oNj20fsVHHvI1trZ*DO_6I=8vJ`%miy z=0`HFNQ#WWidHi5TyiM)^G#Pb+OtD9Fn3z(tuiD<#$ZJ{Yxb<#UlA{L$nZtr49_cT MEi(0W0LmRJ?DkSF3;+NC literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/objects/f9/0f9dcbdac2cce5cc166346160e19cb693ef4e8 b/tests/resources/cherrypick/.gitted/objects/f9/0f9dcbdac2cce5cc166346160e19cb693ef4e8 new file mode 100644 index 0000000000000000000000000000000000000000..71be9f8344cfa96b5507c6838810363e0ec86ead GIT binary patch literal 31 ncmb+|D2m`>sX+V%+9EI6Gf_H5Vcp^ebE79$wXxHL-jzrF@1&$BsKMM)~ literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/refs/heads/master b/tests/resources/cherrypick/.gitted/refs/heads/master new file mode 100644 index 0000000000000000000000000000000000000000..aa8913beb94df8a497b92e77755f1318da830535 GIT binary patch literal 41 ucmV~$!4Uu;2m`Rc(?~g?j6*rye*_aWV)Bv#PngR$)EQ~eRFUD&N3%ZORSKd2 literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/refs/heads/merge-branch b/tests/resources/cherrypick/.gitted/refs/heads/merge-branch new file mode 100644 index 0000000000000000000000000000000000000000..ea5b277ecc75bdff8525b6f5a9823fcfe93be1f1 GIT binary patch literal 41 ucmV~$NdW*L2n4{tX%G;$4rl)e&P0wHNtRc?#5E5#9~#z+Z5G9%cFza&7Yktk literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/refs/heads/merge-conflicts b/tests/resources/cherrypick/.gitted/refs/heads/merge-conflicts new file mode 100644 index 0000000000000000000000000000000000000000..f63f17efb72b851c8d582178c2a87034344f1867 GIT binary patch literal 41 vcmV~$$rS)F1O>o*su6sl9Lv*x37M(fT8qm~0YbJB9(q(pma|f7T*uD`_QMN- literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/refs/heads/merge-mainline b/tests/resources/cherrypick/.gitted/refs/heads/merge-mainline new file mode 100644 index 0000000000000000000000000000000000000000..0ec5e458c5de7c524605fbc0d778192715c43148 GIT binary patch literal 41 vcmV~$$q@h`2n4Xd)gUfcISjh}mtZm+P^zl)c$nuCR1*w+Fujn}>}~4<>B0(y literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/refs/heads/orphan b/tests/resources/cherrypick/.gitted/refs/heads/orphan new file mode 100644 index 0000000000000000000000000000000000000000..f4d6a7467f3f4eae43612255f28774f8a12c0a20 GIT binary patch literal 41 ucmXpvNi#4@GEGWLO*Tt0Hcl}&GBZgtH#P$ankSkk8zfnp8Cw`yasdGC3JR+L literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/.gitted/refs/heads/renames b/tests/resources/cherrypick/.gitted/refs/heads/renames new file mode 100644 index 0000000000000000000000000000000000000000..df55871735b618afee3fe45c3c356364f25e64f8 GIT binary patch literal 41 ucmXppNlr0JO))YsHA=QjHnT{xOf)gJ1oACXEzJx~Qj(1lO-+-{4Y&a6_6pDd literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/file1.txt b/tests/resources/cherrypick/file1.txt new file mode 100644 index 0000000000000000000000000000000000000000..38c05a857e831a7e759d83778bfc85d003e21c45 GIT binary patch literal 106 RcmY#%%gjktFyx{=1pwy=8}|SJ literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/file2.txt b/tests/resources/cherrypick/file2.txt new file mode 100644 index 0000000000000000000000000000000000000000..a661b5dec1004e2c62654ded3762370c27cf266b GIT binary patch literal 106 RcmY#%%gjktFyf*;1pw*=90mXY literal 0 HcmV?d00001 diff --git a/tests/resources/cherrypick/file3.txt b/tests/resources/cherrypick/file3.txt new file mode 100644 index 0000000000000000000000000000000000000000..85a4a1d791973644f24c72f5e89420d3064cc452 GIT binary patch literal 106 RcmY#%%gjktFy^8?1pw^=92Ecn literal 0 HcmV?d00001 From 6fefb7af84170fb67a7e6c8493fc00421787bb87 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Sun, 13 Apr 2014 19:53:35 +0200 Subject: [PATCH 5/5] Capture conflict information in MERGE_MSG for revert and merge --- src/merge.c | 1 + src/revert.c | 1 + tests/merge/workdir/simple.c | 10 +++++++++- tests/revert/workdir.c | 14 +++++++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/merge.c b/src/merge.c index 371fad776..10c19b5c5 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2662,6 +2662,7 @@ int git_merge( if ((error = git_merge_trees(&index_new, repo, ancestor_tree, our_tree, their_trees[0], merge_opts)) < 0 || (error = git_merge__indexes(repo, index_new)) < 0 || (error = git_repository_index(&index_repo, repo)) < 0 || + (error = git_merge__append_conflicts_to_merge_msg(repo, index_repo)) < 0 || (error = git_checkout_index(repo, index_repo, &checkout_opts)) < 0) goto on_error; diff --git a/src/revert.c b/src/revert.c index 4039ec34c..29e124f6c 100644 --- a/src/revert.c +++ b/src/revert.c @@ -201,6 +201,7 @@ int git_revert( (error = git_revert_commit(&index_new, repo, commit, our_commit, opts.mainline, &opts.merge_opts)) < 0 || (error = git_merge__indexes(repo, index_new)) < 0 || (error = git_repository_index(&index_repo, repo)) < 0 || + (error = git_merge__append_conflicts_to_merge_msg(repo, index_repo)) < 0 || (error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0) goto on_error; diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c index 032e97f8d..cf5b16e7a 100644 --- a/tests/merge/workdir/simple.c +++ b/tests/merge/workdir/simple.c @@ -214,7 +214,7 @@ void test_merge_workdir_simple__automerge_crlf(void) void test_merge_workdir_simple__mergefile(void) { - git_buf conflicting_buf = GIT_BUF_INIT; + git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT; struct merge_index_entry merge_index_entries[] = { ADDED_IN_MASTER_INDEX_ENTRY, @@ -240,7 +240,15 @@ void test_merge_workdir_simple__mergefile(void) cl_git_pass(git_futils_readbuffer(&conflicting_buf, TEST_REPO_PATH "/conflicting.txt")); cl_assert(strcmp(conflicting_buf.ptr, CONFLICTING_MERGE_FILE) == 0); + cl_git_pass(git_futils_readbuffer(&mergemsg_buf, + TEST_REPO_PATH "/.git/MERGE_MSG")); + cl_assert(strcmp(git_buf_cstr(&mergemsg_buf), + "Merge commit '7cb63eed597130ba4abb87b3e544b85021905520'\n" \ + "\n" \ + "Conflicts:\n" \ + "\tconflicting.txt\n") == 0); git_buf_free(&conflicting_buf); + git_buf_free(&mergemsg_buf); cl_assert(merge_test_index(repo_index, merge_index_entries, 8)); cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3)); diff --git a/tests/revert/workdir.c b/tests/revert/workdir.c index 694f24710..e3d7e968a 100644 --- a/tests/revert/workdir.c +++ b/tests/revert/workdir.c @@ -66,7 +66,7 @@ void test_revert_workdir__conflicts(void) git_reference *head_ref; git_commit *head, *commit; git_oid revert_oid; - git_buf conflicting_buf = GIT_BUF_INIT; + git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT; struct merge_index_entry merge_index_entries[] = { { 0100644, "7731926a337c4eaba1e2187d90ebfa0a93659382", 1, "file1.txt" }, @@ -112,9 +112,21 @@ void test_revert_workdir__conflicts(void) "File one\n" \ ">>>>>>> parent of 72333f4... automergeable changes\n") == 0); + cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG")); + cl_git_pass(git_futils_readbuffer(&mergemsg_buf, + TEST_REPO_PATH "/.git/MERGE_MSG")); + cl_assert(strcmp(mergemsg_buf.ptr, + "Revert \"automergeable changes\"\n" \ + "\n" \ + "This reverts commit 72333f47d4e83616630ff3b0ffe4c0faebcc3c45.\n" + "\n" \ + "Conflicts:\n" \ + "\tfile1.txt\n") == 0); + git_commit_free(commit); git_commit_free(head); git_reference_free(head_ref); + git_buf_free(&mergemsg_buf); git_buf_free(&conflicting_buf); }