- diff_queue(q, p->one, p->two);
- }
- else if (!DIFF_FILE_VALID(p->two)) {
- /* deleted */
- if (p->one->xfrm_flags & RENAME_SRC_GONE)
- ; /* rename/copy deleted it already */
- else
- diff_queue(q, p->one, p->two);
- }
- else if (strcmp(p->one->path, p->two->path)) {
- /* rename or copy */
- struct diff_filepair *dp =
- diff_queue(q, p->one, p->two);
- int msglen = (strlen(p->one->path) +
- strlen(p->two->path) + 100);
- int score = (p->xfrm_work >> RENAME_SCORE_SHIFT);
- dp->xfrm_msg = xmalloc(msglen);
-
- /* if we have a later entry that is a rename/copy
- * that depends on p->one, then we copy here.
- * otherwise we rename it.
- */
- if (needs_to_stay(&outq, i+1, p->one)) {
- /* copy it */
- sprintf(dp->xfrm_msg,
- "similarity index %d%%\n"
- "copy from %s\n"
- "copy to %s\n",
- (int)(0.5 + score * 100 / MAX_SCORE),
- p->one->path, p->two->path);
- }
- else {
- /* rename it, and mark it as gone. */
- p->one->xfrm_flags |= RENAME_SRC_GONE;
- sprintf(dp->xfrm_msg,
- "similarity index %d%%\n"
- "rename old %s\n"
- "rename new %s\n",
- (int)(0.5 + score * 100 / MAX_SCORE),
- p->one->path, p->two->path);
- }