Fix diff constructor name order confusion The diff constructor functions had some confusing names, where the "old" side of the diff was coming after the "new" side. This reverses the order in the function name to make it less confusing. Specifically... * git_diff_index_to_tree becomes git_diff_tree_to_index * git_diff_workdir_to_index becomes git_diff_index_to_workdir * git_diff_workdir_to_tree becomes git_diff_tree_to_workdir
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
diff --git a/examples/Makefile b/examples/Makefile
index da4df52..b306d48 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,7 +1,7 @@
.PHONY: all
CC = gcc
-CFLAGS = -g -I../include -I../src -Wall -Wextra -Wmissing-prototypes
+CFLAGS = -g -I../include -I../src -Wall -Wextra -Wmissing-prototypes -Wno-missing-field-initializers
LFLAGS = -L../build -lgit2 -lz
APPS = general showindex diff
diff --git a/examples/diff.c b/examples/diff.c
index b81a868..63956aa 100644
--- a/examples/diff.c
+++ b/examples/diff.c
@@ -110,12 +110,12 @@ static int check_uint16_param(const char *arg, const char *pattern, uint16_t *va
return 1;
}
-static int check_str_param(const char *arg, const char *pattern, char **val)
+static int check_str_param(const char *arg, const char *pattern, const char **val)
{
size_t len = strlen(pattern);
if (strncmp(arg, pattern, len))
return 0;
- *val = (char *)(arg + len);
+ *val = (const char *)(arg + len);
return 1;
}
@@ -206,20 +206,20 @@ int main(int argc, char *argv[])
if (t1 && t2)
check(git_diff_tree_to_tree(&diff, repo, t1, t2, &opts), "Diff");
else if (t1 && cached)
- check(git_diff_index_to_tree(&diff, repo, t1, NULL, &opts), "Diff");
+ check(git_diff_tree_to_index(&diff, repo, t1, NULL, &opts), "Diff");
else if (t1) {
git_diff_list *diff2;
- check(git_diff_index_to_tree(&diff, repo, t1, NULL, &opts), "Diff");
- check(git_diff_workdir_to_index(&diff2, repo, NULL, &opts), "Diff");
+ check(git_diff_tree_to_index(&diff, repo, t1, NULL, &opts), "Diff");
+ check(git_diff_index_to_workdir(&diff2, repo, NULL, &opts), "Diff");
check(git_diff_merge(diff, diff2), "Merge diffs");
git_diff_list_free(diff2);
}
else if (cached) {
check(resolve_to_tree(repo, "HEAD", &t1), "looking up HEAD");
- check(git_diff_index_to_tree(&diff, repo, t1, NULL, &opts), "Diff");
+ check(git_diff_tree_to_index(&diff, repo, t1, NULL, &opts), "Diff");
}
else
- check(git_diff_workdir_to_index(&diff, repo, NULL, &opts), "Diff");
+ check(git_diff_index_to_workdir(&diff, repo, NULL, &opts), "Diff");
if (color >= 0)
fputs(colors[0], stdout);
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 49f781d..f1db90d 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -227,15 +227,21 @@ typedef struct {
/**
* Description of changes to one file.
*
- * When iterating over a diff list object, this will generally be passed to
- * most callback functions and you can use the contents to understand
- * exactly what has changed.
- *
- * Under some circumstances, not all fields will be filled in, but the code
- * generally tries to fill in as much as possible. One example is that the
- * "binary" field will not actually look at file contents if you do not
- * pass in hunk and/or line callbacks to the diff foreach iteration function.
- * It will just use the git attributes for those files.
+ * The `old_file` repesents the "from" side of the diff and the `new_file`
+ * repesents to "to" side of the diff. What those means depend on the
+ * function that was used to generate the diff and will be documented below.
+ * You can also use the `GIT_DIFF_REVERSE` flag to flip it around.
+ *
+ * Although the two sides of the delta are named "old_file" and "new_file",
+ * they actually may correspond to entries that represent a file, a symbolic
+ * link, a submodule commit id, or even a tree (if you are tracking type
+ * changes or ignored/untracked directories).
+ *
+ * Under some circumstances, in the name of efficiency, not all fields will
+ * be filled in, but we generally try to fill in as much as possible. One
+ * example is that the "binary" field will not examine file contents if you
+ * do not pass in hunk and/or line callbacks to the diff foreach iteration
+ * function. It will just use the git attributes for those files.
*/
typedef struct {
git_diff_file old_file;
@@ -381,9 +387,12 @@ typedef struct {
GIT_EXTERN(void) git_diff_list_free(git_diff_list *diff);
/**
- * Compute a difference between two tree objects.
+ * Create a diff list with the difference between two tree objects.
+ *
+ * This is equivalent to `git diff <old-tree> <new-tree>`
*
- * This is equivalent to `git diff <treeish> <treeish>`
+ * The first tree will be used for the "old_file" side of the delta and the
+ * second tree will be used for the "new_file" side of the delta.
*
* @param diff Output pointer to a git_diff_list pointer to be allocated.
* @param repo The repository containing the trees.
@@ -399,18 +408,21 @@ GIT_EXTERN(int) git_diff_tree_to_tree(
const git_diff_options *opts); /**< can be NULL for defaults */
/**
- * Compute a difference between a tree and the repository index.
+ * Create a diff list between a tree and repository index.
*
* This is equivalent to `git diff --cached <treeish>` or if you pass
* the HEAD tree, then like `git diff --cached`.
*
+ * The tree you pass will be used for the "old_file" side of the delta, and
+ * the index will be used for the "new_file" side of the delta.
+ *
* @param diff Output pointer to a git_diff_list pointer to be allocated.
* @param repo The repository containing the tree and index.
* @param old_tree A git_tree object to diff from.
* @param index The index to diff with; repo index used if NULL.
* @param opts Structure with options to influence diff or NULL for defaults.
*/
-GIT_EXTERN(int) git_diff_index_to_tree(
+GIT_EXTERN(int) git_diff_tree_to_index(
git_diff_list **diff,
git_repository *repo,
git_tree *old_tree,
@@ -418,40 +430,45 @@ GIT_EXTERN(int) git_diff_index_to_tree(
const git_diff_options *opts); /**< can be NULL for defaults */
/**
- * Compute a difference between the working directory and the repository index.
+ * Create a diff list between the repository index and the workdir directory.
*
* This matches the `git diff` command. See the note below on
- * `git_diff_workdir_to_tree` for a discussion of the difference between
+ * `git_diff_tree_to_workdir` for a discussion of the difference between
* `git diff` and `git diff HEAD` and how to emulate a `git diff <treeish>`
* using libgit2.
*
+ * The index will be used for the "old_file" side of the delta, and the
+ * working directory will be used for the "new_file" side of the delta.
+ *
* @param diff Output pointer to a git_diff_list pointer to be allocated.
* @param repo The repository.
* @param index The index to diff from; repo index used if NULL.
* @param opts Structure with options to influence diff or NULL for defaults.
*/
-GIT_EXTERN(int) git_diff_workdir_to_index(
+GIT_EXTERN(int) git_diff_index_to_workdir(
git_diff_list **diff,
git_repository *repo,
git_index *index,
const git_diff_options *opts); /**< can be NULL for defaults */
/**
- * Compute a difference between the working directory and a tree.
+ * Create a diff list between a tree and the working directory.
+ *
+ * The tree you provide will be used for the "old_file" side of the delta,
+ * and the working directory will be used for the "new_file" side.
*
- * This is *NOT* the same as `git diff <treeish>`. Running `git diff HEAD`
- * or the like actually uses information from the index, along with the tree
- * and workdir dir info.
+ * Please note: this is *NOT* the same as `git diff <treeish>`. Running
+ * `git diff HEAD` or the like actually uses information from the index,
+ * along with the tree and working directory info.
*
* This function returns strictly the differences between the tree and the
* files contained in the working directory, regardless of the state of
* files in the index. It may come as a surprise, but there is no direct
* equivalent in core git.
*
- * To emulate `git diff <treeish>`, you should call both
- * `git_diff_index_to_tree` and `git_diff_workdir_to_index`, then call
- * `git_diff_merge` on the results. That will yield a `git_diff_list` that
- * matches the git output.
+ * To emulate `git diff <treeish>`, call both `git_diff_tree_to_index` and
+ * `git_diff_index_to_workdir`, then call `git_diff_merge` on the results.
+ * That will yield a `git_diff_list` that matches the git output.
*
* If this seems confusing, take the case of a file with a staged deletion
* where the file has then been put back into the working dir and modified.
@@ -463,7 +480,7 @@ GIT_EXTERN(int) git_diff_workdir_to_index(
* @param old_tree A git_tree object to diff from.
* @param opts Structure with options to influence diff or NULL for defaults.
*/
-GIT_EXTERN(int) git_diff_workdir_to_tree(
+GIT_EXTERN(int) git_diff_tree_to_workdir(
git_diff_list **diff,
git_repository *repo,
git_tree *old_tree,
diff --git a/src/checkout.c b/src/checkout.c
index d9f0f8f..972366f 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -632,7 +632,7 @@ int git_checkout_index(
if (opts && opts->paths.count > 0)
diff_opts.pathspec = opts->paths;
- if ((error = git_diff_workdir_to_index(&diff, repo, index, &diff_opts)) < 0)
+ if ((error = git_diff_index_to_workdir(&diff, repo, index, &diff_opts)) < 0)
goto cleanup;
if ((error = git_buf_puts(&workdir, git_repository_workdir(repo))) < 0)
diff --git a/src/diff.c b/src/diff.c
index 822ae5b..9c0b45f 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -784,7 +784,7 @@ int git_diff_tree_to_tree(
return error;
}
-int git_diff_index_to_tree(
+int git_diff_tree_to_index(
git_diff_list **diff,
git_repository *repo,
git_tree *old_tree,
@@ -806,7 +806,7 @@ int git_diff_index_to_tree(
return error;
}
-int git_diff_workdir_to_index(
+int git_diff_index_to_workdir(
git_diff_list **diff,
git_repository *repo,
git_index *index,
@@ -828,7 +828,7 @@ int git_diff_workdir_to_index(
}
-int git_diff_workdir_to_tree(
+int git_diff_tree_to_workdir(
git_diff_list **diff,
git_repository *repo,
git_tree *old_tree,
diff --git a/src/stash.c b/src/stash.c
index e32d8fa..705fc75 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -251,7 +251,7 @@ static int build_untracked_tree(
if (git_commit_tree(&i_tree, i_commit) < 0)
goto cleanup;
- if (git_diff_workdir_to_tree(&diff, git_index_owner(index), i_tree, &opts) < 0)
+ if (git_diff_tree_to_workdir(&diff, git_index_owner(index), i_tree, &opts) < 0)
goto cleanup;
if (git_diff_foreach(diff, update_index_cb, NULL, NULL, &data) < 0)
@@ -323,10 +323,10 @@ static int build_workdir_tree(
if (git_commit_tree(&b_tree, b_commit) < 0)
goto cleanup;
- if (git_diff_index_to_tree(&diff, repo, b_tree, NULL, &opts) < 0)
+ if (git_diff_tree_to_index(&diff, repo, b_tree, NULL, &opts) < 0)
goto cleanup;
- if (git_diff_workdir_to_index(&diff2, repo, NULL, &opts) < 0)
+ if (git_diff_index_to_workdir(&diff2, repo, NULL, &opts) < 0)
goto cleanup;
if (git_diff_merge(diff, diff2) < 0)
diff --git a/src/status.c b/src/status.c
index 1ad835a..115217c 100644
--- a/src/status.c
+++ b/src/status.c
@@ -145,11 +145,11 @@ int git_status_foreach_ext(
/* TODO: support EXCLUDE_SUBMODULES flag */
if (show != GIT_STATUS_SHOW_WORKDIR_ONLY &&
- (err = git_diff_index_to_tree(&idx2head, repo, head, NULL, &diffopt)) < 0)
+ (err = git_diff_tree_to_index(&idx2head, repo, head, NULL, &diffopt)) < 0)
goto cleanup;
if (show != GIT_STATUS_SHOW_INDEX_ONLY &&
- (err = git_diff_workdir_to_index(&wd2idx, repo, NULL, &diffopt)) < 0)
+ (err = git_diff_index_to_workdir(&wd2idx, repo, NULL, &diffopt)) < 0)
goto cleanup;
usercb.cb = cb;
diff --git a/src/submodule.c b/src/submodule.c
index 3d9950d..94b4f72 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -1454,7 +1454,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
if (sm->ignore == GIT_SUBMODULE_IGNORE_NONE)
opt.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
- error = git_diff_index_to_tree(&diff, sm_repo, sm_head, NULL, &opt);
+ error = git_diff_tree_to_index(&diff, sm_repo, sm_head, NULL, &opt);
if (!error) {
if (git_diff_num_deltas(diff) > 0)
@@ -1471,7 +1471,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
/* perform index-to-workdir diff on submodule */
- error = git_diff_workdir_to_index(&diff, sm_repo, NULL, &opt);
+ error = git_diff_index_to_workdir(&diff, sm_repo, NULL, &opt);
if (!error) {
size_t untracked =
diff --git a/tests-clar/diff/diffiter.c b/tests-clar/diff/diffiter.c
index 306a13e..8d550ec 100644
--- a/tests-clar/diff/diffiter.c
+++ b/tests-clar/diff/diffiter.c
@@ -16,7 +16,7 @@ void test_diff_diffiter__create(void)
git_diff_list *diff;
size_t d, num_d;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -34,7 +34,7 @@ void test_diff_diffiter__iterate_files(void)
size_t d, num_d;
int count = 0;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(6, (int)num_d);
@@ -57,7 +57,7 @@ void test_diff_diffiter__iterate_files_2(void)
size_t d, num_d;
int count = 0;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(8, (int)num_d);
@@ -85,7 +85,7 @@ void test_diff_diffiter__iterate_files_and_hunks(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff);
@@ -138,7 +138,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -173,7 +173,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
opts.max_size = 50; /* treat anything over 50 bytes as binary! */
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -216,7 +216,7 @@ void test_diff_diffiter__iterate_all(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
@@ -292,7 +292,7 @@ void test_diff_diffiter__iterate_randomly_while_saving_state(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, &opts));
num_d = git_diff_num_deltas(diff);
@@ -419,7 +419,7 @@ void test_diff_diffiter__iterate_and_generate_patch_text(void)
git_diff_list *diff;
size_t d, num_d;
- cl_git_pass(git_diff_workdir_to_index(&diff, repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, repo, NULL, NULL));
num_d = git_diff_num_deltas(diff);
cl_assert_equal_i(8, (int)num_d);
@@ -452,13 +452,13 @@ void test_diff_diffiter__checks_options_version(void)
opts.version = 0;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_fail(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
+ cl_git_fail(git_diff_index_to_workdir(&diff, repo, NULL, &opts));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
giterr_clear();
opts.version = 1024;
- cl_git_fail(git_diff_workdir_to_index(&diff, repo, NULL, &opts));
+ cl_git_fail(git_diff_index_to_workdir(&diff, repo, NULL, &opts));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
}
diff --git a/tests-clar/diff/index.c b/tests-clar/diff/index.c
index 267b329..41941ee 100644
--- a/tests-clar/diff/index.c
+++ b/tests-clar/diff/index.c
@@ -32,7 +32,7 @@ void test_diff_index__0(void)
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
cl_git_pass(git_diff_foreach(
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
@@ -60,7 +60,7 @@ void test_diff_index__0(void)
diff = NULL;
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_index_to_tree(&diff, g_repo, b, NULL, &opts));
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, b, NULL, &opts));
cl_git_pass(git_diff_foreach(
diff, diff_file_cb, diff_hunk_cb, diff_line_cb, &exp));
@@ -125,7 +125,7 @@ void test_diff_index__1(void)
memset(&exp, 0, sizeof(exp));
- cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
cl_assert_equal_i(
GIT_EUSER,
@@ -150,13 +150,13 @@ void test_diff_index__checks_options_version(void)
const git_error *err;
opts.version = 0;
- cl_git_fail(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
+ cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
giterr_clear();
opts.version = 1024;
- cl_git_fail(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
+ cl_git_fail(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
}
diff --git a/tests-clar/diff/workdir.c b/tests-clar/diff/workdir.c
index 10d58b1..1b1b616 100644
--- a/tests-clar/diff/workdir.c
+++ b/tests-clar/diff/workdir.c
@@ -26,7 +26,7 @@ void test_diff_workdir__to_index(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -84,7 +84,7 @@ void test_diff_workdir__to_tree(void)
opts.interhunk_lines = 1;
opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED;
- /* You can't really generate the equivalent of git_diff_workdir_to_tree()
+ /* You can't really generate the equivalent of git_diff_tree_to_workdir()
* using C git. It really wants to interpose the index into the diff.
*
* To validate the following results with command line git, I ran the
@@ -94,7 +94,7 @@ void test_diff_workdir__to_tree(void)
* The results are documented at the bottom of this file in the
* long comment entitled "PREPARATION OF TEST DATA".
*/
- cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, a, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -127,8 +127,8 @@ void test_diff_workdir__to_tree(void)
* a workdir to tree diff (even though it is not really). This is what
* you would get from "git diff --name-status 26a125ee1bf"
*/
- cl_git_pass(git_diff_index_to_tree(&diff, g_repo, a, NULL, &opts));
- cl_git_pass(git_diff_workdir_to_index(&diff2, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, a, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff2, g_repo, NULL, &opts));
cl_git_pass(git_diff_merge(diff, diff2));
git_diff_list_free(diff2);
@@ -164,8 +164,8 @@ void test_diff_workdir__to_tree(void)
/* Again, emulating "git diff <sha>" for testing purposes using
* "git diff --name-status 0017bd4ab1ec3" instead.
*/
- cl_git_pass(git_diff_index_to_tree(&diff, g_repo, b, NULL, &opts));
- cl_git_pass(git_diff_workdir_to_index(&diff2, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, b, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff2, g_repo, NULL, &opts));
cl_git_pass(git_diff_merge(diff, diff2));
git_diff_list_free(diff2);
@@ -216,7 +216,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1;
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -239,7 +239,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "modified_file";
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -262,7 +262,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "subdir";
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -285,7 +285,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec = "*_deleted";
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -324,7 +324,7 @@ void test_diff_workdir__filemode_changes(void)
/* test once with no mods */
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -347,7 +347,7 @@ void test_diff_workdir__filemode_changes(void)
cl_assert(cl_toggle_filemode("issue_592/a.txt"));
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -386,7 +386,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
/* test once with no mods */
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
@@ -402,7 +402,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
cl_assert(cl_toggle_filemode("issue_592/a.txt"));
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, NULL));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, NULL));
memset(&exp, 0, sizeof(exp));
cl_git_pass(git_diff_foreach(
@@ -442,8 +442,8 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1;
- cl_git_pass(git_diff_index_to_tree(&diff_i2t, g_repo, tree, NULL, &opts));
- cl_git_pass(git_diff_workdir_to_index(&diff_w2i, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_tree_to_index(&diff_i2t, g_repo, tree, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff_w2i, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -529,7 +529,7 @@ void test_diff_workdir__eof_newline_changes(void)
opts.pathspec.strings = &pathspec;
opts.pathspec.count = 1;
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -556,7 +556,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_append2file("status/current_file", "\n");
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -583,7 +583,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_rewritefile("status/current_file", "current_file");
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
for (use_iterator = 0; use_iterator <= 1; use_iterator++) {
memset(&exp, 0, sizeof(exp));
@@ -611,7 +611,7 @@ void test_diff_workdir__eof_newline_changes(void)
/* PREPARATION OF TEST DATA
*
- * Since there is no command line equivalent of git_diff_workdir_to_tree,
+ * Since there is no command line equivalent of git_diff_tree_to_workdir,
* it was a bit of a pain to confirm that I was getting the expected
* results in the first part of this tests. Here is what I ended up
* doing to set my expectation for the file counts and results:
@@ -699,13 +699,13 @@ void test_diff_workdir__larger_hunks(void)
/* okay, this is a bit silly, but oh well */
switch (i) {
case 0:
- cl_git_pass(git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
break;
case 1:
- cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, a, &opts));
break;
case 2:
- cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, b, &opts));
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, b, &opts));
break;
}
@@ -748,7 +748,7 @@ void test_diff_workdir__larger_hunks(void)
/* Set up a test that exercises this code. The easiest test using existing
* test data is probably to create a sandbox of submod2 and then run a
- * git_diff_workdir_to_tree against tree
+ * git_diff_tree_to_workdir against tree
* 873585b94bdeabccea991ea5e3ec1a277895b698. As for what you should actually
* test, you can start by just checking that the number of lines of diff
* content matches the actual output of git diff. That will at least
@@ -784,7 +784,7 @@ void test_diff_workdir__submodules(void)
GIT_DIFF_RECURSE_UNTRACKED_DIRS |
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT;
- cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, a, &opts));
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, a, &opts));
/* diff_print(stderr, diff); */
@@ -829,12 +829,12 @@ void test_diff_workdir__cannot_diff_against_a_bare_repository(void)
g_repo = cl_git_sandbox_init("testrepo.git");
cl_assert_equal_i(
- GIT_EBAREREPO, git_diff_workdir_to_index(&diff, g_repo, NULL, &opts));
+ GIT_EBAREREPO, git_diff_index_to_workdir(&diff, g_repo, NULL, &opts));
cl_git_pass(git_repository_head_tree(&tree, g_repo));
cl_assert_equal_i(
- GIT_EBAREREPO, git_diff_workdir_to_tree(&diff, g_repo, tree, &opts));
+ GIT_EBAREREPO, git_diff_tree_to_workdir(&diff, g_repo, tree, &opts));
git_tree_free(tree);
}
@@ -850,7 +850,7 @@ void test_diff_workdir__to_null_tree(void)
g_repo = cl_git_sandbox_init("status");
- cl_git_pass(git_diff_workdir_to_tree(&diff, g_repo, NULL, &opts));
+ cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, NULL, &opts));
memset(&exp, 0, sizeof(exp));
@@ -871,13 +871,13 @@ void test_diff_workdir__checks_options_version(void)
g_repo = cl_git_sandbox_init("status");
opts.version = 0;
- cl_git_fail(git_diff_workdir_to_tree(&diff, g_repo, NULL, &opts));
+ cl_git_fail(git_diff_tree_to_workdir(&diff, g_repo, NULL, &opts));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
giterr_clear();
opts.version = 1024;
- cl_git_fail(git_diff_workdir_to_tree(&diff, g_repo, NULL, &opts));
+ cl_git_fail(git_diff_tree_to_workdir(&diff, g_repo, NULL, &opts));
err = giterr_last();
cl_assert_equal_i(GITERR_INVALID, err->klass);
}