Commit Diff


commit - 70f9e387e340aec6607691061606f0204376e0bf
commit + 5261c201300d4cd171275c0618accb47de1a08ce
blob - abe2f70def14a1346d10f4191b8224393aa0ed42
blob + 6523bd29cb23ef003060976305bef92050abacb5
--- got/Makefile
+++ got/Makefile
@@ -2,7 +2,7 @@
 
 PROG=		got
 SRCS=		got.c delta.c diff.c diffreg.c error.c fileindex.c object.c \
-		path.c pack.c refs.c repository.c sha1.c worktree.c zbuf.c
+		path.c pack.c reference.c repository.c sha1.c worktree.c zbuf.c
 
 CPPFLAGS = -I${.CURDIR}/../include -I${.CURDIR}/../lib
 LDADD = -lutil -lz
blob - 235c72508bacc1437ea6891c01e5b4a715042102
blob + 598997cc014c7b11b38dc879cb7bf84ec7445a0f
--- got/got.c
+++ got/got.c
@@ -29,7 +29,7 @@
 
 #include "got_error.h"
 #include "got_object.h"
-#include "got_refs.h"
+#include "got_reference.h"
 #include "got_repository.h"
 #include "got_worktree.h"
 #include "got_diff.h"
blob - 9c30c84496b4423c3a5d3cb3282db636b246c4d3 (mode 644)
blob + /dev/null
--- include/got_refs.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* A reference which points to an arbitrary object. */
-struct got_reference;
-
-/* Well-known reference names. */
-#define GOT_REF_HEAD		"HEAD"
-#define GOT_REF_ORIG_HEAD	"ORIG_HEAD"
-#define GOT_REF_MERGE_HEAD	"MERGE_HEAD"
-#define GOT_REF_FETCH_HEAD	"FETCH_HEAD"
-
-struct got_repository;
-struct got_object_id;
-
-const struct got_error * got_ref_open(struct got_reference **,
-    struct got_repository *, const char *);
-void got_ref_close(struct got_reference *);
-struct got_reference *got_ref_dup(struct got_reference *);
-const struct got_error *got_ref_resolve(struct got_object_id **,
-    struct got_repository *, struct got_reference *);
-char *got_ref_to_str(struct got_reference *);
blob - /dev/null
blob + 9c30c84496b4423c3a5d3cb3282db636b246c4d3 (mode 644)
--- /dev/null
+++ include/got_reference.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* A reference which points to an arbitrary object. */
+struct got_reference;
+
+/* Well-known reference names. */
+#define GOT_REF_HEAD		"HEAD"
+#define GOT_REF_ORIG_HEAD	"ORIG_HEAD"
+#define GOT_REF_MERGE_HEAD	"MERGE_HEAD"
+#define GOT_REF_FETCH_HEAD	"FETCH_HEAD"
+
+struct got_repository;
+struct got_object_id;
+
+const struct got_error * got_ref_open(struct got_reference **,
+    struct got_repository *, const char *);
+void got_ref_close(struct got_reference *);
+struct got_reference *got_ref_dup(struct got_reference *);
+const struct got_error *got_ref_resolve(struct got_object_id **,
+    struct got_repository *, struct got_reference *);
+char *got_ref_to_str(struct got_reference *);
blob - fd179690cf9795fbf834b926133053006ed3847d (mode 644)
blob + /dev/null
--- lib/refs.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <sha1.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <util.h>
-#include <zlib.h>
-
-#include "got_error.h"
-#include "got_object.h"
-#include "got_repository.h"
-#include "got_refs.h"
-
-#include "got_lib_sha1.h"
-#include "got_lib_path.h"
-#include "got_lib_delta.h"
-#include "got_lib_zbuf.h"
-#include "got_lib_object.h"
-
-/* A symbolic reference. */
-struct got_symref {
-	char *name;
-	char *ref;
-};
-
-/* A non-symbolic reference (there is no better designation). */
-struct got_ref {
-	char *name;
-	u_int8_t sha1[SHA1_DIGEST_LENGTH];
-};
-
-/* A reference which points to an arbitrary object. */
-struct got_reference {
-	unsigned int flags;
-#define GOT_REF_IS_SYMBOLIC	0x01
-
-	union {
-		struct got_ref ref;
-		struct got_symref symref;
-	} ref;
-};
-
-static const struct got_error *
-parse_symref(struct got_reference **ref, const char *name, const char *line)
-{
-	struct got_symref *symref;
-	char *symref_name;
-	char *symref_ref;
-
-	if (line[0] == '\0')
-		return got_error(GOT_ERR_NOT_REF);
-
-	symref_name = strdup(name);
-	if (symref_name == NULL)
-		return got_error_from_errno();
-	symref_ref = strdup(line);
-	if (symref_ref == NULL) {
-		const struct got_error *err = got_error_from_errno();
-		free(symref_name);
-		return err;
-	}
-
-	*ref = calloc(1, sizeof(**ref));
-	if (*ref == NULL)
-		return got_error_from_errno();
-	(*ref)->flags |= GOT_REF_IS_SYMBOLIC;
-	symref = &((*ref)->ref.symref);
-	symref->name = symref_name;
-	symref->ref = symref_ref;
-	return NULL;
-}
-
-static const struct got_error *
-parse_ref_line(struct got_reference **ref, const char *name, const char *line)
-{
-	uint8_t digest[SHA1_DIGEST_LENGTH];
-	char *ref_name;
-
-	if (strncmp(line, "ref: ", 5) == 0) {
-		line += 5;
-		return parse_symref(ref, name, line);
-	}
-
-	ref_name = strdup(name);
-	if (ref_name == NULL)
-		return got_error_from_errno();
-
-	if (!got_parse_sha1_digest(digest, line))
-		return got_error(GOT_ERR_NOT_REF);
-
-	*ref = calloc(1, sizeof(**ref));
-	if (*ref == NULL)
-		return got_error_from_errno();
-	(*ref)->ref.ref.name = ref_name;
-	memcpy(&(*ref)->ref.ref.sha1, digest, SHA1_DIGEST_LENGTH);
-	return NULL;
-}
-
-static const struct got_error *
-parse_ref_file(struct got_reference **ref, const char *name,
-    const char *abspath)
-{
-	const struct got_error *err = NULL;
-	FILE *f = fopen(abspath, "rb");
-	char *line;
-	size_t len;
-	const char delim[3] = {'\0', '\0', '\0'};
-
-	if (f == NULL)
-		return got_error(GOT_ERR_NOT_REF);
-
-	line = fparseln(f, &len, NULL, delim, 0);
-	if (line == NULL) {
-		err = got_error(GOT_ERR_NOT_REF);
-		goto done;
-	}
-
-	err = parse_ref_line(ref, name, line);
-done:
-	free(line);
-	fclose(f);
-	return err;
-}
-
-static char *
-get_refs_dir_path(struct got_repository *repo, const char *refname)
-{
-	if (strcmp(refname, GOT_REF_HEAD) == 0 ||
-	    strcmp(refname, GOT_REF_ORIG_HEAD) == 0 ||
-	    strcmp(refname, GOT_REF_MERGE_HEAD) == 0 ||
-	    strcmp(refname, GOT_REF_FETCH_HEAD) == 0 ||
-	    strncmp(refname, "refs/", 5) == 0)
-		return got_repo_get_path_git_dir(repo);
-
-	return got_repo_get_path_refs(repo);
-}
-
-const struct got_error *
-got_ref_open(struct got_reference **ref, struct got_repository *repo,
-   const char *refname)
-{
-	const struct got_error *err = NULL;
-	char *path_ref = NULL;
-	char *normpath = NULL;
-	char *path_refs = get_refs_dir_path(repo, refname);
-
-	if (path_refs == NULL) {
-		err = got_error_from_errno();
-		goto done;
-	}
-	
-	/* XXX For now, this assumes that refs exist in the filesystem. */
-
-	if (asprintf(&path_ref, "%s/%s", path_refs, refname) == -1) {
-		err = got_error_from_errno();
-		goto done;
-	}
-
-	normpath = got_path_normalize(path_ref);
-	if (normpath == NULL) {
-		err = got_error(GOT_ERR_NOT_REF);
-		goto done;
-	}
-
-	err = parse_ref_file(ref, refname, normpath);
-done:
-	free(normpath);
-	free(path_ref);
-	free(path_refs);
-	return err;
-}
-
-void
-got_ref_close(struct got_reference *ref)
-{
-	if (ref->flags & GOT_REF_IS_SYMBOLIC)
-		free(ref->ref.symref.name);
-	else
-		free(ref->ref.ref.name);
-	free(ref);
-}
-
-struct got_reference *
-got_ref_dup(struct got_reference *ref)
-{
-	struct got_reference *ret;
-
-	ret = calloc(1, sizeof(*ret));
-	if (ret == NULL)
-		return NULL;
-
-	ret->flags = ref->flags;
-	if (ref->flags & GOT_REF_IS_SYMBOLIC) {
-		ret->ref.symref.name = strdup(ref->ref.symref.name);
-		if (ret->ref.symref.name == NULL) {
-			free(ret);
-			return NULL;
-		}
-		ret->ref.symref.ref = strdup(ref->ref.symref.ref);
-		if (ret->ref.symref.ref == NULL) {
-			free(ret->ref.symref.name);
-			free(ret);
-			return NULL;
-		}
-	} else {
-		ref->ref.ref.name = strdup(ref->ref.ref.name);
-		if (ref->ref.ref.name == NULL) {
-			free(ret);
-			return NULL;
-		}
-		memcpy(ret->ref.ref.sha1, ref->ref.ref.sha1,
-		    SHA1_DIGEST_LENGTH);
-	}
-
-	return ret;
-}
-
-static const struct got_error *
-resolve_symbolic_ref(struct got_reference **resolved,
-    struct got_repository *repo, struct got_reference *ref)
-{
-	struct got_reference *nextref;
-	const struct got_error *err;
-
-	err = got_ref_open(&nextref, repo, ref->ref.symref.ref);
-	if (err)
-		return err;
-
-	if (nextref->flags & GOT_REF_IS_SYMBOLIC)
-		err = resolve_symbolic_ref(resolved, repo, nextref);
-	else
-		*resolved = got_ref_dup(nextref);
-
-	got_ref_close(nextref);
-	return err;
-}
-
-const struct got_error *
-got_ref_resolve(struct got_object_id **id, struct got_repository *repo,
-    struct got_reference *ref)
-{
-	const struct got_error *err;
-
-	if (ref->flags & GOT_REF_IS_SYMBOLIC) {
-		struct got_reference *resolved = NULL;
-		err = resolve_symbolic_ref(&resolved, repo, ref);
-		if (err == NULL)
-			err = got_ref_resolve(id, repo, resolved);
-		free(resolved);
-		return err;
-	}
-
-	*id = calloc(1, sizeof(**id));
-	if (*id == NULL)
-		return got_error_from_errno();
-	memcpy((*id)->sha1, ref->ref.ref.sha1, SHA1_DIGEST_LENGTH);
-	return NULL;
-}
-
-char *
-got_ref_to_str(struct got_reference *ref)
-{
-	char *str;
-	if (ref->flags & GOT_REF_IS_SYMBOLIC) {
-		if (asprintf(&str, "ref: %s", ref->ref.symref.ref) == -1)
-			return NULL;
-	} else {
-		str = calloc(1, SHA1_DIGEST_STRING_LENGTH);
-		if (str == NULL)
-			return NULL;
-		str = got_sha1_digest_to_str(ref->ref.ref.sha1, str,
-		    SHA1_DIGEST_STRING_LENGTH);
-	}
-
-	return str;
-}
blob - /dev/null
blob + 90e79b5d45614cce794d98450f5555c99fb41354 (mode 644)
--- /dev/null
+++ lib/reference.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+
+#include <sha1.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <util.h>
+#include <zlib.h>
+
+#include "got_error.h"
+#include "got_object.h"
+#include "got_repository.h"
+#include "got_reference.h"
+
+#include "got_lib_sha1.h"
+#include "got_lib_path.h"
+#include "got_lib_delta.h"
+#include "got_lib_zbuf.h"
+#include "got_lib_object.h"
+
+/* A symbolic reference. */
+struct got_symref {
+	char *name;
+	char *ref;
+};
+
+/* A non-symbolic reference (there is no better designation). */
+struct got_ref {
+	char *name;
+	u_int8_t sha1[SHA1_DIGEST_LENGTH];
+};
+
+/* A reference which points to an arbitrary object. */
+struct got_reference {
+	unsigned int flags;
+#define GOT_REF_IS_SYMBOLIC	0x01
+
+	union {
+		struct got_ref ref;
+		struct got_symref symref;
+	} ref;
+};
+
+static const struct got_error *
+parse_symref(struct got_reference **ref, const char *name, const char *line)
+{
+	struct got_symref *symref;
+	char *symref_name;
+	char *symref_ref;
+
+	if (line[0] == '\0')
+		return got_error(GOT_ERR_NOT_REF);
+
+	symref_name = strdup(name);
+	if (symref_name == NULL)
+		return got_error_from_errno();
+	symref_ref = strdup(line);
+	if (symref_ref == NULL) {
+		const struct got_error *err = got_error_from_errno();
+		free(symref_name);
+		return err;
+	}
+
+	*ref = calloc(1, sizeof(**ref));
+	if (*ref == NULL)
+		return got_error_from_errno();
+	(*ref)->flags |= GOT_REF_IS_SYMBOLIC;
+	symref = &((*ref)->ref.symref);
+	symref->name = symref_name;
+	symref->ref = symref_ref;
+	return NULL;
+}
+
+static const struct got_error *
+parse_ref_line(struct got_reference **ref, const char *name, const char *line)
+{
+	uint8_t digest[SHA1_DIGEST_LENGTH];
+	char *ref_name;
+
+	if (strncmp(line, "ref: ", 5) == 0) {
+		line += 5;
+		return parse_symref(ref, name, line);
+	}
+
+	ref_name = strdup(name);
+	if (ref_name == NULL)
+		return got_error_from_errno();
+
+	if (!got_parse_sha1_digest(digest, line))
+		return got_error(GOT_ERR_NOT_REF);
+
+	*ref = calloc(1, sizeof(**ref));
+	if (*ref == NULL)
+		return got_error_from_errno();
+	(*ref)->ref.ref.name = ref_name;
+	memcpy(&(*ref)->ref.ref.sha1, digest, SHA1_DIGEST_LENGTH);
+	return NULL;
+}
+
+static const struct got_error *
+parse_ref_file(struct got_reference **ref, const char *name,
+    const char *abspath)
+{
+	const struct got_error *err = NULL;
+	FILE *f = fopen(abspath, "rb");
+	char *line;
+	size_t len;
+	const char delim[3] = {'\0', '\0', '\0'};
+
+	if (f == NULL)
+		return got_error(GOT_ERR_NOT_REF);
+
+	line = fparseln(f, &len, NULL, delim, 0);
+	if (line == NULL) {
+		err = got_error(GOT_ERR_NOT_REF);
+		goto done;
+	}
+
+	err = parse_ref_line(ref, name, line);
+done:
+	free(line);
+	fclose(f);
+	return err;
+}
+
+static char *
+get_refs_dir_path(struct got_repository *repo, const char *refname)
+{
+	if (strcmp(refname, GOT_REF_HEAD) == 0 ||
+	    strcmp(refname, GOT_REF_ORIG_HEAD) == 0 ||
+	    strcmp(refname, GOT_REF_MERGE_HEAD) == 0 ||
+	    strcmp(refname, GOT_REF_FETCH_HEAD) == 0 ||
+	    strncmp(refname, "refs/", 5) == 0)
+		return got_repo_get_path_git_dir(repo);
+
+	return got_repo_get_path_refs(repo);
+}
+
+const struct got_error *
+got_ref_open(struct got_reference **ref, struct got_repository *repo,
+   const char *refname)
+{
+	const struct got_error *err = NULL;
+	char *path_ref = NULL;
+	char *normpath = NULL;
+	char *path_refs = get_refs_dir_path(repo, refname);
+
+	if (path_refs == NULL) {
+		err = got_error_from_errno();
+		goto done;
+	}
+	
+	/* XXX For now, this assumes that refs exist in the filesystem. */
+
+	if (asprintf(&path_ref, "%s/%s", path_refs, refname) == -1) {
+		err = got_error_from_errno();
+		goto done;
+	}
+
+	normpath = got_path_normalize(path_ref);
+	if (normpath == NULL) {
+		err = got_error(GOT_ERR_NOT_REF);
+		goto done;
+	}
+
+	err = parse_ref_file(ref, refname, normpath);
+done:
+	free(normpath);
+	free(path_ref);
+	free(path_refs);
+	return err;
+}
+
+void
+got_ref_close(struct got_reference *ref)
+{
+	if (ref->flags & GOT_REF_IS_SYMBOLIC)
+		free(ref->ref.symref.name);
+	else
+		free(ref->ref.ref.name);
+	free(ref);
+}
+
+struct got_reference *
+got_ref_dup(struct got_reference *ref)
+{
+	struct got_reference *ret;
+
+	ret = calloc(1, sizeof(*ret));
+	if (ret == NULL)
+		return NULL;
+
+	ret->flags = ref->flags;
+	if (ref->flags & GOT_REF_IS_SYMBOLIC) {
+		ret->ref.symref.name = strdup(ref->ref.symref.name);
+		if (ret->ref.symref.name == NULL) {
+			free(ret);
+			return NULL;
+		}
+		ret->ref.symref.ref = strdup(ref->ref.symref.ref);
+		if (ret->ref.symref.ref == NULL) {
+			free(ret->ref.symref.name);
+			free(ret);
+			return NULL;
+		}
+	} else {
+		ref->ref.ref.name = strdup(ref->ref.ref.name);
+		if (ref->ref.ref.name == NULL) {
+			free(ret);
+			return NULL;
+		}
+		memcpy(ret->ref.ref.sha1, ref->ref.ref.sha1,
+		    SHA1_DIGEST_LENGTH);
+	}
+
+	return ret;
+}
+
+static const struct got_error *
+resolve_symbolic_ref(struct got_reference **resolved,
+    struct got_repository *repo, struct got_reference *ref)
+{
+	struct got_reference *nextref;
+	const struct got_error *err;
+
+	err = got_ref_open(&nextref, repo, ref->ref.symref.ref);
+	if (err)
+		return err;
+
+	if (nextref->flags & GOT_REF_IS_SYMBOLIC)
+		err = resolve_symbolic_ref(resolved, repo, nextref);
+	else
+		*resolved = got_ref_dup(nextref);
+
+	got_ref_close(nextref);
+	return err;
+}
+
+const struct got_error *
+got_ref_resolve(struct got_object_id **id, struct got_repository *repo,
+    struct got_reference *ref)
+{
+	const struct got_error *err;
+
+	if (ref->flags & GOT_REF_IS_SYMBOLIC) {
+		struct got_reference *resolved = NULL;
+		err = resolve_symbolic_ref(&resolved, repo, ref);
+		if (err == NULL)
+			err = got_ref_resolve(id, repo, resolved);
+		free(resolved);
+		return err;
+	}
+
+	*id = calloc(1, sizeof(**id));
+	if (*id == NULL)
+		return got_error_from_errno();
+	memcpy((*id)->sha1, ref->ref.ref.sha1, SHA1_DIGEST_LENGTH);
+	return NULL;
+}
+
+char *
+got_ref_to_str(struct got_reference *ref)
+{
+	char *str;
+	if (ref->flags & GOT_REF_IS_SYMBOLIC) {
+		if (asprintf(&str, "ref: %s", ref->ref.symref.ref) == -1)
+			return NULL;
+	} else {
+		str = calloc(1, SHA1_DIGEST_STRING_LENGTH);
+		if (str == NULL)
+			return NULL;
+		str = got_sha1_digest_to_str(ref->ref.ref.sha1, str,
+		    SHA1_DIGEST_STRING_LENGTH);
+	}
+
+	return str;
+}
blob - 086900f78bedad14dd2f6881c2e8949f43b8a9cc
blob + 611e9526b1ab2357953b99cd6ef6703388720a13
--- lib/repository.c
+++ lib/repository.c
@@ -25,7 +25,7 @@
 #include <zlib.h>
 
 #include "got_error.h"
-#include "got_refs.h"
+#include "got_reference.h"
 #include "got_repository.h"
 
 #include "got_lib_path.h"
blob - a7d4b7d71eb224730c97b9f7a5d4e046a56101d9
blob + 4fe01db2011a09de7575dbead225e8a5cdd61e41
--- lib/worktree.c
+++ lib/worktree.c
@@ -30,7 +30,7 @@
 
 #include "got_error.h"
 #include "got_repository.h"
-#include "got_refs.h"
+#include "got_reference.h"
 #include "got_object.h"
 #include "got_worktree.h"
 
blob - 765397c281537ffd8b4ec4031d0b6943e805cc56
blob + 452c4df4f034ed4c0e9ad4a3edf6185facac954e
--- regress/repository/Makefile
+++ regress/repository/Makefile
@@ -1,7 +1,7 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = repository_test
-SRCS = path.c repository.c error.c refs.c object.c sha1.c diff.c \
+SRCS = path.c repository.c error.c reference.c object.c sha1.c diff.c \
 	diffreg.c pack.c delta.c zbuf.c repository_test.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
blob - 85c1d231761e8669b269cdccc1fef619aeb9ce99
blob + ee04dc00dd2a769d5216f1acd5271c554871c21c
--- regress/repository/repository_test.c
+++ regress/repository/repository_test.c
@@ -28,7 +28,7 @@
 
 #include "got_error.h"
 #include "got_object.h"
-#include "got_refs.h"
+#include "got_reference.h"
 #include "got_repository.h"
 #include "got_diff.h"
 
blob - 80bbcfe5e86ffbf85c04cf490e3d168e3022e274
blob + 49d5b1d64b78f5f5f35942045f0799409ac76d7f
--- regress/worktree/Makefile
+++ regress/worktree/Makefile
@@ -1,8 +1,8 @@
 .PATH:${.CURDIR}/../../lib
 
 PROG = worktree_test
-SRCS = worktree.c repository.c object.c path.c error.c refs.c sha1.c pack.c \
-	delta.c zbuf.c fileindex.c worktree_test.c
+SRCS = worktree.c repository.c object.c path.c error.c reference.c sha1.c \
+	pack.c delta.c zbuf.c fileindex.c worktree_test.c
 
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
blob - 4fbb8881a53c1ccf94fc910bd447d44b64295018
blob + 0e19e1cd770c8f3d68e25d54e5b72912ceaaac00
--- regress/worktree/worktree_test.c
+++ regress/worktree/worktree_test.c
@@ -31,7 +31,7 @@
 
 #include "got_error.h"
 #include "got_object.h"
-#include "got_refs.h"
+#include "got_reference.h"
 #include "got_repository.h"
 #include "got_worktree.h"