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 module libgit2_d.revparse; 8 9 10 private static import libgit2_d.types; 11 12 /** 13 * @file git2/revparse.h 14 * @brief Git revision parsing routines 15 * @defgroup git_revparse Git revision parsing routines 16 * @ingroup Git 17 * @{ 18 */ 19 extern (C): 20 nothrow @nogc: 21 public: 22 23 /** 24 * Find a single object, as specified by a revision string. 25 * 26 * See `man gitrevisions`, or 27 * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for 28 * information on the syntax accepted. 29 * 30 * The returned object should be released with `git_object_free` when no 31 * longer needed. 32 * 33 * Params: 34 * out_ = pointer to output object 35 * repo = the repository to search in 36 * spec = the textual specification for an object 37 * 38 * Returns: 0 on success, git_error_code.GIT_ENOTFOUND, git_error_code.GIT_EAMBIGUOUS, git_error_code.GIT_EINVALIDSPEC or an error code 39 */ 40 //GIT_EXTERN 41 int git_revparse_single(libgit2_d.types.git_object** out_, libgit2_d.types.git_repository* repo, const (char)* spec); 42 43 /** 44 * Find a single object and intermediate reference by a revision string. 45 * 46 * See `man gitrevisions`, or 47 * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for 48 * information on the syntax accepted. 49 * 50 * In some cases (`@{<-n>}` or `<branchname>@{upstream}`), the expression may 51 * point to an intermediate reference. When such expressions are being passed 52 * in, `reference_out` will be valued as well. 53 * 54 * The returned object should be released with `git_object_free` and the 55 * returned reference with `git_reference_free` when no longer needed. 56 * 57 * Params: 58 * object_out = pointer to output object 59 * reference_out = pointer to output reference or null 60 * repo = the repository to search in 61 * spec = the textual specification for an object 62 * 63 * Returns: 0 on success, git_error_code.GIT_ENOTFOUND, git_error_code.GIT_EAMBIGUOUS, git_error_code.GIT_EINVALIDSPEC or an error code 64 */ 65 //GIT_EXTERN 66 int git_revparse_ext(libgit2_d.types.git_object** object_out, libgit2_d.types.git_reference** reference_out, libgit2_d.types.git_repository* repo, const (char)* spec); 67 68 /** 69 * Revparse flags. These indicate the intended behavior of the spec passed to 70 * git_revparse. 71 */ 72 enum git_revparse_mode_t 73 { 74 /** 75 * The spec targeted a single object. 76 */ 77 GIT_REVPARSE_SINGLE = 1 << 0, 78 79 /** 80 * The spec targeted a range of commits. 81 */ 82 GIT_REVPARSE_RANGE = 1 << 1, 83 84 /** 85 * The spec used the '...' operator, which invokes special semantics. 86 */ 87 GIT_REVPARSE_MERGE_BASE = 1 << 2, 88 } 89 90 //Declaration name in C language 91 enum 92 { 93 GIT_REVPARSE_SINGLE = .git_revparse_mode_t.GIT_REVPARSE_SINGLE, 94 GIT_REVPARSE_RANGE = .git_revparse_mode_t.GIT_REVPARSE_RANGE, 95 GIT_REVPARSE_MERGE_BASE = .git_revparse_mode_t.GIT_REVPARSE_MERGE_BASE, 96 } 97 98 /** 99 * Git Revision Spec: output of a `git_revparse` operation 100 */ 101 struct git_revspec 102 { 103 /** 104 * The left element of the revspec; must be freed by the user 105 */ 106 libgit2_d.types.git_object* from; 107 108 /** 109 * The right element of the revspec; must be freed by the user 110 */ 111 libgit2_d.types.git_object* to; 112 113 /** 114 * The intent of the revspec (i.e. `git_revparse_mode_t` flags) 115 */ 116 uint flags; 117 } 118 119 /** 120 * Parse a revision string for `from`, `to`, and intent. 121 * 122 * See `man gitrevisions` or 123 * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for 124 * information on the syntax accepted. 125 * 126 * Params: 127 * revspec = Pointer to an user-allocated git_revspec struct where the result of the rev-parse will be stored 128 * repo = the repository to search in 129 * spec = the rev-parse spec to parse 130 * 131 * Returns: 0 on success, GIT_INVALIDSPEC, git_error_code.GIT_ENOTFOUND, git_error_code.GIT_EAMBIGUOUS or an error code 132 */ 133 //GIT_EXTERN 134 int git_revparse(.git_revspec* revspec, libgit2_d.types.git_repository* repo, const (char)* spec); 135 136 /** @} */