commit - 2a104ff6e79d3ac7369f542553c609d2b15f1a55
commit + 48cae60d0ae734495d85aa8a8d9409e71cfe7d76
blob - e8c441e13d1229c15786b463059253b440bad107
blob + 2abb63153d40d88e1af8f211eb545027c1061b0a
--- got/got.c
+++ got/got.c
char *s;
const char *name;
struct got_tag_object *tag = NULL;
+ struct got_object_id *ref_id;
int cmp;
name = got_ref_get_name(re->ref);
if (s != NULL && s[strlen(s)] == '\0')
continue;
}
+ err = got_ref_resolve(&ref_id, repo, re->ref);
+ if (err)
+ return err;
if (strncmp(name, "tags/", 5) == 0) {
- err = got_object_open_as_tag(&tag, repo, re->id);
+ err = got_object_open_as_tag(&tag, repo, ref_id);
if (err) {
- if (err->code != GOT_ERR_OBJ_TYPE)
+ if (err->code != GOT_ERR_OBJ_TYPE) {
+ free(ref_id);
return err;
+ }
/* Ref points at something other than a tag. */
err = NULL;
tag = NULL;
}
}
cmp = got_object_id_cmp(tag ?
- got_object_tag_get_object_id(tag) : re->id, id);
+ got_object_tag_get_object_id(tag) : ref_id, id);
+ free(ref_id);
if (tag)
got_object_tag_close(tag);
if (cmp != 0)
blob - 5286f89210b64f38fc36e7dde5d75328f4e4834f
blob + 5f2594f5af806ea9b99c358f35fa4e7ce16f7efb
--- include/got_reference.h
+++ include/got_reference.h
*/
char *got_ref_to_str(struct got_reference *);
-/* A list of references and the object ID which they resolve to. */
+/* List of references. */
struct got_reflist_entry {
SIMPLEQ_ENTRY(got_reflist_entry) entry;
struct got_reference *ref;
- struct got_object_id *id;
};
SIMPLEQ_HEAD(got_reflist_head, got_reflist_entry);
blob - 1e9c2329c7868b58ee5e319672ef807b8c84c77e
blob + 0106f4d117b8902efa3b6b09159dc97bf18a70d6
--- lib/reference.c
+++ lib/reference.c
new->ref = got_ref_dup(re->ref);
if (new->ref == NULL) {
- err = got_error_from_errno("got_ref_dup");
- free(new);
- return err;
- }
-
- new->id = got_object_id_dup(re->id);
- if (new->id == NULL) {
err = got_error_from_errno("got_ref_dup");
- free(new->id);
free(new);
return err;
}
got_ref_cmp_cb cmp_cb, void *cmp_arg)
{
const struct got_error *err;
- struct got_object_id *id;
struct got_reflist_entry *new, *re, *prev = NULL;
int cmp;
*newp = NULL;
-
- err = got_ref_resolve(&id, repo, ref);
- if (err)
- return err;
new = malloc(sizeof(*new));
- if (new == NULL) {
- free(id);
+ if (new == NULL)
return got_error_from_errno("malloc");
- }
new->ref = ref;
- new->id = id;
*newp = new;
/*
return err;
if (cmp == 0) {
/* duplicate */
- free(new->id);
free(new);
*newp = NULL;
return NULL;
re = SIMPLEQ_FIRST(refs);
SIMPLEQ_REMOVE_HEAD(refs, entry);
got_ref_close(re->ref);
- free(re->id);
free(re);
}
blob - 5a2b0f63e102cbd3386aaf8e158af7b55f76e5f9
blob + e3bb018f3eacad94323e5fb2868f589bcc778b52
--- regress/cmdline/ref.sh
+++ regress/cmdline/ref.sh
got ref -r $testroot/repo -d master
got ref -l -r $testroot/repo > $testroot/stdout
- echo "refs/heads/ref1: $commit_id" > $testroot/stdout.expected
+ echo "HEAD: refs/heads/master" > $testroot/stdout.expected
+ echo "refs/heads/ref1: $commit_id" >> $testroot/stdout.expected
echo "refs/heads/ref3: $commit_id" >> $testroot/stdout.expected
cmp -s $testroot/stdout $testroot/stdout.expected
ret="$?"
blob - d46c6ecd59b56ea667bc10d635dff590823e90d5
blob + c85b72cb7d79be804da3d376cc54c65fee5d8dfd
--- tog/tog.c
+++ tog/tog.c
SIMPLEQ_FOREACH(re, refs, entry) {
struct got_tag_object *tag = NULL;
+ struct got_object_id *ref_id;
int cmp;
name = got_ref_get_name(re->ref);
if (s != NULL && s[strlen(s)] == '\0')
continue;
}
+ err = got_ref_resolve(&ref_id, repo, re->ref);
+ if (err)
+ break;
if (strncmp(name, "tags/", 5) == 0) {
- err = got_object_open_as_tag(&tag, repo, re->id);
+ err = got_object_open_as_tag(&tag, repo, ref_id);
if (err) {
- if (err->code != GOT_ERR_OBJ_TYPE)
+ if (err->code != GOT_ERR_OBJ_TYPE) {
+ free(ref_id);
break;
+ }
/* Ref points at something other than a tag. */
err = NULL;
tag = NULL;
}
}
cmp = got_object_id_cmp(tag ?
- got_object_tag_get_object_id(tag) : re->id, id);
+ got_object_tag_get_object_id(tag) : ref_id, id);
+ free(ref_id);
if (tag)
got_object_tag_close(tag);
if (cmp != 0)