commit: convert to use parse_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 6654c8894effaf12ae73a2a6e5bc72433f4a3479
1 file changed +9 -9
builtin/commit.c
+9 -9
@@ -284,17 +284,17 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
284 {
285 int fd;
286 struct string_list partial;
287 - const char **pathspec = NULL;
287 + struct pathspec pathspec;
288 char *old_index_env = NULL;
289 int refresh_flags = REFRESH_QUIET;
290
291 if (is_status)
292 refresh_flags |= REFRESH_UNMERGED;
293 + parse_pathspec(&pathspec, 0,
294 + PATHSPEC_PREFER_FULL,
295 + prefix, argv);
296
294 - if (*argv)
295 - pathspec = get_pathspec(prefix, argv);
296 -
297 - if (read_cache_preload(pathspec) < 0)
297 + if (read_cache_preload(pathspec.raw) < 0)
298 die(_("index file corrupt"));
299
300 if (interactive) {
@@ -336,9 +336,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
336 * (A) if all goes well, commit the real index;
337 * (B) on failure, rollback the real index.
338 */
339 - if (all || (also && pathspec && *pathspec)) {
339 + if (all || (also && pathspec.nr)) {
340 fd = hold_locked_index(&index_lock, 1);
341 - add_files_to_cache(also ? prefix : NULL, pathspec, 0);
341 + add_files_to_cache(also ? prefix : NULL, pathspec.raw, 0);
342 refresh_cache_or_die(refresh_flags);
343 update_main_cache_tree(WRITE_TREE_SILENT);
344 if (write_cache(fd, active_cache, active_nr) ||
@@ -357,7 +357,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
357 * and create commit from the_index.
358 * We still need to refresh the index here.
359 */
360 - if (!only && (!pathspec || !*pathspec)) {
360 + if (!only && !pathspec.nr) {
361 fd = hold_locked_index(&index_lock, 1);
362 refresh_cache_or_die(refresh_flags);
363 if (active_cache_changed) {
@@ -402,7 +402,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
402
403 memset(&partial, 0, sizeof(partial));
404 partial.strdup_strings = 1;
405 - if (list_paths(&partial, !current_head ? NULL : "HEAD", prefix, pathspec))
405 + if (list_paths(&partial, !current_head ? NULL : "HEAD", prefix, pathspec.raw))
406 exit(1);
407
408 discard_cache();