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

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: make 'got add' robert-compatible
To:
"Todd C. Miller" <Todd.Miller@sudo.ws>
Cc:
gameoftrees@openbsd.org
Date:
Wed, 7 Jul 2021 19:14:25 +0200

Download raw body.

Thread
On Wed, Jul 07, 2021 at 09:55:16AM -0600, Todd C. Miller wrote:
> On Tue, 06 Jul 2021 17:08:05 +0200, Stefan Sperling wrote:
> 
> > Require the -I option to add ignored files to version control
> > even when 'got add' is not recursing into directories with -R.
> >
> > Inspired by robert@ accidentally committing a ./iridium.core file to the
> > CVS ports tree in spite of "*.core" being on cvs's default ignore list.
> 
> This sounds safer for "got add *" but what happens if you do "got
> add foo.core"?  Is there an error message or will it silently add
> nothing?

It will print nothing and add nothing.

Raising an error is a bad idea since the ignored file would usually be
picked up by some wildcard expression and we still want that case to
succeed ('cvs add *' is likely what robert actually did).

One option is to list ignored files as such, using a new status code.
I've already played with this. An earlier version of my patch printed this:

 $ got add foo.core
 I foo.core
 $

This tells the user why foo.core wasn't added, which on the surface
seems much better than the behaviour implemented by my current patch,
which looks like this:

 $ got add foo.core
 $

But unless we special-case things the recursive case would then also
report ignored files. Which would look like this:

 $ got add -R .
 A README
 I foo.core
 I obj/bar.o
 I obj/foo.o
 A src/foo.c
 A src/bar.c
 I src/bar.c.orig
 $

Whereas the current output just would be:

 $ got add -R .
 A README
 A src/foo.c
 A src/bar.c
 $

So this new output for -R would potentially display many more ignored files
than added files which might not be desirable. We could perhaps collapse
ignored directories to make this less of an issue:

 $ got add -R .
 A README
 I foo.core
 I obj/
 A src/foo.c
 A src/bar.c
 I src/bar.c.orig
 $

Implementing the above idea would require further internal changes:
The ignores feature currently works by not even calling the status walk
callback on ignored files. The introduction of a new status code 'I' would
require updating all existing consumers of the status crawl (add, delete,
status, and more) to filter out such files.
This is certainly something we could do if we want 'add -R' to display
every file/directory which was ignored. I would not be opposed to this.
I decided against including such changes in the patch under discussion
because the changes bloat up the patch and might as well be done later.