Skip to content

Commit

Permalink
Merge pull request #270 from jeffhostetler/fix-deserialize-error-vfs
Browse files Browse the repository at this point in the history
deserialize-status: silently fallback if we cannot read cache file
  • Loading branch information
jeffhostetler authored and dscho committed May 20, 2020
2 parents d7e1443 + 6a4c177 commit b26b4d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
18 changes: 12 additions & 6 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,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
&& (wt_status_deserialize_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 (wt_status_deserialize_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;
Expand Down
16 changes: 16 additions & 0 deletions t/t7524-serialized-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,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 implicit_fallback_test &&
git -C implicit_fallback_test -c status.deserializepath=foobar status
'

test_expect_success 'fallback when explicit' '
git init explicit_fallback_test &&
git -C explicit_fallback_test status --deserialize=foobar
'

test_expect_success 'deserialize from stdin' '
git init stdin_test &&
git -C stdin_test status --serialize >serialized_status.dat &&
cat serialize_status.dat | git -C stdin_test status --deserialize
'

test_done

0 comments on commit b26b4d0

Please sign in to comment.