2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_git_refs_h__
8 #define INCLUDE_git_refs_h__
17 * @brief Git reference management routines
18 * @defgroup git_reference Git reference management routines
25 * Lookup a reference by name in a repository.
27 * The returned reference must be freed by the user.
29 * The name will be checked for validity.
30 * See `git_reference_symbolic_create()` for rules about valid names.
32 * @param out pointer to the looked-up reference
33 * @param repo the repository to look up the reference
34 * @param name the long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)
35 * @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code.
37 GIT_EXTERN(int) git_reference_lookup(git_reference
**out
, git_repository
*repo
, const char *name
);
40 * Lookup a reference by name and resolve immediately to OID.
42 * This function provides a quick way to resolve a reference name straight
43 * through to the object id that it refers to. This avoids having to
44 * allocate or free any `git_reference` objects for simple situations.
46 * The name will be checked for validity.
47 * See `git_reference_symbolic_create()` for rules about valid names.
49 * @param out Pointer to oid to be filled in
50 * @param repo The repository in which to look up the reference
51 * @param name The long name for the reference (e.g. HEAD, refs/heads/master, refs/tags/v0.1.0, ...)
52 * @return 0 on success, GIT_ENOTFOUND, GIT_EINVALIDSPEC or an error code.
54 GIT_EXTERN(int) git_reference_name_to_id(
55 git_oid
*out
, git_repository
*repo
, const char *name
);
58 * Lookup a reference by DWIMing its short name
60 * Apply the git precedence rules to the given shorthand to determine
61 * which reference the user is referring to.
63 * @param out pointer in which to store the reference
64 * @param repo the repository in which to look
65 * @param shorthand the short name for the reference
66 * @return 0 or an error code
68 GIT_EXTERN(int) git_reference_dwim(git_reference
**out
, git_repository
*repo
, const char *shorthand
);
71 * Conditionally create a new symbolic reference.
73 * A symbolic reference is a reference name that refers to another
74 * reference name. If the other name moves, the symbolic name will move,
75 * too. As a simple example, the "HEAD" reference might refer to
76 * "refs/heads/master" while on the "master" branch of a repository.
78 * The symbolic reference will be created in the repository and written to
79 * the disk. The generated reference object must be freed by the user.
81 * Valid reference names must follow one of two patterns:
83 * 1. Top-level names must contain only capital letters and underscores,
84 * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
85 * 2. Names prefixed with "refs/" can be almost anything. You must avoid
86 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
87 * sequences ".." and "@{" which have special meaning to revparse.
89 * This function will return an error if a reference already exists with the
90 * given name unless `force` is true, in which case it will be overwritten.
92 * The message for the reflog will be ignored if the reference does
93 * not belong in the standard set (HEAD, branches and remote-tracking
94 * branches) and it does not have a reflog.
96 * It will return GIT_EMODIFIED if the reference's value at the time
97 * of updating does not match the one passed through `current_value`
98 * (i.e. if the ref has changed since the user read it).
100 * If `current_value` is all zeros, this function will return GIT_EMODIFIED
101 * if the ref already exists.
103 * @param out Pointer to the newly created reference
104 * @param repo Repository where that reference will live
105 * @param name The name of the reference
106 * @param target The target of the reference
107 * @param force Overwrite existing references
108 * @param current_value The expected value of the reference when updating
109 * @param log_message The one line long message to be appended to the reflog
110 * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC, GIT_EMODIFIED or an error code
112 GIT_EXTERN(int) git_reference_symbolic_create_matching(git_reference
**out
, git_repository
*repo
, const char *name
, const char *target
, int force
, const char *current_value
, const char *log_message
);
115 * Create a new symbolic reference.
117 * A symbolic reference is a reference name that refers to another
118 * reference name. If the other name moves, the symbolic name will move,
119 * too. As a simple example, the "HEAD" reference might refer to
120 * "refs/heads/master" while on the "master" branch of a repository.
122 * The symbolic reference will be created in the repository and written to
123 * the disk. The generated reference object must be freed by the user.
125 * Valid reference names must follow one of two patterns:
127 * 1. Top-level names must contain only capital letters and underscores,
128 * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
129 * 2. Names prefixed with "refs/" can be almost anything. You must avoid
130 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
131 * sequences ".." and "@{" which have special meaning to revparse.
133 * This function will return an error if a reference already exists with the
134 * given name unless `force` is true, in which case it will be overwritten.
136 * The message for the reflog will be ignored if the reference does
137 * not belong in the standard set (HEAD, branches and remote-tracking
138 * branches) and it does not have a reflog.
140 * @param out Pointer to the newly created reference
141 * @param repo Repository where that reference will live
142 * @param name The name of the reference
143 * @param target The target of the reference
144 * @param force Overwrite existing references
145 * @param log_message The one line long message to be appended to the reflog
146 * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code
148 GIT_EXTERN(int) git_reference_symbolic_create(git_reference
**out
, git_repository
*repo
, const char *name
, const char *target
, int force
, const char *log_message
);
151 * Create a new direct reference.
153 * A direct reference (also called an object id reference) refers directly
154 * to a specific object id (a.k.a. OID or SHA) in the repository. The id
155 * permanently refers to the object (although the reference itself can be
156 * moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0"
157 * refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977.
159 * The direct reference will be created in the repository and written to
160 * the disk. The generated reference object must be freed by the user.
162 * Valid reference names must follow one of two patterns:
164 * 1. Top-level names must contain only capital letters and underscores,
165 * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
166 * 2. Names prefixed with "refs/" can be almost anything. You must avoid
167 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
168 * sequences ".." and "@{" which have special meaning to revparse.
170 * This function will return an error if a reference already exists with the
171 * given name unless `force` is true, in which case it will be overwritten.
173 * The message for the reflog will be ignored if the reference does
174 * not belong in the standard set (HEAD, branches and remote-tracking
175 * branches) and it does not have a reflog.
177 * @param out Pointer to the newly created reference
178 * @param repo Repository where that reference will live
179 * @param name The name of the reference
180 * @param id The object id pointed to by the reference.
181 * @param force Overwrite existing references
182 * @param log_message The one line long message to be appended to the reflog
183 * @return 0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code
185 GIT_EXTERN(int) git_reference_create(git_reference
**out
, git_repository
*repo
, const char *name
, const git_oid
*id
, int force
, const char *log_message
);
188 * Conditionally create new direct reference
190 * A direct reference (also called an object id reference) refers directly
191 * to a specific object id (a.k.a. OID or SHA) in the repository. The id
192 * permanently refers to the object (although the reference itself can be
193 * moved). For example, in libgit2 the direct ref "refs/tags/v0.17.0"
194 * refers to OID 5b9fac39d8a76b9139667c26a63e6b3f204b3977.
196 * The direct reference will be created in the repository and written to
197 * the disk. The generated reference object must be freed by the user.
199 * Valid reference names must follow one of two patterns:
201 * 1. Top-level names must contain only capital letters and underscores,
202 * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
203 * 2. Names prefixed with "refs/" can be almost anything. You must avoid
204 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
205 * sequences ".." and "@{" which have special meaning to revparse.
207 * This function will return an error if a reference already exists with the
208 * given name unless `force` is true, in which case it will be overwritten.
210 * The message for the reflog will be ignored if the reference does
211 * not belong in the standard set (HEAD, branches and remote-tracking
212 * branches) and it does not have a reflog.
214 * It will return GIT_EMODIFIED if the reference's value at the time
215 * of updating does not match the one passed through `current_id`
216 * (i.e. if the ref has changed since the user read it).
218 * @param out Pointer to the newly created reference
219 * @param repo Repository where that reference will live
220 * @param name The name of the reference
221 * @param id The object id pointed to by the reference.
222 * @param force Overwrite existing references
223 * @param current_id The expected value of the reference at the time of update
224 * @param log_message The one line long message to be appended to the reflog
225 * @return 0 on success, GIT_EMODIFIED if the value of the reference
226 * has changed, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code
228 GIT_EXTERN(int) git_reference_create_matching(git_reference
**out
, git_repository
*repo
, const char *name
, const git_oid
*id
, int force
, const git_oid
*current_id
, const char *log_message
);
231 * Get the OID pointed to by a direct reference.
233 * Only available if the reference is direct (i.e. an object id reference,
234 * not a symbolic one).
236 * To find the OID of a symbolic ref, call `git_reference_resolve()` and
237 * then this function (or maybe use `git_reference_name_to_id()` to
238 * directly resolve a reference name all the way through to an OID).
240 * @param ref The reference
241 * @return a pointer to the oid if available, NULL otherwise
243 GIT_EXTERN(const git_oid
*) git_reference_target(const git_reference
*ref
);
246 * Return the peeled OID target of this reference.
248 * This peeled OID only applies to direct references that point to
249 * a hard Tag object: it is the result of peeling such Tag.
251 * @param ref The reference
252 * @return a pointer to the oid if available, NULL otherwise
254 GIT_EXTERN(const git_oid
*) git_reference_target_peel(const git_reference
*ref
);
257 * Get full name to the reference pointed to by a symbolic reference.
259 * Only available if the reference is symbolic.
261 * @param ref The reference
262 * @return a pointer to the name if available, NULL otherwise
264 GIT_EXTERN(const char *) git_reference_symbolic_target(const git_reference
*ref
);
267 * Get the type of a reference.
269 * Either direct (GIT_REFERENCE_DIRECT) or symbolic (GIT_REFERENCE_SYMBOLIC)
271 * @param ref The reference
274 GIT_EXTERN(git_reference_t
) git_reference_type(const git_reference
*ref
);
277 * Get the full name of a reference.
279 * See `git_reference_symbolic_create()` for rules about valid names.
281 * @param ref The reference
282 * @return the full name for the ref
284 GIT_EXTERN(const char *) git_reference_name(const git_reference
*ref
);
287 * Resolve a symbolic reference to a direct reference.
289 * This method iteratively peels a symbolic reference until it resolves to
290 * a direct reference to an OID.
292 * The peeled reference is returned in the `resolved_ref` argument, and
293 * must be freed manually once it's no longer needed.
295 * If a direct reference is passed as an argument, a copy of that
296 * reference is returned. This copy must be manually freed too.
298 * @param out Pointer to the peeled reference
299 * @param ref The reference
300 * @return 0 or an error code
302 GIT_EXTERN(int) git_reference_resolve(git_reference
**out
, const git_reference
*ref
);
305 * Get the repository where a reference resides.
307 * @param ref The reference
308 * @return a pointer to the repo
310 GIT_EXTERN(git_repository
*) git_reference_owner(const git_reference
*ref
);
313 * Create a new reference with the same name as the given reference but a
314 * different symbolic target. The reference must be a symbolic reference,
315 * otherwise this will fail.
317 * The new reference will be written to disk, overwriting the given reference.
319 * The target name will be checked for validity.
320 * See `git_reference_symbolic_create()` for rules about valid names.
322 * The message for the reflog will be ignored if the reference does
323 * not belong in the standard set (HEAD, branches and remote-tracking
324 * branches) and it does not have a reflog.
326 * @param out Pointer to the newly created reference
327 * @param ref The reference
328 * @param target The new target for the reference
329 * @param log_message The one line long message to be appended to the reflog
330 * @return 0 on success, GIT_EINVALIDSPEC or an error code
332 GIT_EXTERN(int) git_reference_symbolic_set_target(
336 const char *log_message
);
339 * Conditionally create a new reference with the same name as the given reference but a
340 * different OID target. The reference must be a direct reference, otherwise
343 * The new reference will be written to disk, overwriting the given reference.
345 * @param out Pointer to the newly created reference
346 * @param ref The reference
347 * @param id The new target OID for the reference
348 * @param log_message The one line long message to be appended to the reflog
349 * @return 0 on success, GIT_EMODIFIED if the value of the reference
350 * has changed since it was read, or an error code
352 GIT_EXTERN(int) git_reference_set_target(
356 const char *log_message
);
359 * Rename an existing reference.
361 * This method works for both direct and symbolic references.
363 * The new name will be checked for validity.
364 * See `git_reference_symbolic_create()` for rules about valid names.
366 * If the `force` flag is not enabled, and there's already
367 * a reference with the given name, the renaming will fail.
370 * The user needs to write a proper reflog entry if the
371 * reflog is enabled for the repository. We only rename
372 * the reflog if it exists.
374 * @param ref The reference to rename
375 * @param new_name The new name for the reference
376 * @param force Overwrite an existing reference
377 * @param log_message The one line long message to be appended to the reflog
378 * @return 0 on success, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
381 GIT_EXTERN(int) git_reference_rename(
382 git_reference
**new_ref
,
384 const char *new_name
,
386 const char *log_message
);
389 * Delete an existing reference.
391 * This method works for both direct and symbolic references. The reference
392 * will be immediately removed on disk but the memory will not be freed.
393 * Callers must call `git_reference_free`.
395 * This function will return an error if the reference has changed
396 * from the time it was looked up.
398 * @param ref The reference to remove
399 * @return 0, GIT_EMODIFIED or an error code
401 GIT_EXTERN(int) git_reference_delete(git_reference
*ref
);
404 * Delete an existing reference by name
406 * This method removes the named reference from the repository without
407 * looking at its old value.
409 * @param name The reference to remove
410 * @return 0 or an error code
412 GIT_EXTERN(int) git_reference_remove(git_repository
*repo
, const char *name
);
415 * Fill a list with all the references that can be found in a repository.
417 * The string array will be filled with the names of all references; these
418 * values are owned by the user and should be free'd manually when no
419 * longer needed, using `git_strarray_free()`.
421 * @param array Pointer to a git_strarray structure where
422 * the reference names will be stored
423 * @param repo Repository where to find the refs
424 * @return 0 or an error code
426 GIT_EXTERN(int) git_reference_list(git_strarray
*array
, git_repository
*repo
);
429 * Callback used to iterate over references
431 * @see git_reference_foreach
433 * @param reference The reference object
434 * @param payload Payload passed to git_reference_foreach
435 * @return non-zero to terminate the iteration
437 typedef int GIT_CALLBACK(git_reference_foreach_cb
)(git_reference
*reference
, void *payload
);
440 * Callback used to iterate over reference names
442 * @see git_reference_foreach_name
444 * @param name The reference name
445 * @param payload Payload passed to git_reference_foreach_name
446 * @return non-zero to terminate the iteration
448 typedef int GIT_CALLBACK(git_reference_foreach_name_cb
)(const char *name
, void *payload
);
451 * Perform a callback on each reference in the repository.
453 * The `callback` function will be called for each reference in the
454 * repository, receiving the reference object and the `payload` value
455 * passed to this method. Returning a non-zero value from the callback
456 * will terminate the iteration.
458 * Note that the callback function is responsible to call `git_reference_free`
459 * on each reference passed to it.
461 * @param repo Repository where to find the refs
462 * @param callback Function which will be called for every listed ref
463 * @param payload Additional data to pass to the callback
464 * @return 0 on success, non-zero callback return value, or error code
466 GIT_EXTERN(int) git_reference_foreach(
467 git_repository
*repo
,
468 git_reference_foreach_cb callback
,
472 * Perform a callback on the fully-qualified name of each reference.
474 * The `callback` function will be called for each reference in the
475 * repository, receiving the name of the reference and the `payload` value
476 * passed to this method. Returning a non-zero value from the callback
477 * will terminate the iteration.
479 * @param repo Repository where to find the refs
480 * @param callback Function which will be called for every listed ref name
481 * @param payload Additional data to pass to the callback
482 * @return 0 on success, non-zero callback return value, or error code
484 GIT_EXTERN(int) git_reference_foreach_name(
485 git_repository
*repo
,
486 git_reference_foreach_name_cb callback
,
490 * Create a copy of an existing reference.
492 * Call `git_reference_free` to free the data.
494 * @param dest pointer where to store the copy
495 * @param source object to copy
496 * @return 0 or an error code
498 GIT_EXTERN(int) git_reference_dup(git_reference
**dest
, git_reference
*source
);
501 * Free the given reference.
503 * @param ref git_reference
505 GIT_EXTERN(void) git_reference_free(git_reference
*ref
);
508 * Compare two references.
510 * @param ref1 The first git_reference
511 * @param ref2 The second git_reference
512 * @return 0 if the same, else a stable but meaningless ordering.
514 GIT_EXTERN(int) git_reference_cmp(
515 const git_reference
*ref1
,
516 const git_reference
*ref2
);
519 * Create an iterator for the repo's references
521 * @param out pointer in which to store the iterator
522 * @param repo the repository
523 * @return 0 or an error code
525 GIT_EXTERN(int) git_reference_iterator_new(
526 git_reference_iterator
**out
,
527 git_repository
*repo
);
530 * Create an iterator for the repo's references that match the
533 * @param out pointer in which to store the iterator
534 * @param repo the repository
535 * @param glob the glob to match against the reference names
536 * @return 0 or an error code
538 GIT_EXTERN(int) git_reference_iterator_glob_new(
539 git_reference_iterator
**out
,
540 git_repository
*repo
,
544 * Get the next reference
546 * @param out pointer in which to store the reference
547 * @param iter the iterator
548 * @return 0, GIT_ITEROVER if there are no more; or an error code
550 GIT_EXTERN(int) git_reference_next(git_reference
**out
, git_reference_iterator
*iter
);
553 * Get the next reference's name
555 * This function is provided for convenience in case only the names
556 * are interesting as it avoids the allocation of the `git_reference`
557 * object which `git_reference_next()` needs.
559 * @param out pointer in which to store the string
560 * @param iter the iterator
561 * @return 0, GIT_ITEROVER if there are no more; or an error code
563 GIT_EXTERN(int) git_reference_next_name(const char **out
, git_reference_iterator
*iter
);
566 * Free the iterator and its associated resources
568 * @param iter the iterator to free
570 GIT_EXTERN(void) git_reference_iterator_free(git_reference_iterator
*iter
);
573 * Perform a callback on each reference in the repository whose name
574 * matches the given pattern.
576 * This function acts like `git_reference_foreach()` with an additional
577 * pattern match being applied to the reference name before issuing the
578 * callback function. See that function for more information.
580 * The pattern is matched using fnmatch or "glob" style where a '*' matches
581 * any sequence of letters, a '?' matches any letter, and square brackets
582 * can be used to define character ranges (such as "[0-9]" for digits).
584 * @param repo Repository where to find the refs
585 * @param glob Pattern to match (fnmatch-style) against reference name.
586 * @param callback Function which will be called for every listed ref
587 * @param payload Additional data to pass to the callback
588 * @return 0 on success, GIT_EUSER on non-zero callback, or error code
590 GIT_EXTERN(int) git_reference_foreach_glob(
591 git_repository
*repo
,
593 git_reference_foreach_name_cb callback
,
597 * Check if a reflog exists for the specified reference.
599 * @param repo the repository
600 * @param refname the reference's name
601 * @return 0 when no reflog can be found, 1 when it exists;
602 * otherwise an error code.
604 GIT_EXTERN(int) git_reference_has_log(git_repository
*repo
, const char *refname
);
607 * Ensure there is a reflog for a particular reference.
609 * Make sure that successive updates to the reference will append to
612 * @param repo the repository
613 * @param refname the reference's name
614 * @return 0 or an error code.
616 GIT_EXTERN(int) git_reference_ensure_log(git_repository
*repo
, const char *refname
);
619 * Check if a reference is a local branch.
621 * @param ref A git reference
623 * @return 1 when the reference lives in the refs/heads
624 * namespace; 0 otherwise.
626 GIT_EXTERN(int) git_reference_is_branch(const git_reference
*ref
);
629 * Check if a reference is a remote tracking branch
631 * @param ref A git reference
633 * @return 1 when the reference lives in the refs/remotes
634 * namespace; 0 otherwise.
636 GIT_EXTERN(int) git_reference_is_remote(const git_reference
*ref
);
639 * Check if a reference is a tag
641 * @param ref A git reference
643 * @return 1 when the reference lives in the refs/tags
644 * namespace; 0 otherwise.
646 GIT_EXTERN(int) git_reference_is_tag(const git_reference
*ref
);
649 * Check if a reference is a note
651 * @param ref A git reference
653 * @return 1 when the reference lives in the refs/notes
654 * namespace; 0 otherwise.
656 GIT_EXTERN(int) git_reference_is_note(const git_reference
*ref
);
659 * Normalization options for reference lookup
663 * No particular normalization.
665 GIT_REFERENCE_FORMAT_NORMAL
= 0u,
668 * Control whether one-level refnames are accepted
669 * (i.e., refnames that do not contain multiple /-separated
670 * components). Those are expected to be written only using
671 * uppercase letters and underscore (FETCH_HEAD, ...)
673 GIT_REFERENCE_FORMAT_ALLOW_ONELEVEL
= (1u << 0),
676 * Interpret the provided name as a reference pattern for a
677 * refspec (as used with remote repositories). If this option
678 * is enabled, the name is allowed to contain a single * (<star>)
679 * in place of a one full pathname component
680 * (e.g., foo/<star>/bar but not foo/bar<star>).
682 GIT_REFERENCE_FORMAT_REFSPEC_PATTERN
= (1u << 1),
685 * Interpret the name as part of a refspec in shorthand form
686 * so the `ONELEVEL` naming rules aren't enforced and 'master'
687 * becomes a valid name.
689 GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND
= (1u << 2)
690 } git_reference_format_t
;
693 * Normalize reference name and check validity.
695 * This will normalize the reference name by removing any leading slash
696 * '/' characters and collapsing runs of adjacent slashes between name
697 * components into a single slash.
699 * Once normalized, if the reference name is valid, it will be returned in
700 * the user allocated buffer.
702 * See `git_reference_symbolic_create()` for rules about valid names.
704 * @param buffer_out User allocated buffer to store normalized name
705 * @param buffer_size Size of buffer_out
706 * @param name Reference name to be checked.
707 * @param flags Flags to constrain name validation rules - see the
708 * GIT_REFERENCE_FORMAT constants above.
709 * @return 0 on success, GIT_EBUFS if buffer is too small, GIT_EINVALIDSPEC
712 GIT_EXTERN(int) git_reference_normalize_name(
719 * Recursively peel reference until object of the specified type is found.
721 * The retrieved `peeled` object is owned by the repository
722 * and should be closed with the `git_object_free` method.
724 * If you pass `GIT_OBJECT_ANY` as the target type, then the object
725 * will be peeled until a non-tag object is met.
727 * @param out Pointer to the peeled git_object
728 * @param ref The reference to be processed
729 * @param type The type of the requested object (GIT_OBJECT_COMMIT,
730 * GIT_OBJECT_TAG, GIT_OBJECT_TREE, GIT_OBJECT_BLOB or GIT_OBJECT_ANY).
731 * @return 0 on success, GIT_EAMBIGUOUS, GIT_ENOTFOUND or an error code
733 GIT_EXTERN(int) git_reference_peel(
735 const git_reference
*ref
,
739 * Ensure the reference name is well-formed.
741 * Valid reference names must follow one of two patterns:
743 * 1. Top-level names must contain only capital letters and underscores,
744 * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
745 * 2. Names prefixed with "refs/" can be almost anything. You must avoid
746 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
747 * sequences ".." and "@{" which have special meaning to revparse.
749 * @param valid output pointer to set with validity of given reference name
750 * @param refname name to be checked.
751 * @return 0 on success or an error code
753 GIT_EXTERN(int) git_reference_name_is_valid(int *valid
, const char *refname
);
756 * Get the reference's short name
758 * This will transform the reference name into a name "human-readable"
759 * version. If no shortname is appropriate, it will return the full
762 * The memory is owned by the reference and must not be freed.
764 * @param ref a reference
765 * @return the human-readable version of the name
767 GIT_EXTERN(const char *) git_reference_shorthand(const git_reference
*ref
);