summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-07-05 20:32:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-05 20:32:57 (GMT)
commit00b7cf2379901394c971db5ab59ce70e12e434b7 (patch)
tree8faa0060f04463c5ee526b5db5e0240a272bf679 /cache.h
parent8e90578ffbce029a09c2a56e95ba3009f27e4937 (diff)
parente83e71c5e15f2c6aaf9bdb8ee9593a46c3bb9a5b (diff)
downloadgit-00b7cf2379901394c971db5ab59ce70e12e434b7.zip
git-00b7cf2379901394c971db5ab59ce70e12e434b7.tar.gz
git-00b7cf2379901394c971db5ab59ce70e12e434b7.tar.bz2
Merge branch 'jt/unify-object-info'
Code clean-ups. * jt/unify-object-info: sha1_file: refactor has_sha1_file_with_flags sha1_file: do not access pack if unneeded sha1_file: teach sha1_object_info_extended more flags sha1_file: refactor read_object sha1_file: move delta base cache code up sha1_file: rename LOOKUP_REPLACE_OBJECT sha1_file: rename LOOKUP_UNKNOWN_OBJECT sha1_file: teach packed_object_info about typename
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h36
1 files changed, 16 insertions, 20 deletions
diff --git a/cache.h b/cache.h
index c12f452..71fe092 100644
--- a/cache.h
+++ b/cache.h
@@ -1160,13 +1160,12 @@ extern char *xdg_config_home(const char *filename);
*/
extern char *xdg_cache_home(const char *filename);
-/* object replacement */
-#define LOOKUP_REPLACE_OBJECT 1
-#define LOOKUP_UNKNOWN_OBJECT 2
-extern void *read_sha1_file_extended(const unsigned char *sha1, enum object_type *type, unsigned long *size, unsigned flag);
+extern void *read_sha1_file_extended(const unsigned char *sha1,
+ enum object_type *type,
+ unsigned long *size, int lookup_replace);
static inline void *read_sha1_file(const unsigned char *sha1, enum object_type *type, unsigned long *size)
{
- return read_sha1_file_extended(sha1, type, size, LOOKUP_REPLACE_OBJECT);
+ return read_sha1_file_extended(sha1, type, size, 1);
}
/*
@@ -1188,13 +1187,6 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh
return do_lookup_replace_object(sha1);
}
-static inline const unsigned char *lookup_replace_object_extended(const unsigned char *sha1, unsigned flag)
-{
- if (!(flag & LOOKUP_REPLACE_OBJECT))
- return sha1;
- return lookup_replace_object(sha1);
-}
-
/* Read and unpack a sha1 file into memory, write memory to a sha1 file */
extern int sha1_object_info(const unsigned char *, unsigned long *);
extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
@@ -1231,15 +1223,10 @@ int read_loose_object(const char *path,
void **contents);
/*
- * Return true iff we have an object named sha1, whether local or in
- * an alternate object database, and whether packed or loose. This
- * function does not respect replace references.
- *
- * If the QUICK flag is set, do not re-check the pack directory
- * when we cannot find the object (this means we may give a false
- * negative answer if another process is simultaneously repacking).
+ * Convenience for sha1_object_info_extended() with a NULL struct
+ * object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass
+ * nonzero flags to also set other flags.
*/
-#define HAS_SHA1_QUICK 0x1
extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);
static inline int has_sha1_file(const unsigned char *sha1)
{
@@ -1806,6 +1793,7 @@ struct object_info {
off_t *disk_sizep;
unsigned char *delta_base_sha1;
struct strbuf *typename;
+ void **contentp;
/* Response */
enum {
@@ -1837,6 +1825,14 @@ struct object_info {
*/
#define OBJECT_INFO_INIT {NULL}
+/* Invoke lookup_replace_object() on the given hash */
+#define OBJECT_INFO_LOOKUP_REPLACE 1
+/* Allow reading from a loose object file of unknown/bogus type */
+#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
+/* Do not check cached storage */
+#define OBJECT_INFO_SKIP_CACHED 4
+/* Do not retry packed storage after checking packed and loose storage */
+#define OBJECT_INFO_QUICK 8
extern int sha1_object_info_extended(const unsigned char *, struct object_info *, unsigned flags);
extern int packed_object_info(struct packed_git *pack, off_t offset, struct object_info *);