Skip to content

Commit 0aa65f8

Browse files
committed
path: add functions to detect .gitconfig and .gitattributes
1 parent 9de97ae commit 0aa65f8

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

include/git2/sys/path.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) the libgit2 contributors. All rights reserved.
3+
*
4+
* This file is part of libgit2, distributed under the GNU GPL v2 with
5+
* a Linking Exception. For full terms see the included COPYING file.
6+
*/
7+
#ifndef INCLUDE_sys_git_path_h__
8+
#define INCLUDE_sys_git_path_h__
9+
10+
#include "git2/common.h"
11+
#include "git2/types.h"
12+
13+
GIT_BEGIN_DECL
14+
15+
/**
16+
* Check whether a path component corresponds to a .gitmodules file
17+
*
18+
* @param name the path component to check
19+
*/
20+
GIT_EXTERN(int) git_path_is_dotgit_modules(const char *name);
21+
22+
/**
23+
* Check whether a path component corresponds to a .gitignore file
24+
*
25+
* @param name the path component to check
26+
*/
27+
GIT_EXTERN(int) git_path_is_dotgit_ignore(const char *name);
28+
29+
/**
30+
* Check whether a path component corresponds to a .gitignore file
31+
*
32+
* @param name the path component to check
33+
*/
34+
GIT_EXTERN(int) git_path_is_dotgit_attributes(const char *name);
35+
36+
GIT_END_DECL
37+
#endif

src/path.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,3 +1854,13 @@ int git_path_is_dotgit_modules(const char *name)
18541854
{
18551855
return !verify_dotgit_generic(name, "gitmodules", "gi7eba");
18561856
}
1857+
1858+
int git_path_is_dotgit_ignore(const char *name)
1859+
{
1860+
return !verify_dotgit_generic(name, "gitignore", "gi250a");
1861+
}
1862+
1863+
int git_path_is_dotgit_attributes(const char *name)
1864+
{
1865+
return !verify_dotgit_generic(name, "gitattributes", "gi7d29");
1866+
}

0 commit comments

Comments
 (0)