Skip to content

The pattern "/a*/**" in .gitignore should not match a file "ab" in the project root #154

Closed

Description

@stippi2

We use go-git in a project, and ran across the issue that a modified file already under version control was not committed when performing:

worktree.Commit("...", &git.CommitOptions{All: true, ...}})

I've tracked this down to a pattern contained in the .gitignore of the project in the form of "/a*/**". This should match all files contained in a folder that startes with "a" or any of it's sub-folders. The pattern matching of go-git also matches a file starting with "a" contained in the project root. This is not the case with git itself. I've opened the following PR to provide a test-case:

#153

Activity

  1. github-actions commented on Dec 5, 2023

    @github-actions

    To help us keep things tidy and focus on the active tasks, we've introduced a stale bot to spot issues/PRs that haven't had any activity in a while.

    This particular issue hasn't had any updates or activity in the past 90 days, so it's been labeled as 'stale'. If it remains inactive for the next 30 days, it'll be automatically closed.

    We understand everyone's busy, but if this issue is still important to you, please feel free to add a comment or make an update to keep it active.

    Thanks for your understanding and cooperation!

  2. added
    stale
    on Dec 5, 2023
  3. stippi2 commented on Dec 5, 2023

    @stippi2
    Author

    :-( At the time, I invested a considerable amount of time to debug this issue. I even opened a PR with a test case. It's not my fault that this issue receives no attention and there is no activity. I hate stale bots. What sort of metric is this? An issue might still be there, but it hasn't received any attention... So let's just close it until the next person runs into it. Maybe or maybe not. If so few people run into it that enough time passes for the stale bot to close the issues inbetween, it must not be important. Yay.

  4. added
    bug
    help wanted
    and removed
    stale
    on Dec 5, 2023
  5. pjbgf commented on Dec 5, 2023

    @pjbgf
    Member

    @stippi2 I agree that stale bots can be ruthless at times. We currently have it enabled in this repository due to the high number of issues that are old and haven't been looked at yet (such as this one).

    I am reopenning this as the issue is still occurring (as per results of the test from your PR):

    ----------------------------------------------------------------------
    FAIL: pattern_test.go:291: PatternSuite.TestGlobMatch_folderVersusFile
    
    pattern_test.go:294:
        c.Assert(r, Equals, NoMatch)
    ... obtained gitignore.MatchResult = 1
    ... expected gitignore.MatchResult = 0
    
  6. alphapapa commented on Dec 18, 2023

    @alphapapa

    We currently have it enabled in this repository due to the high number of issues that are old and haven't been looked at yet (such as this one).

    FWIW, bots like this seem disrespectful to users and contributors. I remember when Ubuntu started using one of these on its bug tracker, on issues that still needed to be fixed and had been reported by multiple users. All it did was waste my time replying "yes it's still an issue" to emails in my already-overflowing inbox, over and over again. Then, if anyone missed replying "yes it's still an issue" in time, the bot would close the issue, and then some other user would end up filing a duplicate report, which didn't help anyone. For me it was the last straw, and I stopped contributing to Ubuntu altogether.

    It stands in stark contrast to other projects, like Debian, that treat reports as valuable contributions that shouldn't be discarded carelessly or automatically. Just yesterday, on one of my own projects, a contributor got around to sending a PR to an issue that was idle for over 2 years. It wasn't urgent, but it was important, and it finally happened.

    Anyway, if a project wants to drive away bug reporters and contributors, bots like this are an excellent way to do so. But it would be more respectful to simply disallow new submissions, so as not to waste anyone's time.

  7. github-actions commented on Apr 5, 2024

    @github-actions

    To help us keep things tidy and focus on the active tasks, we've introduced a stale bot to spot issues/PRs that haven't had any activity in a while.

    This particular issue hasn't had any updates or activity in the past 90 days, so it's been labeled as 'stale'. If it remains inactive for the next 30 days, it'll be automatically closed.

    We understand everyone's busy, but if this issue is still important to you, please feel free to add a comment or make an update to keep it active.

    Thanks for your understanding and cooperation!

  8. added
    stale
    on Apr 5, 2024
  9. added
    no-autoclose
    and removed
    stale
    on Apr 5, 2024
  10. stippi2 commented on Apr 5, 2024

    @stippi2
    Author

    Stale, but still relevant and worthy of fixing.

  11. pjbgf commented on Apr 5, 2024

    @pjbgf
    Member

    @stippi2 I labelled it with no-autoclose so the bot will ignore it going forwards.

    By the way, I am happy to review a PR on this in case you are still keen and available to fix the issue.

  12. 0xDEC0DE commented on Apr 15, 2025

    @0xDEC0DE
    Contributor

    I feel it is important to note that the fix to this issue is, technically, a breaking change.

    There could be any number of "bad" .gitignore files out there relying on this behavior that will suddenly appear to stop working with the new version. The commit message is fairly pithy, and people may not notice, so if you're in the habit of mentioning breaking changes in your release notes, this should go on the pile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wantedno-autoclose

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions