summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 38c6f78)
raw | patch | inline | side by side (parent: 38c6f78)
author | Junio C Hamano <junkio@cox.net> | |
Sun, 22 May 2005 02:42:18 +0000 (19:42 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sun, 22 May 2005 05:49:19 +0000 (22:49 -0700) |
Update the diff-raw format as Linus and I discussed, except that
it does not use sequence of underscore '_' letters to express
nonexistence. All '0' mode is used for that purpose instead.
The new diff-raw format can express rename/copy, and the earlier
restriction that -M and -C _must_ be used with the patch format
output is no longer necessary. The patch makes -M and -C flags
independent of -p flag, so you need to say git-whatchanged -M -p
to get the diff/patch format.
Updated are both documentations and tests.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
it does not use sequence of underscore '_' letters to express
nonexistence. All '0' mode is used for that purpose instead.
The new diff-raw format can express rename/copy, and the earlier
restriction that -M and -C _must_ be used with the patch format
output is no longer necessary. The patch makes -M and -C flags
independent of -p flag, so you need to say git-whatchanged -M -p
to get the diff/patch format.
Updated are both documentations and tests.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
16 files changed:
index 9e645399752e9b18f097840906fc640a1121d982..7e9a515ad74b16c3f82eba71a9503c6696c77503 100644 (file)
git-diff-files [<pattern>...]::
compares the cache and the files on the filesystem.
-The following desription uses "old" and "new" to mean those
-compared entities.
-For files in old but not in new (i.e. removed):
+An output line is formatted this way:
- -<mode> \t <type> \t <object> \t <path>
+ ':' <mode> ' ' <mode> ' ' <sha1> ' ' <sha1> I <path> I <path> L
-For files not in old but in new (i.e. added):
+By default, I and L are '\t' and '\n' respectively. When '-z'
+flag is in effect, both I and L are '\0'.
- +<mode> \t <type> \t <object> \t <path>
+In each <mode>, <sha1> and <path> pair, left hand side describes
+the left hand side of what is being compared (<tree-ish> in
+git-diff-cache, <tree-ish-1> in git-diff-tree, cache contents in
+git-diff-files). Non-existence is shown by having 000000 in the
+<mode> column. That is, 000000 appears as the first <mode> for
+newly created files, and as the second <mode> for deleted files.
-For files that differ:
+Usually two <path> are the same. When rename/copy detection is
+used, however, an "create" and another "delete" records can be
+merged into a single record that has two <path>, old name and
+new name.
- *<old-mode>-><new-mode> \t <type> \t <old-sha1>-><new-sha1> \t <path>
+<sha1> is shown as all 0's if new is a file on the filesystem
+and it is out of sync with the cache. Example:
-<new-sha1> is shown as all 0's if new is a file on the
-filesystem and it is out of sync with the cache. Example:
-
- *100644->100644 blob 5be4a4.......->000000....... file.c
+ :100644 100644 5be4a4...... 000000...... file.c file.c
Generating patches with -p
index 2cfdffd87cf4e735d228747fba82287c99d0c7f4..e89aaa503ff18bb96442f9ecf499bd5734679df5 100644 (file)
\0 line termination on output
-M::
- Detect renames; implies -p.
+ Detect renames.
-C::
- Detect copies as well as renames; implies -p.
+ Detect copies as well as renames.
-S<string>::
Look for differences that contains the change in <string>.
index 51a3d0fcd66153479aa31ef0a7eb943a85da88f9..9f9bb1453121ae9f8641ca65dfe70d2575ffa2f9 100644 (file)
Output diff in reverse.
-M::
- Detect renames; implies -p.
+ Detect renames.
-C::
- Detect copies as well as renames; implies -p.
+ Detect copies as well as renames.
-S<string>::
Look for differences that contains the change in <string>.
index bdc8d5a53b3bbdf8ae548c52de6f814c83a6802d..ea680ccbfadb701d650e44ec58f2a72bc97fec44 100644 (file)
git-diff-tree, this flag implies '-r' as well.
-M::
- Detect renames; implies -p, in turn implying also '-r'.
+ Detect renames.
-C::
- Detect copies as well as renames; implies -p, in turn
- implying also '-r'.
+ Detect copies as well as renames.
-R::
Output diff in reverse.
diff --git a/diff-cache.c b/diff-cache.c
index fe6f45534443d4e317b45448ad266ed39b7743c6..54691a94c4da738008aa87877451c73f2e364b5d 100644 (file)
--- a/diff-cache.c
+++ b/diff-cache.c
#include "diff.h"
static int cached_only = 0;
-static int generate_patch = 0;
+static int diff_output_format = DIFF_FORMAT_HUMAN;
static int match_nonexisting = 0;
-static int line_termination = '\n';
static int detect_rename = 0;
static int reverse_diff = 0;
static int diff_score_opt = 0;
continue;
}
if (!strcmp(arg, "-p")) {
- generate_patch = 1;
+ diff_output_format = DIFF_FORMAT_PATCH;
continue;
}
if (!strncmp(arg, "-M", 2)) {
- generate_patch = detect_rename = 1;
+ detect_rename = 1;
diff_score_opt = diff_scoreopt_parse(arg);
continue;
}
if (!strncmp(arg, "-C", 2)) {
- generate_patch = 1;
detect_rename = 2;
diff_score_opt = diff_scoreopt_parse(arg);
continue;
}
if (!strcmp(arg, "-z")) {
- line_termination = '\0';
+ diff_output_format = DIFF_FORMAT_MACHINE;
continue;
}
if (!strcmp(arg, "-R")) {
if (argc != 2 || get_sha1(argv[1], tree_sha1))
usage(diff_cache_usage);
- diff_setup(reverse_diff, (generate_patch ? -1 : line_termination));
+ diff_setup(reverse_diff, diff_output_format);
mark_merge_entries();
diff --git a/diff-files.c b/diff-files.c
index a47bd4376ce7a31054f70ddc22004bb54f1b2939..884d45246f97a5276d6d5e83222427b83c35f69d 100644 (file)
--- a/diff-files.c
+++ b/diff-files.c
static const char *diff_files_usage =
"git-diff-files [-p] [-q] [-r] [-z] [-M] [-C] [-R] [-S<string>] [paths...]";
-static int generate_patch = 0;
-static int line_termination = '\n';
+static int diff_output_format = DIFF_FORMAT_HUMAN;
static int detect_rename = 0;
static int reverse_diff = 0;
static int diff_score_opt = 0;
while (1 < argc && argv[1][0] == '-') {
if (!strcmp(argv[1], "-p"))
- generate_patch = 1;
+ diff_output_format = DIFF_FORMAT_PATCH;
else if (!strcmp(argv[1], "-q"))
silent = 1;
else if (!strcmp(argv[1], "-r"))
else if (!strcmp(argv[1], "-s"))
; /* no-op */
else if (!strcmp(argv[1], "-z"))
- line_termination = 0;
+ diff_output_format = DIFF_FORMAT_MACHINE;
else if (!strcmp(argv[1], "-R"))
reverse_diff = 1;
else if (!strcmp(argv[1], "-S"))
pickaxe = argv[1] + 2;
else if (!strncmp(argv[1], "-M", 2)) {
diff_score_opt = diff_scoreopt_parse(argv[1]);
- detect_rename = generate_patch = 1;
+ detect_rename = 1;
}
else if (!strncmp(argv[1], "-C", 2)) {
diff_score_opt = diff_scoreopt_parse(argv[1]);
detect_rename = 2;
- generate_patch = 1;
}
else
usage(diff_files_usage);
exit(1);
}
- diff_setup(reverse_diff, (generate_patch ? -1 : line_termination));
+ diff_setup(reverse_diff, diff_output_format);
for (i = 0; i < entries; i++) {
struct stat st;
diff --git a/diff-helper.c b/diff-helper.c
index 108ca07ed09e2a54e05adf6a2b659746cb0770fc..d64d3baf990c6ecd9fbd6680cfadc1e121984ef2 100644 (file)
--- a/diff-helper.c
+++ b/diff-helper.c
static int detect_rename = 0;
static int diff_score_opt = 0;
-static int generate_patch = 1;
static const char *pickaxe = NULL;
+static int diff_output_style = DIFF_FORMAT_PATCH;
+static int line_termination = '\n';
+static int inter_name_termination = '\t';
-static int parse_oneside_change(const char *cp, int *mode,
- unsigned char *sha1, char *path)
+static int parse_diff_raw(char *buf1, char *buf2, char *buf3)
{
- int ch, m;
+ char old_path[PATH_MAX];
+ unsigned char old_sha1[20], new_sha1[20];
+ char *ep;
+ char *cp = buf1;
+ int ch, old_mode, new_mode;
- m = 0;
- while ((ch = *cp) && '0' <= ch && ch <= '7') {
- m = (m << 3) | (ch - '0');
+ old_mode = new_mode = 0;
+ while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
+ old_mode = (old_mode << 3) | (ch - '0');
+ cp++;
+ }
+ if (*cp++ != ' ')
+ return -1;
+ while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
+ new_mode = (new_mode << 3) | (ch - '0');
cp++;
}
- *mode = m;
- if (strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6) &&
- strncmp(cp, "\ttree\t", 6) && strncmp(cp, " tree ", 6))
+ if (*cp++ != ' ')
return -1;
- cp += 6;
- if (get_sha1_hex(cp, sha1))
+ if (get_sha1_hex(cp, old_sha1))
return -1;
cp += 40;
- if ((*cp != '\t') && *cp != ' ')
+ if (*cp++ != ' ')
return -1;
- strcpy(path, ++cp);
- return 0;
-}
-
-static int parse_diff_raw_output(const char *buf)
-{
- char path[PATH_MAX];
- unsigned char old_sha1[20], new_sha1[20];
- const char *cp = buf;
- int ch, old_mode, new_mode;
-
- switch (*cp++) {
- case 'U':
- diff_unmerge(cp + 1);
- break;
- case '+':
- if (parse_oneside_change(cp, &new_mode, new_sha1, path))
- return -1;
- diff_addremove('+', new_mode, new_sha1, path, NULL);
- break;
- case '-':
- if (parse_oneside_change(cp, &old_mode, old_sha1, path))
- return -1;
- diff_addremove('-', old_mode, old_sha1, path, NULL);
- break;
- case '*':
- old_mode = new_mode = 0;
- while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
- old_mode = (old_mode << 3) | (ch - '0');
- cp++;
- }
- if (strncmp(cp, "->", 2))
- return -1;
- cp += 2;
- while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
- new_mode = (new_mode << 3) | (ch - '0');
- cp++;
- }
- if (strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6) &&
- strncmp(cp, "\ttree\t", 6) && strncmp(cp, " tree ", 6))
- return -1;
- cp += 6;
- if (get_sha1_hex(cp, old_sha1))
- return -1;
- cp += 40;
- if (strncmp(cp, "->", 2))
- return -1;
- cp += 2;
- if (get_sha1_hex(cp, new_sha1))
- return -1;
- cp += 40;
- if ((*cp != '\t') && *cp != ' ')
- return -1;
- strcpy(path, ++cp);
- diff_change(old_mode, new_mode, old_sha1, new_sha1, path, NULL);
- break;
- default:
+ if (get_sha1_hex(cp, new_sha1))
return -1;
- }
+ cp += 40;
+ if (*cp++ != inter_name_termination)
+ return -1;
+ if (buf2)
+ cp = buf2;
+ ep = strchr(cp, inter_name_termination);
+ if (!ep)
+ return -1;
+ *ep++ = 0;
+ strcpy(old_path, cp);
+ diff_guif(old_mode, new_mode, old_sha1, new_sha1,
+ old_path, buf3 ? buf3 : ep);
return 0;
}
"git-diff-helper [-z] [-R] [-M] [-C] [-S<string>] paths...";
int main(int ac, const char **av) {
- struct strbuf sb;
- int reverse = 0;
- int line_termination = '\n';
+ struct strbuf sb1, sb2, sb3;
+ int reverse_diff = 0;
- strbuf_init(&sb);
+ strbuf_init(&sb1);
+ strbuf_init(&sb2);
+ strbuf_init(&sb3);
while (1 < ac && av[1][0] == '-') {
if (av[1][1] == 'R')
- reverse = 1;
+ reverse_diff = 1;
else if (av[1][1] == 'z')
- line_termination = 0;
+ line_termination = inter_name_termination = 0;
else if (av[1][1] == 'p') /* hidden from the help */
- generate_patch = 0;
+ diff_output_style = DIFF_FORMAT_HUMAN;
+ else if (av[1][1] == 'P') /* hidden from the help */
+ diff_output_style = DIFF_FORMAT_MACHINE;
else if (av[1][1] == 'M') {
detect_rename = 1;
diff_score_opt = diff_scoreopt_parse(av[1]);
}
/* the remaining parameters are paths patterns */
- diff_setup(reverse, (generate_patch ? -1 : line_termination));
+ diff_setup(reverse_diff, diff_output_style);
while (1) {
int status;
- read_line(&sb, stdin, line_termination);
- if (sb.eof)
+ read_line(&sb1, stdin, line_termination);
+ if (sb1.eof)
break;
- status = parse_diff_raw_output(sb.buf);
+ switch (sb1.buf[0]) {
+ case 'U':
+ diff_unmerge(sb1.buf + 2);
+ continue;
+ case ':':
+ break;
+ default:
+ goto unrecognized;
+ }
+ if (!line_termination) {
+ read_line(&sb2, stdin, line_termination);
+ if (sb2.eof)
+ break;
+ read_line(&sb3, stdin, line_termination);
+ if (sb3.eof)
+ break;
+ status = parse_diff_raw(sb1.buf+1, sb2.buf, sb3.buf);
+ }
+ else
+ status = parse_diff_raw(sb1.buf+1, NULL, NULL);
if (status) {
+ unrecognized:
diff_flush(av+1, ac-1);
- printf("%s%c", sb.buf, line_termination);
+ printf("%s%c", sb1.buf, line_termination);
}
}
-
if (detect_rename)
diff_detect_rename(detect_rename, diff_score_opt);
if (pickaxe)
diff --git a/diff-tree.c b/diff-tree.c
index e8bad722140f6275dcea00b4ac86c378a079d73a..3428a6ee9db212b8fbf13d81602fe44394dae4cb 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
static int ignore_merges = 1;
static int recursive = 0;
static int read_stdin = 0;
-static int line_termination = '\n';
-static int generate_patch = 0;
+static int diff_output_format = DIFF_FORMAT_HUMAN;
static int detect_rename = 0;
static int reverse_diff = 0;
static int diff_score_opt = 0;
@@ -269,7 +268,7 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co
static void call_diff_setup(void)
{
- diff_setup(reverse_diff, (generate_patch ? -1 : line_termination));
+ diff_setup(reverse_diff, diff_output_format);
}
static void call_diff_flush(void)
continue;
}
if (!strcmp(arg, "-p")) {
- recursive = generate_patch = 1;
+ diff_output_format = DIFF_FORMAT_PATCH;
+ recursive = 1;
continue;
}
if (!strncmp(arg, "-S", 2)) {
continue;
}
if (!strncmp(arg, "-M", 2)) {
- detect_rename = recursive = generate_patch = 1;
+ detect_rename = 1;
diff_score_opt = diff_scoreopt_parse(arg);
continue;
}
if (!strncmp(arg, "-C", 2)) {
detect_rename = 2;
- recursive = generate_patch = 1;
diff_score_opt = diff_scoreopt_parse(arg);
continue;
}
if (!strcmp(arg, "-z")) {
- line_termination = '\0';
+ diff_output_format = DIFF_FORMAT_MACHINE;
continue;
}
if (!strcmp(arg, "-m")) {
index 85505fa54880881b2d109c16e69e3b21cf66ba31..a6cbf44f443bf5dffb29576e1f426a252cc9eba9 100644 (file)
--- a/diff.c
+++ b/diff.c
static unsigned char null_sha1[20] = { 0, };
static int reverse_diff;
-static int diff_raw_output = -1;
+static int generate_patch;
+static int line_termination = '\n';
+static int inter_name_termination = '\t';
static const char **pathspec;
static int speccnt;
struct diff_filespec *spec = xmalloc(sizeof(*spec) + namelen + 1);
spec->path = (char *)(spec + 1);
strcpy(spec->path, path);
- spec->should_free = spec->should_munmap = spec->file_valid = 0;
+ spec->should_free = spec->should_munmap = 0;
spec->xfrm_flags = 0;
spec->size = 0;
spec->data = 0;
+ spec->mode = 0;
+ memset(spec->sha1, 0, 20);
return spec;
}
void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
unsigned short mode)
{
- spec->mode = mode;
- memcpy(spec->sha1, sha1, 20);
- spec->sha1_valid = !!memcmp(sha1, null_sha1, 20);
- spec->file_valid = 1;
+ if (mode) { /* just playing defensive */
+ spec->mode = mode;
+ memcpy(spec->sha1, sha1, 20);
+ spec->sha1_valid = !!memcmp(sha1, null_sha1, 20);
+ }
}
/*
int diff_populate_filespec(struct diff_filespec *s)
{
int err = 0;
- if (!s->file_valid)
+ if (!DIFF_FILE_VALID(s))
die("internal error: asking to populate invalid file.");
if (S_ISDIR(s->mode))
return -1;
struct diff_tempfile *temp,
struct diff_filespec *one)
{
- if (!one->file_valid) {
+ if (!DIFF_FILE_VALID(one)) {
not_a_valid_file:
/* A '-' entry produces this for file-2, and
* a '+' entry produces this for file-1.
return MAX_SCORE * num / scale;
}
-void diff_setup(int reverse_diff_, int diff_raw_output_)
+void diff_setup(int reverse_diff_, int diff_output_style)
{
reverse_diff = reverse_diff_;
- diff_raw_output = diff_raw_output_;
+ generate_patch = 0;
+ switch (diff_output_style) {
+ case DIFF_FORMAT_HUMAN:
+ line_termination = '\n';
+ inter_name_termination = '\t';
+ break;
+ case DIFF_FORMAT_MACHINE:
+ line_termination = inter_name_termination = 0;
+ break;
+ case DIFF_FORMAT_PATCH:
+ generate_patch = 1;
+ break;
+ }
}
struct diff_queue_struct diff_queued_diff;
return dp;
}
-static const char *git_object_type(unsigned mode)
-{
- return S_ISDIR(mode) ? "tree" : "blob";
-}
-
static void diff_flush_raw(struct diff_filepair *p)
{
- struct diff_filespec *it;
- int addremove;
-
- /* raw output does not have a way to express rename nor copy */
- if (strcmp(p->one->path, p->two->path))
- return;
-
- if (p->one->file_valid && p->two->file_valid) {
- char hex[41];
- strcpy(hex, sha1_to_hex(p->one->sha1));
- printf("*%06o->%06o %s %s->%s %s%c",
- p->one->mode, p->two->mode,
- git_object_type(p->one->mode),
- hex, sha1_to_hex(p->two->sha1),
- p->one->path, diff_raw_output);
- return;
- }
-
- if (p->one->file_valid) {
- it = p->one;
- addremove = '-';
- } else {
- it = p->two;
- addremove = '+';
- }
-
- printf("%c%06o %s %s %s%c",
- addremove,
- it->mode, git_object_type(it->mode),
- sha1_to_hex(it->sha1), it->path, diff_raw_output);
+ /*
+ * We used to reject rename/copy but new diff-raw can express them.
+ */
+ printf(":%06o %06o %s ",
+ p->one->mode, p->two->mode, sha1_to_hex(p->one->sha1));
+ printf("%s%c%s%c%s%c",
+ sha1_to_hex(p->two->sha1), inter_name_termination,
+ p->one->path, inter_name_termination,
+ p->two->path, line_termination);
}
static void diff_flush_patch(struct diff_filepair *p)
name = p->one->path;
other = (strcmp(name, p->two->path) ? p->two->path : NULL);
- if ((p->one->file_valid && S_ISDIR(p->one->mode)) ||
- (p->two->file_valid && S_ISDIR(p->two->mode)))
+ if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) ||
+ (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode)))
return; /* no tree diffs in patch format */
run_external_diff(name, other, p->one, p->two, p->xfrm_msg);
* and filter and clean them up here before producing the output.
*/
- if (!one->file_valid && !two->file_valid)
+ if (!DIFF_FILE_VALID(one) && !DIFF_FILE_VALID(two))
return 1; /* not interesting */
/* deletion, addition, mode change and renames are all interesting. */
- if ((one->file_valid != two->file_valid) || (one->mode != two->mode) ||
+ if (DIFF_FILE_VALID(one) != DIFF_FILE_VALID(two) ||
+ (one->mode != two->mode) ||
strcmp(one->path, two->path))
return 0;
{
if (identical(p->one, p->two))
return;
- if (0 <= diff_raw_output)
- diff_flush_raw(p);
- else
+ if (generate_patch)
diff_flush_patch(p);
+ else
+ diff_flush_raw(p);
}
int diff_queue_is_empty(void)
diff_queue(&diff_queued_diff, one, two);
}
+void diff_guif(unsigned old_mode,
+ unsigned new_mode,
+ const unsigned char *old_sha1,
+ const unsigned char *new_sha1,
+ const char *old_path,
+ const char *new_path)
+{
+ struct diff_filespec *one, *two;
+
+ if (reverse_diff) {
+ unsigned tmp;
+ const unsigned char *tmp_c;
+ tmp = old_mode; old_mode = new_mode; new_mode = tmp;
+ tmp_c = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_c;
+ }
+ one = alloc_filespec(old_path);
+ two = alloc_filespec(new_path);
+ if (old_mode)
+ fill_filespec(one, old_sha1, old_mode);
+ if (new_mode)
+ fill_filespec(two, new_sha1, new_mode);
+ diff_queue(&diff_queued_diff, one, two);
+}
+
void diff_change(unsigned old_mode, unsigned new_mode,
const unsigned char *old_sha1,
const unsigned char *new_sha1,
- const char *base, const char *path) {
+ const char *base, const char *path)
+{
char concatpath[PATH_MAX];
struct diff_filespec *one, *two;
void diff_unmerge(const char *path)
{
- if (0 <= diff_raw_output) {
- printf("U %s%c", path, diff_raw_output);
- return;
- }
- run_external_diff(path, NULL, NULL, NULL, NULL);
+ if (generate_patch)
+ run_external_diff(path, NULL, NULL, NULL, NULL);
+ else
+ printf("U %s%c", path, line_termination);
}
index 7b9f37d1b8af201fbcf5dcf43b2b1187841dc6c6..1fc8469cfc2f1463274333c0bebab0e4e495bc6b 100644 (file)
--- a/diff.h
+++ b/diff.h
const unsigned char *sha2,
const char *base, const char *path);
+extern void diff_guif(unsigned mode1,
+ unsigned mode2,
+ const unsigned char *sha1,
+ const unsigned char *sha2,
+ const char *path1,
+ const char *path2);
+
extern void diff_unmerge(const char *path);
extern int diff_scoreopt_parse(const char *opt);
-extern void diff_setup(int reverse, int diff_raw_output);
+#define DIFF_FORMAT_HUMAN 0
+#define DIFF_FORMAT_MACHINE 1
+#define DIFF_FORMAT_PATCH 2
+extern void diff_setup(int reverse, int diff_output_style);
extern void diff_detect_rename(int, int);
extern void diff_pickaxe(const char *);
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 9b9d0b73f2656cc989b397f7fdc26c37f19d6dc1..0bad705d579e641774a6f324cf9fc4a7a2068f58 100644 (file)
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
- if (!p->one->file_valid) {
- if (!p->two->file_valid)
+ if (!DIFF_FILE_VALID(p->one)) {
+ if (!DIFF_FILE_VALID(p->two))
continue; /* ignore nonsense */
/* created */
if (contains(p->two, needle, len))
diff_queue(&outq, p->one, p->two);
}
- else if (!p->two->file_valid) {
+ else if (!DIFF_FILE_VALID(p->two)) {
if (contains(p->one, needle, len))
diff_queue(&outq, p->one, p->two);
}
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 9a13cafd6856607f429b517067c3f4c03975fb36..28b1de25de4d8444bdf369506f04126b6aede665 100644 (file)
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
fprintf(stderr, "queue[%d] %s (%s) %s %06o %s\n",
x, one,
s->path,
- s->file_valid ? "valid" : "invalid",
+ DIFF_FILE_VALID(s) ? "valid" : "invalid",
s->mode,
s->sha1_valid ? sha1_to_hex(s->sha1) : "");
fprintf(stderr, "queue[%d] %s size %lu flags %d\n",
*/
while (i < q->nr) {
struct diff_filepair *p = q->queue[i++];
- if (!p->two->file_valid)
+ if (!DIFF_FILE_VALID(p->two))
continue; /* removed is fine */
if (strcmp(p->one->path, it->path))
continue; /* not relevant */
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
- if (!p->one->file_valid)
- if (!p->two->file_valid)
+ if (!DIFF_FILE_VALID(p->one))
+ if (!DIFF_FILE_VALID(p->two))
continue; /* ignore nonsense */
else
diff_rename_pool_add(&created, p->two);
- else if (!p->two->file_valid)
+ else if (!DIFF_FILE_VALID(p->two))
diff_rename_pool_add(&deleted, p->one);
else if (1 < detect_rename) /* find copy, too */
diff_rename_pool_add(&stay, p->one);
*/
for (i = 0; i < q->nr; i++) {
struct diff_filepair *dp, *p = q->queue[i];
- if (!p->one->file_valid) {
- if (p->two->file_valid) {
+ if (!DIFF_FILE_VALID(p->one)) {
+ if (DIFF_FILE_VALID(p->two)) {
/* creation */
dp = diff_queue(&outq, p->one, p->two);
dp->xfrm_work = 4;
}
/* otherwise it is a nonsense; just ignore it */
}
- else if (!p->two->file_valid) {
+ else if (!DIFF_FILE_VALID(p->two)) {
/* deletion */
dp = diff_queue(&outq, p->one, p->two);
dp->xfrm_work = 2;
/* Copy it out to q, removing duplicates. */
for (i = 0; i < outq.nr; i++) {
struct diff_filepair *p = outq.queue[i];
- if (!p->one->file_valid) {
+ if (!DIFF_FILE_VALID(p->one)) {
/* created */
if (p->two->xfrm_flags & RENAME_DST_MATCHED)
; /* rename/copy created it already */
else
diff_queue(q, p->one, p->two);
}
- else if (!p->two->file_valid) {
+ else if (!DIFF_FILE_VALID(p->two)) {
/* deleted */
if (p->one->xfrm_flags & RENAME_SRC_GONE)
; /* rename/copy deleted it already */
diff --git a/diffcore.h b/diffcore.h
index 2938271511b2020a682135b96ad281f3c5a49bfc..5eca32afcc570c83338b6afbbba0db68bf8d2f84 100644 (file)
--- a/diffcore.h
+++ b/diffcore.h
* if false, use the name and read from
* the filesystem.
*/
- unsigned file_valid : 1; /* if false the file does not exist */
+#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
unsigned should_free : 1; /* data should be free()'ed */
unsigned should_munmap : 1; /* data should be munmap()'ed */
};
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 1a3a51122523222ec6668368723c49dcad9104b4..831fe9558031392215d3375a605114f04f8d5284 100755 (executable)
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
test "$newtree" = "$tree"'
cat >expected <<\EOF
-*100644->100644 blob f87290f8eb2cbbea7857214459a0739927eab154->0000000000000000000000000000000000000000 path0
-*120000->120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01->0000000000000000000000000000000000000000 path0sym
-*100644->100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7->0000000000000000000000000000000000000000 path2/file2
-*120000->120000 blob d8ce161addc5173867a3c3c730924388daedbc38->0000000000000000000000000000000000000000 path2/file2sym
-*100644->100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376->0000000000000000000000000000000000000000 path3/file3
-*120000->120000 blob 8599103969b43aff7e430efea79ca4636466794f->0000000000000000000000000000000000000000 path3/file3sym
-*100644->100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f->0000000000000000000000000000000000000000 path3/subp3/file3
-*120000->120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c->0000000000000000000000000000000000000000 path3/subp3/file3sym
+:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 path0 path0
+:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 path0sym path0sym
+:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 path2/file2 path2/file2
+:120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 path2/file2sym path2/file2sym
+:100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 path3/file3 path3/file3
+:120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 path3/file3sym path3/file3sym
+:100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 path3/subp3/file3 path3/subp3/file3
+:120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 path3/subp3/file3sym path3/subp3/file3sym
EOF
test_expect_success \
'validate git-diff-files output for a know cache/work tree state.' \
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index 5da05be2c1a0d49b7b405e5a7f5cbf4d0af0790a..ecce6afc9039ac9e234bba1cea78ea3d0b922198 100644 (file)
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
. ../lib-read-tree-m-3way.sh
cat >.test-plain-OA <<\EOF
-+100644 blob ccba72ad3888a3520b39efcf780b9ee64167535d AA
-+100644 blob 7e426fb079479fd67f6d81f984e4ec649a44bc25 AN
--100644 blob bcc68ef997017466d5c9094bcf7692295f588c9a DD
-+040000 tree 6d50f65d3bdab91c63444294d38f08aeff328e42 DF
--100644 blob 141c1f1642328e4bc46a7d801a71da392e66791e DM
--100644 blob 35abde1506ddf806572ff4d407bd06885d0f8ee9 DN
-+100644 blob 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL
-*100644->100644 blob 03f24c8c4700babccfd28b654e7e8eac402ad6cd->103d9f89b50b9aad03054b579be5e7aa665f2d57 MD
-*100644->100644 blob b258508afb7ceb449981bd9d63d2d3e971bf8d34->b431b272d829ff3aa4d1a5085f4394ab4d3305b6 MM
-*100644->100644 blob bd084b0c27c7b6cc34f11d6d0509a29be3caf970->a716d58de4a570e0038f5c307bd8db34daea021f MN
-*100644->100644 blob 40c959f984c8b89a2b02520d17f00d717f024397->2ac547ae9614a00d1b28275de608131f7a0e259f SS
-*100644->100644 blob 4ac13458899ab908ef3b1128fa378daefc88d356->4c86f9a85fbc5e6804ee2e17a797538fbe785bca TT
-*040000->040000 tree 7d670fdcdb9929f6c7dac196ff78689cd1c566a1->5e5f22072bb39f6e12cf663a57cb634c76eefb49 Z
+:000000 100644 0000000000000000000000000000000000000000 ccba72ad3888a3520b39efcf780b9ee64167535d AA AA
+:000000 100644 0000000000000000000000000000000000000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 AN AN
+:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 DD DD
+:000000 040000 0000000000000000000000000000000000000000 6d50f65d3bdab91c63444294d38f08aeff328e42 DF DF
+:100644 000000 141c1f1642328e4bc46a7d801a71da392e66791e 0000000000000000000000000000000000000000 DM DM
+:100644 000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 0000000000000000000000000000000000000000 DN DN
+:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL LL
+:100644 100644 03f24c8c4700babccfd28b654e7e8eac402ad6cd 103d9f89b50b9aad03054b579be5e7aa665f2d57 MD MD
+:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 MM MM
+:100644 100644 bd084b0c27c7b6cc34f11d6d0509a29be3caf970 a716d58de4a570e0038f5c307bd8db34daea021f MN MN
+:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f SS SS
+:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 4c86f9a85fbc5e6804ee2e17a797538fbe785bca TT TT
+:040000 040000 7d670fdcdb9929f6c7dac196ff78689cd1c566a1 5e5f22072bb39f6e12cf663a57cb634c76eefb49 Z Z
EOF
cat >.test-recursive-OA <<\EOF
-+100644 blob ccba72ad3888a3520b39efcf780b9ee64167535d AA
-+100644 blob 7e426fb079479fd67f6d81f984e4ec649a44bc25 AN
--100644 blob bcc68ef997017466d5c9094bcf7692295f588c9a DD
-+100644 blob 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 DF/DF
--100644 blob 141c1f1642328e4bc46a7d801a71da392e66791e DM
--100644 blob 35abde1506ddf806572ff4d407bd06885d0f8ee9 DN
-+100644 blob 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL
-*100644->100644 blob 03f24c8c4700babccfd28b654e7e8eac402ad6cd->103d9f89b50b9aad03054b579be5e7aa665f2d57 MD
-*100644->100644 blob b258508afb7ceb449981bd9d63d2d3e971bf8d34->b431b272d829ff3aa4d1a5085f4394ab4d3305b6 MM
-*100644->100644 blob bd084b0c27c7b6cc34f11d6d0509a29be3caf970->a716d58de4a570e0038f5c307bd8db34daea021f MN
-*100644->100644 blob 40c959f984c8b89a2b02520d17f00d717f024397->2ac547ae9614a00d1b28275de608131f7a0e259f SS
-*100644->100644 blob 4ac13458899ab908ef3b1128fa378daefc88d356->4c86f9a85fbc5e6804ee2e17a797538fbe785bca TT
-+100644 blob 8acb8e9750e3f644bf323fcf3d338849db106c77 Z/AA
-+100644 blob 087494262084cefee7ed484d20c8dc0580791272 Z/AN
--100644 blob 879007efae624d2b1307214b24a956f0a8d686a8 Z/DD
--100644 blob 9b541b2275c06e3a7b13f28badf5294e2ae63df4 Z/DM
--100644 blob beb5d38c55283d280685ea21a0e50cfcc0ca064a Z/DN
-*100644->100644 blob d41fda41b7ec4de46b43cb7ea42a45001ae393d5->a79ac3be9377639e1c7d1edf1ae1b3a5f0ccd8a9 Z/MD
-*100644->100644 blob 4ca22bae2527d3d9e1676498a0fba3b355bd1278->61422ba9c2c873416061a88cd40a59a35b576474 Z/MM
-*100644->100644 blob b16d7b25b869f2beb124efa53467d8a1550ad694->a5c544c21cfcb07eb80a4d89a5b7d1570002edfd Z/MN
+:000000 100644 0000000000000000000000000000000000000000 ccba72ad3888a3520b39efcf780b9ee64167535d AA AA
+:000000 100644 0000000000000000000000000000000000000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 AN AN
+:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 DD DD
+:000000 100644 0000000000000000000000000000000000000000 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 DF/DF DF/DF
+:100644 000000 141c1f1642328e4bc46a7d801a71da392e66791e 0000000000000000000000000000000000000000 DM DM
+:100644 000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 0000000000000000000000000000000000000000 DN DN
+:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL LL
+:100644 100644 03f24c8c4700babccfd28b654e7e8eac402ad6cd 103d9f89b50b9aad03054b579be5e7aa665f2d57 MD MD
+:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 MM MM
+:100644 100644 bd084b0c27c7b6cc34f11d6d0509a29be3caf970 a716d58de4a570e0038f5c307bd8db34daea021f MN MN
+:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f SS SS
+:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 4c86f9a85fbc5e6804ee2e17a797538fbe785bca TT TT
+:000000 100644 0000000000000000000000000000000000000000 8acb8e9750e3f644bf323fcf3d338849db106c77 Z/AA Z/AA
+:000000 100644 0000000000000000000000000000000000000000 087494262084cefee7ed484d20c8dc0580791272 Z/AN Z/AN
+:100644 000000 879007efae624d2b1307214b24a956f0a8d686a8 0000000000000000000000000000000000000000 Z/DD Z/DD
+:100644 000000 9b541b2275c06e3a7b13f28badf5294e2ae63df4 0000000000000000000000000000000000000000 Z/DM Z/DM
+:100644 000000 beb5d38c55283d280685ea21a0e50cfcc0ca064a 0000000000000000000000000000000000000000 Z/DN Z/DN
+:100644 100644 d41fda41b7ec4de46b43cb7ea42a45001ae393d5 a79ac3be9377639e1c7d1edf1ae1b3a5f0ccd8a9 Z/MD Z/MD
+:100644 100644 4ca22bae2527d3d9e1676498a0fba3b355bd1278 61422ba9c2c873416061a88cd40a59a35b576474 Z/MM Z/MM
+:100644 100644 b16d7b25b869f2beb124efa53467d8a1550ad694 a5c544c21cfcb07eb80a4d89a5b7d1570002edfd Z/MN Z/MN
EOF
cat >.test-plain-OB <<\EOF
-+100644 blob 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA
--100644 blob bcc68ef997017466d5c9094bcf7692295f588c9a DD
-+100644 blob 71420ab81e254145d26d6fc0cddee64c1acd4787 DF
-*100644->100644 blob 141c1f1642328e4bc46a7d801a71da392e66791e->3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM
-+100644 blob 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL
--100644 blob 03f24c8c4700babccfd28b654e7e8eac402ad6cd MD
-*100644->100644 blob b258508afb7ceb449981bd9d63d2d3e971bf8d34->19989d4559aae417fedee240ccf2ba315ea4dc2b MM
-+100644 blob 15885881ea69115351c09b38371f0348a3fb8c67 NA
--100644 blob a4e179e4291e5536a5e1c82e091052772d2c5a93 ND
-*100644->100644 blob c8f25781e8f1792e3e40b74225e20553041b5226->cdb9a8c3da571502ac30225e9c17beccb8387983 NM
-*100644->100644 blob 40c959f984c8b89a2b02520d17f00d717f024397->2ac547ae9614a00d1b28275de608131f7a0e259f SS
-*100644->100644 blob 4ac13458899ab908ef3b1128fa378daefc88d356->c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT
-*040000->040000 tree 7d670fdcdb9929f6c7dac196ff78689cd1c566a1->1ba523955d5160681af65cb776411f574c1e8155 Z
+:000000 100644 0000000000000000000000000000000000000000 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA AA
+:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 DD DD
+:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 DF DF
+:100644 100644 141c1f1642328e4bc46a7d801a71da392e66791e 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM DM
+:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL LL
+:100644 000000 03f24c8c4700babccfd28b654e7e8eac402ad6cd 0000000000000000000000000000000000000000 MD MD
+:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 19989d4559aae417fedee240ccf2ba315ea4dc2b MM MM
+:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 NA NA
+:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 ND ND
+:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 NM NM
+:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f SS SS
+:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT TT
+:040000 040000 7d670fdcdb9929f6c7dac196ff78689cd1c566a1 1ba523955d5160681af65cb776411f574c1e8155 Z Z
EOF
cat >.test-recursive-OB <<\EOF
-+100644 blob 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA
--100644 blob bcc68ef997017466d5c9094bcf7692295f588c9a DD
-+100644 blob 71420ab81e254145d26d6fc0cddee64c1acd4787 DF
-*100644->100644 blob 141c1f1642328e4bc46a7d801a71da392e66791e->3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM
-+100644 blob 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL
--100644 blob 03f24c8c4700babccfd28b654e7e8eac402ad6cd MD
-*100644->100644 blob b258508afb7ceb449981bd9d63d2d3e971bf8d34->19989d4559aae417fedee240ccf2ba315ea4dc2b MM
-+100644 blob 15885881ea69115351c09b38371f0348a3fb8c67 NA
--100644 blob a4e179e4291e5536a5e1c82e091052772d2c5a93 ND
-*100644->100644 blob c8f25781e8f1792e3e40b74225e20553041b5226->cdb9a8c3da571502ac30225e9c17beccb8387983 NM
-*100644->100644 blob 40c959f984c8b89a2b02520d17f00d717f024397->2ac547ae9614a00d1b28275de608131f7a0e259f SS
-*100644->100644 blob 4ac13458899ab908ef3b1128fa378daefc88d356->c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT
-+100644 blob 6c0b99286d0bce551ac4a7b3dff8b706edff3715 Z/AA
--100644 blob 879007efae624d2b1307214b24a956f0a8d686a8 Z/DD
-*100644->100644 blob 9b541b2275c06e3a7b13f28badf5294e2ae63df4->d77371d15817fcaa57eeec27f770c505ba974ec1 Z/DM
--100644 blob d41fda41b7ec4de46b43cb7ea42a45001ae393d5 Z/MD
-*100644->100644 blob 4ca22bae2527d3d9e1676498a0fba3b355bd1278->697aad7715a1e7306ca76290a3dd4208fbaeddfa Z/MM
-+100644 blob d12979c22fff69c59ca9409e7a8fe3ee25eaee80 Z/NA
--100644 blob a18393c636b98e9bd7296b8b437ea4992b72440c Z/ND
-*100644->100644 blob 3fdbe17fd013303a2e981e1ca1c6cd6e72789087->7e09d6a3a14bd630913e8c75693cea32157b606d Z/NM
+:000000 100644 0000000000000000000000000000000000000000 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA AA
+:100644 000000 bcc68ef997017466d5c9094bcf7692295f588c9a 0000000000000000000000000000000000000000 DD DD
+:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 DF DF
+:100644 100644 141c1f1642328e4bc46a7d801a71da392e66791e 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM DM
+:000000 100644 0000000000000000000000000000000000000000 1d41122ebdd7a640f29d3c9cc4f9d70094374762 LL LL
+:100644 000000 03f24c8c4700babccfd28b654e7e8eac402ad6cd 0000000000000000000000000000000000000000 MD MD
+:100644 100644 b258508afb7ceb449981bd9d63d2d3e971bf8d34 19989d4559aae417fedee240ccf2ba315ea4dc2b MM MM
+:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 NA NA
+:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 ND ND
+:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 NM NM
+:100644 100644 40c959f984c8b89a2b02520d17f00d717f024397 2ac547ae9614a00d1b28275de608131f7a0e259f SS SS
+:100644 100644 4ac13458899ab908ef3b1128fa378daefc88d356 c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT TT
+:000000 100644 0000000000000000000000000000000000000000 6c0b99286d0bce551ac4a7b3dff8b706edff3715 Z/AA Z/AA
+:100644 000000 879007efae624d2b1307214b24a956f0a8d686a8 0000000000000000000000000000000000000000 Z/DD Z/DD
+:100644 100644 9b541b2275c06e3a7b13f28badf5294e2ae63df4 d77371d15817fcaa57eeec27f770c505ba974ec1 Z/DM Z/DM
+:100644 000000 d41fda41b7ec4de46b43cb7ea42a45001ae393d5 0000000000000000000000000000000000000000 Z/MD Z/MD
+:100644 100644 4ca22bae2527d3d9e1676498a0fba3b355bd1278 697aad7715a1e7306ca76290a3dd4208fbaeddfa Z/MM Z/MM
+:000000 100644 0000000000000000000000000000000000000000 d12979c22fff69c59ca9409e7a8fe3ee25eaee80 Z/NA Z/NA
+:100644 000000 a18393c636b98e9bd7296b8b437ea4992b72440c 0000000000000000000000000000000000000000 Z/ND Z/ND
+:100644 100644 3fdbe17fd013303a2e981e1ca1c6cd6e72789087 7e09d6a3a14bd630913e8c75693cea32157b606d Z/NM Z/NM
EOF
cat >.test-plain-AB <<\EOF
-*100644->100644 blob ccba72ad3888a3520b39efcf780b9ee64167535d->6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA
--100644 blob 7e426fb079479fd67f6d81f984e4ec649a44bc25 AN
-+100644 blob 71420ab81e254145d26d6fc0cddee64c1acd4787 DF
--040000 tree 6d50f65d3bdab91c63444294d38f08aeff328e42 DF
-+100644 blob 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM
-+100644 blob 35abde1506ddf806572ff4d407bd06885d0f8ee9 DN
--100644 blob 103d9f89b50b9aad03054b579be5e7aa665f2d57 MD
-*100644->100644 blob b431b272d829ff3aa4d1a5085f4394ab4d3305b6->19989d4559aae417fedee240ccf2ba315ea4dc2b MM
-*100644->100644 blob a716d58de4a570e0038f5c307bd8db34daea021f->bd084b0c27c7b6cc34f11d6d0509a29be3caf970 MN
-+100644 blob 15885881ea69115351c09b38371f0348a3fb8c67 NA
--100644 blob a4e179e4291e5536a5e1c82e091052772d2c5a93 ND
-*100644->100644 blob c8f25781e8f1792e3e40b74225e20553041b5226->cdb9a8c3da571502ac30225e9c17beccb8387983 NM
-*100644->100644 blob 4c86f9a85fbc5e6804ee2e17a797538fbe785bca->c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT
-*040000->040000 tree 5e5f22072bb39f6e12cf663a57cb634c76eefb49->1ba523955d5160681af65cb776411f574c1e8155 Z
+:100644 100644 ccba72ad3888a3520b39efcf780b9ee64167535d 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA AA
+:100644 000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 0000000000000000000000000000000000000000 AN AN
+:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 DF DF
+:040000 000000 6d50f65d3bdab91c63444294d38f08aeff328e42 0000000000000000000000000000000000000000 DF DF
+:000000 100644 0000000000000000000000000000000000000000 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM DM
+:000000 100644 0000000000000000000000000000000000000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 DN DN
+:100644 000000 103d9f89b50b9aad03054b579be5e7aa665f2d57 0000000000000000000000000000000000000000 MD MD
+:100644 100644 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 19989d4559aae417fedee240ccf2ba315ea4dc2b MM MM
+:100644 100644 a716d58de4a570e0038f5c307bd8db34daea021f bd084b0c27c7b6cc34f11d6d0509a29be3caf970 MN MN
+:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 NA NA
+:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 ND ND
+:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 NM NM
+:100644 100644 4c86f9a85fbc5e6804ee2e17a797538fbe785bca c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT TT
+:040000 040000 5e5f22072bb39f6e12cf663a57cb634c76eefb49 1ba523955d5160681af65cb776411f574c1e8155 Z Z
EOF
cat >.test-recursive-AB <<\EOF
-*100644->100644 blob ccba72ad3888a3520b39efcf780b9ee64167535d->6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA
--100644 blob 7e426fb079479fd67f6d81f984e4ec649a44bc25 AN
-+100644 blob 71420ab81e254145d26d6fc0cddee64c1acd4787 DF
--100644 blob 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 DF/DF
-+100644 blob 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM
-+100644 blob 35abde1506ddf806572ff4d407bd06885d0f8ee9 DN
--100644 blob 103d9f89b50b9aad03054b579be5e7aa665f2d57 MD
-*100644->100644 blob b431b272d829ff3aa4d1a5085f4394ab4d3305b6->19989d4559aae417fedee240ccf2ba315ea4dc2b MM
-*100644->100644 blob a716d58de4a570e0038f5c307bd8db34daea021f->bd084b0c27c7b6cc34f11d6d0509a29be3caf970 MN
-+100644 blob 15885881ea69115351c09b38371f0348a3fb8c67 NA
--100644 blob a4e179e4291e5536a5e1c82e091052772d2c5a93 ND
-*100644->100644 blob c8f25781e8f1792e3e40b74225e20553041b5226->cdb9a8c3da571502ac30225e9c17beccb8387983 NM
-*100644->100644 blob 4c86f9a85fbc5e6804ee2e17a797538fbe785bca->c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT
-*100644->100644 blob 8acb8e9750e3f644bf323fcf3d338849db106c77->6c0b99286d0bce551ac4a7b3dff8b706edff3715 Z/AA
--100644 blob 087494262084cefee7ed484d20c8dc0580791272 Z/AN
-+100644 blob d77371d15817fcaa57eeec27f770c505ba974ec1 Z/DM
-+100644 blob beb5d38c55283d280685ea21a0e50cfcc0ca064a Z/DN
--100644 blob a79ac3be9377639e1c7d1edf1ae1b3a5f0ccd8a9 Z/MD
-*100644->100644 blob 61422ba9c2c873416061a88cd40a59a35b576474->697aad7715a1e7306ca76290a3dd4208fbaeddfa Z/MM
-*100644->100644 blob a5c544c21cfcb07eb80a4d89a5b7d1570002edfd->b16d7b25b869f2beb124efa53467d8a1550ad694 Z/MN
-+100644 blob d12979c22fff69c59ca9409e7a8fe3ee25eaee80 Z/NA
--100644 blob a18393c636b98e9bd7296b8b437ea4992b72440c Z/ND
-*100644->100644 blob 3fdbe17fd013303a2e981e1ca1c6cd6e72789087->7e09d6a3a14bd630913e8c75693cea32157b606d Z/NM
+:100644 100644 ccba72ad3888a3520b39efcf780b9ee64167535d 6aa2b5335b16431a0ef71e5c0a28be69183cf6a2 AA AA
+:100644 000000 7e426fb079479fd67f6d81f984e4ec649a44bc25 0000000000000000000000000000000000000000 AN AN
+:000000 100644 0000000000000000000000000000000000000000 71420ab81e254145d26d6fc0cddee64c1acd4787 DF DF
+:100644 000000 68a6d8b91da11045cf4aa3a5ab9f2a781c701249 0000000000000000000000000000000000000000 DF/DF DF/DF
+:000000 100644 0000000000000000000000000000000000000000 3c4d8de5fbad08572bab8e10eef8dbb264cf0231 DM DM
+:000000 100644 0000000000000000000000000000000000000000 35abde1506ddf806572ff4d407bd06885d0f8ee9 DN DN
+:100644 000000 103d9f89b50b9aad03054b579be5e7aa665f2d57 0000000000000000000000000000000000000000 MD MD
+:100644 100644 b431b272d829ff3aa4d1a5085f4394ab4d3305b6 19989d4559aae417fedee240ccf2ba315ea4dc2b MM MM
+:100644 100644 a716d58de4a570e0038f5c307bd8db34daea021f bd084b0c27c7b6cc34f11d6d0509a29be3caf970 MN MN
+:000000 100644 0000000000000000000000000000000000000000 15885881ea69115351c09b38371f0348a3fb8c67 NA NA
+:100644 000000 a4e179e4291e5536a5e1c82e091052772d2c5a93 0000000000000000000000000000000000000000 ND ND
+:100644 100644 c8f25781e8f1792e3e40b74225e20553041b5226 cdb9a8c3da571502ac30225e9c17beccb8387983 NM NM
+:100644 100644 4c86f9a85fbc5e6804ee2e17a797538fbe785bca c4e4a12231b9fa79a0053cb6077fcb21bb5b135a TT TT
+:100644 100644 8acb8e9750e3f644bf323fcf3d338849db106c77 6c0b99286d0bce551ac4a7b3dff8b706edff3715 Z/AA Z/AA
+:100644 000000 087494262084cefee7ed484d20c8dc0580791272 0000000000000000000000000000000000000000 Z/AN Z/AN
+:000000 100644 0000000000000000000000000000000000000000 d77371d15817fcaa57eeec27f770c505ba974ec1 Z/DM Z/DM
+:000000 100644 0000000000000000000000000000000000000000 beb5d38c55283d280685ea21a0e50cfcc0ca064a Z/DN Z/DN
+:100644 000000 a79ac3be9377639e1c7d1edf1ae1b3a5f0ccd8a9 0000000000000000000000000000000000000000 Z/MD Z/MD
+:100644 100644 61422ba9c2c873416061a88cd40a59a35b576474 697aad7715a1e7306ca76290a3dd4208fbaeddfa Z/MM Z/MM
+:100644 100644 a5c544c21cfcb07eb80a4d89a5b7d1570002edfd b16d7b25b869f2beb124efa53467d8a1550ad694 Z/MN Z/MN
+:000000 100644 0000000000000000000000000000000000000000 d12979c22fff69c59ca9409e7a8fe3ee25eaee80 Z/NA Z/NA
+:100644 000000 a18393c636b98e9bd7296b8b437ea4992b72440c 0000000000000000000000000000000000000000 Z/ND Z/ND
+:100644 100644 3fdbe17fd013303a2e981e1ca1c6cd6e72789087 7e09d6a3a14bd630913e8c75693cea32157b606d Z/NM Z/NM
EOF
-
x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
x40="$x40$x40$x40$x40$x40$x40$x40$x40"
z40='0000000000000000000000000000000000000000'
# object ID for the changed files because it wants you to look at the
# filesystem.
sed <"$2" >.test-tmp \
- -e '/^+/d;/\^*/s/\( '$x40'->\)'$x40' /\1'$z40' /' &&
+ -e '/^:000000 /d;s/'$x40' /'$z40' /' &&
diff "$1" .test-tmp
}
index 3dde165e3a120e7edf4a3aac685ce6ba56c870da..167d0b95b54cedc1adcc6c1040b681c9bc051760 100644 (file)
--- a/t/t4003-diff-rename-1.sh
+++ b/t/t4003-diff-rename-1.sh
# both are slightly edited. So we say you copy-and-edit one,
# and rename-and-edit the other.
-GIT_DIFF_OPTS=--unified=0 git-diff-cache -M $tree |
+GIT_DIFF_OPTS=--unified=0 git-diff-cache -M -p $tree |
sed -e 's/\([0-9][0-9]*\)/#/g' >current &&
cat >expected <<\EOF
diff --git a/COPYING b/COPYING.#
# both are slightly edited. So we say you edited one,
# and copy-and-edit the other.
-GIT_DIFF_OPTS=--unified=0 git-diff-cache -C $tree |
+GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p $tree |
sed -e 's/\([0-9][0-9]*\)/#/g' >current
cat >expected <<\EOF
diff --git a/COPYING b/COPYING.#
# this is only possible because -C mode now reports the unmodified
# file to the diff-core.
-GIT_DIFF_OPTS=--unified=0 git-diff-cache -C $tree |
+GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p $tree |
sed -e 's/\([0-9][0-9]*\)/#/g' >current
cat >expected <<\EOF
diff --git a/COPYING b/COPYING.#