зеркало из https://github.com/microsoft/git.git
deserialize-status: silently fallback if we cannot read cache file
Teach Git to not throw a fatal error when an explicitly-specified status-cache file (`git status --deserialize=<foo>`) could not be found or opened for reading and silently fallback to a traditional scan. This matches the behavior when the status-cache file is implicitly given via a config setting. Note: the current version causes a test to start failing. Mark this as an expected result for now. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
This commit is contained in:
Родитель
16993e822d
Коммит
297161e9ae
|
@ -232,12 +232,18 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
|
|||
free(deserialize_path);
|
||||
deserialize_path = xstrdup(arg);
|
||||
}
|
||||
if (deserialize_path && *deserialize_path
|
||||
&& (access(deserialize_path, R_OK) != 0))
|
||||
die("cannot find serialization file '%s'",
|
||||
deserialize_path);
|
||||
|
||||
do_explicit_deserialize = 1;
|
||||
if (!deserialize_path || !*deserialize_path)
|
||||
do_explicit_deserialize = 1; /* read stdin */
|
||||
else if (access(deserialize_path, R_OK) == 0)
|
||||
do_explicit_deserialize = 1; /* can read from this file */
|
||||
else {
|
||||
/*
|
||||
* otherwise, silently fallback to the normal
|
||||
* collection scan
|
||||
*/
|
||||
do_implicit_deserialize = 0;
|
||||
do_explicit_deserialize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -439,4 +439,20 @@ test_expect_success 'ensure deserialize -v does not crash' '
|
|||
grep -q "deserialize/reject:args/verbose" verbose_test.log_v
|
||||
'
|
||||
|
||||
test_expect_success 'fallback when implicit' '
|
||||
git init -b main implicit_fallback_test &&
|
||||
git -C implicit_fallback_test -c status.deserializepath=foobar status
|
||||
'
|
||||
|
||||
test_expect_success 'fallback when explicit' '
|
||||
git init -b main explicit_fallback_test &&
|
||||
git -C explicit_fallback_test status --deserialize=foobar
|
||||
'
|
||||
|
||||
test_expect_success 'deserialize from stdin' '
|
||||
git init -b main stdin_test &&
|
||||
git -C stdin_test status --serialize >serialized_status.dat &&
|
||||
cat serialize_status.dat | git -C stdin_test status --deserialize
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Загрузка…
Ссылка в новой задаче