Skip to content

Commit 64e4ba5

Browse files
jamillderrickstolee
authored andcommitted
Teach ahead-behind and serialized status to play nicely together
1 parent 3ce006c commit 64e4ba5

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

t/t7522-serialized-status.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ test_expect_success 'setup' '
4747
git commit -m"Adding original file." &&
4848
mkdir untracked &&
4949
touch ignored.ign ignored_dir/ignored_2.txt \
50-
untracked_1.txt untracked/untracked_2.txt untracked/untracked_3.txt
50+
untracked_1.txt untracked/untracked_2.txt untracked/untracked_3.txt &&
51+
52+
test_oid_cache <<-EOF
53+
branch_oid sha1:68d4a437ea4c2de65800f48c053d4d543b55c410
54+
55+
branch_oid sha256:6b95e4b1ea911dad213f2020840f5e92d3066cf9e38cf35f79412ec58d409ce4
56+
EOF
5157
'
5258

5359
test_expect_success 'verify untracked-files=complete with no conversion' '
@@ -138,4 +144,30 @@ test_expect_success 'verify serialized status handles path scopes' '
138144
test_cmp expect output
139145
'
140146

147+
test_expect_success 'verify no-ahead-behind and serialized status integration' '
148+
test_when_finished "rm serialized_status.dat new_change.txt output" &&
149+
cat >expect <<-EOF &&
150+
# branch.oid $(test_oid branch_oid)
151+
# branch.head alt_branch
152+
# branch.upstream main
153+
# branch.ab +1 -0
154+
? expect
155+
? serialized_status.dat
156+
? untracked/
157+
? untracked_1.txt
158+
EOF
159+
160+
git checkout -b alt_branch main --track >/dev/null &&
161+
touch alt_branch_changes.txt &&
162+
git add alt_branch_changes.txt &&
163+
test_tick &&
164+
git commit -m"New commit on alt branch" &&
165+
166+
git status --untracked-files=complete --ignored=matching --serialize >serialized_status.dat &&
167+
touch new_change.txt &&
168+
169+
git -c status.aheadBehind=false status --porcelain=v2 --branch --ahead-behind --deserialize=serialized_status.dat >output &&
170+
test_cmp expect output
171+
'
172+
141173
test_done

wt-status-deserialize.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
513513
/* show_branch */
514514
/* show_stash */
515515
/* hints */
516+
/* ahead_behind_flags */
516517
if (cmd_s->detect_rename != des_s->detect_rename) {
517518
trace_printf_key(&trace_deserialize, "reject: detect_rename");
518519
return DESERIALIZE_ERR;
@@ -551,6 +552,7 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
551552
des_s->show_branch = cmd_s->show_branch;
552553
des_s->show_stash = cmd_s->show_stash;
553554
/* hints */
555+
des_s->ahead_behind_flags = cmd_s->ahead_behind_flags;
554556
des_s->status_format = cmd_s->status_format;
555557
des_s->fp = cmd_s->fp;
556558
if (cmd_s->prefix && *cmd_s->prefix)
@@ -559,7 +561,6 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
559561
return DESERIALIZE_OK;
560562
}
561563

562-
563564
/*
564565
* Read raw serialized status data from the given file
565566
*

wt-status-serialize.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void wt_serialize_v1_header(struct wt_status *s, int fd)
4848
/* show_branch */
4949
/* show_stash */
5050
packet_write_fmt(fd, "hints %d\n", s->hints);
51+
/* ahead_behind_flags */
5152
packet_write_fmt(fd, "detect_rename %d\n", s->detect_rename);
5253
packet_write_fmt(fd, "rename_score %d\n", s->rename_score);
5354
packet_write_fmt(fd, "rename_limit %d\n", s->rename_limit);

0 commit comments

Comments
 (0)