From c7974b49d04bc318d61a010d2c5d2e75095f410b Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Wed, 26 Jun 2013 12:03:33 -0700 Subject: [PATCH 1/2] Fail on unmodified deltas when they're unexpected --- tests-clar/diff/submodules.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests-clar/diff/submodules.c b/tests-clar/diff/submodules.c index 6e52a6319..46fe6c21c 100644 --- a/tests-clar/diff/submodules.c +++ b/tests-clar/diff/submodules.c @@ -47,7 +47,7 @@ static void check_diff_patches(git_diff_list *diff, const char **expected) for (d = 0; d < num_d; ++d, git_diff_patch_free(patch)) { cl_git_pass(git_diff_get_patch(&patch, &delta, diff, d)); - if (delta->status == GIT_DELTA_UNMODIFIED) + if (delta->status == GIT_DELTA_UNMODIFIED && expected[d] == NULL) continue; if (expected[d] && !strcmp(expected[d], "")) From c67ff958c4d8e37a717c77dd9cdb4bdfc88a6fd8 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 27 Jun 2013 07:38:27 -0700 Subject: [PATCH 2/2] Fix bug marking submodule diffs as unmodified There was a bug where submodules whose HEAD had not been moved were being marked as having an UNMODIFIED delta record instead of being left MODIFIED. This fixes that and fixes the tests to notice if a submodule has been incorrectly marked as UNMODIFIED. --- src/diff_patch.c | 6 +++++- tests-clar/diff/submodules.c | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/diff_patch.c b/src/diff_patch.c index 9060d0a24..1b4adac03 100644 --- a/src/diff_patch.c +++ b/src/diff_patch.c @@ -10,6 +10,7 @@ #include "diff_driver.h" #include "diff_patch.h" #include "diff_xdiff.h" +#include "fileops.h" /* cached information about a single span in a diff */ typedef struct diff_patch_line diff_patch_line; @@ -175,9 +176,12 @@ static int diff_patch_load(git_diff_patch *patch, git_diff_output *output) goto cleanup; } - /* if we were previously missing an oid, update MODIFIED->UNMODIFIED */ + /* if previously missing an oid, and now that we have it the two sides + * are the same (and not submodules), update MODIFIED -> UNMODIFIED + */ if (incomplete_data && patch->ofile.file->mode == patch->nfile.file->mode && + patch->ofile.file->mode != GIT_FILEMODE_COMMIT && git_oid_equal(&patch->ofile.file->oid, &patch->nfile.file->oid) && patch->delta->status == GIT_DELTA_MODIFIED) /* not RENAMED/COPIED! */ patch->delta->status = GIT_DELTA_UNMODIFIED; diff --git a/tests-clar/diff/submodules.c b/tests-clar/diff/submodules.c index 46fe6c21c..5de46732b 100644 --- a/tests-clar/diff/submodules.c +++ b/tests-clar/diff/submodules.c @@ -47,8 +47,10 @@ static void check_diff_patches(git_diff_list *diff, const char **expected) for (d = 0; d < num_d; ++d, git_diff_patch_free(patch)) { cl_git_pass(git_diff_get_patch(&patch, &delta, diff, d)); - if (delta->status == GIT_DELTA_UNMODIFIED && expected[d] == NULL) + if (delta->status == GIT_DELTA_UNMODIFIED) { + cl_assert(expected[d] == NULL); continue; + } if (expected[d] && !strcmp(expected[d], "")) continue;