Re: [PATCH 3/3] builtin-add: simplify (and increase accuracy of) exclude handling

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

 



Hej Jeff,

Thanks for looking into this and making these patches. :)

Jeff King <peff@xxxxxxxx> 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
-
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]

  Powered by Linux