Skip to content

Commit 525e7fb

Browse files
committed
path.c: document the purpose of is_ntfs_dotgit()
Previously, this function was completely undocumented. It is worth, though, to explain what is going on, as it is not really obvious at all. Suggested-by: Garima Singh <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e1d911d commit 525e7fb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

path.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,34 @@ static int only_spaces_and_periods(const char *path, size_t len, size_t skip)
13021302
return 1;
13031303
}
13041304

1305+
/*
1306+
* On NTFS, we need to be careful to disallow certain synonyms of the `.git/`
1307+
* directory:
1308+
*
1309+
* - For historical reasons, file names that end in spaces or periods are
1310+
* automatically trimmed. Therefore, `.git . . ./` is a valid way to refer
1311+
* to `.git/`.
1312+
*
1313+
* - For other historical reasons, file names that do not conform to the 8.3
1314+
* format (up to eight characters for the basename, three for the file
1315+
* extension, certain characters not allowed such as `+`, etc) are associated
1316+
* with a so-called "short name", at least on the `C:` drive by default.
1317+
* Which means that `git~1/` is a valid way to refer to `.git/`.
1318+
*
1319+
* Note: Technically, `.git/` could receive the short name `git~2` if the
1320+
* short name `git~1` were already used. In Git, however, we guarantee that
1321+
* `.git` is the first item in a directory, therefore it will be associated
1322+
* with the short name `git~1` (unless short names are disabled).
1323+
*
1324+
* When this function returns 1, it indicates that the specified file/directory
1325+
* name refers to a `.git` file or directory, or to any of these synonyms, and
1326+
* Git should therefore not track it.
1327+
*
1328+
* This function is intended to be used by `git fsck` even on platforms where
1329+
* the backslash is a regular filename character, therefore it needs to handle
1330+
* backlash characters in the provided `name` specially: they are interpreted
1331+
* as directory separators.
1332+
*/
13051333
int is_ntfs_dotgit(const char *name)
13061334
{
13071335
size_t len;

0 commit comments

Comments
 (0)