diff-index.con commit Merge branch 'jc/mailinfo' into next (7b8e4ab)
   1#include "cache.h"
   2#include "diff.h"
   3#include "commit.h"
   4#include "revision.h"
   5
   6static const char diff_cache_usage[] =
   7"git-diff-index [-m] [--cached] "
   8"[<common diff options>] <tree-ish> [<path>...]"
   9COMMON_DIFF_OPTIONS_HELP;
  10
  11int main(int argc, const char **argv)
  12{
  13        struct rev_info rev;
  14        int cached = 0;
  15        int i;
  16
  17        git_config(git_diff_config);
  18        init_revisions(&rev);
  19        rev.abbrev = 0;
  20
  21        argc = setup_revisions(argc, argv, &rev, NULL);
  22        for (i = 1; i < argc; i++) {
  23                const char *arg = argv[i];
  24                        
  25                if (!strcmp(arg, "--cached"))
  26                        cached = 1;
  27                else
  28                        usage(diff_cache_usage);
  29        }
  30        /*
  31         * Make sure there is one revision (i.e. pending object),
  32         * and there is no revision filtering parameters.
  33         */
  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);
  38}