diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/attr.c | 7 | ||||
-rw-r--r-- | src/attr_file.h | 5 | ||||
-rw-r--r-- | src/ignore.c | 17 | ||||
-rw-r--r-- | src/ignore.h | 2 | ||||
-rw-r--r-- | src/status.c | 15 | ||||
-rw-r--r-- | src/util.h | 2 |
6 files changed, 23 insertions, 25 deletions
diff --git a/src/attr.c b/src/attr.c index cbc2a5bf5..dc42379ff 100644 --- a/src/attr.c +++ b/src/attr.c @@ -3,11 +3,6 @@ #include "config.h" #include <ctype.h> -#define GIT_ATTR_FILE_INREPO "info/attributes" -#define GIT_ATTR_FILE ".gitattributes" -#define GIT_ATTR_FILE_SYSTEM "gitattributes" -#define GIT_ATTR_CONFIG "core.attributesfile" - static int collect_attr_files( git_repository *repo, const char *path, git_vector *files); @@ -304,7 +299,7 @@ static int collect_attr_files( if (error < GIT_SUCCESS) goto cleanup; - if (git_repository_config(&cfg, repo) == GIT_SUCCESS) { + if ((error = git_repository_config(&cfg, repo)) == GIT_SUCCESS) { const char *core_attribs = NULL; git_config_get_string(cfg, GIT_ATTR_CONFIG, &core_attribs); git_clearerror(); /* don't care if attributesfile is not set */ diff --git a/src/attr_file.h b/src/attr_file.h index 86836b56f..7190c4c7b 100644 --- a/src/attr_file.h +++ b/src/attr_file.h @@ -11,6 +11,11 @@ #include "vector.h" #include "hashtable.h" +#define GIT_ATTR_FILE ".gitattributes" +#define GIT_ATTR_FILE_INREPO "info/attributes" +#define GIT_ATTR_FILE_SYSTEM "gitattributes" +#define GIT_ATTR_CONFIG "core.attributesfile" + #define GIT_ATTR_FNMATCH_NEGATIVE (1U << 0) #define GIT_ATTR_FNMATCH_DIRECTORY (1U << 1) #define GIT_ATTR_FNMATCH_FULLPATH (1U << 2) diff --git a/src/ignore.c b/src/ignore.c index cdc3edab6..1040574d7 100644 --- a/src/ignore.c +++ b/src/ignore.c @@ -106,7 +106,7 @@ int git_ignore__for_path(git_repository *repo, const char *path, git_vector *sta goto cleanup; /* load core.excludesfile */ - if (git_repository_config(&cfg, repo) == GIT_SUCCESS) { + if ((error = git_repository_config(&cfg, repo)) == GIT_SUCCESS) { const char *core_ignore; error = git_config_get_string(cfg, GIT_IGNORE_CONFIG, &core_ignore); if (error == GIT_SUCCESS && core_ignore != NULL) @@ -157,18 +157,3 @@ found: return error; } - - -int git_ignore_is_ignored(git_repository *repo, const char *path, int *ignored) -{ - int error; - git_vector ignores = GIT_VECTOR_INIT; - - if ((error = git_ignore__for_path(repo, path, &ignores)) == GIT_SUCCESS) - error = git_ignore__lookup(&ignores, path, ignored); - - git_ignore__free(&ignores); - - return error; -} - diff --git a/src/ignore.h b/src/ignore.h index a6e6a1a34..2954445b5 100644 --- a/src/ignore.h +++ b/src/ignore.h @@ -14,6 +14,4 @@ extern int git_ignore__for_path(git_repository *repo, const char *path, git_vect extern void git_ignore__free(git_vector *stack); extern int git_ignore__lookup(git_vector *stack, const char *path, int *ignored); -extern int git_ignore_is_ignored(git_repository *repo, const char *path, int *ignored); - #endif diff --git a/src/status.c b/src/status.c index 72ee7b049..3ead15a87 100644 --- a/src/status.c +++ b/src/status.c @@ -761,3 +761,18 @@ static int alphasorted_futils_direach( git_vector_free(&entry_names); return error; } + + +int git_status_should_ignore(git_repository *repo, const char *path, int *ignored) +{ + int error; + git_vector ignores = GIT_VECTOR_INIT; + + if ((error = git_ignore__for_path(repo, path, &ignores)) == GIT_SUCCESS) + error = git_ignore__lookup(&ignores, path, ignored); + + git_ignore__free(&ignores); + + return error; +} + diff --git a/src/util.h b/src/util.h index bd76a263e..6c929cf0a 100644 --- a/src/util.h +++ b/src/util.h @@ -105,7 +105,7 @@ extern void git__strtolower(char *str); GIT_INLINE(const char *) git__next_line(const char *s) { while (*s && *s != '\n') s++; - while (*s == '\n') s++; + while (*s == '\n' || *s == '\r') s++; return s; } |