Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-01-10 03:37:19 +0400
committerRussell Belfer <arrbee@arrbee.com>2012-01-12 02:39:51 +0400
commitdf743c7d3a04553ffc04ae7cbc64fb300e7f61d2 (patch)
tree7f0dfa714ddb292448cbeaa69f2b5d90a3274d85 /src/path.h
parent7e443f696068cd8c84a759e532c2845348e5a6ad (diff)
Initial implementation of gitignore support
Adds support for .gitignore files to git_status_foreach() and git_status_file(). This includes refactoring the gitattributes code to share logic where possible. The GIT_STATUS_IGNORED flag will now be passed in for files that are ignored (provided they are not already in the index or the head of repo).
Diffstat (limited to 'src/path.h')
-rw-r--r--src/path.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/path.h b/src/path.h
index c308c5bd4..ceb3bb533 100644
--- a/src/path.h
+++ b/src/path.h
@@ -77,4 +77,27 @@ GIT_INLINE(void) git_path_mkposix(char *path)
extern int git__percent_decode(git_buf *decoded_out, const char *input);
extern int git_path_fromurl(git_buf *local_path_out, const char *file_url);
+/*
+ * Use as:
+ *
+ * git_path_walk_up(
+ * git_buf *path, git_buf *iterator, const char *root_path,
+ * ... CALLBACK CODE ...)
+ *
+ * to invoke callback directory by directory up the path until the root_path
+ * is reached (inclusive of a final call at the root_path). If root path is
+ * NULL or the path is not contained in the root_path, then the callback
+ * code will be invoked just once on input path.
+ */
+#define git_path_walk_up(B,IB,ROOT,CODE) do { \
+ ssize_t _stop = ((ROOT) && git__prefixcmp((B)->ptr, (ROOT))) ? (ssize_t)strlen(ROOT) : (B)->size; \
+ ssize_t _scan = (B)->size; char _oldc = '\0'; \
+ (IB)->ptr = (B)->ptr; (IB)->size = (B)->size; \
+ while (_scan >= _stop) { \
+ CODE; \
+ (IB)->ptr[_scan] = _oldc; \
+ _scan = git_buf_rfind_next((IB), '/'); \
+ if (_scan >= 0) { _scan++; _oldc = (IB)->ptr[_scan]; (IB)->size = _scan; (IB)->ptr[_scan] = '\0'; } \
+ } (IB)->ptr[_scan] = _oldc; } while (0)
+
#endif