X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin%2Fadd.c;h=56a4e0af6b35ea9f6d86accad27a1c87bc5ad0d9;hb=385cc9d8c44eb5be9d57e630129752a72c0a08c8;hp=17149cfeedcc39956dc55f8b72acc1227fed5213;hpb=cf4403a01070f03e5c5cc65b52c1351d20ff4e91;p=git.git 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); }