newren / git-filter-repo

Quickly rewrite git repository history (filter-branch replacement)
Other
8.52k stars 708 forks source link

fix(clean-ignore): Consider .gitignore exclusions #560

Closed jmgate closed 4 months ago

jmgate commented 6 months ago

I ran across what I think is the same issue as reported in #76. My repository's .gitignore has, among other things,

*.mat
!path/to/particular.mat

Running clean-ignore --path-glob "*" results in all *.mat files being stripped from the repository history. I'm using

git version 2.39.3 (Apple Git-146)

and if I run

git check-ignore --verbose --non-matching --no-index path/to/particular.mat

I see

.gitignore:2:!path/to/particular.mat    path/to/particular.mat

It sounds like the expected behavior from git check-ignore is to see no output, but that doesn't appear to be the case here. In order to get the clean-ignore script to correctly handle the exclusions in the .gitignore file, I needed to make this slight tweak to it.

If it's the case that the real problem lies in git itself, and not in this repository, then I could file an issue against it instead.

newren commented 4 months ago

Awesome, thanks for the contribution! That's another one from Sandia. :-) Any chance you know of folks in Engineering Sciences (1500) -- is it still called and numbered that? I used to work over in that center.

Anyway, I made a couple small tweaks to transform to 6588bbc98ca0 (clean-ignore: handle .gitignore exclusions, 2024-05-02), and merged it in. Thanks!

jmgate commented 4 months ago

Yup, same name and number. I worked in 1400 for a number of years and had a number of touch points with folks in 1500.