summaryrefslogtreecommitdiff
path: root/src/push.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-30 10:57:42 -0700
committerRussell Belfer <rb@github.com>2014-05-02 09:21:33 -0700
commit702efc891f2a620f10998062ba0c00b34100f632 (patch)
treee80132037df687837a40b5c3d8f1d6a079d35e43 /src/push.c
parent9c8ed4999740e921ecc2966bbcd0dbcfc725f59a (diff)
downloadlibgit2-702efc891f2a620f10998062ba0c00b34100f632.tar.gz
Make init_options fns use unsigned ints and macro
Use an unsigned int for the version and add a helper macro so the code is simplified (and so the error message is a common string).
Diffstat (limited to 'src/push.c')
-rw-r--r--src/push.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/push.c b/src/push.c
index 9943f215c..be5ec1c0e 100644
--- a/src/push.c
+++ b/src/push.c
@@ -716,14 +716,9 @@ void git_push_free(git_push *push)
git__free(push);
}
-int git_push_init_options(git_push_options* opts, int version)
+int git_push_init_options(git_push_options *opts, unsigned int version)
{
- if (version != GIT_PUSH_OPTIONS_VERSION) {
- giterr_set(GITERR_INVALID, "Invalid version %d for git_push_options", version);
- return -1;
- } else {
- git_push_options o = GIT_PUSH_OPTIONS_INIT;
- memcpy(opts, &o, sizeof(o));
- return 0;
- }
+ GIT_INIT_STRUCTURE_FROM_TEMPLATE(
+ opts, version, git_push_options, GIT_PUSH_OPTIONS_INIT);
+ return 0;
}