Skip to content

Commit 67be7c5

Browse files
mhaggergitster
authored andcommitted
packed-backend: new module for handling packed references
Now that the interface between `files_ref_store` and `packed_ref_store` is relatively narrow, move the latter into a new module, "refs/packed-backend.h" and "refs/packed-backend.c". It still doesn't quite implement the `ref_store` interface, but it will soon. This commit moves code around and adjusts its visibility, but doesn't change anything. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d13fa1a commit 67be7c5

File tree

6 files changed

+685
-639
lines changed

6 files changed

+685
-639
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ LIB_OBJS += reflog-walk.o
817817
LIB_OBJS += refs.o
818818
LIB_OBJS += refs/files-backend.o
819819
LIB_OBJS += refs/iterator.o
820+
LIB_OBJS += refs/packed-backend.o
820821
LIB_OBJS += refs/ref-cache.o
821822
LIB_OBJS += ref-filter.o
822823
LIB_OBJS += remote.o

refs.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,24 @@ int refname_is_safe(const char *refname)
173173
return 1;
174174
}
175175

176+
/*
177+
* Return true if refname, which has the specified oid and flags, can
178+
* be resolved to an object in the database. If the referred-to object
179+
* does not exist, emit a warning and return false.
180+
*/
181+
int ref_resolves_to_object(const char *refname,
182+
const struct object_id *oid,
183+
unsigned int flags)
184+
{
185+
if (flags & REF_ISBROKEN)
186+
return 0;
187+
if (!has_sha1_file(oid->hash)) {
188+
error("%s does not point to a valid object!", refname);
189+
return 0;
190+
}
191+
return 1;
192+
}
193+
176194
char *refs_resolve_refdup(struct ref_store *refs,
177195
const char *refname, int resolve_flags,
178196
unsigned char *sha1, int *flags)

0 commit comments

Comments
 (0)