Skip to content

Commit aef298a

Browse files
jeffhostetlerdscho
authored andcommitted
Merge pull request #260 from jeffhostetler/msft-verbose-status-deserialize-v226
status: fix crash in `git status --deserialize --verbose` (based on v2.26)
2 parents f1b4921 + fe951a9 commit aef298a

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

builtin/commit.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,22 @@ int cmd_status(int argc, const char **argv, const char *prefix)
15981598
*/
15991599
try_deserialize = (!do_serialize &&
16001600
(do_implicit_deserialize || do_explicit_deserialize));
1601+
1602+
/*
1603+
* Disable deserialize when verbose is set because it causes us to
1604+
* print diffs for each modified file, but that requires us to have
1605+
* the index loaded and we don't want to do that (at least not now for
1606+
* this seldom used feature). My fear is that would further tangle
1607+
* the merge conflict with upstream.
1608+
*
1609+
* TODO Reconsider this in the future.
1610+
*/
1611+
if (try_deserialize && verbose) {
1612+
trace2_data_string("status", the_repository, "deserialize/reject",
1613+
"args/verbose");
1614+
try_deserialize = 0;
1615+
}
1616+
16011617
if (try_deserialize)
16021618
goto skip_init;
16031619
/*

t/t7524-serialized-status.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,43 @@ EOF
387387
388388
'
389389

390+
test_expect_success 'ensure deserialize -v does not crash' '
391+
392+
git init verbose_test &&
393+
touch verbose_test/a &&
394+
touch verbose_test/b &&
395+
touch verbose_test/c &&
396+
git -C verbose_test add a b c &&
397+
git -C verbose_test commit -m abc &&
398+
399+
echo green >>verbose_test/a &&
400+
git -C verbose_test add a &&
401+
echo red_1 >>verbose_test/b &&
402+
echo red_2 >verbose_test/dirt &&
403+
404+
git -C verbose_test status >output.ref &&
405+
git -C verbose_test status -v >output.ref_v &&
406+
407+
git -C verbose_test --no-optional-locks status --serialize=../verbose_test.dat >output.ser.long &&
408+
git -C verbose_test --no-optional-locks status --serialize=../verbose_test.dat_v -v >output.ser.long_v &&
409+
410+
# Verify that serialization does not affect the status output itself.
411+
test_i18ncmp output.ref output.ser.long &&
412+
test_i18ncmp output.ref_v output.ser.long_v &&
413+
414+
GIT_TRACE2_PERF="$(pwd)"/verbose_test.log \
415+
git -C verbose_test status --deserialize=../verbose_test.dat >output.des.long &&
416+
417+
# Verify that normal deserialize was actually used and produces the same result.
418+
test_i18ncmp output.ser.long output.des.long &&
419+
grep -q "deserialize/result:ok" verbose_test.log &&
420+
421+
GIT_TRACE2_PERF="$(pwd)"/verbose_test.log_v \
422+
git -C verbose_test status --deserialize=../verbose_test.dat_v -v >output.des.long_v &&
423+
424+
# Verify that vebose mode produces the same result because verbose was rejected.
425+
test_i18ncmp output.ser.long_v output.des.long_v &&
426+
grep -q "deserialize/reject:args/verbose" verbose_test.log_v
427+
'
428+
390429
test_done

wt-status-deserialize.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
690690
/*
691691
* Copy over display-related fields from the current command.
692692
*/
693+
des_s->repo = cmd_s->repo;
693694
des_s->verbose = cmd_s->verbose;
694695
/* amend */
695696
/* whence */

0 commit comments

Comments
 (0)