[PATCH] Remove map_sha1_file
[gitweb.git] / diff-tree.c
index 7446e09af4f4b7a5f7475a42bb60c9818e6cc9d5..ea237051ee5e5249f8096ae75b188b6b7a55011a 100644 (file)
@@ -280,11 +280,7 @@ static int call_diff_flush(void)
                return 0;
        }
        if (header) {
-               const char *fmt = "%s";
-               if (diff_output_format == DIFF_FORMAT_MACHINE)
-                       fmt = "%s%c";
-               
-               printf(fmt, header, 0);
+               printf("%s%c", header, diff_output_format == DIFF_FORMAT_MACHINE ? 0 : '\n');
                header = NULL;
        }
        diff_flush(diff_output_format);
@@ -318,18 +314,16 @@ static int diff_root_tree(const unsigned char *new, const char *base)
        return retval;
 }
 
-static char *generate_header(const char *commit, const char *parent, const char *msg, unsigned long len)
+static const char *generate_header(const char *commit, const char *parent, const char *msg, unsigned long len)
 {
        static char this_header[16384];
        int offset;
 
-       offset = sprintf(this_header, "%s%s (from %s)\n", header_prefix, commit, parent);
-       if (verbose_header) {
-               offset += pretty_print_commit(commit_format, msg, len, this_header + offset, sizeof(this_header) - offset);
-               this_header[offset++] = '\n';
-               this_header[offset++] = 0;
-       }
+       if (!verbose_header)
+               return commit;
 
+       offset = sprintf(this_header, "%s%s (from %s)\n", header_prefix, commit, parent);
+       offset += pretty_print_commit(commit_format, msg, len, this_header + offset, sizeof(this_header) - offset);
        return this_header;
 }
 
@@ -403,19 +397,6 @@ static int diff_tree_stdin(char *line)
 static char *diff_tree_usage =
 "git-diff-tree [-p] [-r] [-z] [--stdin] [-m] [-s] [-v] [--pretty] [-t] [-R] [-B] [-M] [-C] [--find-copies-header] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> <tree-ish>";
 
-static enum cmit_fmt get_commit_format(const char *arg)
-{
-       if (!*arg)
-               return CMIT_FMT_DEFAULT;
-       if (!strcmp(arg, "=raw"))
-               return CMIT_FMT_RAW;
-       if (!strcmp(arg, "=medium"))
-               return CMIT_FMT_MEDIUM;
-       if (!strcmp(arg, "=short"))
-               return CMIT_FMT_SHORT;
-       usage(diff_tree_usage);
-}
-
 int main(int argc, const char **argv)
 {
        int nr_sha1;
@@ -457,7 +438,7 @@ int main(int argc, const char **argv)
                        diff_setup_opt |= DIFF_SETUP_REVERSE;
                        continue;
                }
-               if (!strcmp(arg, "-p")) {
+               if (!strcmp(arg, "-p") || !strcmp(arg, "-u")) {
                        diff_output_format = DIFF_FORMAT_PATCH;
                        recursive = 1;
                        continue;