2005-04-20 12:00:09 +08:00
|
|
|
#include "cache.h"
|
2005-04-28 00:21:00 +08:00
|
|
|
#include "diff.h"
|
2006-04-22 17:43:00 +08:00
|
|
|
#include "commit.h"
|
|
|
|
#include "revision.h"
|
2005-04-23 08:15:28 +08:00
|
|
|
|
2005-07-29 17:01:26 +08:00
|
|
|
static const char diff_cache_usage[] =
|
2005-09-08 08:26:23 +08:00
|
|
|
"git-diff-index [-m] [--cached] "
|
2005-07-14 03:52:35 +08:00
|
|
|
"[<common diff options>] <tree-ish> [<path>...]"
|
|
|
|
COMMON_DIFF_OPTIONS_HELP;
|
2005-04-21 10:49:16 +08:00
|
|
|
|
2005-09-21 15:00:47 +08:00
|
|
|
int main(int argc, const char **argv)
|
2005-04-20 12:00:09 +08:00
|
|
|
{
|
2006-04-22 17:43:00 +08:00
|
|
|
struct rev_info rev;
|
|
|
|
int cached = 0;
|
2005-05-25 09:10:11 +08:00
|
|
|
int i;
|
2005-04-20 12:00:09 +08:00
|
|
|
|
2005-11-22 14:52:37 +08:00
|
|
|
git_config(git_diff_config);
|
2006-04-22 17:43:00 +08:00
|
|
|
init_revisions(&rev);
|
|
|
|
rev.abbrev = 0;
|
|
|
|
|
|
|
|
argc = setup_revisions(argc, argv, &rev, NULL);
|
2005-05-25 09:10:11 +08:00
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
const char *arg = argv[i];
|
|
|
|
|
2006-04-22 18:58:04 +08:00
|
|
|
if (!strcmp(arg, "--cached"))
|
2006-04-22 17:43:00 +08:00
|
|
|
cached = 1;
|
|
|
|
else
|
2005-09-21 15:00:47 +08:00
|
|
|
usage(diff_cache_usage);
|
2005-04-20 12:00:09 +08:00
|
|
|
}
|
2006-04-22 17:43:00 +08:00
|
|
|
/*
|
|
|
|
* Make sure there is one revision (i.e. pending object),
|
|
|
|
* and there is no revision filtering parameters.
|
|
|
|
*/
|
|
|
|
if (!rev.pending_objects || rev.pending_objects->next ||
|
|
|
|
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
|
2005-04-21 10:49:16 +08:00
|
|
|
usage(diff_cache_usage);
|
2006-04-22 18:58:04 +08:00
|
|
|
return run_diff_index(&rev, cached);
|
2005-04-20 12:00:09 +08:00
|
|
|
}
|