From 8d39f2a79067c9551286bb552457db71b88b64d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 30 Apr 2013 10:55:17 +0200 Subject: [PATCH] refspec: add direction accessor --- include/git2/refspec.h | 8 ++++++++ src/refspec.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/include/git2/refspec.h b/include/git2/refspec.h index 3e1b502ef..89ab81b02 100644 --- a/include/git2/refspec.h +++ b/include/git2/refspec.h @@ -51,6 +51,14 @@ GIT_EXTERN(const char *) git_refspec_string(const git_refspec *refspec); */ GIT_EXTERN(int) git_refspec_force(const git_refspec *refspec); +/** + * Get the refspec's direction. + * + * @param the refspec + * @return GIT_DIRECTION_FETCH or GIT_DIRECTION_PUSH + */ +GIT_EXTERN(git_direction) git_refspec_direction(const git_refspec *spec); + /** * Check if a refspec's source descriptor matches a reference * diff --git a/src/refspec.c b/src/refspec.c index 256540819..a907df84c 100644 --- a/src/refspec.c +++ b/src/refspec.c @@ -274,3 +274,10 @@ int git_refspec_is_wildcard(const git_refspec *spec) return (spec->src[strlen(spec->src) - 1] == '*'); } + +git_direction git_refspec_direction(const git_refspec *spec) +{ + assert(spec); + + return spec->push; +}