gittup / tup

Tup is a file-based build system.
http://gittup.org/tup/
GNU General Public License v2.0
1.18k stars 145 forks source link

Combining tup and user gitignore entries #476

Open evur opened 1 year ago

evur commented 1 year ago

Tup currently only ignores the .gitignore file if there is no user content inside. This behavior was added in 627aa5659b2faaadb8c86022a759197ee48349d0. This approach has the problem of not ignoring auto-generated .gitignore files and doesn't work correctly on windows. So my suggestion is to merge a file called tup.gitignore (if it exists) with the generated .gitignore.

For example:

(the .gitignore which would normally be generated by Tup)

##### TUP GITIGNORE #####
##### Lines below automatically generated by Tup.
##### Do not edit.
.tup
/.gitignore

tup.gitignore (user created)

/foobar

.gitignore (created by merging the gitignore generated by Tup and tup.gitignore)

##### TUP GITIGNORE #####
##### Lines below automatically generated by Tup.
##### Do not edit.
.tup
/.gitignore
/foobar
gittup commented 7 months ago

I like this idea, it seems like it would help not having to commit changes to .gitignore files that contain a manually entered section just because the Tupfile changes.

What part is not working correctly on Windows currently? As far as I can tell it seems to be working the same as other OSes, which is the .gitignore file is ignored if it is completely auto-generated, and it is not ignored if you put manual content in there.

Regarding the name tup.gitignore, what do you think of something like .gitignore.tup instead? Other tup-related files are either capitalized (eg: Tupfile, Tupfile.ini), or have a .tup extension. I think .gitignore.tup would be a little more consistent in this regard, and would show up in the shell / file-browser alongside the .gitignore file to make it a little more obvious to a user that the .tup version is present and could be modified instead of the base .gitignore file.

Another option is to add parser logic in the Tupfile / Tupfile.lua that allows you to specify extra gitignore entries there. Eg in lua this could be something like:

tup.gitignorefiles({'foo.txt', 'bar.dat'})

In a regular Tupfile it could be that the .gitignore command takes a list of entries to add to the generated .gitignore file.

evur commented 7 months ago

What part is not working correctly on Windows currently? As far as I can tell it seems to be working the same as other OSes, which is the .gitignore file is ignored if it is completely auto-generated, and it is not ignored if you put manual content in there.

Unfortunately I no longer know what the issue was. But it worked on Linux.

Regarding the name tup.gitignore, what do you think of something like .gitignore.tup instead?

Agreed, .gitignore.tup sounds good and is better for sorting. But I've got a new idea: you could preserve the current behavior but use .git/info/exclude instead of .gitignore (see https://git-scm.com/docs/gitignore and https://stackoverflow.com/a/22906964). The user would not normally see this and doesn't need to care about tup's gitignore entries. What do you think about it?

Another option is to add parser logic in the Tupfile / Tupfile.lua that allows you to specify extra gitignore entries there.

This would be interesting when implemented in addition to this feature. It could be used for programmatically specifying gitignore entries. But I can only imagine this being useful in some edge cases.