diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-11-23 13:28:53 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-11-23 13:28:53 -0800 |
commit | 3686aa1caf907d22fe318c28efe93f0e7870ba50 (patch) | |
tree | f99a303bd14c7343be7ccc5b9df5382f1bf79246 /builtin/diff-index.c | |
parent | imap-send: Remove unused 'use_namespace' variable (diff) | |
parent | documentation fix: git difftool uses diff tools, not merge tools. (diff) | |
download | tgif-3686aa1caf907d22fe318c28efe93f0e7870ba50.tar.xz |
Merge branch 'maint' into tj/imap-send-remove-unused
* maint: (18123 commits)
documentation fix: git difftool uses diff tools, not merge tools.
Git 1.7.7.4
Makefile: add missing header file dependencies
notes merge: eliminate OUTPUT macro
mailmap: xcalloc mailmap_info
name-rev --all: do not even attempt to describe non-commit object
Git 1.7.7.3
docs: Update install-doc-quick
docs: don't mention --quiet or --exit-code in git-log(1)
Git 1.7.7.2
t7511: avoid use of reserved filename on Windows.
clone: Quote user supplied path in a single quote pair
read-cache.c: fix index memory allocation
make the sample pre-commit hook script reject names with newlines, too
Reindent closing bracket using tab instead of spaces
Git 1.7.7.1
RelNotes/1.7.7.1: setgid bit patch is about fixing "git init" via Makefile setting
gitweb: fix regression when filtering out forks
Almost ready for 1.7.7.1
pack-objects: don't traverse objects unnecessarily
...
Conflicts:
imap-send.c
Diffstat (limited to 'builtin/diff-index.c')
-rw-r--r-- | builtin/diff-index.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/builtin/diff-index.c b/builtin/diff-index.c new file mode 100644 index 0000000000..2eb32bd9da --- /dev/null +++ b/builtin/diff-index.c @@ -0,0 +1,52 @@ +#include "cache.h" +#include "diff.h" +#include "commit.h" +#include "revision.h" +#include "builtin.h" +#include "submodule.h" + +static const char diff_cache_usage[] = +"git diff-index [-m] [--cached] " +"[<common diff options>] <tree-ish> [<path>...]" +COMMON_DIFF_OPTIONS_HELP; + +int cmd_diff_index(int argc, const char **argv, const char *prefix) +{ + struct rev_info rev; + int cached = 0; + int i; + int result; + + init_revisions(&rev, prefix); + gitmodules_config(); + git_config(git_diff_basic_config, NULL); /* no "diff" UI options */ + rev.abbrev = 0; + + argc = setup_revisions(argc, argv, &rev, NULL); + for (i = 1; i < argc; i++) { + const char *arg = argv[i]; + + if (!strcmp(arg, "--cached")) + cached = 1; + else + usage(diff_cache_usage); + } + if (!rev.diffopt.output_format) + rev.diffopt.output_format = DIFF_FORMAT_RAW; + + /* + * Make sure there is one revision (i.e. pending object), + * and there is no revision filtering parameters. + */ + if (rev.pending.nr != 1 || + rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1) + usage(diff_cache_usage); + if (!cached) + setup_work_tree(); + if (read_cache() < 0) { + perror("read_cache"); + return -1; + } + result = run_diff_index(&rev, cached); + return diff_result_code(&rev.diffopt, result); +} |