]> git.ipfire.org Git - thirdparty/git.git/blob - builtin-diff-index.c
builtin-mv: fix use of uninitialized memory.
[thirdparty/git.git] / builtin-diff-index.c
1 #include "cache.h"
2 #include "diff.h"
3 #include "commit.h"
4 #include "revision.h"
5 #include "builtin.h"
6
7 static const char diff_cache_usage[] =
8 "git-diff-index [-m] [--cached] "
9 "[<common diff options>] <tree-ish> [<path>...]"
10 COMMON_DIFF_OPTIONS_HELP;
11
12 int cmd_diff_index(int argc, const char **argv, const char *prefix)
13 {
14 struct rev_info rev;
15 int cached = 0;
16 int i;
17
18 init_revisions(&rev, prefix);
19 git_config(git_default_config); /* no "diff" UI options */
20 rev.abbrev = 0;
21
22 argc = setup_revisions(argc, argv, &rev, NULL);
23 for (i = 1; i < argc; i++) {
24 const char *arg = argv[i];
25
26 if (!strcmp(arg, "--cached"))
27 cached = 1;
28 else
29 usage(diff_cache_usage);
30 }
31 if (!rev.diffopt.output_format)
32 rev.diffopt.output_format = DIFF_FORMAT_RAW;
33
34 /*
35 * Make sure there is one revision (i.e. pending object),
36 * and there is no revision filtering parameters.
37 */
38 if (rev.pending.nr != 1 ||
39 rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
40 usage(diff_cache_usage);
41 return run_diff_index(&rev, cached);
42 }