From 54768360aa7b1882dd2b76211661abb6014cbf23 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 12 Aug 2009 16:26:31 -0500 Subject: [PATCH 1/3] port --ignore-unmatch from "git rm" to "git add" --- builtin-add.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builtin-add.c b/builtin-add.c index 581a2a1..0597fb9 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -19,6 +19,7 @@ static const char * const builtin_add_usage[] = { }; static int patch_interactive, add_interactive, edit_interactive; static int take_worktree_changes; +static int ignore_unmatch = 0; static void fill_pathspec_matches(const char **pathspec, char *seen, int specs) { @@ -63,7 +64,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p fill_pathspec_matches(pathspec, seen, specs); for (i = 0; i < specs; i++) { - if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i])) + if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]) && !ignore_unmatch) die("pathspec '%s' did not match any files", pathspec[i]); } @@ -108,7 +109,7 @@ static void refresh(int verbose, const char **pathspec) refresh_index(&the_index, verbose ? REFRESH_SAY_CHANGED : REFRESH_QUIET, pathspec, seen); for (i = 0; i < specs; i++) { - if (!seen[i]) + if (!seen[i] && !ignore_unmatch) die("pathspec '%s' did not match any files", pathspec[i]); } free(seen); @@ -226,6 +227,8 @@ static struct option builtin_add_options[] = { OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"), OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"), OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"), + OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch, + "exit with a zero status even if nothing matched"), OPT_END(), }; -- 1.6.3.3