Keep track of whether a pack is local or not
If we want to re-pack just local packfiles, we need to know whether a particular object is local or not. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
73319032c8
commit
9d835df246
3
cache.h
3
cache.h
@ -313,6 +313,7 @@ extern struct packed_git {
|
|||||||
void *pack_base;
|
void *pack_base;
|
||||||
unsigned int pack_last_used;
|
unsigned int pack_last_used;
|
||||||
unsigned int pack_use_cnt;
|
unsigned int pack_use_cnt;
|
||||||
|
int pack_local;
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
char pack_name[0]; /* something like ".git/objects/pack/xxxxx.pack" */
|
char pack_name[0]; /* something like ".git/objects/pack/xxxxx.pack" */
|
||||||
} *packed_git;
|
} *packed_git;
|
||||||
@ -352,7 +353,7 @@ extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
|
|||||||
|
|
||||||
extern int use_packed_git(struct packed_git *);
|
extern int use_packed_git(struct packed_git *);
|
||||||
extern void unuse_packed_git(struct packed_git *);
|
extern void unuse_packed_git(struct packed_git *);
|
||||||
extern struct packed_git *add_packed_git(char *, int);
|
extern struct packed_git *add_packed_git(char *, int, int);
|
||||||
extern int num_packed_objects(const struct packed_git *p);
|
extern int num_packed_objects(const struct packed_git *p);
|
||||||
extern int nth_packed_object_sha1(const struct packed_git *, int, unsigned char*);
|
extern int nth_packed_object_sha1(const struct packed_git *, int, unsigned char*);
|
||||||
extern int find_pack_entry_one(const unsigned char *, struct pack_entry *, struct packed_git *);
|
extern int find_pack_entry_one(const unsigned char *, struct pack_entry *, struct packed_git *);
|
||||||
|
11
sha1_file.c
11
sha1_file.c
@ -416,7 +416,7 @@ int use_packed_git(struct packed_git *p)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct packed_git *add_packed_git(char *path, int path_len)
|
struct packed_git *add_packed_git(char *path, int path_len, int local)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct packed_git *p;
|
struct packed_git *p;
|
||||||
@ -444,6 +444,7 @@ struct packed_git *add_packed_git(char *path, int path_len)
|
|||||||
p->pack_base = NULL;
|
p->pack_base = NULL;
|
||||||
p->pack_last_used = 0;
|
p->pack_last_used = 0;
|
||||||
p->pack_use_cnt = 0;
|
p->pack_use_cnt = 0;
|
||||||
|
p->pack_local = local;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +485,7 @@ void install_packed_git(struct packed_git *pack)
|
|||||||
packed_git = pack;
|
packed_git = pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prepare_packed_git_one(char *objdir)
|
static void prepare_packed_git_one(char *objdir, int local)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
int len;
|
int len;
|
||||||
@ -506,7 +507,7 @@ static void prepare_packed_git_one(char *objdir)
|
|||||||
|
|
||||||
/* we have .idx. Is it a file we can map? */
|
/* we have .idx. Is it a file we can map? */
|
||||||
strcpy(path + len, de->d_name);
|
strcpy(path + len, de->d_name);
|
||||||
p = add_packed_git(path, len + namelen);
|
p = add_packed_git(path, len + namelen, local);
|
||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
p->next = packed_git;
|
p->next = packed_git;
|
||||||
@ -522,11 +523,11 @@ void prepare_packed_git(void)
|
|||||||
|
|
||||||
if (run_once)
|
if (run_once)
|
||||||
return;
|
return;
|
||||||
prepare_packed_git_one(get_object_directory());
|
prepare_packed_git_one(get_object_directory(), 1);
|
||||||
prepare_alt_odb();
|
prepare_alt_odb();
|
||||||
for (alt = alt_odb_list; alt; alt = alt->next) {
|
for (alt = alt_odb_list; alt; alt = alt->next) {
|
||||||
alt->name[0] = 0;
|
alt->name[0] = 0;
|
||||||
prepare_packed_git_one(alt->base);
|
prepare_packed_git_one(alt->base, 0);
|
||||||
}
|
}
|
||||||
run_once = 1;
|
run_once = 1;
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,12 @@ static int verify_one_pack(char *arg, int verbose)
|
|||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
/* Should name foo.idx now */
|
/* Should name foo.idx now */
|
||||||
if ((g = add_packed_git(arg, len)))
|
if ((g = add_packed_git(arg, len, 1)))
|
||||||
break;
|
break;
|
||||||
/* No? did you name just foo? */
|
/* No? did you name just foo? */
|
||||||
strcpy(arg + len, ".idx");
|
strcpy(arg + len, ".idx");
|
||||||
len += 4;
|
len += 4;
|
||||||
if ((g = add_packed_git(arg, len)))
|
if ((g = add_packed_git(arg, len, 1)))
|
||||||
break;
|
break;
|
||||||
return error("packfile %s not found.", arg);
|
return error("packfile %s not found.", arg);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user