Skip to content

Commit d02a363

Browse files
jamilldscho
authored andcommitted
Teach ahead-behind and serialized status to play nicely together
1 parent 69aa356 commit d02a363

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
@@ -524,6 +524,7 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
524524
/* show_branch */
525525
/* show_stash */
526526
/* hints */
527+
/* ahead_behind_flags */
527528
if (cmd_s->detect_rename != des_s->detect_rename) {
528529
trace_printf_key(&trace_deserialize, "reject: detect_rename");
529530
return DESERIALIZE_ERR;
@@ -562,6 +563,7 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
562563
des_s->show_branch = cmd_s->show_branch;
563564
des_s->show_stash = cmd_s->show_stash;
564565
/* hints */
566+
des_s->ahead_behind_flags = cmd_s->ahead_behind_flags;
565567
des_s->status_format = cmd_s->status_format;
566568
des_s->fp = cmd_s->fp;
567569
if (cmd_s->prefix && *cmd_s->prefix)
@@ -570,7 +572,6 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
570572
return DESERIALIZE_OK;
571573
}
572574

573-
574575
/*
575576
* Read raw serialized status data from the given file
576577
*

wt-status-serialize.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static void wt_serialize_v1_header(struct wt_status *s, int fd)
5252
/* show_branch */
5353
/* show_stash */
5454
packet_write_fmt(fd, "hints %d\n", s->hints);
55+
/* ahead_behind_flags */
5556
packet_write_fmt(fd, "detect_rename %d\n", s->detect_rename);
5657
packet_write_fmt(fd, "rename_score %d\n", s->rename_score);
5758
packet_write_fmt(fd, "rename_limit %d\n", s->rename_limit);

0 commit comments

Comments
 (0)