summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-11-02 00:05:32 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2013-11-11 15:35:51 +0100
commit359dce726d215be65aee719c7316b43e3851c031 (patch)
tree7a4a0c0af01d2d02683a3aed27eca8315f1f9ca0 /include/git2
parent266af6d81960144334c16e061f1d30f94f8a1b46 (diff)
downloadlibgit2-359dce726d215be65aee719c7316b43e3851c031.tar.gz
remote: make _ls return the list directly
The callback-based method of listing remote references dates back to the beginning of the network code's lifetime, when we didn't know any better. We need to keep the list around for update_tips() after disconnect() so let's make use of this to simply give the user a pointer to the array so they can write straightforward code instead of having to go through a callback.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/remote.h13
-rw-r--r--include/git2/transport.h12
2 files changed, 13 insertions, 12 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 1f33c92e8..9e7d218a8 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -254,15 +254,16 @@ GIT_EXTERN(int) git_remote_connect(git_remote *remote, git_direction direction);
* The remote (or more exactly its transport) must be connected. The
* memory belongs to the remote.
*
- * If you a return a non-zero value from the callback, this will stop
- * looping over the refs.
+ * The array will stay valid as long as the remote object exists and
+ * its transport isn't changed, but a copy is recommended for usage of
+ * the data.
*
+ * @param out pointer to the array
+ * @param size the number of remote heads
* @param remote the remote
- * @param list_cb function to call with each ref discovered at the remote
- * @param payload additional data to pass to the callback
- * @return 0 on success, GIT_EUSER on non-zero callback, or error code
+ * @return 0 on success, or an error code
*/
-GIT_EXTERN(int) git_remote_ls(git_remote *remote, git_headlist_cb list_cb, void *payload);
+GIT_EXTERN(int) git_remote_ls(const git_remote_head ***out, size_t *size, git_remote *remote);
/**
* Download and index the packfile
diff --git a/include/git2/transport.h b/include/git2/transport.h
index 147b3fdcb..81ebf4dc9 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -203,13 +203,13 @@ struct git_transport {
int direction,
int flags);
- /* This function may be called after a successful call to connect(). The
- * provided callback is invoked for each ref discovered on the remote
- * end. */
+ /* This function may be called after a successful call to
+ * connect(). The array returned is owned by the transport and
+ * is guranteed until the next call of a transport function. */
int (*ls)(
- git_transport *transport,
- git_headlist_cb list_cb,
- void *payload);
+ const git_remote_head ***out,
+ size_t *size,
+ git_transport *transport);
/* Executes the push whose context is in the git_push object. */
int (*push)(git_transport *transport, git_push *push);