Skip to content

Commit 813cfbb

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 <jeffhost@microsoft.com>
1 parent 7011585 commit 813cfbb

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

t/t7522-serialized-status.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,16 @@ EOF
281281
282282
'
283283

284+
test_expect_success 'renames' '
285+
git init -b main rename_test &&
286+
echo OLDNAME >rename_test/OLDNAME &&
287+
git -C rename_test add OLDNAME &&
288+
git -C rename_test commit -m OLDNAME &&
289+
git -C rename_test mv OLDNAME NEWNAME &&
290+
git -C rename_test status --serialize=renamed.dat >output.1 &&
291+
echo DIRT >rename_test/DIRT &&
292+
git -C rename_test status --deserialize=renamed.dat >output.2 &&
293+
test_cmp output.1 output.2
294+
'
295+
284296
test_done

wt-status-deserialize.c

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

220221
trace_printf_key(
221222
&trace_deserialize,
222-
"change: %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
223+
"change: %d %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
223224
d->worktree_status,
224225
d->index_status,
225226
d->stagemask,
227+
d->rename_status,
226228
d->rename_score,
227229
d->mode_head,
228230
d->mode_index,

wt-status-serialize.c

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

8181
trace_printf_key(&trace_serialize,
82-
"change: %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
82+
"change: %d %d %d %d %d %o %o %o %d %d %s %s '%s' '%s'",
8383
d->worktree_status,
8484
d->index_status,
8585
d->stagemask,
86+
d->rename_status,
8687
d->rename_score,
8788
d->mode_head,
8889
d->mode_index,
@@ -97,6 +98,7 @@ static inline void wt_serialize_v1_changed(struct wt_status *s, int fd,
9798
sd.fixed.worktree_status = htonl(d->worktree_status);
9899
sd.fixed.index_status = htonl(d->index_status);
99100
sd.fixed.stagemask = htonl(d->stagemask);
101+
sd.fixed.rename_status = htonl(d->rename_status);
100102
sd.fixed.rename_score = htonl(d->rename_score);
101103
sd.fixed.mode_head = htonl(d->mode_head);
102104
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
@@ -193,6 +193,7 @@ struct wt_status_serialize_data_fixed
193193
uint32_t worktree_status;
194194
uint32_t index_status;
195195
uint32_t stagemask;
196+
uint32_t rename_status;
196197
uint32_t rename_score;
197198
uint32_t mode_head;
198199
uint32_t mode_index;

0 commit comments

Comments
 (0)