Skip to content

Commit 77882f6

Browse files
author
Junio C Hamano
committed
Retire diffcore-pathspec.
Nobody except diff-stages used it -- the callers instead filtered the input to diffcore themselves. Make diff-stages do that as well and retire diffcore-pathspec. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent a13ba12 commit 77882f6

File tree

5 files changed

+11
-81
lines changed

5 files changed

+11
-81
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ LIB_H = \
197197
tree-walk.h
198198

199199
DIFF_OBJS = \
200-
diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
200+
diff.o diffcore-break.o diffcore-order.o \
201201
diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
202202
diffcore-delta.o
203203

diff-stages.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ static const char diff_stages_usage[] =
1111
"git-diff-stages [<common diff options>] <stage1> <stage2> [<path>...]"
1212
COMMON_DIFF_OPTIONS_HELP;
1313

14-
static void diff_stages(int stage1, int stage2)
14+
static void diff_stages(int stage1, int stage2, const char **pathspec)
1515
{
1616
int i = 0;
1717
while (i < active_nr) {
1818
struct cache_entry *ce, *stages[4] = { NULL, };
1919
struct cache_entry *one, *two;
2020
const char *name;
21-
int len;
21+
int len, skip;
22+
2223
ce = active_cache[i];
24+
skip = !ce_path_match(ce, pathspec);
2325
len = ce_namelen(ce);
2426
name = ce->name;
2527
for (;;) {
@@ -34,7 +36,8 @@ static void diff_stages(int stage1, int stage2)
3436
}
3537
one = stages[stage1];
3638
two = stages[stage2];
37-
if (!one && !two)
39+
40+
if (skip || (!one && !two))
3841
continue;
3942
if (!one)
4043
diff_addremove(&diff_options, '+', ntohl(two->ce_mode),
@@ -54,8 +57,8 @@ static void diff_stages(int stage1, int stage2)
5457
int main(int ac, const char **av)
5558
{
5659
int stage1, stage2;
57-
58-
setup_git_directory();
60+
const char *prefix = setup_git_directory();
61+
const char **pathspec = NULL;
5962

6063
git_config(git_diff_config);
6164
read_cache();
@@ -89,12 +92,12 @@ int main(int ac, const char **av)
8992
usage(diff_stages_usage);
9093

9194
av += 3; /* The rest from av[0] are for paths restriction. */
92-
diff_options.paths = av;
95+
pathspec = get_pathspec(prefix, av);
9396

9497
if (diff_setup_done(&diff_options) < 0)
9598
usage(diff_stages_usage);
9699

97-
diff_stages(stage1, stage2);
100+
diff_stages(stage1, stage2, pathspec);
98101
diffcore_std(&diff_options);
99102
diff_flush(&diff_options);
100103
return 0;

diff.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,6 @@ static void diffcore_apply_filter(const char *filter)
13751375

13761376
void diffcore_std(struct diff_options *options)
13771377
{
1378-
if (options->paths && options->paths[0])
1379-
diffcore_pathspec(options->paths);
13801378
if (options->break_opt != -1)
13811379
diffcore_break(options->break_opt);
13821380
if (options->detect_rename)

diff.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ typedef void (*add_remove_fn_t)(struct diff_options *options,
2020
const char *base, const char *path);
2121

2222
struct diff_options {
23-
const char **paths;
2423
const char *filter;
2524
const char *orderfile;
2625
const char *pickaxe;

diffcore-pathspec.c

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)