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