Skip to content

Commit 0f05154

Browse files
bk2204gitster
authored andcommitted
worktree: convert struct worktree to object_id
Convert the head_sha1 member to be head_oid instead. This is required to convert resolve_ref_unsafe. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a98e610 commit 0f05154

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

builtin/worktree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static void show_worktree_porcelain(struct worktree *wt)
410410
if (wt->is_bare)
411411
printf("bare\n");
412412
else {
413-
printf("HEAD %s\n", sha1_to_hex(wt->head_sha1));
413+
printf("HEAD %s\n", oid_to_hex(&wt->head_oid));
414414
if (wt->is_detached)
415415
printf("detached\n");
416416
else if (wt->head_ref)
@@ -430,7 +430,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
430430
strbuf_addstr(&sb, "(bare)");
431431
else {
432432
strbuf_addf(&sb, "%-*s ", abbrev_len,
433-
find_unique_abbrev(wt->head_sha1, DEFAULT_ABBREV));
433+
find_unique_abbrev(wt->head_oid.hash, DEFAULT_ABBREV));
434434
if (wt->is_detached)
435435
strbuf_addstr(&sb, "(detached HEAD)");
436436
else if (wt->head_ref) {
@@ -455,7 +455,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)
455455

456456
if (path_len > *maxlen)
457457
*maxlen = path_len;
458-
sha1_len = strlen(find_unique_abbrev(wt[i]->head_sha1, *abbrev));
458+
sha1_len = strlen(find_unique_abbrev(wt[i]->head_oid.hash, *abbrev));
459459
if (sha1_len > *abbrev)
460460
*abbrev = sha1_len;
461461
}

worktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void add_head_info(struct worktree *wt)
3131
target = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),
3232
"HEAD",
3333
0,
34-
wt->head_sha1, &flags);
34+
wt->head_oid.hash, &flags);
3535
if (!target)
3636
return;
3737

worktree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ struct worktree {
88
char *id;
99
char *head_ref; /* NULL if HEAD is broken or detached */
1010
char *lock_reason; /* internal use */
11-
unsigned char head_sha1[20];
11+
struct object_id head_oid;
1212
int is_detached;
1313
int is_bare;
1414
int is_current;

0 commit comments

Comments
 (0)