Skip to content

Commit 9b1adf3

Browse files
Merge pull request git-for-windows#157 from jeffhostetler/vfs-222-status-cache-untracked-hint
status: deserialize with -uno does not print correct hint
2 parents 58ad016 + bebbc42 commit 9b1adf3

File tree

2 files changed

+65
-6
lines changed

2 files changed

+65
-6
lines changed

t/t7524-serialized-status.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,59 @@ test_expect_success 'renames' '
333333
test_i18ncmp output.1 output.2
334334
'
335335

336+
test_expect_success 'hint message when cached with u=complete' '
337+
git init hint &&
338+
echo xxx >hint/xxx &&
339+
git -C hint add xxx &&
340+
git -C hint commit -m xxx &&
341+
342+
cat >expect.clean <<EOF &&
343+
On branch master
344+
nothing to commit, working tree clean
345+
EOF
346+
347+
cat >expect.use_u <<EOF &&
348+
On branch master
349+
nothing to commit (use -u to show untracked files)
350+
EOF
351+
352+
# Capture long format output from "no", "normal", and "all"
353+
# (without using status cache) and verify it matches expected
354+
# output.
355+
356+
git -C hint status --untracked-files=normal >hint.output_normal &&
357+
test_i18ncmp expect.clean hint.output_normal &&
358+
359+
git -C hint status --untracked-files=all >hint.output_all &&
360+
test_i18ncmp expect.clean hint.output_all &&
361+
362+
git -C hint status --untracked-files=no >hint.output_no &&
363+
test_i18ncmp expect.use_u hint.output_no &&
364+
365+
# Create long format output for "complete" and create status cache.
366+
367+
git -C hint status --untracked-files=complete --ignored=matching --serialize=../hint.dat >hint.output_complete &&
368+
test_i18ncmp expect.clean hint.output_complete &&
369+
370+
# Capture long format output using the status cache and verify
371+
# that the output matches the non-cached version. There are 2
372+
# ways to specify untracked-files, so do them both.
373+
374+
git -C hint status --deserialize=../hint.dat -unormal >hint.d1_normal &&
375+
test_i18ncmp expect.clean hint.d1_normal &&
376+
git -C hint -c status.showuntrackedfiles=normal status --deserialize=../hint.dat >hint.d2_normal &&
377+
test_i18ncmp expect.clean hint.d2_normal &&
378+
379+
git -C hint status --deserialize=../hint.dat -uall >hint.d1_all &&
380+
test_i18ncmp expect.clean hint.d1_all &&
381+
git -C hint -c status.showuntrackedfiles=all status --deserialize=../hint.dat >hint.d2_all &&
382+
test_i18ncmp expect.clean hint.d2_all &&
383+
384+
git -C hint status --deserialize=../hint.dat -uno >hint.d1_no &&
385+
test_i18ncmp expect.use_u hint.d1_no &&
386+
git -C hint -c status.showuntrackedfiles=no status --deserialize=../hint.dat >hint.d2_no &&
387+
test_i18ncmp expect.use_u hint.d2_no
388+
389+
'
390+
336391
test_done

wt-status-deserialize.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,24 @@ static int wt_deserialize_v1_ignored_items(struct wt_status *s,
442442
}
443443

444444
static int validate_untracked_files_arg(enum untracked_status_type cmd,
445-
enum untracked_status_type des,
445+
enum untracked_status_type *des,
446446
enum deserialize_parse_strategy *strategy)
447447
{
448448
*strategy = DESERIALIZE_STRATEGY_AS_IS;
449449

450-
if (cmd == des) {
450+
if (cmd == *des) {
451451
*strategy = DESERIALIZE_STRATEGY_AS_IS;
452452
} else if (cmd == SHOW_NO_UNTRACKED_FILES) {
453453
*strategy = DESERIALIZE_STRATEGY_SKIP;
454-
} else if (des == SHOW_COMPLETE_UNTRACKED_FILES) {
455-
if (cmd == SHOW_ALL_UNTRACKED_FILES)
454+
*des = cmd;
455+
} else if (*des == SHOW_COMPLETE_UNTRACKED_FILES) {
456+
if (cmd == SHOW_ALL_UNTRACKED_FILES) {
456457
*strategy = DESERIALIZE_STRATEGY_ALL;
457-
else if (cmd == SHOW_NORMAL_UNTRACKED_FILES)
458+
*des = cmd;
459+
} else if (cmd == SHOW_NORMAL_UNTRACKED_FILES) {
458460
*strategy = DESERIALIZE_STRATEGY_NORMAL;
461+
*des = cmd;
462+
}
459463
} else {
460464
return DESERIALIZE_ERR;
461465
}
@@ -497,7 +501,7 @@ static int wt_deserialize_v1(const struct wt_status *cmd_s, struct wt_status *s,
497501
* We now have the header parsed. Look at the command args (as passed in), and see how to parse
498502
* the serialized data
499503
*/
500-
if (validate_untracked_files_arg(cmd_s->show_untracked_files, s->show_untracked_files, &untracked_strategy)) {
504+
if (validate_untracked_files_arg(cmd_s->show_untracked_files, &s->show_untracked_files, &untracked_strategy)) {
501505
set_deserialize_reject_reason("args/untracked-files");
502506
trace_printf_key(&trace_deserialize, "reject: show_untracked_file: command: %d, serialized : %d",
503507
cmd_s->show_untracked_files,

0 commit comments

Comments
 (0)