[PATCH] diff: fix the culling of unneeded delete record.
The commit 15d061b435
[PATCH] Fix the way diffcore-rename records unremoved source.
still leaves unneeded delete records in its output stream by
mistake, which was covered up by having an extra check to turn
such a delete into a no-op downstream. Fix the check in the
diffcore-rename to simplify the output routine.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
9d429ff6ff
commit
2cd68882ee
23
diff.c
23
diff.c
@ -792,27 +792,8 @@ static void diff_resolve_rename_copy(void)
|
|||||||
p->status = 'U';
|
p->status = 'U';
|
||||||
else if (!DIFF_FILE_VALID(p->one))
|
else if (!DIFF_FILE_VALID(p->one))
|
||||||
p->status = 'N';
|
p->status = 'N';
|
||||||
else if (!DIFF_FILE_VALID(p->two)) {
|
else if (!DIFF_FILE_VALID(p->two))
|
||||||
/* Deleted entry may have been picked up by
|
p->status = 'D';
|
||||||
* another rename-copy entry. So we scan the
|
|
||||||
* queue and if we find one that uses us as the
|
|
||||||
* source we do not say delete for this entry.
|
|
||||||
*/
|
|
||||||
for (j = 0; j < q->nr; j++) {
|
|
||||||
pp = q->queue[j];
|
|
||||||
if (!strcmp(p->one->path, pp->one->path) &&
|
|
||||||
DIFF_PAIR_RENAME(pp)) {
|
|
||||||
/* rename/copy are always valid
|
|
||||||
* so we do not say DIFF_FILE_VALID()
|
|
||||||
* on pp->one and pp->two.
|
|
||||||
*/
|
|
||||||
p->status = 'X';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!p->status)
|
|
||||||
p->status = 'D';
|
|
||||||
}
|
|
||||||
else if (DIFF_PAIR_TYPE_CHANGED(p))
|
else if (DIFF_PAIR_TYPE_CHANGED(p))
|
||||||
p->status = 'T';
|
p->status = 'T';
|
||||||
|
|
||||||
|
@ -328,26 +328,48 @@ void diffcore_rename(int detect_rename, int minimum_score)
|
|||||||
outq.nr = outq.alloc = 0;
|
outq.nr = outq.alloc = 0;
|
||||||
for (i = 0; i < q->nr; i++) {
|
for (i = 0; i < q->nr; i++) {
|
||||||
struct diff_filepair *p = q->queue[i];
|
struct diff_filepair *p = q->queue[i];
|
||||||
struct diff_rename_dst *dst = locate_rename_dst(p->two, 0);
|
|
||||||
struct diff_filepair *pair_to_free = NULL;
|
struct diff_filepair *pair_to_free = NULL;
|
||||||
|
|
||||||
if (dst) {
|
if (!DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
|
||||||
/* creation */
|
/*
|
||||||
if (dst->pair) {
|
* Creation
|
||||||
/* renq has rename/copy to produce
|
*
|
||||||
* this file already, so we do not
|
* We would output this create record if it has
|
||||||
* emit the creation record in the
|
* not been turned into a rename/copy already.
|
||||||
* output.
|
*/
|
||||||
*/
|
struct diff_rename_dst *dst =
|
||||||
|
locate_rename_dst(p->two, 0);
|
||||||
|
if (dst && dst->pair) {
|
||||||
diff_q(&outq, dst->pair);
|
diff_q(&outq, dst->pair);
|
||||||
pair_to_free = p;
|
pair_to_free = p;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* no matching rename/copy source, so record
|
/* no matching rename/copy source, so
|
||||||
* this as a creation.
|
* record this as a creation.
|
||||||
*/
|
*/
|
||||||
diff_q(&outq, p);
|
diff_q(&outq, p);
|
||||||
}
|
}
|
||||||
|
else if (DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two)) {
|
||||||
|
/*
|
||||||
|
* Deletion
|
||||||
|
*
|
||||||
|
* We would output this delete record if renq
|
||||||
|
* does not have a rename/copy to move
|
||||||
|
* p->one->path out.
|
||||||
|
*/
|
||||||
|
for (j = 0; j < renq.nr; j++)
|
||||||
|
if (!strcmp(renq.queue[j]->one->path,
|
||||||
|
p->one->path))
|
||||||
|
break;
|
||||||
|
if (j < renq.nr)
|
||||||
|
/* this path remains */
|
||||||
|
pair_to_free = p;
|
||||||
|
|
||||||
|
if (pair_to_free)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
diff_q(&outq, p);
|
||||||
|
}
|
||||||
else if (!diff_unmodified_pair(p))
|
else if (!diff_unmodified_pair(p))
|
||||||
/* all the usual ones need to be kept */
|
/* all the usual ones need to be kept */
|
||||||
diff_q(&outq, p);
|
diff_q(&outq, p);
|
||||||
|
Loading…
Reference in New Issue
Block a user