Skip .gitignore files that already being tracked
The generated recipe is meant for .gitignore files that are not supposed to be tracked by git, so, it makes sense to skip all the .gitignore files that already tracked by git.
Updated the PR, fixed a mistake.
Weird. I left a comment on your PR but I don't see it. What I said was: if a directory has a handwritten .gitignore then it's Makefile.am should NOT include git.mk.
@behdad you left it on the commit which just get orphared by the new one.
It does not harm to have this check anyway, sometimes we might want to inlude the git.mk in Makefile.am in order to get the subdirectory .gitignore generated.
This originally intend to fix the submodule problem your previous commit tried to but failed(do not know why, it does not work in the gitg project which has libgd as submodule).
@techlivezheng can you debug why it's not working at least? I can't get past configure for any libgd-using app...
@behdad Okay, will let you know.
@behdad Your fix in caee737 only makes sure that git.mk not recurse into any subdirecty with a '.git' file/directory exists. When the 'make' runs inside the subdirectory, this does not help, you can see it below, the libgd's .gitignore is generated in the libgd's make all. libgd's Makefile.am contains include $(top_srcdir)/git.mk at the end which will trigger the recipe for all: $(srcdir)/.gitignore. To fix this, you need to add -f "$$subdir/.git" check in $(srcdir)/.gitignore recipe too, because .git inside the submodule is usually a file, but this does not guaranteed, a directory would also work in the old git version(this behavior is still supported), so I guess the best fix is to ignore the tracked .gitignore anyway. Using git.mk, the .gitignore should not be tracked, if it is tracked,we ignore it. By the way, we really should not modify a tracked .gitignore. If a user tracks a .gitgnore, it means he may intend to mannually take care of it. If the user do want to use git.mk update the tracked .gitignore, then may be add some makefile flag for it?
*** Building gitg *** [1/1]
make
git.mk: Generating .gitignore
make all-recursive
make[1]: Entering directory `/home/techlive/Workspace/projects/0.folk/gitg'
Making all in libgd
make[2]: Entering directory `/home/techlive/Workspace/projects/0.folk/gitg/libgd'
git.mk: Generating .gitignore
make[2]: Leaving directory `/home/techlive/Workspace/projects/0.folk/gitg/libgd'
Making all in libgitg
@techlivezheng this is what I'm saying: libgd/Makefile.am must NOT include git.mk!
I believe the reason it did before was that before the submodule fix, build could be broken if any subdirectory didn't include git.mk. It's not the case anymore. But I can see how your solution can be helpful too. I'll go ahead and take it I guess. Right now git.mk never calls git, but that's not a huge deal I suppose.
this is what I'm saying: libgd/Makefile.am must NOT include git.mk!
@behdad We can do this for our own sub-direcotry, the problem is you can not control a submodule's directory, it is a top-directory for its own project but a sub-directory for ours.