Skip to content

Commit bd42007

Browse files
jeffhostetlerdscho
authored andcommitted
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 bbfe83c + 5bcf4cd commit bd42007

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
@@ -332,4 +332,59 @@ test_expect_success 'renames' '
332332
test_i18ncmp output.1 output.2
333333
'
334334

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