[RFD/PATCH] add: ignore only ignored files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"git add foo bar" adds neither foo nor bar when bar is ignored, but dies
to let the user recheck their command invocation. This becomes less
helpful when "git add foo.*" is subject to shell expansion and some of
the expanded files are ignored.

"git add --ignore-errors" is supposed to ignore errors when indexing
some files and adds the others. It does ignore errors from actual
indexing attempts, but does not ignore the error "file is ignored" as
outlined above.

Change "git add --ignore-errors foo bar" to add foo when bar is ignored,
i.e. to ignore the ignore error.

Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx>
---
Thus buggs me whenever I add a new TeX project when there are *.aux and
*.log around also[*]. Aside from that personal itch: For a user reading the
documentation, the difference between "thinking about indexing a file"
and "technically indexing a file" is probably irrelevant, and most would
expect "git add --ignore-errors" to ignore the "file is ignored" error
as well and continue adding the remaining files.

This is a behaviour change, though (albeit only for the option/config case),
so it's RFD. If the direction is OK a test would be in order.

We could add yet another ignore option, of course, which just screams to be called
--ignore-ignored, along with a config add.ignoreIgnored. I dunno...

[*] And who wants to quote their *, really? ;)

 builtin/add.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/add.c b/builtin/add.c
index ae6d3e2..8cadb71 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -284,7 +284,9 @@ static int add_files(struct dir_struct *dir, int flags)
 		for (i = 0; i < dir->ignored_nr; i++)
 			fprintf(stderr, "%s\n", dir->ignored[i]->name);
 		fprintf(stderr, _("Use -f if you really want to add them.\n"));
-		die(_("no files added"));
+		if (!ignore_add_errors)
+			die(_("no files added"));
+		exit_status = 1;
 	}
 
 	for (i = 0; i < dir->nr; i++)
-- 
2.2.0.rc2.293.gc05a35d

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]