summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e9b5b75)
raw | patch | inline | side by side (parent: e9b5b75)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 26 Apr 2006 06:40:09 +0000 (23:40 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 26 Apr 2006 06:40:09 +0000 (23:40 -0700) |
The patch format shows complete rewrite as deletion of all old lines
followed by addition of all new lines. Count lines consistenly with
that when doing diffstat.
Signed-off-by: Junio C Hamano <junkio@cox.net>
followed by addition of all new lines. Count lines consistenly with
that when doing diffstat.
Signed-off-by: Junio C Hamano <junkio@cox.net>
diff.c | patch | blob | history |
index 13b216f2733763b4e6cc6a3c37ff2624d7f55266..6762fcee5af881b93b97da2dff190137768c1a8e 100644 (file)
--- a/diff.c
+++ b/diff.c
static void builtin_diffstat(const char *name_a, const char *name_b,
struct diff_filespec *one,
struct diff_filespec *two,
- struct diffstat_t *diffstat)
+ struct diffstat_t *diffstat,
+ int complete_rewrite)
{
mmfile_t mf1, mf2;
struct diffstat_file *data;
data->is_unmerged = 1;
return;
}
-
+ if (complete_rewrite) {
+ diff_populate_filespec(one, 0);
+ diff_populate_filespec(two, 0);
+ data->deleted = count_lines(one->data, one->size);
+ data->added = count_lines(two->data, two->size);
+ return;
+ }
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff");
{
const char *name;
const char *other;
+ int complete_rewrite = 0;
if (DIFF_PAIR_UNMERGED(p)) {
/* unmerged */
- builtin_diffstat(p->one->path, NULL, NULL, NULL, diffstat);
+ builtin_diffstat(p->one->path, NULL, NULL, NULL, diffstat, 0);
return;
}
diff_fill_sha1_info(p->one);
diff_fill_sha1_info(p->two);
- builtin_diffstat(name, other, p->one, p->two, diffstat);
+ if (p->status == DIFF_STATUS_MODIFIED && p->score)
+ complete_rewrite = 1;
+ builtin_diffstat(name, other, p->one, p->two, diffstat, complete_rewrite);
}
void diff_setup(struct diff_options *options)