Remove `git_merge_result` as it's now unnecessary
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911
diff --git a/include/git2/merge.h b/include/git2/merge.h
index 7065cbc..a4432ee 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -472,27 +472,11 @@ GIT_EXTERN(int) git_merge_commits(
const git_merge_options *opts);
/**
- * Merges the given commit(s) into HEAD and either returns immediately
- * if there was no merge to perform (the specified commits have already
- * been merged or would produce a fast-forward) or performs the merge
- * and writes the results into the working directory.
+ * Merges the given commit(s) into HEAD, writing the results into the working
+ * directory. Any changes are staged for commit and any conflicts are written
+ * to the index. Callers should inspect the repository's index after this
+ * completes, resolve any conflicts and prepare a commit.
*
- * Callers should inspect the `git_merge_result`:
- *
- * If `git_merge_result_is_uptodate` is true, there is no work to perform.
- *
- * If `git_merge_result_is_fastforward` is true, the caller should update
- * any necessary references to the commit ID returned by
- * `git_merge_result_fastforward_id` and check that out in order to complete
- * the fast-forward.
- *
- * Otherwise, callers should inspect the resulting index, resolve any
- * conflicts and prepare a commit.
- *
- * The resultant `git_merge_result` should be free with
- * `git_merge_result_free`.
- *
- * @param out the results of the merge
* @param repo the repository to merge
* @param merge_heads the heads to merge into
* @param merge_heads_len the number of heads to merge
@@ -501,52 +485,12 @@ GIT_EXTERN(int) git_merge_commits(
* @return 0 on success or error code
*/
GIT_EXTERN(int) git_merge(
- git_merge_result **out,
git_repository *repo,
const git_merge_head **their_heads,
size_t their_heads_len,
const git_merge_options *merge_opts,
const git_checkout_options *checkout_opts);
-/**
- * Returns true if a merge is "up-to-date", meaning that the commit(s)
- * that were provided to `git_merge` are already included in `HEAD`
- * and there is no work to do.
- *
- * @return true if the merge is up-to-date, false otherwise
- */
-GIT_EXTERN(int) git_merge_result_is_uptodate(git_merge_result *merge_result);
-
-/**
- * Returns true if a merge is eligible to be "fast-forwarded", meaning that
- * the commit that was provided to `git_merge` need not be merged, it can
- * simply be checked out, because the current `HEAD` is the merge base of
- * itself and the given commit. To perform the fast-forward, the caller
- * should check out the results of `git_merge_result_fastforward_id`.
- *
- * This will never be true if `GIT_MERGE_NO_FASTFORWARD` is supplied as
- * a merge option.
- *
- * @return true if the merge is fast-forwardable, false otherwise
- */
-GIT_EXTERN(int) git_merge_result_is_fastforward(git_merge_result *merge_result);
-
-/**
- * Gets the fast-forward OID if the merge was a fastforward.
- *
- * @param out pointer to populate with the OID of the fast-forward
- * @param merge_result the results of the merge
- * @return 0 on success or error code
- */
-GIT_EXTERN(int) git_merge_result_fastforward_id(git_oid *out, git_merge_result *merge_result);
-
-/**
- * Frees a `git_merge_result`.
- *
- * @param result merge result to free
- */
-GIT_EXTERN(void) git_merge_result_free(git_merge_result *merge_result);
-
/** @} */
GIT_END_DECL
#endif
diff --git a/src/merge.c b/src/merge.c
index 589cf43..66b8be6 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2548,14 +2548,12 @@ done:
}
int git_merge(
- git_merge_result **out,
git_repository *repo,
const git_merge_head **their_heads,
size_t their_heads_len,
const git_merge_options *merge_opts,
const git_checkout_options *given_checkout_opts)
{
- git_merge_result *result;
git_reference *our_ref = NULL;
git_checkout_options checkout_opts;
git_merge_head *ancestor_head = NULL, *our_head = NULL;
@@ -2564,18 +2562,13 @@ int git_merge(
size_t i;
int error = 0;
- assert(out && repo && their_heads);
-
- *out = NULL;
+ assert(repo && their_heads);
if (their_heads_len != 1) {
giterr_set(GITERR_MERGE, "Can only merge a single branch");
return -1;
}
- result = git__calloc(1, sizeof(git_merge_result));
- GITERR_CHECK_ALLOC(result);
-
their_trees = git__calloc(their_heads_len, sizeof(git_tree *));
GITERR_CHECK_ALLOC(their_trees);
@@ -2610,16 +2603,12 @@ int git_merge(
(error = git_checkout_index(repo, index_repo, &checkout_opts)) < 0)
goto on_error;
- result->index = index_new;
-
- *out = result;
goto done;
on_error:
merge_state_cleanup(repo);
git_index_free(index_new);
- git__free(result);
done:
git_index_free(index_repo);
@@ -2640,41 +2629,6 @@ done:
return error;
}
-/* Merge result data */
-
-int git_merge_result_is_uptodate(git_merge_result *merge_result)
-{
- assert(merge_result);
-
- return merge_result->is_uptodate;
-}
-
-int git_merge_result_is_fastforward(git_merge_result *merge_result)
-{
- assert(merge_result);
-
- return merge_result->is_fastforward;
-}
-
-int git_merge_result_fastforward_id(git_oid *out, git_merge_result *merge_result)
-{
- assert(out && merge_result);
-
- git_oid_cpy(out, &merge_result->fastforward_oid);
- return 0;
-}
-
-void git_merge_result_free(git_merge_result *merge_result)
-{
- if (merge_result == NULL)
- return;
-
- git_index_free(merge_result->index);
- merge_result->index = NULL;
-
- git__free(merge_result);
-}
-
/* Merge heads are the input to merge */
static int merge_head_init(
diff --git a/src/merge.h b/src/merge.h
index 44c808d..2362da0 100644
--- a/src/merge.h
+++ b/src/merge.h
@@ -120,16 +120,6 @@ struct git_merge_head {
git_commit *commit;
};
-/** Internal structure for merge results */
-struct git_merge_result {
- bool is_uptodate;
-
- bool is_fastforward;
- git_oid fastforward_oid;
-
- git_index *index;
-};
-
int git_merge__bases_many(
git_commit_list **out,
git_revwalk *walk,
diff --git a/tests/merge/merge_helpers.c b/tests/merge/merge_helpers.c
index 53a0e7b..154985f 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/merge/merge_helpers.c
@@ -79,7 +79,7 @@ int merge_commits_from_branches(
return 0;
}
-int merge_branches(git_merge_result **result, git_repository *repo,
+int merge_branches(git_repository *repo,
const char *ours_branch, const char *theirs_branch,
git_merge_options *merge_opts, git_checkout_options *checkout_opts)
{
@@ -95,7 +95,7 @@ int merge_branches(git_merge_result **result, git_repository *repo,
cl_git_pass(git_reference_lookup(&theirs_ref, repo, theirs_branch));
cl_git_pass(git_merge_head_from_ref(&theirs_head, repo, theirs_ref));
- cl_git_pass(git_merge(result, repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts));
git_reference_free(head_ref);
git_reference_free(theirs_ref);
diff --git a/tests/merge/merge_helpers.h b/tests/merge/merge_helpers.h
index 71f8446..fddf8fa 100644
--- a/tests/merge/merge_helpers.h
+++ b/tests/merge/merge_helpers.h
@@ -92,7 +92,7 @@ int merge_commits_from_branches(
const char *ours_name, const char *theirs_name,
git_merge_options *opts);
-int merge_branches(git_merge_result **result, git_repository *repo,
+int merge_branches(git_repository *repo,
const char *ours_branch, const char *theirs_branch,
git_merge_options *merge_opts, git_checkout_options *checkout_opts);
diff --git a/tests/merge/workdir/dirty.c b/tests/merge/workdir/dirty.c
index 99d0d54..1d596c5 100644
--- a/tests/merge/workdir/dirty.c
+++ b/tests/merge/workdir/dirty.c
@@ -86,7 +86,7 @@ static void set_core_autocrlf_to(git_repository *repo, bool value)
git_config_free(cfg);
}
-static int merge_branch(git_merge_result **result, int merge_file_favor, int checkout_strategy)
+static int merge_branch(int merge_file_favor, int checkout_strategy)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
@@ -99,7 +99,7 @@ static int merge_branch(git_merge_result **result, int merge_file_favor, int che
merge_opts.file_favor = merge_file_favor;
checkout_opts.checkout_strategy = checkout_strategy;
- error = git_merge(result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts);
+ error = git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts);
git_merge_head_free(their_heads[0]);
@@ -177,7 +177,6 @@ static void stage_content(char *content[])
{
git_reference *head;
git_object *head_object;
- git_merge_result *result = NULL;
git_buf path = GIT_BUF_INIT;
char *filename, *text;
size_t i;
@@ -198,7 +197,6 @@ static void stage_content(char *content[])
cl_git_pass(git_index_add_bypath(repo_index, filename));
}
- git_merge_result_free(result);
git_object_free(head_object);
git_reference_free(head);
git_buf_free(&path);
@@ -208,7 +206,6 @@ static int merge_dirty_files(char *dirty_files[])
{
git_reference *head;
git_object *head_object;
- git_merge_result *result = NULL;
int error;
cl_git_pass(git_repository_head(&head, repo));
@@ -217,9 +214,8 @@ static int merge_dirty_files(char *dirty_files[])
write_files(dirty_files);
- error = merge_branch(&result, 0, 0);
+ error = merge_branch(0, 0);
- git_merge_result_free(result);
git_object_free(head_object);
git_reference_free(head);
@@ -230,7 +226,6 @@ static int merge_differently_filtered_files(char *files[])
{
git_reference *head;
git_object *head_object;
- git_merge_result *result = NULL;
int error;
cl_git_pass(git_repository_head(&head, repo));
@@ -242,9 +237,8 @@ static int merge_differently_filtered_files(char *files[])
cl_git_pass(git_index_write(repo_index));
- error = merge_branch(&result, 0, 0);
+ error = merge_branch(0, 0);
- git_merge_result_free(result);
git_object_free(head_object);
git_reference_free(head);
@@ -252,17 +246,9 @@ static int merge_differently_filtered_files(char *files[])
}
static int merge_staged_files(char *staged_files[])
-{
- git_merge_result *result = NULL;
- int error;
-
+{
stage_random_files(staged_files);
-
- error = merge_branch(&result, 0, 0);
-
- git_merge_result_free(result);
-
- return error;
+ return merge_branch(0, 0);
}
void test_merge_workdir_dirty__unaffected_dirty_files_allowed(void)
@@ -297,7 +283,6 @@ void test_merge_workdir_dirty__staged_files_in_index_disallowed(void)
void test_merge_workdir_dirty__identical_staged_files_allowed(void)
{
- git_merge_result *result;
char **content;
size_t i;
@@ -307,9 +292,7 @@ void test_merge_workdir_dirty__identical_staged_files_allowed(void)
stage_content(content);
git_index_write(repo_index);
- cl_git_pass(merge_branch(&result, 0, 0));
-
- git_merge_result_free(result);
+ cl_git_pass(merge_branch(0, 0));
}
}
diff --git a/tests/merge/workdir/renames.c b/tests/merge/workdir/renames.c
index 915a9d9..807a88f 100644
--- a/tests/merge/workdir/renames.c
+++ b/tests/merge/workdir/renames.c
@@ -34,7 +34,6 @@ void test_merge_workdir_renames__cleanup(void)
void test_merge_workdir_renames__renames(void)
{
- git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -67,16 +66,13 @@ void test_merge_workdir_renames__renames(void)
merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
merge_opts.rename_threshold = 50;
- cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
+ cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
-
- git_merge_result_free(result);
}
void test_merge_workdir_renames__ours(void)
{
git_index *index;
- git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
@@ -107,18 +103,16 @@ void test_merge_workdir_renames__ours(void)
merge_opts.rename_threshold = 50;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS;
- cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, &checkout_opts));
+ cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, &checkout_opts));
cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_index_write(index));
cl_assert(merge_test_workdir(repo, merge_index_entries, 20));
- git_merge_result_free(result);
git_index_free(index);
}
void test_merge_workdir_renames__similar(void)
{
- git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
/*
@@ -156,9 +150,7 @@ void test_merge_workdir_renames__similar(void)
merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
merge_opts.rename_threshold = 50;
- cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
+ cl_git_pass(merge_branches(repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
-
- git_merge_result_free(result);
}
diff --git a/tests/merge/workdir/setup.c b/tests/merge/workdir/setup.c
index 7085995..49b38b2 100644
--- a/tests/merge/workdir/setup.c
+++ b/tests/merge/workdir/setup.c
@@ -970,7 +970,6 @@ void test_merge_workdir_setup__retained_after_success(void)
git_oid our_oid;
git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1];
- git_merge_result *result;
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
@@ -979,7 +978,7 @@ void test_merge_workdir_setup__retained_after_success(void)
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
@@ -990,7 +989,6 @@ void test_merge_workdir_setup__retained_after_success(void)
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
- git_merge_result_free(result);
}
void test_merge_workdir_setup__removed_after_failure(void)
@@ -998,7 +996,6 @@ void test_merge_workdir_setup__removed_after_failure(void)
git_oid our_oid;
git_reference *octo1_ref;
git_merge_head *our_head, *their_heads[1];
- git_merge_result *result;
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
@@ -1010,7 +1007,7 @@ void test_merge_workdir_setup__removed_after_failure(void)
"Conflicting file!\n\nMerge will fail!\n");
cl_git_fail(git_merge(
- &result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
+ repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
cl_assert(!git_path_exists("merge-resolve/" GIT_MERGE_HEAD_FILE));
cl_assert(!git_path_exists("merge-resolve/" GIT_ORIG_HEAD_FILE));
@@ -1021,5 +1018,4 @@ void test_merge_workdir_setup__removed_after_failure(void)
git_merge_head_free(our_head);
git_merge_head_free(their_heads[0]);
- git_merge_result_free(result);
}
diff --git a/tests/merge/workdir/simple.c b/tests/merge/workdir/simple.c
index 0527832..032e97f 100644
--- a/tests/merge/workdir/simple.c
+++ b/tests/merge/workdir/simple.c
@@ -92,11 +92,10 @@ void test_merge_workdir_simple__cleanup(void)
cl_git_sandbox_cleanup();
}
-static git_merge_result *merge_simple_branch(int merge_file_favor, int checkout_strategy)
+static void merge_simple_branch(int merge_file_favor, int checkout_strategy)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
- git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
@@ -105,11 +104,9 @@ static git_merge_result *merge_simple_branch(int merge_file_favor, int checkout_
merge_opts.file_favor = merge_file_favor;
checkout_opts.checkout_strategy = checkout_strategy;
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts));
git_merge_head_free(their_heads[0]);
-
- return result;
}
static void set_core_autocrlf_to(git_repository *repo, bool value)
@@ -126,7 +123,6 @@ void test_merge_workdir_simple__automerge(void)
{
git_index *index;
const git_index_entry *entry;
- git_merge_result *result;
git_buf automergeable_buf = GIT_BUF_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -151,8 +147,7 @@ void test_merge_workdir_simple__automerge(void)
set_core_autocrlf_to(repo, false);
- cl_assert(result = merge_simple_branch(0, 0));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(0, 0);
cl_git_pass(git_futils_readbuffer(&automergeable_buf,
TEST_REPO_PATH "/automergeable.txt"));
@@ -162,8 +157,6 @@ void test_merge_workdir_simple__automerge(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
- git_merge_result_free(result);
-
git_repository_index(&index, repo);
cl_assert((entry = git_index_get_bypath(index, "automergeable.txt", 0)) != NULL);
@@ -177,8 +170,6 @@ void test_merge_workdir_simple__automerge_crlf(void)
#ifdef GIT_WIN32
git_index *index;
const git_index_entry *entry;
-
- git_merge_result *result;
git_buf automergeable_buf = GIT_BUF_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -202,8 +193,7 @@ void test_merge_workdir_simple__automerge_crlf(void)
set_core_autocrlf_to(repo, true);
- cl_assert(result = merge_simple_branch(0, 0));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(0, 0);
cl_git_pass(git_futils_readbuffer(&automergeable_buf,
TEST_REPO_PATH "/automergeable.txt"));
@@ -213,8 +203,6 @@ void test_merge_workdir_simple__automerge_crlf(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
- git_merge_result_free(result);
-
git_repository_index(&index, repo);
cl_assert((entry = git_index_get_bypath(index, "automergeable.txt", 0)) != NULL);
@@ -226,7 +214,6 @@ void test_merge_workdir_simple__automerge_crlf(void)
void test_merge_workdir_simple__mergefile(void)
{
- git_merge_result *result;
git_buf conflicting_buf = GIT_BUF_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -248,8 +235,7 @@ void test_merge_workdir_simple__mergefile(void)
REMOVED_IN_MASTER_REUC_ENTRY
};
- cl_assert(result = merge_simple_branch(0, 0));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(0, 0);
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
@@ -258,13 +244,10 @@ void test_merge_workdir_simple__mergefile(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
-
- git_merge_result_free(result);
}
void test_merge_workdir_simple__diff3(void)
{
- git_merge_result *result;
git_buf conflicting_buf = GIT_BUF_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -286,8 +269,7 @@ void test_merge_workdir_simple__diff3(void)
REMOVED_IN_MASTER_REUC_ENTRY
};
- cl_assert(result = merge_simple_branch(0, GIT_CHECKOUT_CONFLICT_STYLE_DIFF3));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(0, GIT_CHECKOUT_CONFLICT_STYLE_DIFF3);
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
@@ -296,13 +278,10 @@ void test_merge_workdir_simple__diff3(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
-
- git_merge_result_free(result);
}
void test_merge_workdir_simple__union(void)
{
- git_merge_result *result;
git_buf conflicting_buf = GIT_BUF_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -325,8 +304,7 @@ void test_merge_workdir_simple__union(void)
set_core_autocrlf_to(repo, false);
- cl_assert(result = merge_simple_branch(GIT_MERGE_FILE_FAVOR_UNION, 0));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(GIT_MERGE_FILE_FAVOR_UNION, 0);
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
@@ -335,13 +313,10 @@ void test_merge_workdir_simple__union(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 6));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 4));
-
- git_merge_result_free(result);
}
void test_merge_workdir_simple__diff3_from_config(void)
{
- git_merge_result *result;
git_config *config;
git_buf conflicting_buf = GIT_BUF_INIT;
@@ -367,8 +342,7 @@ void test_merge_workdir_simple__diff3_from_config(void)
cl_git_pass(git_repository_config(&config, repo));
cl_git_pass(git_config_set_string(config, "merge.conflictstyle", "diff3"));
- cl_assert(result = merge_simple_branch(0, 0));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(0, 0);
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
@@ -378,13 +352,11 @@ void test_merge_workdir_simple__diff3_from_config(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
- git_merge_result_free(result);
git_config_free(config);
}
void test_merge_workdir_simple__merge_overrides_config(void)
{
- git_merge_result *result;
git_config *config;
git_buf conflicting_buf = GIT_BUF_INIT;
@@ -410,8 +382,7 @@ void test_merge_workdir_simple__merge_overrides_config(void)
cl_git_pass(git_repository_config(&config, repo));
cl_git_pass(git_config_set_string(config, "merge.conflictstyle", "diff3"));
- cl_assert(result = merge_simple_branch(0, GIT_CHECKOUT_CONFLICT_STYLE_MERGE));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(0, GIT_CHECKOUT_CONFLICT_STYLE_MERGE);
cl_git_pass(git_futils_readbuffer(&conflicting_buf,
TEST_REPO_PATH "/conflicting.txt"));
@@ -421,14 +392,11 @@ void test_merge_workdir_simple__merge_overrides_config(void)
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
- git_merge_result_free(result);
git_config_free(config);
}
void test_merge_workdir_simple__checkout_ours(void)
{
- git_merge_result *result;
-
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
AUTOMERGEABLE_INDEX_ENTRY,
@@ -448,21 +416,16 @@ void test_merge_workdir_simple__checkout_ours(void)
REMOVED_IN_MASTER_REUC_ENTRY
};
- cl_assert(result = merge_simple_branch(0, GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(0, GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS);
cl_assert(merge_test_index(repo_index, merge_index_entries, 8));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 3));
cl_assert(git_path_exists(TEST_REPO_PATH "/conflicting.txt"));
-
- git_merge_result_free(result);
}
void test_merge_workdir_simple__favor_ours(void)
{
- git_merge_result *result;
-
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
AUTOMERGEABLE_INDEX_ENTRY,
@@ -479,19 +442,14 @@ void test_merge_workdir_simple__favor_ours(void)
REMOVED_IN_MASTER_REUC_ENTRY,
};
- cl_assert(result = merge_simple_branch(GIT_MERGE_FILE_FAVOR_OURS, 0));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(GIT_MERGE_FILE_FAVOR_OURS, 0);
cl_assert(merge_test_index(repo_index, merge_index_entries, 6));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 4));
-
- git_merge_result_free(result);
}
void test_merge_workdir_simple__favor_theirs(void)
{
- git_merge_result *result;
-
struct merge_index_entry merge_index_entries[] = {
ADDED_IN_MASTER_INDEX_ENTRY,
AUTOMERGEABLE_INDEX_ENTRY,
@@ -508,13 +466,10 @@ void test_merge_workdir_simple__favor_theirs(void)
REMOVED_IN_MASTER_REUC_ENTRY,
};
- cl_assert(result = merge_simple_branch(GIT_MERGE_FILE_FAVOR_THEIRS, 0));
- cl_assert(!git_merge_result_is_fastforward(result));
+ merge_simple_branch(GIT_MERGE_FILE_FAVOR_THEIRS, 0);
cl_assert(merge_test_index(repo_index, merge_index_entries, 6));
cl_assert(merge_test_reuc(repo_index, merge_reuc_entries, 4));
-
- git_merge_result_free(result);
}
void test_merge_workdir_simple__directory_file(void)
@@ -522,7 +477,6 @@ void test_merge_workdir_simple__directory_file(void)
git_reference *head;
git_oid their_oids[1], head_commit_id;
git_merge_head *their_heads[1];
- git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
git_commit *head_commit;
@@ -558,21 +512,19 @@ void test_merge_workdir_simple__directory_file(void)
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
merge_opts.file_favor = 0;
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 20));
git_reference_free(head);
git_commit_free(head_commit);
git_merge_head_free(their_heads[0]);
- git_merge_result_free(result);
}
void test_merge_workdir_simple__unrelated(void)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
- git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -591,19 +543,17 @@ void test_merge_workdir_simple__unrelated(void)
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
merge_opts.file_favor = 0;
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 9));
git_merge_head_free(their_heads[0]);
- git_merge_result_free(result);
}
void test_merge_workdir_simple__unrelated_with_conflicts(void)
{
git_oid their_oids[1];
git_merge_head *their_heads[1];
- git_merge_result *result;
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
struct merge_index_entry merge_index_entries[] = {
@@ -624,12 +574,11 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
merge_opts.file_favor = 0;
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 11));
git_merge_head_free(their_heads[0]);
- git_merge_result_free(result);
}
void test_merge_workdir_simple__binary(void)
@@ -637,7 +586,6 @@ void test_merge_workdir_simple__binary(void)
git_oid our_oid, their_oid, our_file_oid;
git_commit *our_commit;
git_merge_head *their_head;
- git_merge_result *result;
const git_index_entry *binary_entry;
struct merge_index_entry merge_index_entries[] = {
@@ -654,7 +602,7 @@ void test_merge_workdir_simple__binary(void)
cl_git_pass(git_merge_head_from_id(&their_head, repo, &their_oid));
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_assert(merge_test_index(repo_index, merge_index_entries, 3));
@@ -665,6 +613,5 @@ void test_merge_workdir_simple__binary(void)
cl_assert(git_oid_cmp(&binary_entry->id, &our_file_oid) == 0);
git_merge_head_free(their_head);
- git_merge_result_free(result);
git_commit_free(our_commit);
}
diff --git a/tests/merge/workdir/submodules.c b/tests/merge/workdir/submodules.c
index 296f30d..e093e77 100644
--- a/tests/merge/workdir/submodules.c
+++ b/tests/merge/workdir/submodules.c
@@ -31,7 +31,6 @@ void test_merge_workdir_submodules__automerge(void)
git_reference *our_ref, *their_ref;
git_commit *our_commit;
git_merge_head *their_head;
- git_merge_result *result;
git_index *index;
struct merge_index_entry merge_index_entries[] = {
@@ -50,13 +49,12 @@ void test_merge_workdir_submodules__automerge(void)
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_git_pass(git_repository_index(&index, repo));
cl_assert(merge_test_index(index, merge_index_entries, 6));
git_index_free(index);
- git_merge_result_free(result);
git_merge_head_free(their_head);
git_commit_free(our_commit);
git_reference_free(their_ref);
@@ -68,7 +66,6 @@ void test_merge_workdir_submodules__take_changed(void)
git_reference *our_ref, *their_ref;
git_commit *our_commit;
git_merge_head *their_head;
- git_merge_result *result;
git_index *index;
struct merge_index_entry merge_index_entries[] = {
@@ -85,13 +82,12 @@ void test_merge_workdir_submodules__take_changed(void)
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH));
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
cl_git_pass(git_repository_index(&index, repo));
cl_assert(merge_test_index(index, merge_index_entries, 4));
git_index_free(index);
- git_merge_result_free(result);
git_merge_head_free(their_head);
git_commit_free(our_commit);
git_reference_free(their_ref);
diff --git a/tests/merge/workdir/trivial.c b/tests/merge/workdir/trivial.c
index ffbb56c..cc82d99 100644
--- a/tests/merge/workdir/trivial.c
+++ b/tests/merge/workdir/trivial.c
@@ -34,7 +34,6 @@ static int merge_trivial(const char *ours, const char *theirs)
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
git_reference *our_ref, *their_ref;
git_merge_head *their_heads[1];
- git_merge_result *result;
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
@@ -48,13 +47,12 @@ static int merge_trivial(const char *ours, const char *theirs)
cl_git_pass(git_reference_lookup(&their_ref, repo, branch_buf.ptr));
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, their_ref));
- cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, NULL, NULL));
+ cl_git_pass(git_merge(repo, (const git_merge_head **)their_heads, 1, NULL, NULL));
git_buf_free(&branch_buf);
git_reference_free(our_ref);
git_reference_free(their_ref);
git_merge_head_free(their_heads[0]);
- git_merge_result_free(result);
return 0;
}