Merge branch 'jc/diff' into next
[git] / diff-index.c
1 #include "cache.h"
2 #include "diff.h"
3 #include "commit.h"
4 #include "revision.h"
5
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;
10
11 int main(int argc, const char **argv)
12 {
13         struct rev_info rev;
14         int match_missing = 0;
15         int cached = 0;
16         int i;
17
18         git_config(git_diff_config);
19         init_revisions(&rev);
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, "-m"))
27                         match_missing = 1; 
28                 else if (!strcmp(arg, "--cached"))
29                         cached = 1;
30                 else
31                         usage(diff_cache_usage);
32         }
33         /*
34          * Make sure there is one revision (i.e. pending object),
35          * and there is no revision filtering parameters.
36          */
37         if (!rev.pending_objects || rev.pending_objects->next ||
38             rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
39                 usage(diff_cache_usage);
40         return run_diff_index(&rev, cached, match_missing);
41 }