From a66c4bc846cb59512c1aa164211f3f912d9bc425 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 29 Apr 2013 02:57:01 -0700 Subject: More tests for diff untracked directories This includes more tests for various scenarios when diff includes an untracked directory in the workdir with contents either ignored or not. --- tests-clar/diff/diff_helpers.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests-clar/diff/diff_helpers.c') diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c index 19c005e2e..e7f97c034 100644 --- a/tests-clar/diff/diff_helpers.c +++ b/tests-clar/diff/diff_helpers.c @@ -28,7 +28,15 @@ int diff_file_cb( { diff_expects *e = payload; - GIT_UNUSED(progress); + if (e->debug) + fprintf(stderr, "%c %s (%.3f)\n", + git_diff_status_char(delta->status), + delta->old_file.path, progress); + + if (e->names) + cl_assert_equal_s(e->names[e->files], delta->old_file.path); + if (e->statuses) + cl_assert_equal_i(e->statuses[e->files], (int)delta->status); e->files++; -- cgit v1.2.1 From e35e2684f693f28afb7a8f28028b4cb8bdd19f49 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 7 May 2013 04:32:17 -0700 Subject: Add GIT_DIFF_LINE_CONTEXT_EOFNL This adds a new line origin constant for the special line that is used when both files end without a newline. In the course of writing the tests for this, I was having problems with modifying a file but not having diff notice because it was the same size and modified less than one second from the start of the test, so I decided to start working on nanosecond timestamp support. This commit doesn't contain the nanosecond support, but it contains the reorganization of maybe_modified and the hooks so that if the nanosecond data were being read by stat() (or rather being copied by git_index_entry__init_from_stat), then the nsec would be taken into account. This new stuff could probably use some more tests, although there is some amount of it here. --- tests-clar/diff/diff_helpers.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'tests-clar/diff/diff_helpers.c') diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c index e7f97c034..75eda0520 100644 --- a/tests-clar/diff/diff_helpers.c +++ b/tests-clar/diff/diff_helpers.c @@ -97,20 +97,15 @@ int diff_line_cb( e->lines++; switch (line_origin) { case GIT_DIFF_LINE_CONTEXT: + case GIT_DIFF_LINE_CONTEXT_EOFNL: /* techically not a line */ e->line_ctxt++; break; case GIT_DIFF_LINE_ADDITION: - e->line_adds++; - break; - case GIT_DIFF_LINE_ADD_EOFNL: - /* technically not a line add, but we'll count it as such */ + case GIT_DIFF_LINE_ADD_EOFNL: /* technically not a line add */ e->line_adds++; break; case GIT_DIFF_LINE_DELETION: - e->line_dels++; - break; - case GIT_DIFF_LINE_DEL_EOFNL: - /* technically not a line delete, but we'll count it as such */ + case GIT_DIFF_LINE_DEL_EOFNL: /* technically not a line delete */ e->line_dels++; break; default: -- cgit v1.2.1 From 67db583dabf6e154037302a24b7f79028f403454 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 23 May 2013 15:06:07 -0700 Subject: More diff rename tests; better split swap handling This adds a couple more tests of different rename scenarios. Also, this fixes a problem with the case where you have two "split" deltas and the left half of one matches the right half of the other. That case was already being handled, but in the wrong order in a way that could result in bad output. Also, if the swap also happened to put the other two halves into the correct place (i.e. two files exchanged places with each other), then the second delta was left with the SPLIT flag set when it really should be cleared. --- tests-clar/diff/diff_helpers.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests-clar/diff/diff_helpers.c') diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c index 75eda0520..4e23792a6 100644 --- a/tests-clar/diff/diff_helpers.c +++ b/tests-clar/diff/diff_helpers.c @@ -213,3 +213,8 @@ void diff_print(FILE *fp, git_diff_list *diff) { cl_git_pass(git_diff_print_patch(diff, diff_print_cb, fp ? fp : stderr)); } + +void diff_print_raw(FILE *fp, git_diff_list *diff) +{ + cl_git_pass(git_diff_print_raw(diff, diff_print_cb, fp ? fp : stderr)); +} -- cgit v1.2.1