read-tree -m -u: do not overwrite or remove untracked working tree files.
[git.git] / diff-index.c
blob8c9f60173b18a68f6ea224b2e6fc9c0eab4b9d0f
1 #include "cache.h"
2 #include "diff.h"
3 #include "commit.h"
4 #include "revision.h"
6 static const char diff_cache_usage[] =
7 "git-diff-index [-m] [--cached] "
8 "[<common diff options>] <tree-ish> [<path>...]"
9 COMMON_DIFF_OPTIONS_HELP;
11 int main(int argc, const char **argv)
13 struct rev_info rev;
14 int cached = 0;
15 int i;
17 git_config(git_diff_config);
18 init_revisions(&rev);
19 rev.abbrev = 0;
21 argc = setup_revisions(argc, argv, &rev, NULL);
22 for (i = 1; i < argc; i++) {
23 const char *arg = argv[i];
25 if (!strcmp(arg, "--cached"))
26 cached = 1;
27 else
28 usage(diff_cache_usage);
31 * Make sure there is one revision (i.e. pending object),
32 * and there is no revision filtering parameters.
34 if (!rev.pending_objects || rev.pending_objects->next ||
35 rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
36 usage(diff_cache_usage);
37 return run_diff_index(&rev, cached);