X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=diff-tree.c;h=233a25066818b49c94112f6f2680c6f6d7c881f8;hb=52e9578985fb636ec1d3f6cf794fdadd5ec896fc;hp=b43df18ef5e6f20366e8c5f3ae24b8466edebb8b;hpb=57fe64a40d95dd99d798c6d7c81c1a76d24a8e7c;p=git.git diff --git a/diff-tree.c b/diff-tree.c index b43df18e..233a2506 100644 --- a/diff-tree.c +++ b/diff-tree.c @@ -11,7 +11,9 @@ static int read_stdin = 0; static int line_termination = '\n'; static int generate_patch = 0; static int detect_rename = 0; +static int reverse_diff = 0; static int diff_score_opt = 0; +static char *pickaxe = 0; static const char *header = NULL; static const char *header_prefix = ""; @@ -106,7 +108,7 @@ static int compare_tree_entry(void *tree1, unsigned long size1, void *tree2, uns pathlen1 = strlen(path1); pathlen2 = strlen(path2); - cmp = cache_name_compare(path1, pathlen1, path2, pathlen2); + cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2); if (cmp < 0) { show_file("-", tree1, size1, base); return -1; @@ -253,10 +255,10 @@ static int diff_tree_sha1(const unsigned char *old, const unsigned char *new, co unsigned long size1, size2; int retval; - tree1 = read_object_with_reference(old, "tree", &size1, 0); + tree1 = read_object_with_reference(old, "tree", &size1, NULL); if (!tree1) die("unable to read source tree (%s)", sha1_to_hex(old)); - tree2 = read_object_with_reference(new, "tree", &size2, 0); + tree2 = read_object_with_reference(new, "tree", &size2, NULL); if (!tree2) die("unable to read destination tree (%s)", sha1_to_hex(new)); retval = diff_tree(tree1, size1, tree2, size2, base); @@ -270,9 +272,9 @@ static int diff_tree_sha1_top(const unsigned char *old, { int ret; - diff_setup(detect_rename, diff_score_opt, 0, - (generate_patch ? -1 : line_termination), - 0, 0); + diff_setup(detect_rename, diff_score_opt, pickaxe, + reverse_diff, (generate_patch ? -1 : line_termination), + NULL, 0); ret = diff_tree_sha1(old, new, base); diff_flush(); return ret; @@ -284,10 +286,10 @@ static int diff_root_tree(const unsigned char *new, const char *base) void *tree; unsigned long size; - diff_setup(detect_rename, diff_score_opt, 0, - (generate_patch ? -1 : line_termination), - 0, 0); - tree = read_object_with_reference(new, "tree", &size, 0); + diff_setup(detect_rename, diff_score_opt, pickaxe, + reverse_diff, (generate_patch ? -1 : line_termination), + NULL, 0); + tree = read_object_with_reference(new, "tree", &size, NULL); if (!tree) die("unable to read root tree (%s)", sha1_to_hex(new)); retval = diff_tree("", 0, tree, size, base); @@ -429,7 +431,7 @@ static int diff_tree_stdin(char *line) } static char *diff_tree_usage = -"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-m] [-s] [-v] "; +"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-C] [-R] [-S] [-m] [-s] [-v] "; int main(int argc, char **argv) { @@ -464,15 +466,29 @@ int main(int argc, char **argv) recursive = 1; continue; } + if (!strcmp(arg, "-R")) { + reverse_diff = 1; + continue; + } if (!strcmp(arg, "-p")) { recursive = generate_patch = 1; continue; } + if (!strncmp(arg, "-S", 2)) { + pickaxe = arg + 2; + continue; + } if (!strncmp(arg, "-M", 2)) { detect_rename = recursive = generate_patch = 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'; continue;