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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Oct 15, 2017 at 22:07 UTC 0f05154c7064f82f122b845e0fe49a487d3a8d6e
3 files changed +5 -5
builtin/worktree.c
+3 -3
@@ -410,7 +410,7 @@ static void show_worktree_porcelain(struct worktree *wt)
410 if (wt->is_bare)
411 printf("bare\n");
412 else {
413 - printf("HEAD %s\n", sha1_to_hex(wt->head_sha1));
413 + printf("HEAD %s\n", oid_to_hex(&wt->head_oid));
414 if (wt->is_detached)
415 printf("detached\n");
416 else if (wt->head_ref)
@@ -430,7 +430,7 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
430 strbuf_addstr(&sb, "(bare)");
431 else {
432 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));
434 if (wt->is_detached)
435 strbuf_addstr(&sb, "(detached HEAD)");
436 else if (wt->head_ref) {
@@ -455,7 +455,7 @@ static void measure_widths(struct worktree **wt, int *abbrev, int *maxlen)
455
456 if (path_len > *maxlen)
457 *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));
459 if (sha1_len > *abbrev)
460 *abbrev = sha1_len;
461 }
worktree.c
+1 -1
@@ -31,7 +31,7 @@ static void add_head_info(struct worktree *wt)
31 target = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),
32 "HEAD",
33 0,
34 - wt->head_sha1, &flags);
34 + wt->head_oid.hash, &flags);
35 if (!target)
36 return;
37
worktree.h
+1 -1
@@ -8,7 +8,7 @@ struct worktree {
8 char *id;
9 char *head_ref; /* NULL if HEAD is broken or detached */
10 char *lock_reason; /* internal use */
11 - unsigned char head_sha1[20];
11 + struct object_id head_oid;
12 int is_detached;
13 int is_bare;
14 int is_current;