git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Supporting `git add -a <exclude submodules>`
@ 2023-10-17 20:59 Joanna Wang
  2023-10-17 21:36 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Joanna Wang @ 2023-10-17 20:59 UTC (permalink / raw)
  To: gitster; +Cc: git, Joanna Wang

> choose among attr:submodule, attr:type=<what>, attr:bits=<permbits>, decide what keyword to use
Whatever we choose, do we want to block these keywords from being used
by folks in their .gitattributes files?
That would break any existing usage of the keywords. Is this a concern?

Option A: To keep things working, we could add this support for attr,
but then always prioritize whatever is set in .gitattributes. So this
new behavior would only be triggered if the keywords (e.g.
"submodule", "type", "bits") aren't set in .gitattributes (or w/e list
of attributes are being read).

Option B: Or we could add this new behavior for `attr-bits:<permbits>`
or just `bits:<permbits>`.

I personally don't see big UX differences between A and B. Any opinions on this?

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Supporting `git add -a <exclude submodules>`
@ 2023-10-17 22:48 Joanna Wang
  2023-10-17 23:02 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Joanna Wang @ 2023-10-17 22:48 UTC (permalink / raw)
  To: gitster; +Cc: git, Joanna Wang, Joanna Wang

 > (2) does collect_some_attrs() or git_check_attr() leave enough
 >   information in check[] to tell between [a] the attr stack had
 >   no opinion on "bits" attribute and [b] the attr stack
 >   explicitly said "bits" attribute is unspecified?
I will double check this but IIUC, I could change this part
(https://github.com/git/git/blob/master/attr.c#L1100-L1105),
such that:
```
if (n == ATTR__UNKNOWN && v = NULL):
  // keep n equal to ATTR_UNKNOWN
```

And here: https://github.com/git/git/blob/master/attr.c#L1238,
if value == 'ATTR__UNKNOWN', then keep it at ATTR__UNKNOWN

> (1) where in that callchain would we intercept and insert our own
>   "bits" value based on the filesystem property?
I was planning to do that somewhere around here:
https://github.com/git/git/blob/master/pathspec.c#L764-L767
 and possibly combine it with adding a new match_mode (e.g.
MATCH_BITS) which would be set by parse_pathspec().
Something like:
```
else if (ATTR_UNKNOWN(value))
    matched = (match_mode == MATCH_BITS &&
!strcmp(item->attr_match[i].value, get_mode(path)));
```

I will dive into the code more to confirm, but that's my current
high-level plan, in case you immediately see something very wrong.

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Supporting `git add -a <exclude submodules>`
@ 2023-09-28 17:06 Joanna Wang
  2023-09-28 18:11 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Joanna Wang @ 2023-09-28 17:06 UTC (permalink / raw)
  To: git

Hi,
We're looking for feedback on the idea of adding git support for users
to express `git add -a <exclude submodules>`.

We recently added submodules to our project.
A lot of our users don't like that when their submodules are on
commits that do not match what is pinned in the root superproject,
running `git add -a` and `git commit -a` (which they are so used to),
will now include those submodules that 99% of the time they do not
want to include.

So we think supporting `git add -a <exclude submodules>` and `git
commit -a <exclude submodules>` might be good to do.
(We know `git -c diff.ignoreSubmodules=all commit -a` is an option,
but this does not work for `git add`. However this support gets
implemented for `git add`, I assume it's ideal for the UX of "don't
include submodules" to be the same for both `git commit` and `git
add`, though I don't think this is a requirement)


In a separate high-level conversation, Junio brought up going about
this with magic pathsepc.
So the work would entail:
- adding 'native' submodule attribute support, so `git add -a
':(exclude,attr:submodule)' can work without having to add 'submodule'
for every submodule path in .gitattributes
- add magic pathspec support to `git add`

(It looks like `git commit -a` does not work with pathspec. In this
case I think that would be fine, we can just tell users they can set
aliases for `git -c diff.ignoreSubmodules=all commit -a` and `git add
-a ':(exclude,attr:submodule)' if they want)

Any thoughts from folks on all of the above?
Thanks!

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

end of thread, other threads:[~2023-10-17 23:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-17 20:59 Supporting `git add -a <exclude submodules>` Joanna Wang
2023-10-17 21:36 ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2023-10-17 22:48 Joanna Wang
2023-10-17 23:02 ` Junio C Hamano
2023-09-28 17:06 Joanna Wang
2023-09-28 18:11 ` Junio C Hamano
2023-09-28 18:16   ` Junio C Hamano
2023-09-28 18:24   ` Junio C Hamano

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).