diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-07-19 11:09:38 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-07-19 11:09:38 -0700 |
commit | 8fbe9b32ce6f5e12ba3f8b9d4e3ccb0b8acf529f (patch) | |
tree | dbca21bec678543260588cc3e04cfcacfd8d9ac5 /builtin | |
parent | 8ac3a66702c43386eb580b7a1a8b1a31cd675327 (diff) | |
parent | 108da0db1277fc2f4820d0a47c02b2c63111f7a5 (diff) | |
download | git-8fbe9b32ce6f5e12ba3f8b9d4e3ccb0b8acf529f.tar.gz git-8fbe9b32ce6f5e12ba3f8b9d4e3ccb0b8acf529f.tar.xz |
Merge branch 'jl/add-n-ignore-missing'
* jl/add-n-ignore-missing:
git add: Add the "--ignore-missing" option for the dry run
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/add.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/builtin/add.c b/builtin/add.c index 17149cfee..56a4e0af6 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -310,7 +310,7 @@ static const char ignore_error[] = "The following paths are ignored by one of your .gitignore files:\n"; static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0; -static int ignore_add_errors, addremove, intent_to_add; +static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0; static struct option builtin_add_options[] = { OPT__DRY_RUN(&show_only), @@ -325,6 +325,7 @@ 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-missing", &ignore_missing, "check if - even missing - files are ignored in dry run"), OPT_END(), }; @@ -385,6 +386,8 @@ int cmd_add(int argc, const char **argv, const char *prefix) if (addremove && take_worktree_changes) die("-A and -u are mutually incompatible"); + if (!show_only && ignore_missing) + die("Option --ignore-missing can only be used together with --dry-run"); if ((addremove || take_worktree_changes) && !argc) { static const char *here[2] = { ".", NULL }; argc = 1; @@ -441,9 +444,14 @@ int cmd_add(int argc, const char **argv, const char *prefix) seen = find_used_pathspec(pathspec); for (i = 0; pathspec[i]; i++) { if (!seen[i] && pathspec[i][0] - && !file_exists(pathspec[i])) - die("pathspec '%s' did not match any files", - pathspec[i]); + && !file_exists(pathspec[i])) { + if (ignore_missing) { + if (excluded(&dir, pathspec[i], DT_UNKNOWN)) + dir_add_ignored(&dir, pathspec[i], strlen(pathspec[i])); + } else + die("pathspec '%s' did not match any files", + pathspec[i]); + } } free(seen); } |