Skip to content

Commit 33b238d

Browse files
paskyPetr Baudis
authored andcommitted
[PATCH] Change diff-tree output format
Changes diff-tree output format so that fields are separated by tabs instead of spaces (readibility, parseability), and tree entry type is listed along the entry (avoids having to figure that out from the mode in the scripts). This is what my scripts expect. Signed-off-by: Petr Baudis <[email protected]>
1 parent 35bb478 commit 33b238d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

diff-tree.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ static void show_file(const char *prefix, void *tree, unsigned long size, const
7373
return;
7474
}
7575

76-
printf("%s%o %s %s%s%c", prefix, mode, sha1_to_hex(sha1), base, path, 0);
76+
printf("%s%o\t%s\t%s\t%s%s%c", prefix, mode,
77+
S_ISDIR(mode) ? "tree" : "blob",
78+
sha1_to_hex(sha1), base, path, 0);
7779
}
7880

7981
static int compare_tree_entry(void *tree1, unsigned long size1, void *tree2, unsigned long size2, const char *base)
@@ -120,7 +122,9 @@ static int compare_tree_entry(void *tree1, unsigned long size1, void *tree2, uns
120122
}
121123

122124
strcpy(old_sha1_hex, sha1_to_hex(sha1));
123-
printf("*%o->%o %s->%s %s%s%c", mode1, mode2, old_sha1_hex, sha1_to_hex(sha2), base, path1, 0);
125+
printf("*%o->%o\t%s\t%s->%s\t%s%s%c", mode1, mode2,
126+
S_ISDIR(mode1) ? "tree" : "blob",
127+
old_sha1_hex, sha1_to_hex(sha2), base, path1, 0);
124128
return 0;
125129
}
126130

0 commit comments

Comments
 (0)