How to hg ignore filename with no extension?
Asked Answered
I

2

5

Mercurial can be configured to ignore files whose filename have a certain extension. For example, *.txt files can be ignored by adding this to ~/.hgignore:

syntax: glob
*.txt

How can I setup my .hgignore file to ignore files whose filenames have no extensions? For example, files named foobar and abracadabra should be ignored, but foobar.cpp and abracadabra.c should be tracked.

Inexcusable answered 13/5, 2013 at 7:55 Comment(0)
I
9

Use regexp syntax instead since it's not possible with glob:

syntax: regexp
^[^.]+$

PS: you can add it right after your syntax: glob section

Ingratiate answered 13/5, 2013 at 7:57 Comment(0)
S
3

If you have a small list of files without extension that you want to ignore, then you can just list them as glob patterns:

syntax: glob
foobar
abracadabra

If you want to ignore all files without an extension, then things become more difficult. If you use the regexp provided by zerkms,

syntax: regexp
^[^.]+$

then you will also ignore directories without an "extension", that is directories without . in their names such as src, and so on.

Because Mercurial matches files and directories top-down while traversing your working copy, and because it doesn't distinguish between files and directories when matching against the patterns in the .hgignore file, you cannot include a directory while ignoring files with the same name.

(You can simulate the opposite: by ignoring foobar/ in regexp syntax you end up ignoring all files inside foobar/ while not ignoring a file named foobar in another directory.)

Sofar answered 14/5, 2013 at 11:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.