diff.c: Reuse the pprint_rename function for diff --summary output.
This avoids some code duplication, and yields more readable results for directory renames. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Alexandre Julliard committed
Feb 10, 2007 at 15:36 UTC
b9f441646c5c8abb92dc110d28decdfe2c9720b2
1 file changed
+4
-27
diff.c
+4
-27
@@ -2430,34 +2430,11 @@ static void show_mode_change(struct diff_filepair *p, int show_name)
2430
2431
static void show_rename_copy(const char *renamecopy, struct diff_filepair *p)
2432
{
2433
- const char *old, *new;
2433
+ char *names = pprint_rename(p->one->path, p->two->path);
2434
2435
- /* Find common prefix */
2436
- old = p->one->path;
2437
- new = p->two->path;
2438
- while (1) {
2439
- const char *slash_old, *slash_new;
2440
- slash_old = strchr(old, '/');
2441
- slash_new = strchr(new, '/');
2442
- if (!slash_old ||
2443
- !slash_new ||
2444
- slash_old - old != slash_new - new ||
2445
- memcmp(old, new, slash_new - new))
2446
- break;
2447
- old = slash_old + 1;
2448
- new = slash_new + 1;
2449
- }
2450
- /* p->one->path thru old is the common prefix, and old and new
2451
- * through the end of names are renames
2452
- */
2453
- if (old != p->one->path)
2454
- printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
2455
- (int)(old - p->one->path), p->one->path,
2456
- old, new, (int)(0.5 + p->score * 100.0/MAX_SCORE));
2457
- else
2458
- printf(" %s %s => %s (%d%%)\n", renamecopy,
2459
- p->one->path, p->two->path,
2460
- (int)(0.5 + p->score * 100.0/MAX_SCORE));
2435
+ printf(" %s %s (%d%%)\n", renamecopy, names,
2436
+ (int)(0.5 + p->score * 100.0/MAX_SCORE));
2437
+ free(names);
2438
show_mode_change(p, 0);
2439
}
2440