"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: got add recursion ignore ignores
To:
Tracey Emery <tracey@traceyemery.net>
Cc:
gameoftrees@openbsd.org
Date:
Fri, 6 Dec 2019 14:17:17 +0100

Download raw body.

Thread
On Thu, Dec 05, 2019 at 12:44:18PM -0700, Tracey Emery wrote:
> On Thu, Dec 05, 2019 at 06:57:12PM +0100, Stefan Sperling wrote:
> > On Thu, Dec 05, 2019 at 10:22:43AM -0700, Tracey Emery wrote:
> > > Hello,
> > > 
> > > The diff below adds -I to disregard ignores. Adding flags to the
> > > got_worktree struct seemed like the simplest approach. If there is a
> > > better alternative, let me know what you think.
> > 
> > Would it work to add a new 'int' argument to worktree_status() instead?
> > It seems no_ignores could be passed from got_worktree_schedule_add()
> > to worktree_status(). All other callers of worktree_status() would pass 0.
> > 
> > Adding this information to a new flags field in struct got_worktree
> > essentially creates a global variable. I'd prefer to pass arguments so
> > that it becomes easier to see where the values get used further down
> > the call chain. And should use of the variable change later, auditing for
> > unused function arguments is easier than auditing for unnecessary checks
> > of a global flag.
> 
> Diff below removes global flag and passes int argument instead.
> 
> Ok?

OK. Though there's a 'goto done' at the wrong indentation level added
in the chunk below, please fix it first:

> blob - 756eaa2ea3216dabe5aaf7080a2c652fdbfd0f74
> file + got/got.c
> --- got/got.c
> +++ got/got.c
> @@ -4218,6 +4222,13 @@ cmd_add(int argc, char *argv[])
>  	if (error)
>  		goto done;
>  
> +	if (!can_recurse && no_ignores) {
> +		error = got_error_msg(GOT_ERR_BAD_PATH,
> +		    "disregarding ignores requires -R option");
> +			goto done;
> +
> +	}
> +
>  	if (!can_recurse) {
>  		char *ondisk_path;
>  		struct stat sb;