/** * ggit_ref_set_target: * @ref: a #GgitRef. * @oid: a #GgitOId. * @log_message: The one line long message to be appended to the reflog. * @error: a #GError for error reporting, or %NULL. * * Create a new reference with the same name as the given reference but a * different OID target. The reference must be a direct reference, otherwise * this will fail. * * The new reference will be written to disk, overwriting the given reference. * * Returns: (transfer full): the newly created #GgitRef. */ GgitRef * ggit_ref_set_target (GgitRef *ref, GgitOId *oid, const gchar *log_message, GError **error) { git_reference *out; gint ret; g_return_val_if_fail (ref != NULL, NULL); g_return_val_if_fail (oid != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); ret = git_reference_set_target (&out, _ggit_native_get (ref), _ggit_oid_get_oid (oid), log_message); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } return _ggit_ref_wrap (out, FALSE); }
/** * ggit_remote_update_tips: * @remote: a #GgitRemote. * @callbacks: a #GgitRemoteCallbacks. * @update_fetch_head: whether to write to FETCH_HEAD. %TRUE to behave like git. * @tags_type: what the behaviour for downloading tags is for this fetch. This is * ignored for push. This must be the same value passed to * ggit_remote_download(). * @message: (allow-none): reflog_message The message to insert into the reflogs. If * %NULL and fetching, the default is "fetch <name>", * where <name> is the name of the remote (or its url, * for in-memory remotes). This parameter is ignored when pushing. * @error: a #GError for error reporting, or %NULL. * * Update tips to the new state. * * Returns: %TRUE if successful, %FALSE otherwise. */ gboolean ggit_remote_update_tips (GgitRemote *remote, GgitRemoteCallbacks *callbacks, gboolean update_fetch_head, GgitRemoteDownloadTagsType tags_type, const gchar *message, GError **error) { gint ret; g_return_val_if_fail (GGIT_IS_REMOTE (remote), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); ret = git_remote_update_tips (_ggit_native_get (remote), _ggit_remote_callbacks_get_native (callbacks), update_fetch_head, (git_remote_autotag_option_t)tags_type, message); if (ret != GIT_OK) { _ggit_error_set (error, ret); return FALSE; } return TRUE; }
/** * ggit_remote_upload: * @remote: a #GgitRemote. * @specs: (array zero-terminated=1) (allow-none): the ref specs. * @push_options: a #GgitPushOptions * @error: a #GError for error reporting, or %NULL. * * Create a packfile and send it to the server * * Returns: %TRUE if successful, %FALSE otherwise. */ gboolean ggit_remote_upload (GgitRemote *remote, const gchar * const *specs, GgitPushOptions *push_options, GError **error) { gint ret; git_strarray gspecs; g_return_val_if_fail (GGIT_IS_REMOTE (remote), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); ggit_utils_get_git_strarray_from_str_array (specs, &gspecs); ret = git_remote_upload (_ggit_native_get (remote), &gspecs, _ggit_push_options_get_push_options (push_options)); if (ret != GIT_OK) { _ggit_error_set (error, ret); return FALSE; } return TRUE; }
/** * ggit_remote_connect: * @remote: a #GgitRemote. * @direction: whether you want to receive or send data. * @callbacks: the callbacks to use for this connection. * @proxy_options: (allow-none): the proxy options. * @custom_headers: (allow-none): extra HTTP headers to use in this connection. * @error: a #GError for error reporting, or %NULL. * * Opens a connection to a remote. * The transport is selected based on the URL. The direction argument * is due to a limitation of the git protocol (over TCP or SSH) which * starts up a specific binary which can only do the one or the other. */ void ggit_remote_connect (GgitRemote *remote, GgitDirection direction, GgitRemoteCallbacks *callbacks, GgitProxyOptions *proxy_options, const gchar * const *custom_headers, GError **error) { gint ret; git_strarray headers; g_return_if_fail (GGIT_IS_REMOTE (remote)); g_return_if_fail (error == NULL || *error == NULL); ggit_utils_get_git_strarray_from_str_array (custom_headers, &headers); ret = git_remote_connect (_ggit_native_get (remote), (git_direction)direction, _ggit_remote_callbacks_get_native (callbacks), proxy_options != NULL ? _ggit_proxy_options_get_proxy_options (proxy_options) : NULL, &headers); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_patch_to_stream: * @patch: a #GgitPatch. * @stream: a #GOutputStream. * @error: a #GError for error reporting, or %NULL. * * Write the contents of a patch to the provided stream. * * Returns: %TRUE if the patch was written successfully, %FALSE otherwise. * **/ gboolean ggit_patch_to_stream (GgitPatch *patch, GOutputStream *stream, GError **error) { PatchToStream info; gint ret; g_return_val_if_fail (patch != NULL, FALSE); g_return_val_if_fail (G_IS_OUTPUT_STREAM (stream), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); info.stream = stream; info.error = error; ret = git_patch_print (patch->patch, patch_to_stream, &info); if (ret != GIT_OK) { if (error != NULL && *error == NULL) { _ggit_error_set (error, ret); } return FALSE; } return TRUE; }
/** * ggit_patch_new_from_blobs: * @old_blob: (allow-none): a #GgitBlob to diff from. * @old_as_path: (allow-none): treat @old_blob as if it had this filename, or %NULL, * @new_blob: (allow-none): a #GgitBlob to diff to. * @new_as_path: (allow-none): treat @new_blob as if it had this filename, or %NULL, * @diff_options: (allow-none): a #GgitDiffOptions, or %NULL. * @error: a #GError for error reporting, or %NULL. * * Directly generate a patch from the difference between two blobs. * * This is just like ggit_diff_blobs() except it generates a patch object * for the difference instead of directly making callbacks. You can use the * standard ggit_patch accessor functions to read the patch data, and * you must call ggit_patch_unref on the patch when done. */ GgitPatch * ggit_patch_new_from_blobs (GgitBlob *old_blob, const gchar *old_as_path, GgitBlob *new_blob, const gchar *new_as_path, GgitDiffOptions *diff_options, GError **error) { gint ret; const git_diff_options *gdiff_options; git_patch *patch; g_return_val_if_fail (error == NULL || *error == NULL, NULL); gdiff_options = _ggit_diff_options_get_diff_options (diff_options); ret = git_patch_from_blobs (&patch, old_blob ? _ggit_native_get (old_blob) : NULL, old_as_path, new_blob ? _ggit_native_get (new_blob) : NULL, new_as_path, (git_diff_options *) gdiff_options); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } return _ggit_patch_wrap (patch); }
/** * ggit_ref_rename: * @ref: a #GgitRef. * @new_name: the new name. * @force: %TRUE to force the renaming. * @log_message: The one line long message to be appended to the reflog. * @error: a #GError for error reporting, or %NULL. * * Rename an existing reference. * * This method works for both direct and symbolic references. * * The new name will be checked for validity. * See `ggit_ref_create_symbolic()` for rules about valid names. * * If not error, @ref will be deleted from disk and a * new #GgitRef will be returned. * * The reference will be immediately renamed in-memory and on disk. * * If the `force` flag is not enabled, and there's already * a reference with the given name, the renaming will fail. * * IMPORTANT: * The user needs to write a proper reflog entry if the * reflog is enabled for the repository. We only rename * the reflog if it exists. * * Returns: (transfer full): a newly created #GgitRef. */ GgitRef * ggit_ref_rename (GgitRef *ref, const gchar *new_name, gboolean force, const gchar *log_message, GError **error) { git_reference *out; gint ret; g_return_val_if_fail (ref != NULL, NULL); g_return_val_if_fail (new_name != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); force = (force != FALSE); ret = git_reference_rename (&out, _ggit_native_get (ref), new_name, force, log_message); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } return _ggit_ref_wrap (out, FALSE); }
/** * ggit_branch_get_upstream: * @branch: a #GgitBranch. * @error: a #GError for error reporting, or %NULL. * * Gets the reference supporting the remote tracking branch, * given a local branch reference. * * Returns: (transfer full) (allow-none): the reference supporting the remote tracking branch. */ GgitRef * ggit_branch_get_upstream (GgitBranch *branch, GError **error) { gint ret; git_reference *upstream; const gchar *name; GgitRef *ref; g_return_val_if_fail (GGIT_IS_BRANCH (branch), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); ret = git_branch_upstream (&upstream, _ggit_native_get (branch)); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } name = git_reference_name (_ggit_native_get (upstream)); if (g_str_has_prefix (name, "refs/heads/")) { ref = GGIT_REF (_ggit_branch_wrap (upstream)); } else { ref = _ggit_ref_wrap (upstream); } return ref; }
/** * ggit_reflog_append: * @reflog: a #GgitReflog. * @oid: a #GgitOId. * @committer: a #GgitSignature. * @message: the message. * @error: a #GError for error reporting, or %NULL. * * Creates a reflog entry. * * Returns: %TRUE if the reflog was successfully created, or %FALSE if error is set. */ gboolean ggit_reflog_append (GgitReflog *reflog, GgitOId *oid, GgitSignature *committer, const gchar *message, GError **error) { gint ret; g_return_val_if_fail (reflog != NULL, FALSE); g_return_val_if_fail (oid != NULL, FALSE); g_return_val_if_fail (GGIT_IS_SIGNATURE (committer), FALSE); g_return_val_if_fail (message != NULL && *message != '\0', FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); ret = git_reflog_append (reflog->reflog, _ggit_oid_get_oid (oid), _ggit_native_get (committer), message); if (ret != GIT_OK) { _ggit_error_set (error, ret); return FALSE; } return TRUE; }
/** * ggit_config_set_string: * @config: a #GgitConfig. * @name: the name of the configuration value. * @value: the new value. * @error: a #GError for error reporting, or %NULL. * * Set a new string value of a configuration. * * Returns: %TRUE if the value was successfully set, %FALSE otherwise. * **/ gboolean ggit_config_set_string (GgitConfig *config, const gchar *name, const gchar *value, GError **error) { gint ret; g_return_val_if_fail (GGIT_IS_CONFIG (config), FALSE); g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); if (value == NULL) { ret = git_config_delete_entry (_ggit_native_get (config), name); } else { ret = git_config_set_string (_ggit_native_get (config), name, value); } if (ret != GIT_OK) { _ggit_error_set (error, ret); return FALSE; } return TRUE; }
/** * ggit_config_add_file: * @config: a #GgitConfig. * @file: a #GFile. * @level: a #GgitConfigLevel. * @force: if a config file already exists for the given priority level, replace it. * @error: a #GError for error reporting, or %NULL. * * Add an on-disk config file instance to an existing config * * The on-disk file pointed at by @file will be opened and * parsed; it's expected to be a native Git config file following * the default Git config syntax (see man git-config). * * Further queries on this config object will access each * of the config file instances in order (instances with * a higher priority level will be accessed first). */ void ggit_config_add_file (GgitConfig *config, GFile *file, GgitConfigLevel level, gboolean force, GError **error) { gint ret; gchar *path; g_return_if_fail (GGIT_IS_CONFIG (config)); g_return_if_fail (G_IS_FILE (file)); g_return_if_fail (error == NULL || *error == NULL); path = g_file_get_path (file); ret = git_config_add_file_ondisk (_ggit_native_get (config), path, (git_config_level_t)level, force); g_free (path); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_ref_get_log: * @ref: a #GgitRef. * @error: a #GError for error reporting, or %NULL. * * Gets the #GgitReflog for @ref. The reflog will be created if it doesn't exist * yet. * * Returns: (transfer full): the reflog. */ GgitReflog * ggit_ref_get_log (GgitRef *ref, GError **error) { git_reflog *reflog; git_reference *nref; gint ret; g_return_val_if_fail (GGIT_IS_REF (ref), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); nref = _ggit_native_get (ref); ret = git_reflog_read (&reflog, git_reference_owner (nref), git_reference_name (nref)); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } return _ggit_reflog_wrap (ref, reflog); }
/** * ggit_config_new_from_file: * @file: the file to load. * @error: a #GError for error reporting, or %NULL. * * Create a new config from a single on disk file. This is a convenience * API and is exactly the same as creating an empty #GgitConfig using * #ggit_config_new and adding the file with #ggit_config_add_file. The * level will be set to #GGIT_CONFIG_LEVEL_LOCAL. If the config could not be * loaded this function returns %NULL and @error will be set accordingly. * * Returns: (transfer full): a #GgitConfig. * **/ GgitConfig * ggit_config_new_from_file (GFile *file, GError **error) { git_config *config; gchar *path; gint ret; g_return_val_if_fail (G_IS_FILE (file), NULL); path = g_file_get_path (file); g_return_val_if_fail (path != NULL, NULL); ret = git_config_open_ondisk (&config, path); g_free (path); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } else { return _ggit_config_wrap (config); } }
/** * ggit_config_match: * @config: a #GgitConfig. * @regex: a #GRegex. * @match_info: (out) (allow-none): a #GMatchInfo. * @error: a #GError for error reporting, or %NULL. * * Matches a configuration against a regular expression. @match_info will * contain the match information if the return value is not %NULL, otherwise * @error will be set. * * Returns: (allow-none): the value of that matched configuration * **/ const gchar * ggit_config_match (GgitConfig *config, GRegex *regex, GMatchInfo **match_info, GError **error) { MatchInfo info = {0,}; g_return_val_if_fail (GGIT_IS_CONFIG (config), FALSE); g_return_val_if_fail (regex != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); info.regex = regex; ggit_config_foreach (config, (GgitConfigCallback)match_foreach, &info, NULL); if (info.ret) { if (match_info) { *match_info = info.ret; } else { g_match_info_free (info.ret); } } if (!info.value) { _ggit_error_set (error, GGIT_ERROR_NOTFOUND); } return info.value; }
/** * ggit_branch_move: * @branch: a #GgitBranch. * @new_branch_name: target name of the branch once the move is performed; this name is validated for consistency. * @flags: a #GgitCreateFlags. * @error: a #GError for error reporting, or %NULL. * * Moves/renames an existing branch reference. * * Returns: (transfer full): the new branch. **/ GgitBranch * ggit_branch_move (GgitBranch *branch, const gchar *new_branch_name, GgitCreateFlags flags, GError **error) { git_reference *out; gboolean force; gint ret; g_return_val_if_fail (GGIT_IS_BRANCH (branch), NULL); g_return_val_if_fail (new_branch_name != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); force = flags & GGIT_CREATE_FORCE; ret = git_branch_move (&out, _ggit_native_get (branch), new_branch_name, force ? 1 : 0); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } return _ggit_branch_wrap (out); }
/** * ggit_tag_get_target: * @tag: a #GgitTag. * @error: a #GError for error reporting, or %NULL. * * Gets the target #GgitObject of @tag. * * This method performs a repository lookup for the * given object and returns it. * * Returns: (transfer full): the target #GgitObject of the tag. */ GgitObject * ggit_tag_get_target (GgitTag *tag, GError **error) { GgitObject *object = NULL; git_tag *t; git_object *obj; gint ret; g_return_val_if_fail (GGIT_IS_TAG (tag), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); t = _ggit_native_get (tag); ret = git_tag_target (&obj, t); if (ret != GIT_OK) { _ggit_error_set (error, ret); } else { object = ggit_utils_create_real_object (obj, TRUE); } return object; }
/** * ggit_tree_walk: * @tree: a #GgitTree. * @mode: the walking order. * @callback: (scope call): the callback to call for each entry. * @user_data: (closure): user data for the callback. * @error: a #GError for error reporting, or %NULL. * * Walk all the entries of a tree object recursively (resolving and walking * subtrees of the tree as needed). The @error will be set to the error returned * by @callback (if any). * **/ void ggit_tree_walk (GgitTree *tree, GgitTreeWalkMode mode, GgitTreeWalkCallback callback, gpointer user_data, GError **error) { gint ret; WalkInfo info = {0,}; g_return_if_fail (GGIT_IS_TREE (tree)); g_return_if_fail (callback != NULL); g_return_if_fail (error == NULL || *error == NULL); info.callback = callback; info.user_data = user_data; ret = git_tree_walk (_ggit_native_get (tree), (git_treewalk_mode)mode, (git_treewalk_cb)walk_callback_wrapper, &info); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_tree_get_by_path: * @tree: a #GgitTree. * @path: a path. * @error: a #GError for error reporting, or %NULL. * * Retrieves a tree entry contained in a tree or in any of its subtrees, * given its relative path. * * Returns: (transfer full): a #GgitTreeEntry. * **/ GgitTreeEntry * ggit_tree_get_by_path (GgitTree *tree, const gchar *path, GError **error) { git_tree *t; GgitTreeEntry *entry = NULL; git_tree_entry *tree_entry; gint ret; g_return_val_if_fail (GGIT_IS_TREE (tree), NULL); g_return_val_if_fail (path != NULL, NULL); t = _ggit_native_get (tree); ret = git_tree_entry_bypath (&tree_entry, t, path); if (ret == GIT_OK) { entry = _ggit_tree_entry_wrap (tree_entry, TRUE); } else { _ggit_error_set (error, ret); } return entry; }
/** * ggit_reflog_rename: * @reflog: a #GgitReflog. * @new_name: the new name of the reference. * @error: a #GError for error reporting, or %NULL. * * Renames the reflog for to @new_name, on error @error is set. */ gboolean ggit_reflog_rename (GgitReflog *reflog, const gchar *new_name, GError **error) { git_reference *nref; gint ret; g_return_val_if_fail (reflog != NULL, FALSE); g_return_val_if_fail (new_name != NULL && *new_name != '\0', FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); nref = _ggit_native_get (reflog->ref); ret = git_reflog_rename (git_reference_owner (nref), git_reference_name (nref), new_name); if (ret != GIT_OK) { _ggit_error_set (error, ret); return FALSE; } return TRUE; }
/** * ggit_config_foreach: * @config: a #GgitConfig. * @callback: (scope call): a #GgitConfigCallback. * @user_data: (allow-none): the user data for @callback. * @error: a #GError for error reporting, or %NULL. * * Call @callback for each configuration value. * * Returns: %TRUE if successfull, %FALSE otherwise * **/ gboolean ggit_config_foreach (GgitConfig *config, GgitConfigCallback callback, gpointer user_data, GError **error) { gint ret; CallbackWrapperData wrapper_data; g_return_val_if_fail (GGIT_IS_CONFIG (config), FALSE); g_return_val_if_fail (callback != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); wrapper_data.user_data = user_data; wrapper_data.callback = callback; ret = git_config_foreach (_ggit_native_get (config), callback_wrapper, &wrapper_data); if (ret != GIT_OK) { _ggit_error_set (error, ret); return FALSE; } return TRUE; }
/** * ggit_tag_get_target: * @tag: a #GgitTag. * @error: a #GError for error reporting, or %NULL. * * Gets the target #GgitObject of @tag. * * This method performs a repository lookup for the * given object and returns it. * * Returns: (transfer full): the target #GgitObject of the tag. */ GgitObject * ggit_tag_get_target (GgitTag *tag, GError **error) { GgitObject *object = NULL; git_tag *t; git_object *obj; gint ret; g_return_val_if_fail (GGIT_IS_TAG (tag), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); t = (git_tag *)GGIT_OBJECT (tag)->priv->obj; ret = git_tag_target (&obj, t); if (ret != GIT_SUCCESS) { _ggit_error_set (error, ret); } else { object = ggit_utils_create_real_object (obj); } return object; }
/** * ggit_config_refresh: * @config: a #GgitConfig. * @error: a #GError for error reporting, or %NULL. * * Reloads changed config files. * * A config file may be changed on disk out from under the in-memory * config object. This function causes us to look for files that have * been modified since we last loaded them and refresh the config with * the latest information. */ void ggit_config_refresh (GgitConfig *config, GError **error) { gint ret; g_return_if_fail (GGIT_IS_CONFIG (config)); g_return_if_fail (error == NULL || *error == NULL); ret = git_config_refresh (_ggit_native_get (config)); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_ref_delete: * @ref: a #GgitRef. * @error: a #GError for error reporting, or %NULL. * * Deletes @ref. * * This method works for both direct and symbolic references. * * The reference will be immediately removed on disk and from * memory. The given reference pointer will no longer be valid. */ void ggit_ref_delete (GgitRef *ref, GError **error) { gint ret; g_return_if_fail (ref != NULL); g_return_if_fail (error == NULL || *error == NULL); ret = git_reference_delete (_ggit_native_get (ref)); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_branch_delete: * @branch: a #GgitBranch. * @error: a #GError for error reporting, or %NULL. * * Deletes an existing branch reference. * * If the branch is successfully deleted, this object is * not useful anymore and if should be freed with g_object_unref(). */ void ggit_branch_delete (GgitBranch *branch, GError **error) { gint ret; g_return_if_fail (GGIT_IS_BRANCH (branch)); g_return_if_fail (error == NULL || *error == NULL); ret = git_branch_delete (_ggit_native_get (branch)); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_branch_set_upstream: * @branch: a #GgitBranch. * @upstream_branch_name: name of the upstream branch; if %NULL unsets it. * @error: a #GError for error reporting, or %NULL. * * Sets the upstream branch, for a given local branch reference */ void ggit_branch_set_upstream (GgitBranch *branch, const gchar *upstream_branch_name, GError **error) { gint ret; g_return_if_fail (GGIT_IS_BRANCH (branch)); g_return_if_fail (error == NULL || *error == NULL); ret = git_branch_set_upstream (_ggit_native_get (branch), upstream_branch_name); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_branch_is_head: * @branch: a #GgitBranch. * @error: a #GError for error reporting, or %NULL. * * Determines if the current local branch is pointed at by HEAD. * * Returns: %TRUE if the current local branch is pointed at by HEAD. */ gboolean ggit_branch_is_head (GgitBranch *branch, GError **error) { gint ret; g_return_val_if_fail (GGIT_IS_BRANCH (branch), FALSE); ret = git_branch_is_head (_ggit_native_get (branch)); if (ret < 0) { _ggit_error_set (error, ret); } return (ret == 1); }
/** * ggit_config_new_default: * @error: a #GError for error reporting, or %NULL. * * Get the global, XDG and system configuration files merged into one * #GgitConfig with their appropriate priority levels. If an error occured * trying to load the various configuration files, this function will return * %NULL and @error will be set accordingly. * * Returns: (transfer none): A #GgitConfig * **/ GgitConfig * ggit_config_new_default (GError **error) { git_config *config; gint ret; ret = git_config_open_default (&config); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } else { return _ggit_config_wrap (config); } }
/** * ggit_reflog_write: * @reflog: a #GgitReflog. * @error: a #GError. * * Write the reflog to disk. * * Returns: %TRUE if the reflog was successfully written, or %FALSE on error. * **/ gboolean ggit_reflog_write (GgitReflog *reflog, GError **error) { gint ret; g_return_val_if_fail (reflog != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); ret = git_reflog_write (reflog->reflog); if (ret != GIT_OK) { _ggit_error_set (error, ret); return FALSE; } return TRUE; }
/** * ggit_ref_delete_log: * @ref: a #GgitRef. * @error: a #GError for error reporting, or %NULL. * * Deletes the log for @ref, on error @error is set. */ void ggit_ref_delete_log (GgitRef *ref, GError **error) { git_reference *nref; gint ret; g_return_if_fail (GGIT_IS_REF (ref)); g_return_if_fail (error == NULL || *error == NULL); nref = _ggit_native_get (ref); ret = git_reflog_delete (git_reference_owner (nref), git_reference_name (nref)); if (ret != GIT_OK) { _ggit_error_set (error, ret); } }
/** * ggit_branch_get_upstream: * @branch: a #GgitBranch. * @error: a #GError for error reporting, or %NULL. * * Gets the reference supporting the remote tracking branch, * given a local branch reference. * * Returns: (transfer full) (allow-none): the reference supporting the remote tracking branch. */ GgitRef * ggit_branch_get_upstream (GgitBranch *branch, GError **error) { gint ret; git_reference *upstream; g_return_val_if_fail (GGIT_IS_BRANCH (branch), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); ret = git_branch_upstream (&upstream, _ggit_native_get (branch)); if (ret != GIT_OK) { _ggit_error_set (error, ret); return NULL; } return _ggit_ref_wrap (upstream, FALSE); }