зеркало из https://github.com/microsoft/git.git
Fix rev index in 2.42.0 series (#600)
Cherry-pick rev-index fixes from v2.41.0.vfs.0.5 into v2.42.0.*
This commit is contained in:
Коммит
44bda5a220
|
@ -1733,6 +1733,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
|
||||||
unsigned foreign_nr = 1; /* zero is a "good" value, assume bad */
|
unsigned foreign_nr = 1; /* zero is a "good" value, assume bad */
|
||||||
int report_end_of_input = 0;
|
int report_end_of_input = 0;
|
||||||
int hash_algo = 0;
|
int hash_algo = 0;
|
||||||
|
int dash_o = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* index-pack never needs to fetch missing objects except when
|
* index-pack never needs to fetch missing objects except when
|
||||||
|
@ -1826,6 +1827,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
|
||||||
if (index_name || (i+1) >= argc)
|
if (index_name || (i+1) >= argc)
|
||||||
usage(index_pack_usage);
|
usage(index_pack_usage);
|
||||||
index_name = argv[++i];
|
index_name = argv[++i];
|
||||||
|
dash_o = 1;
|
||||||
} else if (starts_with(arg, "--index-version=")) {
|
} else if (starts_with(arg, "--index-version=")) {
|
||||||
char *c;
|
char *c;
|
||||||
opts.version = strtoul(arg + 16, &c, 10);
|
opts.version = strtoul(arg + 16, &c, 10);
|
||||||
|
@ -1868,6 +1870,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
|
||||||
index_name = derive_filename(pack_name, "pack", "idx", &index_name_buf);
|
index_name = derive_filename(pack_name, "pack", "idx", &index_name_buf);
|
||||||
|
|
||||||
opts.flags &= ~(WRITE_REV | WRITE_REV_VERIFY);
|
opts.flags &= ~(WRITE_REV | WRITE_REV_VERIFY);
|
||||||
|
if (rev_index && dash_o && !ends_with(index_name, ".idx"))
|
||||||
|
rev_index = 0;
|
||||||
if (rev_index) {
|
if (rev_index) {
|
||||||
opts.flags |= verify ? WRITE_REV_VERIFY : WRITE_REV;
|
opts.flags |= verify ? WRITE_REV_VERIFY : WRITE_REV;
|
||||||
if (index_name)
|
if (index_name)
|
||||||
|
|
|
@ -355,6 +355,30 @@ test_expect_success 'build pack index for an existing pack' '
|
||||||
:
|
:
|
||||||
'
|
'
|
||||||
|
|
||||||
|
# The `--rev-index` option of `git index-pack` is now the default, so
|
||||||
|
# a `foo.rev` REV file will be created when a `foo.idx` IDX file is
|
||||||
|
# created. Normally, these pathnames are based upon the `foo.pack`
|
||||||
|
# PACK file pathname.
|
||||||
|
#
|
||||||
|
# However, the `-o` option lets you set the pathname of the IDX file
|
||||||
|
# indepdent of the PACK file.
|
||||||
|
#
|
||||||
|
# Verify what happens if these suffixes are changed.
|
||||||
|
#
|
||||||
|
test_expect_success 'complain about index name' '
|
||||||
|
# Normal case { .pack, .idx, .rev }
|
||||||
|
cat test-1-${packname_1}.pack >test-complain-0.pack &&
|
||||||
|
git index-pack -o test-complain-0.idx --rev-index test-complain-0.pack &&
|
||||||
|
test -f test-complain-0.idx &&
|
||||||
|
test -f test-complain-0.rev &&
|
||||||
|
|
||||||
|
# Non .idx suffix -- implicitly omits the .rev
|
||||||
|
cat test-1-${packname_1}.pack >test-complain-1.pack &&
|
||||||
|
git index-pack -o test-complain-1.idx-suffix --rev-index test-complain-1.pack &&
|
||||||
|
test -f test-complain-1.idx-suffix &&
|
||||||
|
! test -f test-complain-1.rev
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'unpacking with --strict' '
|
test_expect_success 'unpacking with --strict' '
|
||||||
|
|
||||||
for j in a b c d e f g
|
for j in a b c d e f g
|
||||||
|
|
Загрузка…
Ссылка в новой задаче