git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
28bc51d0d8f443bf86b76670c24d08b5725e1588 blob 2231 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.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;

static int parse_distinct_options(int argc, const char **argv,
				  struct rev_info *revs, unsigned int *options)
{
	int i, left;

	for (i = left = 1; i < argc; i++) {
		const char *arg = argv[i];
		int leave = 0;

		if (!strcmp(arg, "--cached"))
			*options |= DIFF_INDEX_CACHED;
		else if (!strcmp(arg, "--merge-base"))
			*options |= DIFF_INDEX_MERGE_BASE;
		else if (!strcmp(arg, "-m"))
			revs->match_missing = 1;
		else
			leave = 1;

		if (leave)
			argv[left++] = arg;
	}

	argv[left] = NULL;

	return left;
}

int cmd_diff_index(int argc, const char **argv, const char *prefix)
{
	struct rev_info rev;
	unsigned int option = 0;
	int result;

	if (argc == 2 && !strcmp(argv[1], "-h"))
		usage(diff_cache_usage);

	git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
	repo_init_revisions(the_repository, &rev, prefix);
	rev.abbrev = 0;
	prefix = precompose_argv_prefix(argc, argv, prefix);

	/*
	 * It's essential to parse our distinct options before calling
	 * setup_revisions(), for the latter not to see "-m".
	 */
	argc = parse_distinct_options(argc, argv, &rev, &option);
	argc = setup_revisions(argc, argv, &rev, NULL);

	if (argc > 1)
		usage(diff_cache_usage);

	if (!rev.diffopt.output_format)
		rev.diffopt.output_format = DIFF_FORMAT_RAW;

	rev.diffopt.rotate_to_strict = 1;

	/*
	 * 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 (!(option & DIFF_INDEX_CACHED)) {
		setup_work_tree();
		if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
			perror("read_cache_preload");
			return -1;
		}
	} else if (read_cache() < 0) {
		perror("read_cache");
		return -1;
	}
	result = run_diff_index(&rev, option);
	UNLEAK(rev);
	return diff_result_code(&rev.diffopt, result);
}
debug log:

solving 28bc51d0d8f4 ...
found 28bc51d0d8f4 in https://public-inbox.org/git/20210510153451.15090-3-sorganov@gmail.com/
found 176fe7ff2b4e in git.git.git
preparing index
index prepared:
100644 176fe7ff2b4e15b4a95ffc3019528318af84b42a	builtin/diff-index.c

applying [1/1] https://public-inbox.org/git/20210510153451.15090-3-sorganov@gmail.com/
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 176fe7ff2b4e..28bc51d0d8f4 100644

Checking patch builtin/diff-index.c...
Applied patch builtin/diff-index.c cleanly.

index at:
100644 28bc51d0d8f443bf86b76670c24d08b5725e1588	builtin/diff-index.c

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).