@matheusbsbs / matheus-bagliano / commits / 984b83ef23
Fork 0

Add --ignore-errors to git-add to allow it to skip files with read errors

Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alex Riesen committed May 12, 2008 at 19:58 UTC 984b83ef23fdcf6a933f635f182e7bc10130094a
2 files changed +15 -3
Documentation/git-add.txt
+6 -1
@@ -9,7 +9,7 @@ SYNOPSIS
9 --------
10 [verse]
11 'git-add' [-n] [-v] [-f] [--interactive | -i] [--patch | -p] [-u] [--refresh]
12 - [--] <filepattern>...
12 + [--ignore-errors] [--] <filepattern>...
13
14 DESCRIPTION
15 -----------
@@ -83,6 +83,11 @@ OPTIONS
83 Don't add the file(s), but only refresh their stat()
84 information in the index.
85
86 +\--ignore-errors::
87 + If some files could not be added because of errors indexing
88 + them, do not abort the operation, but continue adding the
89 + others. The command shall still exit with non-zero status.
90 +
91 \--::
92 This option can be used to separate command-line options from
93 the list of files, (useful when filenames might be mistaken
builtin-add.c
+9 -2
@@ -191,6 +191,7 @@ static const char ignore_error[] =
191 "The following paths are ignored by one of your .gitignore files:\n";
192
193 static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
194 +static int ignore_add_errors;
195
196 static struct option builtin_add_options[] = {
197 OPT__DRY_RUN(&show_only),
@@ -201,6 +202,7 @@ static struct option builtin_add_options[] = {
202 OPT_BOOLEAN('f', NULL, &ignored_too, "allow adding otherwise ignored files"),
203 OPT_BOOLEAN('u', NULL, &take_worktree_changes, "update tracked files"),
204 OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
205 + OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
206 OPT_END(),
207 };
208
@@ -231,6 +233,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
233
234 if (verbose)
235 flags |= ADD_FILES_VERBOSE;
236 + if (ignore_add_errors)
237 + flags |= ADD_FILES_IGNORE_ERRORS;
238
239 exit_status = add_files_to_cache(prefix, pathspec, flags);
240 goto finish;
@@ -274,8 +278,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
278 }
279
280 for (i = 0; i < dir.nr; i++)
277 - if (add_file_to_cache(dir.entries[i]->name, verbose))
278 - die("adding files failed");
281 + if (add_file_to_cache(dir.entries[i]->name, verbose)) {
282 + if (!ignore_add_errors)
283 + die("adding files failed");
284 + exit_status = 1;
285 + }
286
287 finish:
288 if (active_cache_changed) {