From de429956cdfb6856854638bf5755462e70abbddc Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sat, 24 Aug 2019 00:48:41 -0700 Subject: [PATCH 01/10] bpo-37936: Systematically distinguish rooted vs. unrooted in .gitignore. A root cause of bpo-37936 is that it's easy to write a .gitignore rule that's intended to apply to a specific file (e.g., the `pyconfig.h` generated by `./configure`) but actually applies to all similarly-named files in the tree (e.g., `PC/pyconfig.h`.) Specifically, any rule with no non-trailing slashes is applied in an "unrooted" way, to files anywhere in the tree. This means that if we write the rules in the most obvious-looking way, then * for specific files we want to ignore that happen to be in subdirectories (like `Modules/config.c`), the rule will work as intended, staying "rooted" to the top of the tree; but * when a specific file we want to ignore happens to be at the root of the repo (like `platform`), then the obvious rule (`platform`) will apply much more broadly than intended: if someone tries to add a file or directory named `platform` somewhere else in the tree, it will unexpectedly get ignored. That's surprising behavior that can make the .gitignore file's behavior feel finicky and unpredictable. To avoid it, we can simply always give a rule "rooted" behavior when that's what's intended, by systematically using leading slashes. Further, to help make the pattern obvious when looking at the file and minimize any need for thinking about the syntax when adding new rules: separate the rules into one group for each type, with brief comments identifying them. For most of these rules it's clear whether they're meant to be rooted or unrooted, but in a handful of cases I've only guessed. In that case the safer default (the choice that won't hide information) is the narrower, rooted meaning, with a leading slash. If for some of these the unrooted meaning is desired after all, it'll be easy to move them to the unrooted section at the top. --- .gitignore | 100 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 54c598e109e06b..e7a7e269ef8363 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ -# Two-trick pony for OSX and other case insensitive file systems: -# Ignore ./python binary on Unix but still look into ./Python/ directory. -/python -!/Python/ +##### +# First, rules intended to apply in all subdirectories. +# These contain no slash, or only a trailing slash. *.cover *.iml @@ -18,6 +17,25 @@ *.profraw *.dyn .gdb_history +.purify +__pycache__ +.idea/ +tags +TAGS +.vs/ +.vscode/ +gmon.out +.mypy_cache/ + +# Ignore core dumps... but not Tools/msi/core/ or the like. +core +!core/ + + +##### +# Then, rules meant for a specific location relative to the repo root. +# These must contain a non-trailing slash (and may also have a trailing slash.) + Doc/build/ Doc/venv/ Doc/.venv/ @@ -29,7 +47,7 @@ Lib/lib2to3/*.pickle Lib/test/data/* !Lib/test/data/README /Makefile -Makefile.pre +/Makefile.pre Misc/python.pc Misc/python-embed.pc Misc/python-config.sh @@ -69,46 +87,40 @@ PCbuild/arm64/ PCbuild/obj/ PCbuild/win32/ Tools/unicode/data/ -.purify -__pycache__ -autom4te.cache -build/ -buildno -config.cache -config.log -config.status -config.status.lineno -core -!Tools/msi/core/ -db_home -.hg/ -.idea/ -ipch/ -libpython*.a -libpython*.so* -libpython*.dylib -libpython*.dll -platform -pybuilddir.txt +/autom4te.cache +/build/ +/buildno +/config.cache +/config.log +/config.status +/config.status.lineno +/db_home +/.hg/ +/ipch/ +/libpython*.a +/libpython*.so* +/libpython*.dylib +/libpython*.dll +/platform +/pybuilddir.txt /pyconfig.h -python-config -python-config.py -python.bat -python.exe -python-gdb.py -python.exe-gdb.py -reflog.txt -.svn/ -tags -TAGS -.coverage -coverage/ -externals/ -htmlcov/ +/python-config +/python-config.py +/python.bat +/python.exe +/python-gdb.py +/python.exe-gdb.py +/reflog.txt +/.svn/ +/.coverage +/coverage/ +/externals/ +/htmlcov/ Tools/msi/obj Tools/ssl/amd64 Tools/ssl/win32 -.vs/ -.vscode/ -gmon.out -.mypy_cache/ + +# Two-trick pony for OSX and other case insensitive file systems: +# Ignore ./python binary on Unix but still look into ./Python/ directory. +/python +!/Python/ From 96dde8c1b3e4436f465699def28b44d1432f9e97 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 00:55:03 -0700 Subject: [PATCH 02/10] Add a NEWS entry. --- .../next/Build/2019-09-10-00-54-48.bpo-37936.E7XEwu.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2019-09-10-00-54-48.bpo-37936.E7XEwu.rst diff --git a/Misc/NEWS.d/next/Build/2019-09-10-00-54-48.bpo-37936.E7XEwu.rst b/Misc/NEWS.d/next/Build/2019-09-10-00-54-48.bpo-37936.E7XEwu.rst new file mode 100644 index 00000000000000..5ded61eafe947c --- /dev/null +++ b/Misc/NEWS.d/next/Build/2019-09-10-00-54-48.bpo-37936.E7XEwu.rst @@ -0,0 +1,5 @@ +The :file:`.gitignore` file systematically keeps "rooted", with a +non-trailing slash, all the rules that are meant to apply to files in a +specific place in the repo. Previously, when the intended file to ignore +happened to be at the root of the repo, we'd most often accidentally also +ignore files and directories with the same name anywhere in the tree. From bdf15c81db0bae76045ddcb47c17f54d042b3eda Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:38:21 -0700 Subject: [PATCH 03/10] Cut redundant specific-.vs rule, thanks to zware's eagle eye --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e7a7e269ef8363..1004623657488d 100644 --- a/.gitignore +++ b/.gitignore @@ -80,7 +80,6 @@ PCbuild/*-pgi PCbuild/*-pgo PCbuild/*.VC.db PCbuild/*.VC.opendb -PCbuild/.vs/ PCbuild/amd64/ PCbuild/arm32/ PCbuild/arm64/ From 9de8ab3b2bb375166573383c389233d127b3c9ac Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:42:46 -0700 Subject: [PATCH 04/10] Cut buildno rule. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1004623657488d..36214b6a2bc019 100644 --- a/.gitignore +++ b/.gitignore @@ -88,7 +88,6 @@ PCbuild/win32/ Tools/unicode/data/ /autom4te.cache /build/ -/buildno /config.cache /config.log /config.status From e992e75f1111e1ad53ace42d4f6dc04c6eaf5a05 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:44:49 -0700 Subject: [PATCH 05/10] Cut db_home vestiges (from tests for bsddb, gone in 3.0) --- .gitignore | 1 - Lib/test/libregrtest/runtest.py | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 36214b6a2bc019..c4dea5dd119a0b 100644 --- a/.gitignore +++ b/.gitignore @@ -92,7 +92,6 @@ Tools/unicode/data/ /config.log /config.status /config.status.lineno -/db_home /.hg/ /ipch/ /libpython*.a diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py index e7dce180cb3753..eeb108bb447394 100644 --- a/Lib/test/libregrtest/runtest.py +++ b/Lib/test/libregrtest/runtest.py @@ -313,9 +313,7 @@ def cleanup_test_droppings(test_name, verbose): # since if a test leaves a file open, it cannot be deleted by name (while # there's nothing we can do about that here either, we can display the # name of the offending test, which is a real help). - for name in (support.TESTFN, - "db_home", - ): + for name in (support.TESTFN,): if not os.path.exists(name): continue From 3ae3ab1985175411ef95cc18071e76aeb4274e1e Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:49:25 -0700 Subject: [PATCH 06/10] Cut rule for ipch -- believed to go inside already-ignored PCbuild subdirs --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index c4dea5dd119a0b..f9aeb8dd78242a 100644 --- a/.gitignore +++ b/.gitignore @@ -93,7 +93,6 @@ Tools/unicode/data/ /config.status /config.status.lineno /.hg/ -/ipch/ /libpython*.a /libpython*.so* /libpython*.dylib From d4cac40af758dc459ba586714bbb08e4060c87a1 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:52:28 -0700 Subject: [PATCH 07/10] Generalize rules for *.a, *.so*, *.dylib, *.dll . --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f9aeb8dd78242a..c8d3d0154f4213 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,10 @@ *.cover *.iml *.o +*.a +*.so* +*.dylib +*.dll *.orig *.pyc *.pyd @@ -93,10 +97,6 @@ Tools/unicode/data/ /config.status /config.status.lineno /.hg/ -/libpython*.a -/libpython*.so* -/libpython*.dylib -/libpython*.dll /platform /pybuilddir.txt /pyconfig.h From 19bc9e72f9c08063a9a6c9b3803c8d9e1ff93490 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:55:06 -0700 Subject: [PATCH 08/10] Generalize excluding *.exe . --- .gitignore | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c8d3d0154f4213..3c2195ba01e11e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,9 @@ TAGS gmon.out .mypy_cache/ +*.exe +!Lib/distutils/command/*.exe + # Ignore core dumps... but not Tools/msi/core/ or the like. core !core/ @@ -60,12 +63,9 @@ Modules/Setup.local Modules/config.c Modules/ld_so_aix Programs/_freeze_importlib -Programs/_freeze_importlib.exe Programs/_testembed -Programs/_testembed.exe PC/python_nt*.h PC/pythonnt_rc*.h -PC/*/*.exe PC/*/*.exp PC/*/*.lib PC/*/*.bsc @@ -103,7 +103,6 @@ Tools/unicode/data/ /python-config /python-config.py /python.bat -/python.exe /python-gdb.py /python.exe-gdb.py /reflog.txt From 2f0d01884669254cb86c4f627ec11941d3d4a993 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:57:20 -0700 Subject: [PATCH 09/10] Ignore .hg/ and .svn/ anywhere. --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3c2195ba01e11e..960a4405bcb066 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ .gdb_history .purify __pycache__ +.hg/ +.svn/ .idea/ tags TAGS @@ -96,7 +98,6 @@ Tools/unicode/data/ /config.log /config.status /config.status.lineno -/.hg/ /platform /pybuilddir.txt /pyconfig.h @@ -106,7 +107,6 @@ Tools/unicode/data/ /python-gdb.py /python.exe-gdb.py /reflog.txt -/.svn/ /.coverage /coverage/ /externals/ From 175b726d14107e63d62e7db38ac906c5dfd20344 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 10 Sep 2019 20:58:06 -0700 Subject: [PATCH 10/10] Ignore .coverage anywhere. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 960a4405bcb066..0e3f973d0fc7c8 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ TAGS .vs/ .vscode/ gmon.out +.coverage .mypy_cache/ *.exe @@ -107,7 +108,6 @@ Tools/unicode/data/ /python-gdb.py /python.exe-gdb.py /reflog.txt -/.coverage /coverage/ /externals/ /htmlcov/ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy