8 * Set this to 0 to prevent oid_object_info_extended() from fetching missing
9 * blobs. This has a difference only if extensions.partialClone is set.
11 * Its default value is 1.
13 extern int fetch_if_missing
;
15 #define HASH_WRITE_OBJECT 1
16 #define HASH_FORMAT_CHECK 2
17 #define HASH_RENORMALIZE 4
19 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
);
20 int index_path(struct index_state
*istate
, struct object_id
*oid
, const char *path
, struct stat
*st
, unsigned flags
);
23 * Create the directory containing the named path, using care to be
24 * somewhat safe against races. Return one of the scld_error values to
25 * indicate success/failure. On error, set errno to describe the
28 * SCLD_VANISHED indicates that one of the ancestor directories of the
29 * path existed at one point during the function call and then
30 * suddenly vanished, probably because another process pruned the
31 * directory while we were working. To be robust against this kind of
32 * race, callers might want to try invoking the function again when it
33 * returns SCLD_VANISHED.
35 * safe_create_leading_directories() temporarily changes path while it
36 * is working but restores it before returning.
37 * safe_create_leading_directories_const() doesn't modify path, even
38 * temporarily. Both these variants adjust the permissions of the
39 * created directories to honor core.sharedRepository, so they are best
40 * suited for files inside the git dir. For working tree files, use
41 * safe_create_leading_directories_no_share() instead, as it ignores
42 * the core.sharedRepository setting.
51 enum scld_error
safe_create_leading_directories(char *path
);
52 enum scld_error
safe_create_leading_directories_const(const char *path
);
53 enum scld_error
safe_create_leading_directories_no_share(char *path
);
55 int mkdir_in_gitdir(const char *path
);
57 int git_open_cloexec(const char *name
, int flags
);
58 #define git_open(name) git_open_cloexec(name, O_RDONLY)
61 * unpack_loose_header() initializes the data stream needed to unpack
62 * a loose object header.
66 * - ULHR_OK on success
68 * - ULHR_TOO_LONG if the header was too long
70 * It will only parse up to MAX_HEADER_LEN bytes unless an optional
71 * "hdrbuf" argument is non-NULL. This is intended for use with
72 * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
73 * reporting. The full header will be extracted to "hdrbuf" for use
74 * with parse_loose_header(), ULHR_TOO_LONG will still be returned
75 * from this function to indicate that the header was too long.
77 enum unpack_loose_header_result
{
82 enum unpack_loose_header_result
unpack_loose_header(git_zstream
*stream
,
84 unsigned long mapsize
,
87 struct strbuf
*hdrbuf
);
90 * parse_loose_header() parses the starting "<type> <len>\0" of an
91 * object. If it doesn't follow that format -1 is returned. To check
92 * the validity of the <type> populate the "typep" in the "struct
93 * object_info". It will be OBJ_BAD if the object type is unknown. The
94 * parsed <len> can be retrieved via "oi->sizep", and from there
95 * passed to unpack_loose_rest().
98 int parse_loose_header(const char *hdr
, struct object_info
*oi
);
101 * With in-core object data in "buf", rehash it to make sure the
102 * object name actually matches "oid" to detect object corruption.
104 * A negative value indicates an error, usually that the OID is not
105 * what we expected, but it might also indicate another error.
107 int check_object_signature(struct repository
*r
, const struct object_id
*oid
,
108 void *map
, unsigned long size
,
109 enum object_type type
);
112 * A streaming version of check_object_signature().
113 * Try reading the object named with "oid" using
114 * the streaming interface and rehash it to do the same.
116 int stream_object_signature(struct repository
*r
, const struct object_id
*oid
);
118 int finalize_object_file(const char *tmpfile
, const char *filename
);
120 /* Helper to check and "touch" a file */
121 int check_and_freshen_file(const char *fn
, int freshen
);
123 void *read_object_with_reference(struct repository
*r
,
124 const struct object_id
*oid
,
125 enum object_type required_type
,
127 struct object_id
*oid_ret
);
129 #endif /* OBJECT_FILE_H */