]> git.ipfire.org Git - thirdparty/git.git/blame - diff-index.c
Builtin git-show-branch.
[thirdparty/git.git] / diff-index.c
CommitLineData
e74f8f6a 1#include "cache.h"
f92a4465 2#include "diff.h"
e09ad6e1
JH
3#include "commit.h"
4#include "revision.h"
b5af9107 5
4d1f1190 6static const char diff_cache_usage[] =
215a7ad1 7"git-diff-index [-m] [--cached] "
dda2d79a
JH
8"[<common diff options>] <tree-ish> [<path>...]"
9COMMON_DIFF_OPTIONS_HELP;
c5bac17a 10
6b5ee137 11int main(int argc, const char **argv)
e74f8f6a 12{
e09ad6e1 13 struct rev_info rev;
e09ad6e1 14 int cached = 0;
6c56c534 15 int i;
e74f8f6a 16
9ce392f4 17 git_config(git_diff_config);
e09ad6e1
JH
18 init_revisions(&rev);
19 rev.abbrev = 0;
20
21 argc = setup_revisions(argc, argv, &rev, NULL);
6c56c534
LT
22 for (i = 1; i < argc; i++) {
23 const char *arg = argv[i];
6c56c534 24
5c21ac0e 25 if (!strcmp(arg, "--cached"))
e09ad6e1
JH
26 cached = 1;
27 else
6b5ee137 28 usage(diff_cache_usage);
e74f8f6a 29 }
e09ad6e1
JH
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)
c5bac17a 36 usage(diff_cache_usage);
5c21ac0e 37 return run_diff_index(&rev, cached);
e74f8f6a 38}