strbuf: convert strbuf_add_unique_abbrev to use struct object_id
Convert the declaration and definition of strbuf_add_unique_abbrev to make it take a pointer to struct object_id. Predeclare the struct in strbuf.h, as cache.h includes strbuf.h before it declares the struct, and otherwise the struct declaration would have the wrong scope. Apply the following semantic patch, along with the standard object_id transforms, to adjust the callers: @@ expression E1, E2, E3; @@ - strbuf_add_unique_abbrev(E1, E2.hash, E3); + strbuf_add_unique_abbrev(E1, &E2, E3); @@ expression E1, E2, E3; @@ - strbuf_add_unique_abbrev(E1, E2->hash, E3); + strbuf_add_unique_abbrev(E1, E2, E3); Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
1776979573
commit
30e677e0e2
@ -1188,7 +1188,7 @@ static void abbrev_sha1_in_line(struct strbuf *line)
|
||||
strbuf_trim(split[1]);
|
||||
if (!get_oid(split[1]->buf, &oid)) {
|
||||
strbuf_reset(split[1]);
|
||||
strbuf_add_unique_abbrev(split[1], oid.hash,
|
||||
strbuf_add_unique_abbrev(split[1], &oid,
|
||||
DEFAULT_ABBREV);
|
||||
strbuf_addch(split[1], ' ');
|
||||
strbuf_reset(line);
|
||||
@ -1422,7 +1422,7 @@ static char *get_branch(const struct worktree *wt, const char *path)
|
||||
;
|
||||
else if (!get_oid_hex(sb.buf, &oid)) {
|
||||
strbuf_reset(&sb);
|
||||
strbuf_add_unique_abbrev(&sb, oid.hash, DEFAULT_ABBREV);
|
||||
strbuf_add_unique_abbrev(&sb, &oid, DEFAULT_ABBREV);
|
||||
} else if (!strcmp(sb.buf, "detached HEAD")) /* rebase */
|
||||
goto got_nothing;
|
||||
else /* bisect */
|
||||
@ -1459,7 +1459,7 @@ static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,
|
||||
if (!strcmp(cb->buf.buf, "HEAD")) {
|
||||
/* HEAD is relative. Resolve it to the right reflog entry. */
|
||||
strbuf_reset(&cb->buf);
|
||||
strbuf_add_unique_abbrev(&cb->buf, noid->hash, DEFAULT_ABBREV);
|
||||
strbuf_add_unique_abbrev(&cb->buf, noid, DEFAULT_ABBREV);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user