You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
941 B
40 lines
941 B
20 years ago
|
#include "cache.h"
|
||
20 years ago
|
#include "diff.h"
|
||
19 years ago
|
#include "commit.h"
|
||
|
#include "revision.h"
|
||
19 years ago
|
#include "builtin.h"
|
||
20 years ago
|
|
||
20 years ago
|
static const char diff_cache_usage[] =
|
||
19 years ago
|
"git-diff-index [-m] [--cached] "
|
||
20 years ago
|
"[<common diff options>] <tree-ish> [<path>...]"
|
||
|
COMMON_DIFF_OPTIONS_HELP;
|
||
20 years ago
|
|
||
19 years ago
|
int cmd_diff_index(int argc, const char **argv, char **envp)
|
||
20 years ago
|
{
|
||
19 years ago
|
struct rev_info rev;
|
||
|
int cached = 0;
|
||
20 years ago
|
int i;
|
||
20 years ago
|
|
||
19 years ago
|
git_config(git_diff_config);
|
||
19 years ago
|
init_revisions(&rev);
|
||
|
rev.abbrev = 0;
|
||
|
|
||
|
argc = setup_revisions(argc, argv, &rev, NULL);
|
||
20 years ago
|
for (i = 1; i < argc; i++) {
|
||
|
const char *arg = argv[i];
|
||
|
|
||
19 years ago
|
if (!strcmp(arg, "--cached"))
|
||
19 years ago
|
cached = 1;
|
||
|
else
|
||
19 years ago
|
usage(diff_cache_usage);
|
||
20 years ago
|
}
|
||
19 years ago
|
/*
|
||
|
* 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)
|
||
20 years ago
|
usage(diff_cache_usage);
|
||
19 years ago
|
return run_diff_index(&rev, cached);
|
||
20 years ago
|
}
|