]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object-file.h: move declarations for object-file.c functions from cache.h
authorElijah Newren <newren@gmail.com>
Tue, 11 Apr 2023 07:41:53 +0000 (00:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Apr 2023 15:52:10 +0000 (08:52 -0700)
Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
57 files changed:
apply.c
builtin/bugreport.c
builtin/cat-file.c
builtin/clone.c
builtin/credential-cache--daemon.c
builtin/diagnose.c
builtin/difftool.c
builtin/fast-export.c
builtin/fast-import.c
builtin/fetch-pack.c
builtin/fsck.c
builtin/gc.c
builtin/grep.c
builtin/hash-object.c
builtin/index-pack.c
builtin/init-db.c
builtin/log.c
builtin/mktag.c
builtin/mv.c
builtin/pack-objects.c
builtin/prune.c
builtin/rebase.c
builtin/replace.c
builtin/rev-list.c
builtin/sparse-checkout.c
builtin/submodule--helper.c
builtin/update-index.c
builtin/worktree.c
bulk-checkin.c
cache-tree.c
cache.h
commit-graph.c
diff.c
dir.c
environment.c
http.c
merge-recursive.c
midx.c
notes-merge.c
object-file.c
object-file.h [new file with mode: 0644]
object.c
pack-bitmap.c
pack-check.c
pack-mtimes.c
pack-revindex.c
packfile.c
read-cache.c
refs/files-backend.c
rerere.c
revision.c
sequencer.c
server-info.c
streaming.c
submodule.c
tmp-objdir.c
tree-walk.c

diff --git a/apply.c b/apply.c
index 7e40f53ec4c2b568df44ba87b584ccaed99e9b15..2868cef5ddd91efb65817b0a1604fb6ba4c7bc50 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -23,6 +23,7 @@
 #include "ll-merge.h"
 #include "lockfile.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
index 52955e1d389bbd92628a0329a17998a0b8513cfd..03fb0536911650c4b719cffb900e27ba46939256 100644 (file)
@@ -8,6 +8,7 @@
 #include "hook.h"
 #include "hook-list.h"
 #include "diagnose.h"
+#include "object-file.h"
 #include "setup.h"
 #include "wrapper.h"
 
index 60b7a55dfc190868b3e9e1a06458c3db92208fe2..0bafc14e6c03ac1c034e64878b884ebcb15128af 100644 (file)
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
index f1e8aa3f27ed3d80680ece0ab67c2ec8cd24be1b..c7fdffb484c8972545147efb4c0441a0987d6b2c 100644 (file)
@@ -21,6 +21,7 @@
 #include "fetch-pack.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tree.h"
 #include "tree-walk.h"
index 62c09a271d6eb4578ef0360910575c5611f61ffd..4e571d9951b540637526fb9a2eaea4226c6e16fa 100644 (file)
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 
 #ifndef NO_UNIX_SOCKETS
index 0f8b64994c427a241e3d66726775d86a37c51f10..4f22eb2b55d06968896d12ae9257d470d5d3a8fb 100644 (file)
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "diagnose.h"
 
index e010a21bfbc1c4dacc70c9e1866ad4f109af737b..3ffb0524be76bb9bd258f9eeef12280fcbfed266 100644 (file)
@@ -25,6 +25,7 @@
 #include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "dir.h"
 #include "entry.h"
index 0bb779deb698ce4bcfda9d58455db16d14346e60..c7835ea07917c86fb18aea1ef3ceab63bc65613e 100644 (file)
@@ -10,6 +10,7 @@
 #include "hex.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "commit.h"
 #include "object.h"
index 31b8732128d0afcb193518732952e049922ca8ae..9f90f5b9e41a114b8c247220e4ff52534a182cb0 100644 (file)
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
index 60e5a10ffc5a45e4aec12fe827c2edcfd8f3c48f..664ac1ec0e873ee2ea7714ac835eca9badf3e2e5 100644 (file)
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "pkt-line.h"
 #include "fetch-pack.h"
 #include "remote.h"
index 04bc71d148c24b8be488e5c3b49cbdbe22326c2d..35a6de3cdb56e2444d50e73c4a8dbe917a8e68fb 100644 (file)
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
index 000a2ef5e11f9c420dee2ed8e365937227bf0809..b95154fba161705fde14a5b183538343536cdd74 100644 (file)
@@ -25,6 +25,7 @@
 #include "commit.h"
 #include "commit-graph.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-objects.h"
index f66e14389e145eb0b292d5a7ab45bf8137e8eb1a..fb11be6075ab85ab5348a49b106be3dbfab8f2b2 100644 (file)
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
index a15fe4fd3f4f96b9f82535c224956eb957e93b49..a3801211666410eb703fa11bd24a4ba03ff3e6ea 100644 (file)
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "quote.h"
index 5adfb2521cda9ad4b351aa7e98e897cd684ab7bf..0f59cf8aa082e341bbb5606f58d8237944c0c49f 100644 (file)
@@ -18,6 +18,7 @@
 #include "thread-utils.h"
 #include "packfile.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "replace-object.h"
index ba6e0b20fa524e2f4fdb5d43dd977ed2046a36f1..6183f3fb3ffabba2485374da44ca4d5a1e732f13 100644 (file)
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "setup.h"
 #include "worktree.h"
index 5cdc2276cc4dcde807c1b3ebfb2502d015ba9796..b6246c7042c09f01018e64753cd8150a7ce8c325 100644 (file)
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "color.h"
index f9d9a38452bee0f7f6c3fa15c3b4b2d74870c1d1..f33d267fcb634d0e8e71582fc6d523ae6c3a5ec3 100644 (file)
@@ -4,6 +4,7 @@
 #include "parse-options.h"
 #include "tag.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "fsck.h"
 #include "config.h"
index 8f7770aa32bf5e3ef5352c4806166d5c0a282238..32935af48e66bddf032a8e47e0bceb5aa1f706d3 100644 (file)
@@ -11,6 +11,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "pathspec.h"
 #include "lockfile.h"
 #include "dir.h"
index 69c654286149cf1f6635a88cfcac1c22affa2c8a..68c914a8e1aa3bd5c76e65c10ef62812ed31170d 100644 (file)
@@ -33,6 +33,7 @@
 #include "strvec.h"
 #include "list.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "dir.h"
index 09891832fb3f7a8a43016e0837053c7c2ef72f37..5dc9b20720006700584069a3b6aa1211088ff5d7 100644 (file)
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
index ff5dd77608d03f2840022049fdcaa3c7d5efd203..34fea4d8220e787d7f9882252a0beb69848dd38e 100644 (file)
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
index 134f738a4503e96fb8b0f35e65500a4ce90e93c9..f4b3a8efb2348c5e4d10462fff0290087492e601 100644 (file)
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
index c17f0282ae86e0d602ad0cf3607f15eacdfd5c68..6dc8be492a2c424623de0dddc0006a1b0a242f7e 100644 (file)
@@ -11,6 +11,7 @@
 #include "list-objects-filter-options.h"
 #include "object.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
index 34b9d92fb131eefe4295ac0aa79ae2883c3af036..4de37d07fd95ecdd85147f69c7b05ae6cf6ce3ec 100644 (file)
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
index 1f087d7bed2dfb9a82d80774337cd977a9af0e1f..5d999f814e027b9872a6870716b7c1657d8f493e 100644 (file)
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
index 03cda5e60d2bd17c6de251c815d9c2bdd319429b..33b00cef15190467fb79e93cf5e50a251e856030 100644 (file)
@@ -15,6 +15,7 @@
 #include "cache-tree.h"
 #include "tree-walk.h"
 #include "builtin.h"
+#include "object-file.h"
 #include "refs.h"
 #include "resolve-undo.h"
 #include "parse-options.h"
index 69132bba319e41d49e458a7dc5673f5bb0103df9..0621f6f708e93bdb8cde70eded330c84755a1e4f 100644 (file)
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
index 6362b6aabc7f4f363e0e628869cb2213040b4ed1..af15f8a9af4368e4514c0cc2ea777c0fb1df83f3 100644 (file)
@@ -15,6 +15,7 @@
 #include "string-list.h"
 #include "tmp-objdir.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static int odb_transaction_nesting;
index 39f0c74472724142c9c2748d71faa4d377ea0719..ebfe649b330760eb5f13f172c4d5a9f4ed29da41 100644 (file)
@@ -7,6 +7,7 @@
 #include "tree-walk.h"
 #include "cache-tree.h"
 #include "bulk-checkin.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/cache.h b/cache.h
index c06778b69cd11869392aa7018b7f76b189cdbd32..89987cca22a7e0bb184953da065742c3be4ba385 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -3,7 +3,6 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
-#include "git-zlib.h"
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
@@ -596,13 +595,6 @@ int has_racy_timestamp(struct index_state *istate);
 int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 
-#define HASH_WRITE_OBJECT 1
-#define HASH_FORMAT_CHECK 2
-#define HASH_RENORMALIZE  4
-#define HASH_SILENT 8
-int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
-int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
-
 /*
  * Record to sd the data from st that we use to check whether a file
  * might have changed.
@@ -664,107 +656,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Create the directory containing the named path, using care to be
- * somewhat safe against races. Return one of the scld_error values to
- * indicate success/failure. On error, set errno to describe the
- * problem.
- *
- * SCLD_VANISHED indicates that one of the ancestor directories of the
- * path existed at one point during the function call and then
- * suddenly vanished, probably because another process pruned the
- * directory while we were working.  To be robust against this kind of
- * race, callers might want to try invoking the function again when it
- * returns SCLD_VANISHED.
- *
- * safe_create_leading_directories() temporarily changes path while it
- * is working but restores it before returning.
- * safe_create_leading_directories_const() doesn't modify path, even
- * temporarily. Both these variants adjust the permissions of the
- * created directories to honor core.sharedRepository, so they are best
- * suited for files inside the git dir. For working tree files, use
- * safe_create_leading_directories_no_share() instead, as it ignores
- * the core.sharedRepository setting.
- */
-enum scld_error {
-       SCLD_OK = 0,
-       SCLD_FAILED = -1,
-       SCLD_PERMS = -2,
-       SCLD_EXISTS = -3,
-       SCLD_VANISHED = -4
-};
-enum scld_error safe_create_leading_directories(char *path);
-enum scld_error safe_create_leading_directories_const(const char *path);
-enum scld_error safe_create_leading_directories_no_share(char *path);
-
-int mkdir_in_gitdir(const char *path);
-
-int git_open_cloexec(const char *name, int flags);
-#define git_open(name) git_open_cloexec(name, O_RDONLY)
-
-/**
- * unpack_loose_header() initializes the data stream needed to unpack
- * a loose object header.
- *
- * Returns:
- *
- * - ULHR_OK on success
- * - ULHR_BAD on error
- * - ULHR_TOO_LONG if the header was too long
- *
- * It will only parse up to MAX_HEADER_LEN bytes unless an optional
- * "hdrbuf" argument is non-NULL. This is intended for use with
- * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
- * reporting. The full header will be extracted to "hdrbuf" for use
- * with parse_loose_header(), ULHR_TOO_LONG will still be returned
- * from this function to indicate that the header was too long.
- */
-enum unpack_loose_header_result {
-       ULHR_OK,
-       ULHR_BAD,
-       ULHR_TOO_LONG,
-};
-enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
-                                                   unsigned char *map,
-                                                   unsigned long mapsize,
-                                                   void *buffer,
-                                                   unsigned long bufsiz,
-                                                   struct strbuf *hdrbuf);
-
-/**
- * parse_loose_header() parses the starting "<type> <len>\0" of an
- * object. If it doesn't follow that format -1 is returned. To check
- * the validity of the <type> populate the "typep" in the "struct
- * object_info". It will be OBJ_BAD if the object type is unknown. The
- * parsed <len> can be retrieved via "oi->sizep", and from there
- * passed to unpack_loose_rest().
- */
-struct object_info;
-int parse_loose_header(const char *hdr, struct object_info *oi);
-
-/**
- * With in-core object data in "buf", rehash it to make sure the
- * object name actually matches "oid" to detect object corruption.
- *
- * A negative value indicates an error, usually that the OID is not
- * what we expected, but it might also indicate another error.
- */
-int check_object_signature(struct repository *r, const struct object_id *oid,
-                          void *map, unsigned long size,
-                          enum object_type type);
-
-/**
- * A streaming version of check_object_signature().
- * Try reading the object named with "oid" using
- * the streaming interface and rehash it to do the same.
- */
-int stream_object_signature(struct repository *r, const struct object_id *oid);
-
-int finalize_object_file(const char *tmpfile, const char *filename);
-
-/* Helper to check and "touch" a file */
-int check_and_freshen_file(const char *fn, int freshen);
-
 int base_name_compare(const char *name1, size_t len1, int mode1,
                      const char *name2, size_t len2, int mode2);
 int df_name_compare(const char *name1, size_t len1, int mode1,
@@ -772,12 +663,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-void *read_object_with_reference(struct repository *r,
-                                const struct object_id *oid,
-                                enum object_type required_type,
-                                unsigned long *size,
-                                struct object_id *oid_ret);
-
 const char *git_editor(void);
 const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
@@ -819,14 +704,6 @@ struct pack_entry {
        struct packed_git *p;
 };
 
-/*
- * Set this to 0 to prevent oid_object_info_extended() from fetching missing
- * blobs. This has a difference only if extensions.partialClone is set.
- *
- * Its default value is 1.
- */
-extern int fetch_if_missing;
-
 /* Dumb servers support */
 int update_server_info(int);
 
index fe9a8b2342f680e887058c6e6ee9eabb5b442d6a..c20e73ceebf6c6bc7f57468b0104f7326a5f4e70 100644 (file)
@@ -11,6 +11,7 @@
 #include "revision.h"
 #include "hash-lookup.h"
 #include "commit-graph.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "alloc.h"
diff --git a/diff.c b/diff.c
index 9e6ad94bc66a19e6bc7f79b7b75478b289338ecf..f8e0d3b5c592ff66cb6573ab3a155a5635aebc1a 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
diff --git a/dir.c b/dir.c
index d1f1b1ef768fee1b1ac8f7dc55c0b6a55f674d36..aa840995c40bebc029b609dde82b235f1a6e5b9a 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "attr.h"
 #include "refs.h"
index e57292eccc93f8d8cdafb8b935f76a4950e82239..39efa49fe313a53ca7ca59173a7748fe913aca3c 100644 (file)
@@ -19,6 +19,7 @@
 #include "fmt-merge-msg.h"
 #include "commit.h"
 #include "strvec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "tmp-objdir.h"
diff --git a/http.c b/http.c
index 0212c0ad3b2b778eb28ed42c966d82d8e2a6a669..c3916ceb4d8b818e4a48e3137245ea708ccbbde4 100644 (file)
--- a/http.c
+++ b/http.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "protocol.h"
 #include "string-list.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
index 748a6799a303f36184c2ce3cf2e594b10437a951..9875bdb11cb34c174af5d6cca53866652ad162df 100644 (file)
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/midx.c b/midx.c
index 9af3e5de8899cda69ab885c74bfd0e2b72f53bdb..2d0da5732812b3ded5954dbc15429fedb83e9ec4 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "midx.h"
index b496b77d9db128c40c4b30e40360cf9656696409..cc9538ac5c0aa6abc903898ea89c615afbbbc7b3 100644 (file)
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
index a4331e0da613a24b450c383a2a2e2235672725a2..8163ddbaddd309b911e2075d7db2a1a5af55307a 100644 (file)
@@ -36,6 +36,7 @@
 #include "mergesort.h"
 #include "quote.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "setup.h"
diff --git a/object-file.h b/object-file.h
new file mode 100644 (file)
index 0000000..e0cfc3a
--- /dev/null
@@ -0,0 +1,129 @@
+#ifndef OBJECT_FILE_H
+#define OBJECT_FILE_H
+
+#include "git-zlib.h"
+#include "object.h"
+
+/*
+ * Set this to 0 to prevent oid_object_info_extended() from fetching missing
+ * blobs. This has a difference only if extensions.partialClone is set.
+ *
+ * Its default value is 1.
+ */
+extern int fetch_if_missing;
+
+#define HASH_WRITE_OBJECT 1
+#define HASH_FORMAT_CHECK 2
+#define HASH_RENORMALIZE  4
+#define HASH_SILENT 8
+int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
+int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
+
+/*
+ * Create the directory containing the named path, using care to be
+ * somewhat safe against races. Return one of the scld_error values to
+ * indicate success/failure. On error, set errno to describe the
+ * problem.
+ *
+ * SCLD_VANISHED indicates that one of the ancestor directories of the
+ * path existed at one point during the function call and then
+ * suddenly vanished, probably because another process pruned the
+ * directory while we were working.  To be robust against this kind of
+ * race, callers might want to try invoking the function again when it
+ * returns SCLD_VANISHED.
+ *
+ * safe_create_leading_directories() temporarily changes path while it
+ * is working but restores it before returning.
+ * safe_create_leading_directories_const() doesn't modify path, even
+ * temporarily. Both these variants adjust the permissions of the
+ * created directories to honor core.sharedRepository, so they are best
+ * suited for files inside the git dir. For working tree files, use
+ * safe_create_leading_directories_no_share() instead, as it ignores
+ * the core.sharedRepository setting.
+ */
+enum scld_error {
+       SCLD_OK = 0,
+       SCLD_FAILED = -1,
+       SCLD_PERMS = -2,
+       SCLD_EXISTS = -3,
+       SCLD_VANISHED = -4
+};
+enum scld_error safe_create_leading_directories(char *path);
+enum scld_error safe_create_leading_directories_const(const char *path);
+enum scld_error safe_create_leading_directories_no_share(char *path);
+
+int mkdir_in_gitdir(const char *path);
+
+int git_open_cloexec(const char *name, int flags);
+#define git_open(name) git_open_cloexec(name, O_RDONLY)
+
+/**
+ * unpack_loose_header() initializes the data stream needed to unpack
+ * a loose object header.
+ *
+ * Returns:
+ *
+ * - ULHR_OK on success
+ * - ULHR_BAD on error
+ * - ULHR_TOO_LONG if the header was too long
+ *
+ * It will only parse up to MAX_HEADER_LEN bytes unless an optional
+ * "hdrbuf" argument is non-NULL. This is intended for use with
+ * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
+ * reporting. The full header will be extracted to "hdrbuf" for use
+ * with parse_loose_header(), ULHR_TOO_LONG will still be returned
+ * from this function to indicate that the header was too long.
+ */
+enum unpack_loose_header_result {
+       ULHR_OK,
+       ULHR_BAD,
+       ULHR_TOO_LONG,
+};
+enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
+                                                   unsigned char *map,
+                                                   unsigned long mapsize,
+                                                   void *buffer,
+                                                   unsigned long bufsiz,
+                                                   struct strbuf *hdrbuf);
+
+/**
+ * parse_loose_header() parses the starting "<type> <len>\0" of an
+ * object. If it doesn't follow that format -1 is returned. To check
+ * the validity of the <type> populate the "typep" in the "struct
+ * object_info". It will be OBJ_BAD if the object type is unknown. The
+ * parsed <len> can be retrieved via "oi->sizep", and from there
+ * passed to unpack_loose_rest().
+ */
+struct object_info;
+int parse_loose_header(const char *hdr, struct object_info *oi);
+
+/**
+ * With in-core object data in "buf", rehash it to make sure the
+ * object name actually matches "oid" to detect object corruption.
+ *
+ * A negative value indicates an error, usually that the OID is not
+ * what we expected, but it might also indicate another error.
+ */
+int check_object_signature(struct repository *r, const struct object_id *oid,
+                          void *map, unsigned long size,
+                          enum object_type type);
+
+/**
+ * A streaming version of check_object_signature().
+ * Try reading the object named with "oid" using
+ * the streaming interface and rehash it to do the same.
+ */
+int stream_object_signature(struct repository *r, const struct object_id *oid);
+
+int finalize_object_file(const char *tmpfile, const char *filename);
+
+/* Helper to check and "touch" a file */
+int check_and_freshen_file(const char *fn, int freshen);
+
+void *read_object_with_reference(struct repository *r,
+                                const struct object_id *oid,
+                                enum object_type required_type,
+                                unsigned long *size,
+                                struct object_id *oid_ret);
+
+#endif /* OBJECT_FILE_H */
index 45c9721b8c81929a13854d46d0354374370fd02f..6d4ef1524defed90be95ee17372e37ed099cd27e 100644 (file)
--- a/object.c
+++ b/object.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "object.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
index eba838d24ee95a02a14a6c21cc711d151003e677..1371f17d22f846e50cadca142f43256b27fcd037 100644 (file)
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "repository.h"
 #include "trace2.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
index 6974e40a95826e39b3f102d1653b391c9e87cde5..40d88bc5ebe9d9b184a04a43963396a550d7d5bb 100644 (file)
@@ -6,6 +6,7 @@
 #include "pack-revindex.h"
 #include "progress.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 struct idx_entry {
index afed63219060ecb57cc1fdb285bfe0b90eac725c..0096ace080b8f7d934c522a4daac8b4dd889242c 100644 (file)
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 
index 9f9927d9471784fca23208299e9af80b647c80ed..22a1958a1fca7d5035969b96cdfa0a11f1fa9edd 100644 (file)
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "trace2.h"
index 02afbe771379a52d9adfe0b134c8dd8d047f6e67..9ae2278c22edc59207e150f9effb43c745426c2b 100644 (file)
@@ -18,6 +18,7 @@
 #include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
index cbbfc030da788deff1ad09fe7840cf95a8d4092f..f225bf44cd0b5fd05cf74db20023f0161c9d1c89 100644 (file)
@@ -14,6 +14,7 @@
 #include "cache-tree.h"
 #include "refs.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "tree.h"
index e6a6971381e09a5f153b25d29b69bb5b1c1d6270..d0581ee41ac6181961567627f292ad6a0dbcdc14 100644 (file)
@@ -12,6 +12,7 @@
 #include "../dir-iterator.h"
 #include "../lockfile.h"
 #include "../object.h"
+#include "../object-file.h"
 #include "../dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
index 5516e336d010cac54d3dca4fba026a025825acdc..093c0f6f99319e32dc5d6eb6526fa31a7b07d7f7 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -13,6 +13,7 @@
 #include "ll-merge.h"
 #include "attr.h"
 #include "pathspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "strmap.h"
index 7438b50e267f5ca436724447d01f215b2e67b168..3d86e07abb8ab911e2572ceeb5390749ec46e083 100644 (file)
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
index 22b287be984b1dc2bf58be01688b8475cac21147..be10249fd0a607ca2637afab8a627a33fb72958d 100644 (file)
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "object.h"
index 355b6e01a52a0ce25b1a9fdf145749b37085f852..68098ddd1ad6a84b3ad25a85b5361b8f353cd4c0 100644 (file)
@@ -9,6 +9,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "strbuf.h"
 #include "wrapper.h"
index 27e014d8b23d0eb731097f77c80d009ab0b2e52a..b3415724ee4a05c6680284f9d41988614e39d588 100644 (file)
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "packfile.h"
index 4f403b9eeffdb417fdba984ff51676f17a38c132..d09bc22d4b648730bfdc3d13cf8f0c7c33c34dfe 100644 (file)
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
index 5adad1925d1a051c38c08f911dd6d5824e5de305..fff7ff42db7e5edec8660d0477acc3504f56cfb9 100644 (file)
@@ -4,6 +4,7 @@
 #include "chdir-notify.h"
 #include "dir.h"
 #include "environment.h"
+#include "object-file.h"
 #include "sigchain.h"
 #include "string-list.h"
 #include "strbuf.h"
index 59add24c8e920cef4bdfbff56c132b172a029fb0..2993c48c2f31072d7d1109df85d58dbcbf321caa 100644 (file)
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "trace2.h"
 #include "tree.h"