X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=diff-tree.c;h=6f8dc2024c289a92fe81014511a8377364340783;hb=000182eacf99cde27d5916aa415921924b82972c;hp=db37aa714f0d0a7b0b2437ffb5b04351642f1e00;hpb=e3bc7a3bc7b77f44d686003f5a9346a135529f73;p=git.git diff --git a/diff-tree.c b/diff-tree.c index db37aa71..6f8dc202 100644 --- a/diff-tree.c +++ b/diff-tree.c @@ -19,6 +19,7 @@ static int diff_break_opt = -1; static const char *orderfile = NULL; static const char *header = NULL; static const char *header_prefix = ""; +static enum cmit_fmt commit_format = CMIT_FMT_RAW; // What paths are we interested in? static int nr_paths = 0; @@ -44,10 +45,12 @@ static const unsigned char *extract(void *tree, unsigned long size, const char * int len = strlen(tree)+1; const unsigned char *sha1 = tree + len; const char *path = strchr(tree, ' '); + unsigned int mode; - if (!path || size < len + 20 || sscanf(tree, "%o", modep) != 1) + if (!path || size < len + 20 || sscanf(tree, "%o", &mode) != 1) die("corrupt tree file"); *pathp = path+1; + *modep = DIFF_FILE_CANON_MODE(mode); return sha1; } @@ -319,7 +322,7 @@ static char *generate_header(const char *commit, const char *parent, const char offset = sprintf(this_header, "%s%s (from %s)\n", header_prefix, commit, parent); if (verbose_header) { - offset += pretty_print_commit(msg, len, this_header + offset, sizeof(this_header) - offset); + offset += pretty_print_commit(commit_format, msg, len, this_header + offset, sizeof(this_header) - offset); this_header[offset++] = '\n'; this_header[offset++] = 0; } @@ -395,7 +398,7 @@ static int diff_tree_stdin(char *line) } static char *diff_tree_usage = -"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-C] [-R] [-S] [-m] [-s] [-v] [-t] "; +"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-C] [-R] [-S] [-O] [-m] [-s] [-v] [-t] "; int main(int argc, const char **argv) { @@ -457,16 +460,19 @@ int main(int argc, const char **argv) } if (!strncmp(arg, "-M", 2)) { detect_rename = DIFF_DETECT_RENAME; - diff_score_opt = diff_scoreopt_parse(arg); + if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1) + usage(diff_tree_usage); continue; } if (!strncmp(arg, "-C", 2)) { detect_rename = DIFF_DETECT_COPY; - diff_score_opt = diff_scoreopt_parse(arg); + if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1) + usage(diff_tree_usage); continue; } if (!strncmp(arg, "-B", 2)) { - diff_break_opt = diff_scoreopt_parse(arg); + if ((diff_break_opt = diff_scoreopt_parse(arg)) == -1) + usage(diff_tree_usage); continue; } if (!strcmp(arg, "-z")) {