Code

Allow config file to specify Signed-off-by identity in format-patch.
[git.git] / builtin-diff-files.c
1 /*
2  * GIT - The information manager from hell
3  *
4  * Copyright (C) Linus Torvalds, 2005
5  */
6 #include "cache.h"
7 #include "diff.h"
8 #include "commit.h"
9 #include "revision.h"
10 #include "builtin.h"
12 static const char diff_files_usage[] =
13 "git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
14 COMMON_DIFF_OPTIONS_HELP;
16 int cmd_diff_files(int argc, const char **argv, const char *prefix)
17 {
18         struct rev_info rev;
19         int silent = 0;
21         init_revisions(&rev, prefix);
22         git_config(git_default_config); /* no "diff" UI options */
23         rev.abbrev = 0;
25         argc = setup_revisions(argc, argv, &rev, NULL);
26         while (1 < argc && argv[1][0] == '-') {
27                 if (!strcmp(argv[1], "--base"))
28                         rev.max_count = 1;
29                 else if (!strcmp(argv[1], "--ours"))
30                         rev.max_count = 2;
31                 else if (!strcmp(argv[1], "--theirs"))
32                         rev.max_count = 3;
33                 else if (!strcmp(argv[1], "-q"))
34                         silent = 1;
35                 else
36                         usage(diff_files_usage);
37                 argv++; argc--;
38         }
39         if (!rev.diffopt.output_format)
40                 rev.diffopt.output_format = DIFF_FORMAT_RAW;
42         /*
43          * Make sure there are NO revision (i.e. pending object) parameter,
44          * rev.max_count is reasonable (0 <= n <= 3),
45          * there is no other revision filtering parameters.
46          */
47         if (rev.pending.nr ||
48             rev.min_age != -1 || rev.max_age != -1)
49                 usage(diff_files_usage);
50         /*
51          * Backward compatibility wart - "diff-files -s" used to
52          * defeat the common diff option "-s" which asked for
53          * DIFF_FORMAT_NO_OUTPUT.
54          */
55         if (rev.diffopt.output_format == DIFF_FORMAT_NO_OUTPUT)
56                 rev.diffopt.output_format = DIFF_FORMAT_RAW;
57         return run_diff_files(&rev, silent);
58 }