Git fork

packfile: warn people away from parse_packed_git()

With a name like parse_packed_git(), you might think it's the right way
to access a local pack index and its associated objects. But not so!
It's a one-off used by the dumb-http code to access pack idx files we've
downloaded from the remote, but whose packs we might not have.

There's only one caller left for this function, and ideally we'd drop it
completely and just inline it there. But that would require exposing
other internals from packfile.[ch], like alloc_packed_git() and
check_packed_git_idx().

So let's leave it be for now, and just warn people that it's probably
not what they're looking for. Perhaps in the long run if we eventually
drop dumb-http support, we can remove the function entirely then.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>

authored by

Jeff King and committed by
Taylor Blau
6b2fc220 4390fea9

+10 -1
+10 -1
packfile.h
··· 37 */ 38 const char *pack_basename(struct packed_git *p); 39 40 struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path); 41 42 typedef void each_file_in_pack_dir_fn(const char *full_path, size_t full_path_len, ··· 193 * 194 * This function should not be used directly. It is exposed here only so that we 195 * have a convenient entry-point for fuzz testing. For real uses, you should 196 - * probably use open_pack_index() or parse_pack_index() instead. 197 */ 198 int load_idx(const char *path, const unsigned int hashsz, void *idx_map, 199 size_t idx_size, struct packed_git *p);
··· 37 */ 38 const char *pack_basename(struct packed_git *p); 39 40 + /* 41 + * Parse the pack idx file found at idx_path and create a packed_git struct 42 + * which can be used with find_pack_entry_one(). 43 + * 44 + * You probably don't want to use this function! It skips most of the normal 45 + * sanity checks (including whether we even have the matching .pack file), 46 + * and does not add the resulting packed_git struct to the internal list of 47 + * packs. You probably want add_packed_git() instead. 48 + */ 49 struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path); 50 51 typedef void each_file_in_pack_dir_fn(const char *full_path, size_t full_path_len, ··· 202 * 203 * This function should not be used directly. It is exposed here only so that we 204 * have a convenient entry-point for fuzz testing. For real uses, you should 205 + * probably use open_pack_index() instead. 206 */ 207 int load_idx(const char *path, const unsigned int hashsz, void *idx_map, 208 size_t idx_size, struct packed_git *p);