Skip to content

Commit 44c2339

Browse files
committed
Merge branch 'mh/packed-ref-store'
The "ref-store" code reorganization continues. * mh/packed-ref-store: (32 commits) files-backend: cheapen refname_available check when locking refs packed_ref_store: handle a packed-refs file that is a symlink read_packed_refs(): die if `packed-refs` contains bogus data t3210: add some tests of bogus packed-refs file contents repack_without_refs(): don't lock or unlock the packed refs commit_packed_refs(): remove call to `packed_refs_unlock()` clear_packed_ref_cache(): don't protest if the lock is held packed_refs_unlock(), packed_refs_is_locked(): new functions packed_refs_lock(): report errors via a `struct strbuf *err` packed_refs_lock(): function renamed from lock_packed_refs() commit_packed_refs(): use a staging file separate from the lockfile commit_packed_refs(): report errors rather than dying packed_ref_store: make class into a subclass of `ref_store` packed-backend: new module for handling packed references packed_read_raw_ref(): new function, replacing `resolve_packed_ref()` packed_ref_store: support iteration packed_peel_ref(): new function, extracted from `files_peel_ref()` repack_without_refs(): take a `packed_ref_store *` parameter get_packed_ref(): take a `packed_ref_store *` parameter rollback_packed_refs(): take a `packed_ref_store *` parameter ...
2 parents a080a5c + 8ec617c commit 44c2339

File tree

8 files changed

+1098
-564
lines changed

8 files changed

+1098
-564
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ LIB_OBJS += reflog-walk.o
842842
LIB_OBJS += refs.o
843843
LIB_OBJS += refs/files-backend.o
844844
LIB_OBJS += refs/iterator.o
845+
LIB_OBJS += refs/packed-backend.o
845846
LIB_OBJS += refs/ref-cache.o
846847
LIB_OBJS += ref-filter.o
847848
LIB_OBJS += remote.o

refs.c

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

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

0 commit comments

Comments
 (0)