diff-files.con commit Merge branch 'ar/chmod-series' into next (8b72575)
   1/*
   2 * GIT - The information manager from hell
   3 *
   4 * Copyright (C) Linus Torvalds, 2005
   5 */
   6#include "cache.h"
   7#include "diff.h"
   8#include "commit.h"
   9#include "revision.h"
  10
  11static const char diff_files_usage[] =
  12"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
  13COMMON_DIFF_OPTIONS_HELP;
  14
  15int main(int argc, const char **argv)
  16{
  17        struct rev_info rev;
  18        int silent = 0;
  19
  20        git_config(git_diff_config);
  21        init_revisions(&rev);
  22        rev.abbrev = 0;
  23
  24        argc = setup_revisions(argc, argv, &rev, NULL);
  25        while (1 < argc && argv[1][0] == '-') {
  26                if (!strcmp(argv[1], "--base"))
  27                        rev.max_count = 1;
  28                else if (!strcmp(argv[1], "--ours"))
  29                        rev.max_count = 2;
  30                else if (!strcmp(argv[1], "--theirs"))
  31                        rev.max_count = 3;
  32                else if (!strcmp(argv[1], "-q"))
  33                        silent = 1;
  34                else
  35                        usage(diff_files_usage);
  36                argv++; argc--;
  37        }
  38        /*
  39         * Make sure there are NO revision (i.e. pending object) parameter,
  40         * rev.max_count is reasonable (0 <= n <= 3),
  41         * there is no other revision filtering parameters.
  42         */
  43        if (rev.pending_objects ||
  44            rev.min_age != -1 || rev.max_age != -1)
  45                usage(diff_files_usage);
  46        /*
  47         * Backward compatibility wart - "diff-files -s" used to
  48         * defeat the common diff option "-s" which asked for
  49         * DIFF_FORMAT_NO_OUTPUT.
  50         */
  51        if (rev.diffopt.output_format == DIFF_FORMAT_NO_OUTPUT)
  52                rev.diffopt.output_format = DIFF_FORMAT_RAW;
  53        return run_diff_files(&rev, silent);
  54}