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 file is too broad #82117

Closed
gnprice opened this issue Aug 24, 2019 · 12 comments
Closed

gitignore file is too broad #82117

gnprice opened this issue Aug 24, 2019 · 12 comments
Labels
3.8 (EOL) end of life 3.9 only security fixes build The build process and cross-build

Comments

@gnprice
Copy link
Contributor

gnprice commented Aug 24, 2019

BPO 37936
Nosy @brettcannon, @zware, @gnprice, @miss-islington
PRs
  • bpo-37936: Avoid ignoring files that we actually do track. #15451
  • bpo-37936: Remove some .gitignore rules that were intended locally. #15542
  • [3.8] bpo-37936: Remove some .gitignore rules that were intended locally. (GH-15542) #15552
  • [3.7] bpo-37936: Remove some .gitignore rules that were intended locally. (GH-15542) #15553
  • [3.8] bpo-37936: Avoid ignoring files that we actually do track. (GH-15451) #15747
  • [3.7] bpo-37936: Avoid ignoring files that we actually do track. (GH-15451) #15748
  • bpo-37936: Systematically distinguish rooted vs. unrooted in .gitignore. #15823
  • [3.8] bpo-37936: Systematically distinguish rooted vs. unrooted in .gitignore (GH-15823) #15900
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-09-11.09:38:15.442>
    created_at = <Date 2019-08-24.07:15:12.884>
    labels = ['build', '3.8', '3.9']
    title = 'gitignore file is too broad'
    updated_at = <Date 2019-09-11.10:31:15.066>
    user = 'https://github.com/gnprice'

    bugs.python.org fields:

    activity = <Date 2019-09-11.10:31:15.066>
    actor = 'zach.ware'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-09-11.09:38:15.442>
    closer = 'zach.ware'
    components = ['Build']
    creation = <Date 2019-08-24.07:15:12.884>
    creator = 'Greg Price'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37936
    keywords = ['patch']
    message_count = 12.0
    messages = ['350355', '350600', '350640', '350641', '350642', '351379', '351406', '351453', '351581', '351776', '351779', '351801']
    nosy_count = 4.0
    nosy_names = ['brett.cannon', 'zach.ware', 'Greg Price', 'miss-islington']
    pr_nums = ['15451', '15542', '15552', '15553', '15747', '15748', '15823', '15900']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37936'
    versions = ['Python 3.8', 'Python 3.9']

    @gnprice
    Copy link
    Contributor Author

    gnprice commented Aug 24, 2019

    There are a number of files that we track in the repo, but are nevertheless covered by .gitignore.

    This mostly doesn't change anything, because Git itself only cares what .gitignore has to say about files that aren't already tracked. But:

    • It affects any new files someone might add that are covered by the same unintentionally-broad patterns. In that case it'd be likely to cause some confused debugging into why Git wasn't seeing the file; or possibly loss of work, if the person didn't notice that the file had never been committed to Git.

    • More immediately, other tools that aren't Git but consult the Git ignore rules don't necessarily implement this wrinkle. In particular this is unfortunately a WONTFIX bug in ripgrep / rg: Please do not ignore file tracked by git, even it's in .gitignore BurntSushi/ripgrep#1127 .

    I learned of the rg bug (and, for that matter, refreshed myself on just how Git itself handles this case) after some confusion today where I was looking with for references to a given macro, thought I'd looked at all of them... and then later noticed through git log -p -S a reference in [PC/pyconfig.h](https://github.com/python/cpython/blob/main/PC/pyconfig.h) with no subsequent change deleting it. Turned out it was indeed there and I needed to take account of it.

    Here's the list of affected files:

    $ git ls-files -i --exclude-standard 
    .gitignore
    Doc/Makefile
    Lib/test/data/README
    Modules/Setup
    PC/pyconfig.h
    Tools/freeze/test/Makefile
    Tools/msi/core/core.wixproj
    Tools/msi/core/core.wxs
    Tools/msi/core/core_d.wixproj
    Tools/msi/core/core_d.wxs
    Tools/msi/core/core_en-US.wxl
    Tools/msi/core/core_files.wxs
    Tools/msi/core/core_pdb.wixproj
    Tools/msi/core/core_pdb.wxs
    Tools/unicode/Makefile

    Fortunately this is not hard to fix. The semantics of .gitignore have a couple of gotchas, but once you know them it's not really any more complicated to get the behavior exactly right. And I've previously spent the hour or two to read up on it... and when I forget, I just consult my own short notes :), at the top of this file:
    https://github.com/zulip/zulip/blob/master/.gitignore

    I have a minimal fix which takes care of all the files above. I'll post that shortly, and I may also write up a more thorough fix that tries to make it easy not to fall into the same Git pitfall again.

    @gnprice gnprice added 3.9 only security fixes build The build process and cross-build labels Aug 24, 2019
    @gnprice
    Copy link
    Contributor Author

    gnprice commented Aug 27, 2019

    I have a minimal fix which takes care of all the files above. I'll post that shortly, and I may also write up a more thorough fix that tries to make it easy not to fall into the same Git pitfall again.

    Both now done.

    Also just posted #59747 . This is a small edit, deleting some lines whose author evidently never intended them to get committed to the repo. I'd noticed those lines before and been mildly puzzled; writing up the thorough fix caused me to look in the history and see how they were added, and resolve the mystery :). I've kept that as a separate PR just to reduce the number of moving parts in the main one, because the reasoning for it is quite independent.

    @miss-islington
    Copy link
    Contributor

    New changeset 8c9e9b0 by Miss Islington (bot) (Greg Price) in branch 'master':
    bpo-37936: Remove some .gitignore rules that were intended locally. (GH-15542)
    8c9e9b0

    @miss-islington
    Copy link
    Contributor

    New changeset caf7a30 by Miss Islington (bot) in branch '3.8':
    bpo-37936: Remove some .gitignore rules that were intended locally. (GH-15542)
    caf7a30

    @miss-islington
    Copy link
    Contributor

    New changeset 2f0440e by Miss Islington (bot) in branch '3.7':
    bpo-37936: Remove some .gitignore rules that were intended locally. (GH-15542)
    2f0440e

    @miss-islington
    Copy link
    Contributor

    New changeset 5e5e951 by Miss Islington (bot) (Greg Price) in branch 'master':
    bpo-37936: Avoid ignoring files that we actually do track. (GH-15451)
    5e5e951

    @miss-islington
    Copy link
    Contributor

    New changeset c837ad4 by Miss Islington (bot) in branch '3.8':
    bpo-37936: Avoid ignoring files that we actually do track. (GH-15451)
    c837ad4

    @zware
    Copy link
    Member

    zware commented Sep 9, 2019

    New changeset 9ae9ac1 by Zachary Ware (Miss Islington (bot)) in branch '3.7':
    bpo-37936: Avoid ignoring files that we actually do track. (GH-15451) (GH-15748)
    9ae9ac1

    @gnprice
    Copy link
    Contributor Author

    gnprice commented Sep 10, 2019

    Thanks @zach.ware for the review and merge of #59656!

    That was the "minimal" fix, fixing rules that apply to files we have in the repo now. So rg will no longer ignore [PC/pyconfig.h](https://github.com/python/cpython/blob/main/PC/pyconfig.h). :-)

    I've just sent #60027 with the "more thorough" fix on top of that, which tries to make it easy not to fall into the same Git pitfall again.

    @gnprice gnprice reopened this Sep 10, 2019
    @zware
    Copy link
    Member

    zware commented Sep 11, 2019

    New changeset 455122a by Zachary Ware (Greg Price) in branch 'master':
    bpo-37936: Systematically distinguish rooted vs. unrooted in .gitignore (GH-15823)
    455122a

    @zware
    Copy link
    Member

    zware commented Sep 11, 2019

    Ok, now it's done :)

    Thanks, Greg.

    @zware zware added the 3.8 (EOL) end of life label Sep 11, 2019
    @zware zware closed this as completed Sep 11, 2019
    @zware
    Copy link
    Member

    zware commented Sep 11, 2019

    New changeset df935b5 by Zachary Ware in branch '3.8':
    [3.8] bpo-37936: Systematically distinguish rooted vs. unrooted in .gitignore (GH-15823) (GH-15900)
    df935b5

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes build The build process and cross-build
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants