Skip to content

Commit

Permalink
Teach ahead-behind and serialized status to play nicely together
Browse files Browse the repository at this point in the history
  • Loading branch information
jamill authored and derrickstolee committed May 18, 2020
1 parent 3a57194 commit 1ae89a5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions t/t7524-serialized-status.sh
Expand Up @@ -137,4 +137,30 @@ test_expect_success 'verify serialized status handles path scopes' '
test_i18ncmp expect output
'

test_expect_success 'verify no-ahead-behind and serialized status integration' '
test_when_finished "rm serialized_status.dat new_change.txt output" &&
cat >expect <<-\EOF &&
# branch.oid 68d4a437ea4c2de65800f48c053d4d543b55c410
# branch.head alt_branch
# branch.upstream master
# branch.ab +1 -0
? expect
? serialized_status.dat
? untracked/
? untracked_1.txt
EOF
git checkout -b alt_branch master --track >/dev/null &&
touch alt_branch_changes.txt &&
git add alt_branch_changes.txt &&
test_tick &&
git commit -m"New commit on alt branch" &&
git status --untracked-files=complete --ignored=matching --serialize >serialized_status.dat &&
touch new_change.txt &&
git -c status.aheadBehind=false status --porcelain=v2 --branch --ahead-behind --deserialize=serialized_status.dat >output &&
test_i18ncmp expect output
'

test_done
3 changes: 2 additions & 1 deletion wt-status-deserialize.c
Expand Up @@ -510,6 +510,7 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
/* show_branch */
/* show_stash */
/* hints */
/* ahead_behind_flags */
if (cmd_s->detect_rename != des_s->detect_rename) {
trace_printf_key(&trace_deserialize, "reject: detect_rename");
return DESERIALIZE_ERR;
Expand Down Expand Up @@ -548,6 +549,7 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
des_s->show_branch = cmd_s->show_branch;
des_s->show_stash = cmd_s->show_stash;
/* hints */
des_s->ahead_behind_flags = cmd_s->ahead_behind_flags;
des_s->status_format = cmd_s->status_format;
des_s->fp = cmd_s->fp;
if (cmd_s->prefix && *cmd_s->prefix)
Expand All @@ -556,7 +558,6 @@ static int wt_deserialize_fd(const struct wt_status *cmd_s, struct wt_status *de
return DESERIALIZE_OK;
}


/*
* Read raw serialized status data from the given file
*
Expand Down
1 change: 1 addition & 0 deletions wt-status-serialize.c
Expand Up @@ -48,6 +48,7 @@ static void wt_serialize_v1_header(struct wt_status *s, int fd)
/* show_branch */
/* show_stash */
packet_write_fmt(fd, "hints %d\n", s->hints);
/* ahead_behind_flags */
packet_write_fmt(fd, "detect_rename %d\n", s->detect_rename);
packet_write_fmt(fd, "rename_score %d\n", s->rename_score);
packet_write_fmt(fd, "rename_limit %d\n", s->rename_limit);
Expand Down

0 comments on commit 1ae89a5

Please sign in to comment.