]>
Commit | Line | Data |
---|---|---|
8bc9a0c7 LT |
1 | /* |
2 | * GIT - The information manager from hell | |
3 | * | |
4 | * Copyright (C) Linus Torvalds, 2005 | |
5 | */ | |
e83c5163 | 6 | #include "cache.h" |
4a6bf9e1 | 7 | #include "diff.h" |
91539833 LT |
8 | #include "commit.h" |
9 | #include "revision.h" | |
c0fb976a | 10 | |
4d1f1190 | 11 | static const char diff_files_usage[] = |
ea726d02 | 12 | "git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]" |
dda2d79a | 13 | COMMON_DIFF_OPTIONS_HELP; |
b8f80925 | 14 | |
6b5ee137 | 15 | int main(int argc, const char **argv) |
e83c5163 | 16 | { |
6973dcae JH |
17 | struct rev_info rev; |
18 | int silent = 0; | |
e83c5163 | 19 | |
9ce392f4 | 20 | git_config(git_diff_config); |
6973dcae JH |
21 | init_revisions(&rev); |
22 | rev.abbrev = 0; | |
23 | ||
24 | argc = setup_revisions(argc, argv, &rev, NULL); | |
b8f80925 | 25 | while (1 < argc && argv[1][0] == '-') { |
6973dcae JH |
26 | if (!strcmp(argv[1], "--base")) |
27 | rev.max_count = 1; | |
10637b84 | 28 | else if (!strcmp(argv[1], "--ours")) |
6973dcae | 29 | rev.max_count = 2; |
10637b84 | 30 | else if (!strcmp(argv[1], "--theirs")) |
6973dcae | 31 | rev.max_count = 3; |
10637b84 | 32 | else if (!strcmp(argv[1], "-q")) |
d15aa430 | 33 | silent = 1; |
6973dcae JH |
34 | else |
35 | usage(diff_files_usage); | |
b8f80925 | 36 | argv++; argc--; |
e2e5e98a | 37 | } |
6973dcae JH |
38 | /* |
39 | * Make sure there are NO revision (i.e. pending object) parameter, | |
40 | * rev.max_count is reasonable (0 <= n <= 3), | |
41 | * there is no other revision filtering parameters. | |
42 | */ | |
43 | if (rev.pending_objects || | |
44 | rev.min_age != -1 || rev.max_age != -1) | |
4727f640 | 45 | usage(diff_files_usage); |
6973dcae JH |
46 | /* |
47 | * Backward compatibility wart - "diff-files -s" used to | |
48 | * defeat the common diff option "-s" which asked for | |
49 | * DIFF_FORMAT_NO_OUTPUT. | |
b8f80925 | 50 | */ |
6973dcae JH |
51 | if (rev.diffopt.output_format == DIFF_FORMAT_NO_OUTPUT) |
52 | rev.diffopt.output_format = DIFF_FORMAT_RAW; | |
53 | return run_diff_files(&rev, silent); | |
e83c5163 | 54 | } |