Skip to content

Commit 6b2fc22

Browse files
peffttaylorr
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 4390fea commit 6b2fc22

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packfile.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ char *odb_pack_name(struct strbuf *buf, const unsigned char *sha1, const char *e
3737
*/
3838
const char *pack_basename(struct packed_git *p);
3939

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+
*/
4049
struct packed_git *parse_pack_index(unsigned char *sha1, const char *idx_path);
4150

4251
typedef void each_file_in_pack_dir_fn(const char *full_path, size_t full_path_len,
@@ -193,7 +202,7 @@ int is_promisor_object(const struct object_id *oid);
193202
*
194203
* This function should not be used directly. It is exposed here only so that we
195204
* have a convenient entry-point for fuzz testing. For real uses, you should
196-
* probably use open_pack_index() or parse_pack_index() instead.
205+
* probably use open_pack_index() instead.
197206
*/
198207
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
199208
size_t idx_size, struct packed_git *p);

0 commit comments

Comments
 (0)