2005-04-20 06:00:09 +02:00
|
|
|
#include "cache.h"
|
2005-04-27 18:21:00 +02:00
|
|
|
#include "diff.h"
|
2006-04-22 11:43:00 +02:00
|
|
|
#include "commit.h"
|
|
|
|
#include "revision.h"
|
2006-05-23 14:15:36 +02:00
|
|
|
#include "builtin.h"
|
2005-04-23 02:15:28 +02:00
|
|
|
|
2005-07-29 11:01:26 +02:00
|
|
|
static const char diff_cache_usage[] =
|
2005-09-08 02:26:23 +02:00
|
|
|
"git-diff-index [-m] [--cached] "
|
2005-07-13 21:52:35 +02:00
|
|
|
"[<common diff options>] <tree-ish> [<path>...]"
|
|
|
|
COMMON_DIFF_OPTIONS_HELP;
|
2005-04-21 04:49:16 +02:00
|
|
|
|
2006-05-23 14:15:36 +02:00
|
|
|
int cmd_diff_index(int argc, const char **argv, char **envp)
|
2005-04-20 06:00:09 +02:00
|
|
|
{
|
2006-04-22 11:43:00 +02:00
|
|
|
struct rev_info rev;
|
|
|
|
int cached = 0;
|
2005-05-25 03:10:11 +02:00
|
|
|
int i;
|
2005-04-20 06:00:09 +02:00
|
|
|
|
2005-11-22 07:52:37 +01:00
|
|
|
git_config(git_diff_config);
|
2006-04-22 11:43:00 +02:00
|
|
|
init_revisions(&rev);
|
|
|
|
rev.abbrev = 0;
|
|
|
|
|
|
|
|
argc = setup_revisions(argc, argv, &rev, NULL);
|
2005-05-25 03:10:11 +02:00
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
const char *arg = argv[i];
|
|
|
|
|
2006-04-22 12:58:04 +02:00
|
|
|
if (!strcmp(arg, "--cached"))
|
2006-04-22 11:43:00 +02:00
|
|
|
cached = 1;
|
|
|
|
else
|
2005-09-21 09:00:47 +02:00
|
|
|
usage(diff_cache_usage);
|
2005-04-20 06:00:09 +02:00
|
|
|
}
|
2006-04-22 11:43:00 +02: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 04:49:16 +02:00
|
|
|
usage(diff_cache_usage);
|
2006-04-22 12:58:04 +02:00
|
|
|
return run_diff_index(&rev, cached);
|
2005-04-20 06:00:09 +02:00
|
|
|
}
|