git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFD/PATCH] add: ignore only ignored files
@ 2014-11-19 14:52 Michael J Gruber
  2014-11-19 18:51 ` Junio C Hamano
  2014-11-19 19:15 ` Jeff King
  0 siblings, 2 replies; 22+ messages in thread
From: Michael J Gruber @ 2014-11-19 14:52 UTC (permalink / raw)
  To: git

"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@drmicha.warpmail.net>
---
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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2014-11-25  3:57 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-19 14:52 [RFD/PATCH] add: ignore only ignored files Michael J Gruber
2014-11-19 18:51 ` Junio C Hamano
2014-11-19 19:15 ` Jeff King
2014-11-19 21:43   ` Junio C Hamano
2014-11-20  9:42     ` Michael J Gruber
2014-11-20 15:56       ` Jeff King
2014-11-20 17:23         ` Junio C Hamano
2014-11-20 18:20           ` Jeff King
2014-11-21 15:39             ` Michael J Gruber
2014-11-21 16:08               ` [PATCHv2] " Michael J Gruber
2014-11-21 18:01                 ` Jeff King
2014-11-22 14:59                   ` Torsten Bögershausen
2014-11-22 19:19                     ` Jeff King
2014-11-22 21:20                       ` Torsten Bögershausen
2014-11-23 19:50                         ` Jeff King
2014-11-23 18:10                       ` Junio C Hamano
2014-11-23 19:46                         ` Jeff King
2014-11-24 17:41                           ` Junio C Hamano
2014-11-24 20:22                             ` Torsten Bögershausen
2014-11-25  3:57                             ` Jeff King
2014-11-24 10:29                     ` Michael J Gruber
2014-11-24 10:23                   ` Michael J Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).