From: Jonas Fonseca <fonseca@diku.dk>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: Re: [PATCH 3/3] builtin-add: simplify (and increase accuracy of) exclude handling
Date: Mon, 11 Jun 2007 17:01:23 +0200 [thread overview]
Message-ID: <20070611150122.GA11020@diku.dk> (raw)
In-Reply-To: <20070611133956.GC7008@coredump.intra.peff.net>
Hej Jeff,
Thanks for looking into this and making these patches. :)
Jeff King <peff@peff.net> wrote Mon, Jun 11, 2007:
> builtin-add.c | 89 ++++++++++++++++++++++++++++++--------------------------
> dir.c | 1 -
> dir.h | 4 +--
> 3 files changed, 49 insertions(+), 45 deletions(-)
>
> diff --git a/builtin-add.c b/builtin-add.c
> index 1591171..8988930 100644
> --- a/builtin-add.c
> +++ b/builtin-add.c
> @@ -160,6 +166,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
> const char **pathspec;
> struct dir_struct dir;
> int add_interactive = 0;
> + int has_ignored;
>
> for (i = 1; i < argc; i++) {
> if (!strcmp("--interactive", argv[i]) ||
> @@ -237,25 +242,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)
> if (read_cache() < 0)
> die("index file corrupt");
>
> - if (!ignored_too) {
> - int has_ignored = 0;
> - for (i = 0; i < dir.nr; i++)
> - if (dir.entries[i]->ignored)
> - has_ignored = 1;
> - if (has_ignored) {
> - fprintf(stderr, ignore_warning);
> - for (i = 0; i < dir.nr; i++) {
> - if (!dir.entries[i]->ignored)
> - continue;
> - fprintf(stderr, "%s", dir.entries[i]->name);
> - if (dir.entries[i]->ignored_dir)
> - fprintf(stderr, " (directory)");
> - fputc('\n', stderr);
> - }
> - fprintf(stderr,
> - "Use -f if you really want to add them.\n");
> - exit(1);
> + has_ignored = 0;
> + for (i = 0; i < dir.ignored_nr; i++) {
> + if (dir.ignored[i])
> + has_ignored = 1;
> + }
> + if (has_ignored) {
> + fprintf(stderr, ignore_warning);
> + for (i = 0; i < dir.ignored_nr; i++) {
> + if (dir.ignored[i])
> + fprintf(stderr, "%s\n", dir.ignored[i]->name);
> }
> + fprintf(stderr, "Use -f if you really want to add them.\n");
> + exit(1);
> }
>
> for (i = 0; i < dir.nr; i++)
I think you could even get rid of has_ignored with something like this.
diff --git a/builtin-add.c b/builtin-add.c
index 8988930..da6ab11 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -166,7 +166,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
const char **pathspec;
struct dir_struct dir;
int add_interactive = 0;
- int has_ignored;
for (i = 1; i < argc; i++) {
if (!strcmp("--interactive", argv[i]) ||
@@ -242,12 +241,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die("index file corrupt");
- has_ignored = 0;
- for (i = 0; i < dir.ignored_nr; i++) {
- if (dir.ignored[i])
- has_ignored = 1;
- }
- if (has_ignored) {
+ if (dir.ignored_nr) {
fprintf(stderr, ignore_warning);
for (i = 0; i < dir.ignored_nr; i++) {
if (dir.ignored[i])
--
Jonas Fonseca
next prev parent reply other threads:[~2007-06-11 15:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-10 20:46 Adding empty directory gives bogus error message Jonas Fonseca
2007-06-11 12:30 ` Jeff King
2007-06-11 13:39 ` [PATCH 1/3] refactor dir_add_name Jeff King
2007-06-11 14:13 ` Johannes Schindelin
2007-06-11 16:23 ` Junio C Hamano
2007-06-11 19:46 ` Jeff King
2007-06-12 7:13 ` Junio C Hamano
2007-06-12 12:19 ` Jeff King
2007-06-12 21:51 ` Jonas Fonseca
2007-06-11 13:39 ` [PATCH 2/3] dir_struct: add collect_ignored option Jeff King
2007-06-11 13:39 ` [PATCH 3/3] builtin-add: simplify (and increase accuracy of) exclude handling Jeff King
2007-06-11 15:01 ` Jonas Fonseca [this message]
2007-06-11 15:54 ` Jeff King
2007-06-11 19:15 ` Jonas Fonseca
2007-06-11 19:48 ` Jeff King
2007-06-12 21:42 ` Jonas Fonseca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070611150122.GA11020@diku.dk \
--to=fonseca@diku.dk \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).