mirror of
https://git.proxmox.com/git/libgit2
synced 2026-08-26 18:40:39 +00:00
Merge pull request #1956 from libgit2/cmn/fetch-default-head
Remote revamp (director's cut)
This commit is contained in:
@@ -4,21 +4,12 @@
|
||||
#include <string.h>
|
||||
#include "common.h"
|
||||
|
||||
/** Callback to show each item */
|
||||
static int show_ref__cb(git_remote_head *head, void *payload)
|
||||
{
|
||||
char oid[GIT_OID_HEXSZ + 1] = {0};
|
||||
|
||||
(void)payload;
|
||||
git_oid_fmt(oid, &head->oid);
|
||||
printf("%s\t%s\n", oid, head->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int use_remote(git_repository *repo, char *name)
|
||||
{
|
||||
git_remote *remote = NULL;
|
||||
int error;
|
||||
const git_remote_head **refs;
|
||||
size_t refs_len, i;
|
||||
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
||||
|
||||
// Find the remote by name
|
||||
@@ -40,7 +31,18 @@ static int use_remote(git_repository *repo, char *name)
|
||||
if (error < 0)
|
||||
goto cleanup;
|
||||
|
||||
error = git_remote_ls(remote, &show_ref__cb, NULL);
|
||||
/**
|
||||
* Get the list of references on the remote and print out
|
||||
* their name next to what they point to.
|
||||
*/
|
||||
if (git_remote_ls(&refs, &refs_len, remote) < 0)
|
||||
goto cleanup;
|
||||
|
||||
for (i = 0; i < refs_len; i++) {
|
||||
char oid[GIT_OID_HEXSZ + 1] = {0};
|
||||
git_oid_fmt(oid, &refs[i]->oid);
|
||||
printf("%s\t%s\n", oid, refs[i]->name);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
git_remote_free(remote);
|
||||
|
||||
Reference in New Issue
Block a user