aboutsummaryrefslogtreecommitdiff
path: root/diff-helper.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-05-19 19:00:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-19 22:33:07 -0700
commit57fe64a40d95dd99d798c6d7c81c1a76d24a8e7c (patch)
tree8f12e1e6f5bf259b5118dc8cd4a22b23d6c9f32b /diff-helper.c
parentdc26bd890d0a8571c38397e2ab33c0f3963c01a7 (diff)
downloadgit-57fe64a40d95dd99d798c6d7c81c1a76d24a8e7c.tar.gz
git-57fe64a40d95dd99d798c6d7c81c1a76d24a8e7c.tar.xz
[PATCH] diff overhaul
This cleans up the way calls are made into the diff core from diff-tree family and diff-helper. Earlier, these programs had "if (generating_patch)" sprinkled all over the place, but those ugliness are gone and handled uniformly from the diff core, even when not generating patch format. This also allowed diff-cache and diff-files to acquire -R (reverse) option to generate diff in reverse. Users of diff-tree can swap two trees easily so I did not add -R there. [ Linus' note: I'll add -R to "diff-tree" too, since a "commit diff" doesn't have another tree to switch around: the other tree is always the parent(s) of the commit ] Also -M<digits-as-mantissa> suggestion made by Linus has been implemented. Documentation updates are also included. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diff-helper.c')
-rw-r--r--diff-helper.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/diff-helper.c b/diff-helper.c
index 5b0feb1d8..8d896f856 100644
--- a/diff-helper.c
+++ b/diff-helper.c
@@ -7,6 +7,7 @@
#include "diff.h"
static int detect_rename = 0;
+static int diff_score_opt = 0;
static int parse_oneside_change(const char *cp, int *mode,
unsigned char *sha1, char *path)
@@ -19,15 +20,15 @@ static int parse_oneside_change(const char *cp, int *mode,
cp++;
}
*mode = m;
- if (strncmp(cp, "\tblob\t", 6))
+ if (strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6))
return -1;
cp += 6;
if (get_sha1_hex(cp, sha1))
return -1;
cp += 40;
- if (*cp++ != '\t')
+ if ((*cp != '\t') && *cp != ' ')
return -1;
- strcpy(path, cp);
+ strcpy(path, ++cp);
return 0;
}
@@ -63,7 +64,7 @@ static int parse_diff_raw_output(const char *buf)
new_mode = (new_mode << 3) | (ch - '0');
cp++;
}
- if (strncmp(cp, "\tblob\t", 6))
+ if (strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6))
return -1;
cp += 6;
if (get_sha1_hex(cp, old_sha1))
@@ -75,9 +76,9 @@ static int parse_diff_raw_output(const char *buf)
if (get_sha1_hex(cp, new_sha1))
return -1;
cp += 40;
- if (*cp++ != '\t')
+ if ((*cp != '\t') && *cp != ' ')
return -1;
- strcpy(path, cp);
+ strcpy(path, ++cp);
diff_change(old_mode, new_mode, old_sha1, new_sha1, path, 0);
break;
default:
@@ -101,15 +102,17 @@ int main(int ac, const char **av) {
reverse = 1;
else if (av[1][1] == 'z')
line_termination = 0;
- else if (av[1][1] == 'M')
+ else if (av[1][1] == 'M') {
detect_rename = 1;
+ diff_score_opt = diff_scoreopt_parse(av[1]);
+ }
else
usage(diff_helper_usage);
ac--; av++;
}
/* the remaining parameters are paths patterns */
- diff_setup(detect_rename, 0, reverse, av+1, ac-1);
+ diff_setup(detect_rename, diff_score_opt, reverse, -1, av+1, ac-1);
while (1) {
int status;