Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-06-15 03:18:04 +0400
committerRussell Belfer <rb@github.com>2013-06-17 21:03:49 +0400
commita1683f28ce2709e615490939e4e244046654d0e5 (patch)
tree8eae4e60603cac390a5da9a3cbb745ea0e4b2644 /src/diff_patch.c
parentfb03a223189f418d0767d7d04ff7509dfcfe8394 (diff)
More tests and bug fixes for status with rename
This changes the behavior of the status RENAMED flags so that they will be combined with the MODIFIED flags if appropriate. If a file is modified in the index and also renamed, then the status code will have both the GIT_STATUS_INDEX_MODIFIED and INDEX_RENAMED bits set. If it is renamed but the OID has not changed, then just the GIT_STATUS_INDEX_RENAMED bit will be set. Similarly, the flags GIT_STATUS_WT_MODIFIED and GIT_STATUS_WT_RENAMED can both be set independently of one another. This fixes a serious bug where the check for unmodified files that was done at data load time could end up erasing the RENAMED state of a file that was renamed with no changes. Lastly, this contains a bunch of new tests for status with renames, including tests where the only rename changes are case changes. The expected results of these tests have to vary by whether the platform uses a case sensitive filesystem or not, so the expected data covers those platform differences separately.
Diffstat (limited to 'src/diff_patch.c')
-rw-r--r--src/diff_patch.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/diff_patch.c b/src/diff_patch.c
index a1e1fe84c..40cb3371a 100644
--- a/src/diff_patch.c
+++ b/src/diff_patch.c
@@ -175,10 +175,11 @@ static int diff_patch_load(git_diff_patch *patch, git_diff_output *output)
goto cleanup;
}
- /* if we were previously missing an oid, reassess UNMODIFIED state */
+ /* if we were previously missing an oid, update MODIFIED->UNMODIFIED */
if (incomplete_data &&
patch->ofile.file.mode == patch->nfile.file.mode &&
- git_oid_equal(&patch->ofile.file.oid, &patch->nfile.file.oid))
+ 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;
cleanup:
@@ -284,6 +285,7 @@ int git_diff_foreach(
git_xdiff_init(&xo, &diff->opts);
git_vector_foreach(&diff->deltas, idx, patch.delta) {
+
/* check flags against patch status */
if (git_diff_delta__should_skip(&diff->opts, patch.delta))
continue;