Skip to content

Commit 78f4c68

Browse files
jeffhostetlerdscho
authored andcommitted
status: fix rename reporting when using serialization cache
Fix "git status --deserialize" to correctly report both pathnames for renames. Add a test case to verify. A change was made upstream that added an additional "rename_status" field to the "struct wt_status_change_data" structure. It is used during the various print routines to decide if 2 pathnames need to be printed. 5134ccd wt-status.c: rename rename-related fields in wt_status_change_data The fix here is to add that field to the status cache data. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 1787bf7 commit 78f4c68

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

t/t7524-serialized-status.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,16 @@ EOF
269269
270270
'
271271

272+
test_expect_success 'renames' '
273+
git init rename_test &&
274+
echo OLDNAME >rename_test/OLDNAME &&
275+
git -C rename_test add OLDNAME &&
276+
git -C rename_test commit -m OLDNAME &&
277+
git -C rename_test mv OLDNAME NEWNAME &&
278+
git -C rename_test status --serialize=renamed.dat >output.1 &&
279+
echo DIRT >rename_test/DIRT &&
280+
git -C rename_test status --deserialize=renamed.dat >output.2 &&
281+
test_i18ncmp output.1 output.2
282+
'
283+
272284
test_done

wt-status-deserialize.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ static int wt_deserialize_v1_changed_items(const struct wt_status *cmd_s,
200200
d->worktree_status = ntohl(sd->fixed.worktree_status);
201201
d->index_status = ntohl(sd->fixed.index_status);
202202
d->stagemask = ntohl(sd->fixed.stagemask);
203+
d->rename_status = ntohl(sd->fixed.rename_status);
203204
d->rename_score = ntohl(sd->fixed.rename_score);
204205
d->mode_head = ntohl(sd->fixed.mode_head);
205206
d->mode_index = ntohl(sd->fixed.mode_index);
@@ -218,10 +219,11 @@ static int wt_deserialize_v1_changed_items(const struct wt_status *cmd_s,
218219

219220
trace_printf_key(
220221
&trace_deserialize,
221-
"change: %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
222+
"change: %d %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
222223
d->worktree_status,
223224
d->index_status,
224225
d->stagemask,
226+
d->rename_status,
225227
d->rename_score,
226228
d->mode_head,
227229
d->mode_index,

wt-status-serialize.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ static inline void wt_serialize_v1_changed(struct wt_status *s, int fd,
7878
int len_path, len_rename_source;
7979

8080
trace_printf_key(&trace_serialize,
81-
"change: %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
81+
"change: %d %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
8282
d->worktree_status,
8383
d->index_status,
8484
d->stagemask,
85+
d->rename_status,
8586
d->rename_score,
8687
d->mode_head,
8788
d->mode_index,
@@ -96,6 +97,7 @@ static inline void wt_serialize_v1_changed(struct wt_status *s, int fd,
9697
sd.fixed.worktree_status = htonl(d->worktree_status);
9798
sd.fixed.index_status = htonl(d->index_status);
9899
sd.fixed.stagemask = htonl(d->stagemask);
100+
sd.fixed.rename_status = htonl(d->rename_status);
99101
sd.fixed.rename_score = htonl(d->rename_score);
100102
sd.fixed.mode_head = htonl(d->mode_head);
101103
sd.fixed.mode_index = htonl(d->mode_index);

wt-status.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ struct wt_status_serialize_data_fixed
158158
uint32_t worktree_status;
159159
uint32_t index_status;
160160
uint32_t stagemask;
161+
uint32_t rename_status;
161162
uint32_t rename_score;
162163
uint32_t mode_head;
163164
uint32_t mode_index;

0 commit comments

Comments
 (0)