builtin/repack: replace hard-coded constants
Note that while the error messages here are not translated, the end user should never see them. We invoke git pack-objects shortly before both invocations, so we can be fairly certain that the data we're receiving is in fact valid. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
825544a351
commit
2f0c9e9a9b
|
@ -235,8 +235,8 @@ static void repack_promisor_objects(const struct pack_objects_args *args,
|
||||||
while (strbuf_getline_lf(&line, out) != EOF) {
|
while (strbuf_getline_lf(&line, out) != EOF) {
|
||||||
char *promisor_name;
|
char *promisor_name;
|
||||||
int fd;
|
int fd;
|
||||||
if (line.len != 40)
|
if (line.len != the_hash_algo->hexsz)
|
||||||
die("repack: Expecting 40 character sha1 lines only from pack-objects.");
|
die("repack: Expecting full hex object ID lines only from pack-objects.");
|
||||||
string_list_append(names, line.buf);
|
string_list_append(names, line.buf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -407,8 +407,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
out = xfdopen(cmd.out, "r");
|
out = xfdopen(cmd.out, "r");
|
||||||
while (strbuf_getline_lf(&line, out) != EOF) {
|
while (strbuf_getline_lf(&line, out) != EOF) {
|
||||||
if (line.len != 40)
|
if (line.len != the_hash_algo->hexsz)
|
||||||
die("repack: Expecting 40 character sha1 lines only from pack-objects.");
|
die("repack: Expecting full hex object ID lines only from pack-objects.");
|
||||||
string_list_append(&names, line.buf);
|
string_list_append(&names, line.buf);
|
||||||
}
|
}
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
@ -535,14 +535,15 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||||
reprepare_packed_git(the_repository);
|
reprepare_packed_git(the_repository);
|
||||||
|
|
||||||
if (delete_redundant) {
|
if (delete_redundant) {
|
||||||
|
const int hexsz = the_hash_algo->hexsz;
|
||||||
int opts = 0;
|
int opts = 0;
|
||||||
string_list_sort(&names);
|
string_list_sort(&names);
|
||||||
for_each_string_list_item(item, &existing_packs) {
|
for_each_string_list_item(item, &existing_packs) {
|
||||||
char *sha1;
|
char *sha1;
|
||||||
size_t len = strlen(item->string);
|
size_t len = strlen(item->string);
|
||||||
if (len < 40)
|
if (len < hexsz)
|
||||||
continue;
|
continue;
|
||||||
sha1 = item->string + len - 40;
|
sha1 = item->string + len - hexsz;
|
||||||
if (!string_list_has_string(&names, sha1))
|
if (!string_list_has_string(&names, sha1))
|
||||||
remove_redundant_pack(packdir, item->string);
|
remove_redundant_pack(packdir, item->string);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue