summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Olivier Latour <pol@mac.com>2015-03-30 14:06:21 -0700
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-18 20:08:54 +0200
commit7dc1b1c4abd7f9f1ff7628ddea317e74b0040c2c (patch)
tree27e4c90789b71c6d25670b90aa60e8f2b90f8a02
parentfb6df50b7f250a4fd8b2fab257f119a5185e9bf5 (diff)
downloadlibgit2-7dc1b1c4abd7f9f1ff7628ddea317e74b0040c2c.tar.gz
Make sure to also update delta->nfiles when merging diffs
When diffs are generated, the value for the 'nfiles' field of 'git_diff_delta' will be consistent with the value in the 'status' field. Merging diffs can modify the 'status' field of some deltas and the 'nfiles' field needs to be updated accordingly.
-rw-r--r--src/diff_tform.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index d576317f0..37740a52a 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -84,11 +84,14 @@ static git_diff_delta *diff_delta__merge_like_cgit(
* index (i.e. not in HEAD nor workdir) is given as empty.
*/
if (dup->status == GIT_DELTA_DELETED) {
- if (a->status == GIT_DELTA_ADDED)
+ if (a->status == GIT_DELTA_ADDED) {
dup->status = GIT_DELTA_UNMODIFIED;
+ dup->nfiles = 2;
+ }
/* else don't overwrite DELETE status */
} else {
dup->status = a->status;
+ dup->nfiles = a->nfiles;
}
git_oid_cpy(&dup->old_file.id, &a->old_file.id);
@@ -118,10 +121,13 @@ static git_diff_delta *diff_delta__merge_like_cgit_reversed(
return dup;
if (dup->status == GIT_DELTA_DELETED) {
- if (b->status == GIT_DELTA_ADDED)
+ if (b->status == GIT_DELTA_ADDED) {
dup->status = GIT_DELTA_UNMODIFIED;
+ dup->nfiles = 2;
+ }
} else {
dup->status = b->status;
+ dup->nfiles = b->nfiles;
}
git_oid_cpy(&dup->old_file.id, &b->old_file.id);