convert refresh_index to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jul 14, 2013 at 15:35 UTC
9b2d61499b4ff9ded3e1f3d535912ce04c21d72e
5 files changed
+13
-13
builtin/add.c
+7
-8
@@ -226,19 +226,18 @@ static char *prune_directory(struct dir_struct *dir, const char **pathspec,
226
return seen;
227
}
228
229
-static void refresh(int verbose, const char **pathspec)
229
+static void refresh(int verbose, const struct pathspec *pathspec)
230
{
231
char *seen;
232
- int i, specs;
232
+ int i;
233
234
- for (specs = 0; pathspec[specs]; specs++)
235
- /* nothing */;
236
- seen = xcalloc(specs, 1);
234
+ seen = xcalloc(pathspec->nr, 1);
235
refresh_index(&the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET,
236
pathspec, seen, _("Unstaged changes after refreshing the index:"));
239
- for (i = 0; i < specs; i++) {
237
+ for (i = 0; i < pathspec->nr; i++) {
238
if (!seen[i])
241
- die(_("pathspec '%s' did not match any files"), pathspec[i]);
239
+ die(_("pathspec '%s' did not match any files"),
240
+ pathspec->items[i].match);
241
}
242
free(seen);
243
}
@@ -524,7 +523,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
523
}
524
525
if (refresh_only) {
527
- refresh(verbose, pathspec.raw);
526
+ refresh(verbose, &pathspec);
527
goto finish;
528
}
529
if (implicit_dot && prefix)
builtin/commit.c
+1
-1
@@ -1244,7 +1244,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1244
prefix, argv);
1245
1246
read_cache_preload(&s.pathspec);
1247
- refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec.raw, NULL, NULL);
1247
+ refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &s.pathspec, NULL, NULL);
1248
1249
fd = hold_locked_index(&index_lock, 0);
1250
if (0 <= fd)
builtin/rm.c
+1
-1
@@ -314,7 +314,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
314
}
315
316
parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD, prefix, argv);
317
- refresh_index(&the_index, REFRESH_QUIET, pathspec.raw, NULL, NULL);
317
+ refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
318
319
seen = NULL;
320
seen = xcalloc(pathspec.nr, 1);
cache.h
+1
-1
@@ -520,7 +520,7 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
520
#define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */
521
#define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */
522
#define REFRESH_IN_PORCELAIN 0x0020 /* user friendly output, not "needs update" */
523
-extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen, const char *header_msg);
523
+extern int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg);
524
525
struct lock_file {
526
struct lock_file *next;
read-cache.c
+3
-2
@@ -1114,7 +1114,8 @@ static void show_file(const char * fmt, const char * name, int in_porcelain,
1114
printf(fmt, name);
1115
}
1116
1117
-int refresh_index(struct index_state *istate, unsigned int flags, const char **pathspec,
1117
+int refresh_index(struct index_state *istate, unsigned int flags,
1118
+ const struct pathspec *pathspec,
1119
char *seen, const char *header_msg)
1120
{
1121
int i;
@@ -1149,7 +1150,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
1150
continue;
1151
1152
if (pathspec &&
1152
- !match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, seen))
1153
+ !match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, seen))
1154
filtered = 1;
1155
1156
if (ce_stage(ce)) {