summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2018-05-22 13:58:24 +0200
committerPatrick Steinhardt <ps@pks.im>2018-06-01 13:44:32 +0200
commit3adb0dc383165d7e2e89afedc41d2f432ad71b6a (patch)
tree1f725c935f511301e8999144699b8db31f12b271
parentdc5591b47b718ef0a9b3e23b615a0417fe9620c9 (diff)
downloadlibgit2-3adb0dc383165d7e2e89afedc41d2f432ad71b6a.tar.gz
path: expose dotgit detection functions per filesystem
These will be used by the checkout code to detect them for the particular filesystem they're on.
-rw-r--r--src/path.c45
-rw-r--r--src/path.h42
2 files changed, 84 insertions, 3 deletions
diff --git a/src/path.c b/src/path.c
index 26a7d59e6..560cf86f3 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1849,17 +1849,56 @@ static int verify_dotgit_generic(const char *name, const char *dotgit_name, cons
return verify_dotgit_hfs_generic(name, strlen(name), dotgit_name, strlen(dotgit_name));
}
+int git_path_is_ntfs_dotgit_modules(const char *name)
+{
+ return !verify_dotgit_ntfs_generic(name, "gitmodules", "gi7eba");
+}
+
+int git_path_is_hfs_dotgit_modules(const char *name)
+{
+ return !verify_dotgit_hfs_generic(name, strlen(name), "gitmodules", CONST_STRLEN("gitmodules"));
+}
+
int git_path_is_dotgit_modules(const char *name)
{
- return !verify_dotgit_generic(name, "gitmodules", "gi7eba");
+ if (git_path_is_hfs_dotgit_modules(name))
+ return 1;
+
+ return git_path_is_ntfs_dotgit_modules(name);
+}
+
+int git_path_is_ntfs_dotgit_ignore(const char *name)
+{
+ return !verify_dotgit_ntfs_generic(name, "gitignore", "gi250a");
+}
+
+int git_path_is_hfs_dotgit_ignore(const char *name)
+{
+ return !verify_dotgit_hfs_generic(name, strlen(name), "gitignore", CONST_STRLEN("gitignore"));
}
int git_path_is_dotgit_ignore(const char *name)
{
- return !verify_dotgit_generic(name, "gitignore", "gi250a");
+ if (git_path_is_hfs_dotgit_ignore(name))
+ return 1;
+
+ return git_path_is_ntfs_dotgit_ignore(name);
+}
+
+int git_path_is_hfs_dotgit_attributes(const char *name)
+{
+ return !verify_dotgit_hfs_generic(name, strlen(name), "gitattributes", CONST_STRLEN("gitattributes"));
+}
+
+int git_path_is_ntfs_dotgit_attributes(const char *name)
+{
+ return !verify_dotgit_ntfs_generic(name, "gitattributes", "gi7d29");
}
int git_path_is_dotgit_attributes(const char *name)
{
- return !verify_dotgit_generic(name, "gitattributes", "gi7d29");
+ if (git_path_is_hfs_dotgit_attributes(name))
+ return 1;
+
+ return git_path_is_ntfs_dotgit_attributes(name);
}
diff --git a/src/path.h b/src/path.h
index a845a3fd8..553608aa2 100644
--- a/src/path.h
+++ b/src/path.h
@@ -638,6 +638,20 @@ int git_path_normalize_slashes(git_buf *out, const char *path);
extern int git_path_is_dotgit_modules(const char *name);
/**
+ * Check whether a path component corresponds to a .gitmodules file in NTFS
+ *
+ * @param name the path component to check
+ */
+extern int git_path_is_ntfs_dotgit_modules(const char *name);
+
+/**
+ * Check whether a path component corresponds to a .gitmodules file in HFS+
+ *
+ * @param name the path component to check
+ */
+extern int git_path_is_hfs_dotgit_modules(const char *name);
+
+/**
* Check whether a path component corresponds to a .gitignore file
*
* @param name the path component to check
@@ -645,10 +659,38 @@ extern int git_path_is_dotgit_modules(const char *name);
extern int git_path_is_dotgit_ignore(const char *name);
/**
+ * Check whether a path component corresponds to a .gitignore file in NTFS
+ *
+ * @param name the path component to check
+ */
+extern int git_path_is_ntfs_dotgit_ignore(const char *name);
+
+/**
+ * Check whether a path component corresponds to a .gitignore file in HFS+
+ *
+ * @param name the path component to check
+ */
+extern int git_path_is_hfs_dotgit_ignore(const char *name);
+
+/**
* Check whether a path component corresponds to a .gitignore file
*
* @param name the path component to check
*/
extern int git_path_is_dotgit_attributes(const char *name);
+/**
+ * Check whether a path component corresponds to a .gitattributes file in NTFS
+ *
+ * @param name the path component to check
+ */
+extern int git_path_is_ntfs_dotgit_attributes(const char *name);
+
+/**
+ * Check whether a path component corresponds to a .gitattributes file in HFS+
+ *
+ * @param name the path component to check
+ */
+extern int git_path_is_hfs_dotgit_attributes(const char *name);
+
#endif