Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.gitignore.d is broken for files in subdirs due to git behavior revert #333

Closed
jwhitley opened this issue Dec 28, 2023 · 3 comments · Fixed by #334
Closed

.gitignore.d is broken for files in subdirs due to git behavior revert #333

jwhitley opened this issue Dec 28, 2023 · 3 comments · Fixed by #334
Assignees
Labels

Comments

@jwhitley
Copy link
Contributor

Repro steps

  1. Enter a vcsh-controlled repository, e.g. via vcsh foo
  2. Ensure that .gitignore.d/foo exists and is up-to-date. Update via vcsh write-gitignore foo if needed.
  3. git add <some modified file, in a subdirectory and already tracked by foo and in the above gitignore>

Expected results
git add just works.

Actual results
git add produces the "force me" error message, such as the following for a file under ~/.config:

The following paths are ignored by one of your .gitignore files:
.config

Ugh, it looks like git reverted the enhancement regarding gitignore parent directories, and we need to resurrect the old code that added each parent directory of a controlled file into .gitignore.d/foo:

*
!/.config
!/.config/bar
!/.config/bar/baz
!/.config/bar/baz/something.txt

Notes
The 2.43.0 gitignore man page includes this note, which I used to trace back to the revert commit above:

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.

Versions
vcsh: 2.0.5 standalone
git: 2.43.0

@jwhitley
Copy link
Contributor Author

jwhitley commented Dec 28, 2023

Ah, there it is. #196 needs to be reverted, since the corresponding change was reverted (I think all the way back around git 2.8, if I'm reading right 😳)

EDIT: Confirmed, this landed before 2.8.0-rc4.

@alerque
Copy link
Collaborator

alerque commented Dec 28, 2023

Yuck. Thanks for tracking this down (and I was affected too bug figured it was something weird I did locally and hadn't tracked it down with a test case).

Would you like to submit a PR with the revert?

@jwhitley
Copy link
Contributor Author

Literally working on the PR right now. ;-)

@alerque alerque added the bug label Dec 28, 2023
jwhitley added a commit to jwhitley/vcsh that referenced this issue Dec 28, 2023
Fixes RichiH#333.

In git 2.7.0, new git behavior changed gitignore to no longer require
un-ignoring every parent directory above an un-ignored file. vcsh
updated its logic around this in PR RichiH#196 (vcsh commit e4f4ecf).
Unfortunately, git's change was reverted before 2.8.0-rc4 (git commit
5cee349).

This change therefore reverts the logic change in RichiH#196 causing `vcsh
write-gitignore` to once again emit parent directories into generated
`.gitignore.d/<repo>` files.

See RichiH#333 for the gory details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants