Skip to content

Commit cea9661

Browse files
jeffhostetlerdscho
authored andcommitted
Merge pull request #270 from jeffhostetler/fix-deserialize-error-vfs
deserialize-status: silently fallback if we cannot read cache file
2 parents aef298a + e3f5ba9 commit cea9661

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

builtin/commit.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,18 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
213213
free(deserialize_path);
214214
deserialize_path = xstrdup(arg);
215215
}
216-
if (deserialize_path && *deserialize_path
217-
&& (wt_status_deserialize_access(deserialize_path, R_OK) != 0))
218-
die("cannot find serialization file '%s'",
219-
deserialize_path);
220-
221-
do_explicit_deserialize = 1;
216+
if (!deserialize_path || !*deserialize_path)
217+
do_explicit_deserialize = 1; /* read stdin */
218+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
219+
do_explicit_deserialize = 1; /* can read from this file */
220+
else {
221+
/*
222+
* otherwise, silently fallback to the normal
223+
* collection scan
224+
*/
225+
do_implicit_deserialize = 0;
226+
do_explicit_deserialize = 0;
227+
}
222228
}
223229

224230
return 0;

t/t7524-serialized-status.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,20 @@ test_expect_success 'ensure deserialize -v does not crash' '
426426
grep -q "deserialize/reject:args/verbose" verbose_test.log_v
427427
'
428428

429+
test_expect_success 'fallback when implicit' '
430+
git init implicit_fallback_test &&
431+
git -C implicit_fallback_test -c status.deserializepath=foobar status
432+
'
433+
434+
test_expect_success 'fallback when explicit' '
435+
git init explicit_fallback_test &&
436+
git -C explicit_fallback_test status --deserialize=foobar
437+
'
438+
439+
test_expect_success 'deserialize from stdin' '
440+
git init stdin_test &&
441+
git -C stdin_test status --serialize >serialized_status.dat &&
442+
cat serialize_status.dat | git -C stdin_test status --deserialize
443+
'
444+
429445
test_done

0 commit comments

Comments
 (0)