Bug 2880 - Git ignores (almost) all makefiles in subdirectories ./regress/*
Summary: Git ignores (almost) all makefiles in subdirectories ./regress/*
Status: NEW
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Build system (show other bugs)
Version: 7.7p1
Hardware: All All
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-03 10:47 AEST by Torben
Modified: 2018-07-04 04:54 AEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torben 2018-07-03 10:47:08 AEST
The .gitignore file contains the pattern 'Makefile'. Since the pattern is applied recursively in subdirectories the makefiles that build unit tests, etc. are ignored.

.gitignore already contains the exception '!regress/misc/fuzz-harness/Makefile', so it seems appropriate to add exceptions for the other makefiles in ./regress/*.
Comment 1 Damien Miller 2018-07-03 16:39:22 AEST
Hi Torben,

I can't reproduce this. E.g.

$ pwd
/Users/djm/cvs/openssh
$ echo foo >> regress/misc/Makefile
$ git diff
diff --git a/regress/misc/Makefile b/regress/misc/Makefile
index 14c0c279..07a8f1c2 100644
--- a/regress/misc/Makefile
+++ b/regress/misc/Makefile
@@ -1,3 +1,4 @@
 SUBDIR=                kexfuzz

 .include <bsd.subdir.mk>
+foo

Moreover the behaviour you describe seems at odds with this line from the manual for gitignore:

> If the pattern does not contain a slash /, Git treats it as a shell glob 
> pattern and checks for a match against the pathname relative to the location 
> of the .gitignore file (relative to the toplevel of the work tree if not 
> from a .gitignore file).
Comment 2 Torben 2018-07-03 17:38:54 AEST
Hi Damien

I see the same behaviour. However, If the file is not tracked, then I experience a different behaviour. If you, say, create a new git repository with the OpenSSH source files and wants to start tracking all files, then the makefiles will be ignored.

Toy example below

$ pwd
/Users/himsen/tmp
$ mkdir test_root test_root/test_subdir
$ cd test_root
$ git init
$ echo test >> test_subdir/Makefile
$ echo Makefile >> .gitignore
$ git add test_subdir/Makefile
The following paths are ignored by one of your .gitignore files:
test_subdir/Makefile
Use -f if you really want to add them.

Or, in your OpenSSH repository, you can do

$ git rm --cached regress/unittests/Makefile
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        deleted:    regress/unittests/Makefile

seeing that regress/unittests/Makefile does not appear as untracked.
Comment 3 Torben 2018-07-03 18:10:23 AEST
This extract from the Git manual explains that there is indeed a recursive thing going on:

"Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. [...]"
Comment 4 Roumen Petrov 2018-07-04 04:54:18 AEST
The correct if to ignore only Makefile subject of creation, i.e. those listed AC_CONFIG_FILES. Current "ignore" file does not follow this rule.
So can not understand some comments on this issue.