Re: [PATCH v2 17/21] Convert refresh_index to take struct pathspec
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Jan 11, 2013, 14:19 UTC
- Message-ID
- <20130111141939.GA28448@lanh>
- In-Reply-To
- <1357903275-16804-18-git-send-email-pclouds@gmail.com>
On Fri, Jan 11, 2013 at 06:21:11PM +0700, Nguyễn Thái Ngọc Duy wrote:
Show 6 quoted lines
> - for (i = 0; i < specs; i++) {
> + for (i = 0; i < pathspec->nr; i++) {
> if (!seen[i])
> - die(_("pathspec '%s' did not match any files"), pathspec[i]);
> + die(_("pathspec '%s' did not match any files"), pathspec->raw[i]);
> }This needs the following fixup on top. I don't want to send another reroll just a couple hours after I flooded git@vger. I did not plan to work on the series this soon but somehow another problem got me back here.
-- 8< --
diff --git a/builtin/add.c b/builtin/add.c index 1235eb9..e1bcdb9 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -159,7 +159,8 @@ static void refresh(int verbose, const struct pathspec *pathspec) pathspec, seen, _("Unstaged changes after refreshing the index:")); for (i = 0; i < pathspec->nr; i++) { if (!seen[i]) - die(_("pathspec '%s' did not match any files"), pathspec->raw[i]); + die(_("pathspec '%s' did not match any files"), + pathspec->items[i].match); } free(seen); } -- 8< -- and the baaad reason: pathspec->items[] are sorted because of 86e4ca6 (tree_entry_interesting(): fix depth limit with overlapping pathspecs - 2010-12-15). But raw[] are _not_. So raw[i] does not correspond to item[i]. Now seen[] array returned from match_pathspec() has the order corresponding to raw[]. On the other hand match_pathspec_depth() returns seen[] corresponds to items[]. This patch converts match_pathspec() to match_pathspec_depth() so we need to use the correct pathspec array. I'll put these explanation in the next reroll. And don't worry about this subtle difference. My next email kills match_pathspec() for good.