Skip to content

Commit

Permalink
diff-no-index: use diff_tree_setup_paths()
Browse files Browse the repository at this point in the history
diff_options.{paths,nr_paths} will be removed later. Do not
modify them directly.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Feb 3, 2011
1 parent 0602f3e commit 16dc36f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions diff-no-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ void diff_no_index(struct rev_info *revs,

if (prefix) {
int len = strlen(prefix);
const char *paths[3];
memset(paths, 0, sizeof(paths));

revs->diffopt.paths = xcalloc(2, sizeof(char *));
for (i = 0; i < 2; i++) {
const char *p = argv[argc - 2 + i];
/*
Expand All @@ -242,12 +243,12 @@ void diff_no_index(struct rev_info *revs,
p = (strcmp(p, "-")
? xstrdup(prefix_filename(prefix, len, p))
: p);
revs->diffopt.paths[i] = p;
paths[i] = p;
}
diff_tree_setup_paths(paths, &revs->diffopt);
}
else
revs->diffopt.paths = argv + argc - 2;
revs->diffopt.nr_paths = 2;
diff_tree_setup_paths(argv + argc - 2, &revs->diffopt);
revs->diffopt.skip_stat_unmatch = 1;
if (!revs->diffopt.output_format)
revs->diffopt.output_format = DIFF_FORMAT_PATCH;
Expand Down

0 comments on commit 16dc36f

Please sign in to comment.