On 2025-03-18 at 02:04:43, Yissachar Radcliffe wrote: > > When you pipe the results of `git status` to `git add`, you are > > effectively using the `-u` option, since that will only ever list files > > that are tracked. > > I'm not sure what you mean by this; `git status` lists untracked > files. For instance, if I `touch foo.txt` and `git add -u .` then > foo.txt will not be staged. But if I pipe the changes from `git > status` into `git add` then it will be added. Ah, I thought you meant piping the entries without `??`, which are already in the index. Yes, this is faster because it uses the untracked cache in many cases. > Is there a reason `git add .` couldn't use the untracked cache even if > other pathspecs didn't? I have to imagine that `.` is by far the most > common pathspec used and there would be value in speeding that up. I don't see why it's impossible, but nobody has sent a patch. Most Git developers don't use `git add .` because there are better options and typically it isn't recommend to just add everything, so it hasn't been implemented. > I wouldn't expect them to perform identically, but given how much > faster it runs when piping in the data from `git status` I think it's > reasonable to expect it to run much faster than it does today. As I said above, `git add .` isn't something I expect most Git developers use on a daily basis. It's very easy to accidentally add something you didn't intend, such as a build product that was formerly ignored but now is not (because it's no longer generated and someone removed the pattern), so it's not an approach that we typically recommend for that reason. The possibility of files that have accidentally not been ignored properly is not at all uncommon, and I run into it probably a couple times a month between work and home, even though I work with people who usually range from moderately to intimately familiar with Git. If you feel strongly that this should exist, then the code is in `dir.c` (search for `pathspec`), and you could add a special case for this and send a patch. That doesn't guarantee that it will be accepted, but it certainly is more likely if you send a patch. -- brian m. carlson (they/them or he/him) Toronto, Ontario, CA
Attachment:
signature.asc
Description: PGP signature