2 * GIT - The information manager from hell
4 * Copyright (C) Linus Torvalds, 2005
11 #include "submodule.h"
13 static const char diff_files_usage
[] =
14 "git diff-files [-q] [-0 | -1 | -2 | -3 | -c | --cc] [<common-diff-options>] [<path>...]"
15 COMMON_DIFF_OPTIONS_HELP
;
17 int cmd_diff_files(int argc
, const char **argv
, const char *prefix
)
23 git_config(git_diff_basic_config
, NULL
); /* no "diff" UI options */
24 init_revisions(&rev
, prefix
);
27 precompose_argv(argc
, argv
);
29 argc
= setup_revisions(argc
, argv
, &rev
, NULL
);
30 while (1 < argc
&& argv
[1][0] == '-') {
31 if (!strcmp(argv
[1], "--base"))
33 else if (!strcmp(argv
[1], "--ours"))
35 else if (!strcmp(argv
[1], "--theirs"))
37 else if (!strcmp(argv
[1], "-q"))
38 options
|= DIFF_SILENT_ON_REMOVED
;
40 usage(diff_files_usage
);
43 if (!rev
.diffopt
.output_format
)
44 rev
.diffopt
.output_format
= DIFF_FORMAT_RAW
;
47 * Make sure there are NO revision (i.e. pending object) parameter,
48 * rev.max_count is reasonable (0 <= n <= 3), and
49 * there is no other revision filtering parameters.
52 rev
.min_age
!= -1 || rev
.max_age
!= -1 ||
54 usage(diff_files_usage
);
57 * "diff-files --base -p" should not combine merges because it
58 * was not asked to. "diff-files -c -p" should not densify
59 * (the user should ask with "diff-files --cc" explicitly).
61 if (rev
.max_count
== -1 && !rev
.combine_merges
&&
62 (rev
.diffopt
.output_format
& DIFF_FORMAT_PATCH
))
63 rev
.combine_merges
= rev
.dense_combined_merges
= 1;
65 if (read_cache_preload(&rev
.diffopt
.pathspec
) < 0) {
66 perror("read_cache_preload");
69 result
= run_diff_files(&rev
, options
);
70 return diff_result_code(&rev
.diffopt
, result
);