builtin-diff-index.con commit git-send-email: handle email address with quoted comma (0e73b3e)
   1#include "cache.h"
   2#include "diff.h"
   3#include "commit.h"
   4#include "revision.h"
   5#include "builtin.h"
   6
   7static const char diff_cache_usage[] =
   8"git diff-index [-m] [--cached] "
   9"[<common diff options>] <tree-ish> [<path>...]"
  10COMMON_DIFF_OPTIONS_HELP;
  11
  12int 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        int result;
  18
  19        init_revisions(&rev, prefix);
  20        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
  21        rev.abbrev = 0;
  22
  23        argc = setup_revisions(argc, argv, &rev, NULL);
  24        for (i = 1; i < argc; i++) {
  25                const char *arg = argv[i];
  26
  27                if (!strcmp(arg, "--cached"))
  28                        cached = 1;
  29                else
  30                        usage(diff_cache_usage);
  31        }
  32        if (!rev.diffopt.output_format)
  33                rev.diffopt.output_format = DIFF_FORMAT_RAW;
  34
  35        /*
  36         * Make sure there is one revision (i.e. pending object),
  37         * and there is no revision filtering parameters.
  38         */
  39        if (rev.pending.nr != 1 ||
  40            rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
  41                usage(diff_cache_usage);
  42        if (!cached)
  43                setup_work_tree();
  44        if (read_cache() < 0) {
  45                perror("read_cache");
  46                return -1;
  47        }
  48        result = run_diff_index(&rev, cached);
  49        return diff_result_code(&rev.diffopt, result);
  50}