Merge pull request #5535 from libgit2/ethomson/strarray strarray refactoring
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 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
diff --git a/examples/checkout.c b/examples/checkout.c
index 897c42f..204b58d 100644
--- a/examples/checkout.c
+++ b/examples/checkout.c
@@ -239,7 +239,7 @@ next:
out:
git_reference_free(remote_ref);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
return error;
}
diff --git a/examples/general.c b/examples/general.c
index ddc53c3..1622ff8 100644
--- a/examples/general.c
+++ b/examples/general.c
@@ -707,7 +707,7 @@ static void reference_listing(git_repository *repo)
git_reference_free(ref);
}
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
/**
diff --git a/examples/remote.c b/examples/remote.c
index 34d8865..57f758c 100644
--- a/examples/remote.c
+++ b/examples/remote.c
@@ -129,7 +129,7 @@ static int cmd_rename(git_repository *repo, struct remote_opts *o)
puts(problems.strings[0]);
}
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
return retval;
}
@@ -207,7 +207,7 @@ static int cmd_show(git_repository *repo, struct remote_opts *o)
git_remote_free(remote);
}
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
return 0;
}
diff --git a/examples/tag.c b/examples/tag.c
index 4408294..03d9c2b 100644
--- a/examples/tag.c
+++ b/examples/tag.c
@@ -162,7 +162,7 @@ static void action_list_tags(tag_state *state)
each_tag(tag_names.strings[i], state);
}
- git_strarray_free(&tag_names);
+ git_strarray_dispose(&tag_names);
}
static void action_delete_tag(tag_state *state)
diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h
index e5e56ed..ffef145 100644
--- a/include/git2/deprecated.h
+++ b/include/git2/deprecated.h
@@ -524,6 +524,42 @@ typedef int GIT_CALLBACK(git_headlist_cb)(git_remote_head *rhead, void *payload)
/**@}*/
+/** @name Deprecated String Array Functions
+ *
+ * These types are retained for backward compatibility. The newer
+ * versions of these values should be preferred in all new code.
+ *
+ * There is no plan to remove these backward compatibility values at
+ * this time.
+ */
+/**@{*/
+
+/**
+ * Copy a string array object from source to target.
+ *
+ * This function is deprecated, but there is no plan to remove this
+ * function at this time.
+ *
+ * @param tgt target
+ * @param src source
+ * @return 0 on success, < 0 on allocation failure
+ */
+GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
+
+/**
+ * Free the memory referred to by the git_strarray. This is an alias of
+ * `git_strarray_dispose` and is preserved for backward compatibility.
+ *
+ * This function is deprecated, but there is no plan to remove this
+ * function at this time.
+ *
+ * @deprecated Use git_strarray_dispose
+ * @see git_strarray_dispose
+ */
+GIT_EXTERN(void) git_strarray_free(git_strarray *array);
+
+/**@}*/
+
/** @name Deprecated Options Initialization Functions
*
* These functions are retained for backward compatibility. The newer
diff --git a/include/git2/strarray.h b/include/git2/strarray.h
index 86fa25f..0f657e6 100644
--- a/include/git2/strarray.h
+++ b/include/git2/strarray.h
@@ -25,20 +25,16 @@ typedef struct git_strarray {
} git_strarray;
/**
- * Close a string array object
- *
- * This method should be called on `git_strarray` objects where the strings
- * array is allocated and contains allocated strings, such as what you
- * would get from `git_strarray_copy()`. Not doing so, will result in a
- * memory leak.
+ * Free the strings contained in a string array. This method should
+ * be called on `git_strarray` objects that were provided by the
+ * library. Not doing so, will result in a memory leak.
*
* This does not free the `git_strarray` itself, since the library will
- * never allocate that object directly itself (it is more commonly embedded
- * inside another struct or created on the stack).
+ * never allocate that object directly itself.
*
- * @param array git_strarray from which to free string data
+ * @param array The git_strarray that contains strings to free
*/
-GIT_EXTERN(void) git_strarray_free(git_strarray *array);
+GIT_EXTERN(void) git_strarray_dispose(git_strarray *array);
/**
* Copy a string array object from source to target.
diff --git a/src/branch.c b/src/branch.c
index 8926c89..770c9a1 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -548,7 +548,7 @@ cleanup:
if (error < 0)
git_buf_dispose(buf);
- git_strarray_free(&remote_list);
+ git_strarray_dispose(&remote_list);
return error;
}
diff --git a/src/remote.c b/src/remote.c
index 740dd94..b0ccf03 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1237,7 +1237,7 @@ static int prune_candidates(git_vector *candidates, git_remote *remote)
}
out:
- git_strarray_free(&arr);
+ git_strarray_dispose(&arr);
return error;
}
diff --git a/src/repository.c b/src/repository.c
index da92b27..5806155 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -2289,7 +2289,7 @@ int git_repository_foreach_head(git_repository *repo,
out:
git_buf_dispose(&path);
- git_strarray_free(&worktrees);
+ git_strarray_dispose(&worktrees);
return error;
}
diff --git a/src/strarray.c b/src/strarray.c
new file mode 100644
index 0000000..7ad4134
--- /dev/null
+++ b/src/strarray.c
@@ -0,0 +1,61 @@
+/*
+ * 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 "util.h"
+
+#include "common.h"
+
+int git_strarray_copy(git_strarray *tgt, const git_strarray *src)
+{
+ size_t i;
+
+ assert(tgt && src);
+
+ memset(tgt, 0, sizeof(*tgt));
+
+ if (!src->count)
+ return 0;
+
+ tgt->strings = git__calloc(src->count, sizeof(char *));
+ GIT_ERROR_CHECK_ALLOC(tgt->strings);
+
+ for (i = 0; i < src->count; ++i) {
+ if (!src->strings[i])
+ continue;
+
+ tgt->strings[tgt->count] = git__strdup(src->strings[i]);
+ if (!tgt->strings[tgt->count]) {
+ git_strarray_dispose(tgt);
+ memset(tgt, 0, sizeof(*tgt));
+ return -1;
+ }
+
+ tgt->count++;
+ }
+
+ return 0;
+}
+
+void git_strarray_dispose(git_strarray *array)
+{
+ size_t i;
+
+ if (array == NULL)
+ return;
+
+ for (i = 0; i < array->count; ++i)
+ git__free(array->strings[i]);
+
+ git__free(array->strings);
+
+ memset(array, 0, sizeof(*array));
+}
+
+void git_strarray_free(git_strarray *array)
+{
+ git_strarray_dispose(array);
+}
diff --git a/src/transports/local.c b/src/transports/local.c
index 24af7f0..210de9f 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -185,12 +185,12 @@ static int store_refs(transport_local *t)
}
t->have_refs = 1;
- git_strarray_free(&ref_names);
+ git_strarray_dispose(&ref_names);
return 0;
on_error:
git_vector_free(&t->refs);
- git_strarray_free(&ref_names);
+ git_strarray_dispose(&ref_names);
return -1;
}
diff --git a/src/transports/smart.c b/src/transports/smart.c
index bb4d2a2..5f59194 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -132,7 +132,7 @@ static int git_smart__set_custom_headers(
size_t i;
if (t->custom_headers.count)
- git_strarray_free(&t->custom_headers);
+ git_strarray_dispose(&t->custom_headers);
if (!custom_headers)
return 0;
@@ -465,7 +465,7 @@ static void git_smart__free(git_transport *transport)
git_vector_free(refs);
git__free((char *)t->proxy.url);
- git_strarray_free(&t->custom_headers);
+ git_strarray_dispose(&t->custom_headers);
git__free(t);
}
diff --git a/src/util.c b/src/util.c
index 745f840..c4e322d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -22,52 +22,6 @@
# include <Shlwapi.h>
#endif
-void git_strarray_free(git_strarray *array)
-{
- size_t i;
-
- if (array == NULL)
- return;
-
- for (i = 0; i < array->count; ++i)
- git__free(array->strings[i]);
-
- git__free(array->strings);
-
- memset(array, 0, sizeof(*array));
-}
-
-int git_strarray_copy(git_strarray *tgt, const git_strarray *src)
-{
- size_t i;
-
- assert(tgt && src);
-
- memset(tgt, 0, sizeof(*tgt));
-
- if (!src->count)
- return 0;
-
- tgt->strings = git__calloc(src->count, sizeof(char *));
- GIT_ERROR_CHECK_ALLOC(tgt->strings);
-
- for (i = 0; i < src->count; ++i) {
- if (!src->strings[i])
- continue;
-
- tgt->strings[tgt->count] = git__strdup(src->strings[i]);
- if (!tgt->strings[tgt->count]) {
- git_strarray_free(tgt);
- memset(tgt, 0, sizeof(*tgt));
- return -1;
- }
-
- tgt->count++;
- }
-
- return 0;
-}
-
int git__strntol64(int64_t *result, const char *nptr, size_t nptr_len, const char **endptr, int base)
{
const char *p;
diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c
index 8043080..13f0310 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/network/fetchlocal.c
@@ -49,7 +49,7 @@ void test_network_fetchlocal__complete(void)
cl_assert_equal_i(19, (int)refnames.count);
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
}
@@ -77,7 +77,7 @@ void test_network_fetchlocal__prune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(19, (int)refnames.count);
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2"));
@@ -90,7 +90,7 @@ void test_network_fetchlocal__prune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(18, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed"));
@@ -103,7 +103,7 @@ void test_network_fetchlocal__prune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(17, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
@@ -168,7 +168,7 @@ void test_network_fetchlocal__prune_overlapping(void)
assert_ref_exists(repo, "refs/remotes/origin/pr/42");
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(20, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs"));
cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/pull/*/head:refs/remotes/origin/pr/*"));
@@ -183,7 +183,7 @@ void test_network_fetchlocal__prune_overlapping(void)
assert_ref_exists(repo, "refs/remotes/origin/pr/42");
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(20, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs"));
cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/heads/*:refs/remotes/origin/*"));
@@ -195,7 +195,7 @@ void test_network_fetchlocal__prune_overlapping(void)
cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
git_config_free(config);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
}
@@ -224,7 +224,7 @@ void test_network_fetchlocal__fetchprune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(19, (int)refnames.count);
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2"));
@@ -237,7 +237,7 @@ void test_network_fetchlocal__fetchprune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(18, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed"));
@@ -253,7 +253,7 @@ void test_network_fetchlocal__fetchprune(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(17, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
git_repository_free(repo);
@@ -333,13 +333,13 @@ void test_network_fetchlocal__partial(void)
cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(20, (int)refnames.count); /* 18 remote + 1 local */
cl_assert(callcount > 0);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(origin);
}
@@ -420,7 +420,7 @@ void test_network_fetchlocal__multi_remotes(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(33, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
cl_git_pass(git_remote_set_url(repo, "test_with_pushurl", cl_git_fixture_url("testrepo.git")));
cl_git_pass(git_remote_lookup(&test2, repo, "test_with_pushurl"));
@@ -429,7 +429,7 @@ void test_network_fetchlocal__multi_remotes(void)
cl_git_pass(git_reference_list(&refnames, repo));
cl_assert_equal_i(45, (int)refnames.count);
- git_strarray_free(&refnames);
+ git_strarray_dispose(&refnames);
git_remote_free(test);
git_remote_free(test2);
}
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index a29281d..0694a6f 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -61,7 +61,7 @@ static int urlresolve_callback(git_buf *url_resolved, const char *url, int direc
cl_assert(strcmp(url, "git://github.com/libgit2/libgit2") == 0);
cl_assert(strcmp(payload, "payload") == 0);
cl_assert(url_resolved->size == 0);
-
+
if (direction == GIT_DIRECTION_PUSH)
git_buf_sets(url_resolved, "pushresolve");
if (direction == GIT_DIRECTION_FETCH)
@@ -215,11 +215,11 @@ void test_network_remote_remotes__dup(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, _remote));
cl_assert_equal_i(1, (int)array.count);
cl_assert_equal_s("+refs/heads/*:refs/remotes/test/*", array.strings[0]);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
cl_git_pass(git_remote_get_push_refspecs(&array, _remote));
cl_assert_equal_i(0, (int)array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(dup);
}
@@ -318,7 +318,7 @@ void test_network_remote_remotes__list(void)
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 5);
- git_strarray_free(&list);
+ git_strarray_dispose(&list);
cl_git_pass(git_repository_config(&cfg, _repo));
@@ -330,7 +330,7 @@ void test_network_remote_remotes__list(void)
cl_git_pass(git_remote_list(&list, _repo));
cl_assert(list.count == 7);
- git_strarray_free(&list);
+ git_strarray_dispose(&list);
git_config_free(cfg);
}
@@ -466,13 +466,13 @@ void test_network_remote_remotes__query_refspecs(void)
for (i = 0; i < 3; i++) {
cl_assert_equal_s(fetch_refspecs[i], array.strings[i]);
}
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
cl_git_pass(git_remote_get_push_refspecs(&array, remote));
for (i = 0; i < 3; i++) {
cl_assert_equal_s(push_refspecs[i], array.strings[i]);
}
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
git_remote_delete(_repo, "test");
diff --git a/tests/network/remote/rename.c b/tests/network/remote/rename.c
index 0449575..1fd2aff 100644
--- a/tests/network/remote/rename.c
+++ b/tests/network/remote/rename.c
@@ -25,7 +25,7 @@ void test_network_remote_rename__renaming_a_remote_moves_related_configuration_s
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_existence(_repo, "remote.test.fetch", false);
assert_config_entry_existence(_repo, "remote.just/renamed.fetch", true);
@@ -39,7 +39,7 @@ void test_network_remote_rename__renaming_a_remote_updates_branch_related_config
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_value(_repo, "branch.master.remote", "just/renamed");
}
@@ -50,7 +50,7 @@ void test_network_remote_rename__renaming_a_remote_updates_default_fetchrefspec(
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/heads/*:refs/remotes/just/renamed/*");
}
@@ -71,7 +71,7 @@ void test_network_remote_rename__renaming_a_remote_without_a_fetchrefspec_doesnt
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_existence(_repo, "remote.just/renamed.fetch", false);
}
@@ -90,11 +90,11 @@ void test_network_remote_rename__renaming_a_remote_notifies_of_non_default_fetch
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(1, problems.count);
cl_assert_equal_s("+refs/*:refs/*", problems.strings[0]);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/*:refs/*");
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
}
void test_network_remote_rename__new_name_can_contain_dots(void)
@@ -103,7 +103,7 @@ void test_network_remote_rename__new_name_can_contain_dots(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just.renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
assert_config_entry_existence(_repo, "remote.just.renamed.fetch", true);
}
@@ -126,7 +126,7 @@ void test_network_remote_rename__renamed_name_is_persisted(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_git_pass(git_repository_open(&another_repo, "testrepo.git"));
cl_git_pass(git_remote_lookup(&renamed, _repo, "just/renamed"));
@@ -154,7 +154,7 @@ void test_network_remote_rename__renaming_a_remote_moves_the_underlying_referenc
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&underlying, _repo, "refs/remotes/test/master"));
cl_git_pass(git_reference_lookup(&underlying, _repo, "refs/remotes/just/renamed/master"));
@@ -176,7 +176,7 @@ void test_network_remote_rename__overwrite_ref_in_target(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
/* make sure there's only one remote-tracking branch */
cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE));
@@ -214,7 +214,7 @@ void test_network_remote_rename__symref_head(void)
cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "renamed"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_git_pass(git_vector_init(&refs, 2, (git_vector_cmp) git_reference_cmp));
cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE));
diff --git a/tests/object/tag/list.c b/tests/object/tag/list.c
index b8d507f..8a1a2d2 100644
--- a/tests/object/tag/list.c
+++ b/tests/object/tag/list.c
@@ -50,7 +50,7 @@ static void ensure_tag_pattern_match(git_repository *repo,
cl_assert_equal_i((int)sucessfully_found, (int)data->expected_matches);
exit:
- git_strarray_free(&tag_list);
+ git_strarray_dispose(&tag_list);
cl_git_pass(error);
}
@@ -74,7 +74,7 @@ void test_object_tag_list__list_all(void)
cl_assert_equal_i((int)tag_list.count, 6);
- git_strarray_free(&tag_list);
+ git_strarray_dispose(&tag_list);
}
static const struct pattern_match_t matches[] = {
diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c
index 32e7419..b619931 100644
--- a/tests/online/fetchhead.c
+++ b/tests/online/fetchhead.c
@@ -43,7 +43,7 @@ static size_t count_references(void)
cl_git_pass(git_reference_list(&array, g_repo));
refs = array.count;
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
return refs;
}
diff --git a/tests/online/remotes.c b/tests/online/remotes.c
index d79eb1f..f7fe414 100644
--- a/tests/online/remotes.c
+++ b/tests/online/remotes.c
@@ -32,7 +32,7 @@ void test_online_remotes__single_branch(void)
}
cl_assert_equal_i(1, count);
- git_strarray_free(&refs);
+ git_strarray_dispose(&refs);
cl_git_pass(git_remote_lookup(&remote, repo, "origin"));
cl_git_pass(git_remote_get_fetch_refspecs(&refs, remote));
@@ -40,7 +40,7 @@ void test_online_remotes__single_branch(void)
cl_assert_equal_i(1, refs.count);
cl_assert_equal_s(REFSPEC, refs.strings[0]);
- git_strarray_free(&refs);
+ git_strarray_dispose(&refs);
git_remote_free(remote);
git_repository_free(repo);
}
diff --git a/tests/refs/list.c b/tests/refs/list.c
index 725d381..8085ff8 100644
--- a/tests/refs/list.c
+++ b/tests/refs/list.c
@@ -38,7 +38,7 @@ void test_refs_list__all(void)
* loose, but we only list it once */
cl_assert_equal_i((int)ref_list.count, 19);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void)
@@ -53,5 +53,5 @@ void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_exten
cl_git_pass(git_reference_list(&ref_list, g_repo));
cl_assert_equal_i((int)ref_list.count, 19);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
diff --git a/tests/refs/listall.c b/tests/refs/listall.c
index c696fbb..9da8d1a 100644
--- a/tests/refs/listall.c
+++ b/tests/refs/listall.c
@@ -16,7 +16,7 @@ static void ensure_no_refname_starts_with_a_forward_slash(const char *path)
for (i = 0; i < ref_list.count; i++)
cl_assert(git__prefixcmp(ref_list.strings[i], "/") != 0);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
git_repository_free(repo);
}
@@ -42,6 +42,6 @@ void test_refs_listall__from_repository_with_no_trailing_newline(void)
cl_assert(ref_list.count > 0);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
git_repository_free(repo);
}
diff --git a/tests/refs/namespaces.c b/tests/refs/namespaces.c
index bb6bb1c..19456b5 100644
--- a/tests/refs/namespaces.c
+++ b/tests/refs/namespaces.c
@@ -32,5 +32,5 @@ void test_refs_namespaces__namespace_doesnt_show_normal_refs(void)
cl_git_pass(git_repository_set_namespace(g_repo, "namespace"));
cl_git_pass(git_reference_list(&ref_list, g_repo));
cl_assert_equal_i(0, ref_list.count);
- git_strarray_free(&ref_list);
+ git_strarray_dispose(&ref_list);
}
diff --git a/tests/remote/create.c b/tests/remote/create.c
index 5109623..f92be9d 100644
--- a/tests/remote/create.c
+++ b/tests/remote/create.c
@@ -117,7 +117,7 @@ void test_remote_create__with_fetchspec(void)
cl_assert_equal_i(1, array.count);
cl_assert_equal_i(section_count + 2, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -132,7 +132,7 @@ void test_remote_create__with_empty_fetchspec(void)
cl_assert_equal_i(0, array.count);
cl_assert_equal_i(section_count + 1, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -167,7 +167,7 @@ void test_remote_create__anonymous(void)
cl_assert_equal_i(0, array.count);
cl_assert_equal_i(section_count, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -195,7 +195,7 @@ void test_remote_create__detached(void)
cl_assert_equal_i(0, array.count);
cl_assert_equal_i(section_count, count_config_entries_match(_repo, "remote\\."));
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -225,7 +225,7 @@ void test_remote_create__with_opts_named(void)
cl_assert_equal_i(1, array.count);
cl_assert_equal_s("+refs/heads/*:refs/remotes/test-new/*", array.strings[0]);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -248,7 +248,7 @@ void test_remote_create__with_opts_named_and_fetchspec(void)
cl_assert_equal_i(1, array.count);
cl_assert_equal_s("+refs/*:refs/*", array.strings[0]);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -270,7 +270,7 @@ void test_remote_create__with_opts_named_no_fetchspec(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -290,7 +290,7 @@ void test_remote_create__with_opts_anonymous(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
@@ -308,7 +308,7 @@ void test_remote_create__with_opts_detached(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
@@ -320,7 +320,7 @@ void test_remote_create__with_opts_detached(void)
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
cl_assert_equal_i(0, array.count);
- git_strarray_free(&array);
+ git_strarray_dispose(&array);
git_remote_free(remote);
}
diff --git a/tests/remote/list.c b/tests/remote/list.c
index 5abb951..4a6be3d 100644
--- a/tests/remote/list.c
+++ b/tests/remote/list.c
@@ -25,17 +25,17 @@ void test_remote_list__always_checks_disk_config(void)
cl_git_pass(git_remote_list(&remotes, _repo));
cl_assert_equal_sz(remotes.count, 1);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
cl_git_pass(git_remote_create(&remote, _repo, "valid-name", TEST_URL));
cl_git_pass(git_remote_list(&remotes, _repo));
cl_assert_equal_sz(remotes.count, 2);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
cl_git_pass(git_remote_list(&remotes, repo));
cl_assert_equal_sz(remotes.count, 2);
- git_strarray_free(&remotes);
+ git_strarray_dispose(&remotes);
git_repository_free(repo);
git_remote_free(remote);
diff --git a/tests/submodule/add.c b/tests/submodule/add.c
index f4d1e3b..fc458f8 100644
--- a/tests/submodule/add.c
+++ b/tests/submodule/add.c
@@ -90,7 +90,7 @@ void test_submodule_add__url_relative(void)
/* make sure we don't default to origin - rename origin -> test_remote */
cl_git_pass(git_remote_rename(&problems, g_repo, "origin", "test_remote"));
cl_assert_equal_i(0, problems.count);
- git_strarray_free(&problems);
+ git_strarray_dispose(&problems);
cl_git_fail(git_remote_lookup(&remote, g_repo, "origin"));
cl_git_pass(
diff --git a/tests/worktree/bare.c b/tests/worktree/bare.c
index 2a0e882..7234dff 100644
--- a/tests/worktree/bare.c
+++ b/tests/worktree/bare.c
@@ -28,7 +28,7 @@ void test_worktree_bare__list(void)
cl_git_pass(git_worktree_list(&wts, g_repo));
cl_assert_equal_i(wts.count, 0);
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
}
void test_worktree_bare__add(void)
@@ -48,7 +48,7 @@ void test_worktree_bare__add(void)
cl_assert_equal_i(0, git_repository_is_bare(wtrepo));
cl_assert_equal_i(1, git_repository_is_worktree(wtrepo));
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
git_worktree_free(wt);
git_repository_free(wtrepo);
}
diff --git a/tests/worktree/refs.c b/tests/worktree/refs.c
index e62149d..5012552 100644
--- a/tests/worktree/refs.c
+++ b/tests/worktree/refs.c
@@ -56,8 +56,8 @@ void test_worktree_refs__list(void)
}
exit:
- git_strarray_free(&refs);
- git_strarray_free(&wtrefs);
+ git_strarray_dispose(&refs);
+ git_strarray_dispose(&wtrefs);
cl_git_pass(error);
}
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c
index 5e99dbf..716d0aa 100644
--- a/tests/worktree/worktree.c
+++ b/tests/worktree/worktree.c
@@ -30,7 +30,7 @@ void test_worktree_worktree__list(void)
cl_assert_equal_i(wts.count, 1);
cl_assert_equal_s(wts.strings[0], "testrepo-worktree");
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
}
void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
@@ -61,7 +61,7 @@ void test_worktree_worktree__list_with_invalid_worktree_dirs(void)
cl_git_pass(git_worktree_list(&wts, fixture.worktree));
cl_assert_equal_i(wts.count, 1);
cl_assert_equal_s(wts.strings[0], "testrepo-worktree");
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
for (j = 0; j < ARRAY_SIZE(filesets[i]); j++) {
git_buf_truncate(&path, len);
@@ -81,7 +81,7 @@ void test_worktree_worktree__list_in_worktree_repo(void)
cl_assert_equal_i(wts.count, 1);
cl_assert_equal_s(wts.strings[0], "testrepo-worktree");
- git_strarray_free(&wts);
+ git_strarray_dispose(&wts);
}
void test_worktree_worktree__list_without_worktrees(void)
@@ -380,7 +380,7 @@ void test_worktree_worktree__name(void)
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
cl_assert_equal_s(git_worktree_name(wt), "testrepo-worktree");
-
+
git_worktree_free(wt);
}