From c508df5edfe12b9df7dfea4d438c1dab2812b3e9 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 16 Aug 2005 00:10:03 -0400 Subject: [PATCH] [PATCH] Add function to read an index file from an arbitrary filename. Note that the pack file has to be in the usual location if it gets installed later. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- cache.h | 2 ++ sha1_file.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cache.h b/cache.h index dbde95a0b..f14a4ce91 100644 --- a/cache.h +++ b/cache.h @@ -319,6 +319,8 @@ extern int get_ack(int fd, unsigned char *result_sha1); extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, char **match); extern struct packed_git *parse_pack_index(unsigned char *sha1); +extern struct packed_git *parse_pack_index_file(unsigned char *sha1, + char *idx_path); extern void prepare_packed_git(void); extern void install_packed_git(struct packed_git *pack); diff --git a/sha1_file.c b/sha1_file.c index 2d109f928..b6ebbc5c9 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -475,13 +475,19 @@ struct packed_git *add_packed_git(char *path, int path_len) } struct packed_git *parse_pack_index(unsigned char *sha1) +{ + char *path = sha1_pack_index_name(sha1); + return parse_pack_index_file(sha1, path); +} + +struct packed_git *parse_pack_index_file(unsigned char *sha1, char *idx_path) { struct packed_git *p; unsigned long idx_size; void *idx_map; - char *path = sha1_pack_index_name(sha1); + char *path; - if (check_packed_git_idx(path, &idx_size, &idx_map)) + if (check_packed_git_idx(idx_path, &idx_size, &idx_map)) return NULL; path = sha1_pack_name(sha1); -- 2.30.2