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>
raw | patch | inline | side by side (parent: 1776979 )
static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
strbuf_addstr(sb, " ");
static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
strbuf_addstr(sb, " ");
- strbuf_add_unique_abbrev(sb, commit->object.oid.hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(sb, &commit->object.oid , DEFAULT_ABBREV);
strbuf_addch(sb, ' ');
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
strbuf_addch(sb, ' ');
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
if (in_merge_bases(current, updated)) {
struct strbuf quickref = STRBUF_INIT;
int r;
if (in_merge_bases(current, updated)) {
struct strbuf quickref = STRBUF_INIT;
int r;
- strbuf_add_unique_abbrev(&quickref, current->object.oid.hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&quickref, ¤t->object.oid , DEFAULT_ABBREV);
strbuf_addstr(&quickref, "..");
strbuf_addstr(&quickref, "..");
- strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&quickref, &ref->new_oid , DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
(recurse_submodules != RECURSE_SUBMODULES_ON))
check_for_new_submodule_commits(&ref->new_oid);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
(recurse_submodules != RECURSE_SUBMODULES_ON))
check_for_new_submodule_commits(&ref->new_oid);
} else if (force || ref->force) {
struct strbuf quickref = STRBUF_INIT;
int r;
} else if (force || ref->force) {
struct strbuf quickref = STRBUF_INIT;
int r;
- strbuf_add_unique_abbrev(&quickref, current->object.oid.hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&quickref, ¤t->object.oid , DEFAULT_ABBREV);
strbuf_addstr(&quickref, "...");
strbuf_addstr(&quickref, "...");
- strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&quickref, &ref->new_oid , DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
(recurse_submodules != RECURSE_SUBMODULES_ON))
check_for_new_submodule_commits(&ref->new_oid);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
(recurse_submodules != RECURSE_SUBMODULES_ON))
check_for_new_submodule_commits(&ref->new_oid);
strbuf_addstr(sb, rla);
} else {
strbuf_addstr(sb, "tag: tagging ");
strbuf_addstr(sb, rla);
} else {
strbuf_addstr(sb, "tag: tagging ");
- strbuf_add_unique_abbrev(sb, oid->hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(sb, oid, DEFAULT_ABBREV);
}
strbuf_addstr(sb, " (");
}
strbuf_addstr(sb, " (");
strbuf_addf(&o->obuf, "virtual %s\n",
merge_remote_util(commit)->name);
else {
strbuf_addf(&o->obuf, "virtual %s\n",
merge_remote_util(commit)->name);
else {
- strbuf_add_unique_abbrev(&o->obuf, commit->object.oid.hash ,
+ strbuf_add_unique_abbrev(&o->obuf, &commit->object.oid ,
DEFAULT_ABBREV);
strbuf_addch(&o->obuf, ' ');
if (parse_commit(commit) != 0)
DEFAULT_ABBREV);
strbuf_addch(&o->obuf, ' ');
if (parse_commit(commit) != 0)
struct object_id *oidp = &parent->item->object.oid;
strbuf_addch(sb, ' ');
if (pp->abbrev)
struct object_id *oidp = &parent->item->object.oid;
strbuf_addch(sb, ' ');
if (pp->abbrev)
- strbuf_add_unique_abbrev(sb, oidp->hash , pp->abbrev);
+ strbuf_add_unique_abbrev(sb, oidp, pp->abbrev);
else
strbuf_addstr(sb, oid_to_hex(oidp));
parent = parent->next;
else
strbuf_addstr(sb, oid_to_hex(oidp));
parent = parent->next;
return 1;
case 'h': /* abbreviated commit hash */
strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT));
return 1;
case 'h': /* abbreviated commit hash */
strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT));
- strbuf_add_unique_abbrev(sb, commit->object.oid.hash ,
+ strbuf_add_unique_abbrev(sb, &commit->object.oid ,
c->pretty_ctx->abbrev);
strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_RESET));
return 1;
c->pretty_ctx->abbrev);
strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_RESET));
return 1;
strbuf_addstr(sb, oid_to_hex(&commit->tree->object.oid));
return 1;
case 't': /* abbreviated tree hash */
strbuf_addstr(sb, oid_to_hex(&commit->tree->object.oid));
return 1;
case 't': /* abbreviated tree hash */
- strbuf_add_unique_abbrev(sb, commit->tree->object.oid.hash ,
+ strbuf_add_unique_abbrev(sb, &commit->tree->object.oid ,
c->pretty_ctx->abbrev);
return 1;
case 'P': /* parent hashes */
c->pretty_ctx->abbrev);
return 1;
case 'P': /* parent hashes */
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
- strbuf_add_unique_abbrev(sb, p->item->object.oid.hash ,
+ strbuf_add_unique_abbrev(sb, &p->item->object.oid ,
c->pretty_ctx->abbrev);
}
return 1;
c->pretty_ctx->abbrev);
}
return 1;
strbuf_setlen(sb, sb->len + len);
}
strbuf_setlen(sb, sb->len + len);
}
-void strbuf_add_unique_abbrev(struct strbuf *sb, const unsigned char *sha1 ,
+void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid ,
int abbrev_len)
{
int r;
strbuf_grow(sb, GIT_SHA1_HEXSZ + 1);
int abbrev_len)
{
int r;
strbuf_grow(sb, GIT_SHA1_HEXSZ + 1);
- r = find_unique_abbrev_r(sb->buf + sb->len, sha1 , abbrev_len);
+ r = find_unique_abbrev_r(sb->buf + sb->len, oid->hash , abbrev_len);
strbuf_setlen(sb, sb->len + r);
}
strbuf_setlen(sb, sb->len + r);
}
extern char strbuf_slopbuf[];
#define STRBUF_INIT { .alloc = 0, .len = 0, .buf = strbuf_slopbuf }
extern char strbuf_slopbuf[];
#define STRBUF_INIT { .alloc = 0, .len = 0, .buf = strbuf_slopbuf }
+/*
+ * Predeclare this here, since cache.h includes this file before it defines the
+ * struct.
+ */
+struct object_id;
+
/**
* Life Cycle Functions
* --------------------
/**
* Life Cycle Functions
* --------------------
* the strbuf `sb`.
*/
extern void strbuf_add_unique_abbrev(struct strbuf *sb,
* the strbuf `sb`.
*/
extern void strbuf_add_unique_abbrev(struct strbuf *sb,
- const unsigned char *sha1 ,
+ const struct object_id *oid ,
output_header:
strbuf_addf(&sb, "Submodule %s ", path);
output_header:
strbuf_addf(&sb, "Submodule %s ", path);
- strbuf_add_unique_abbrev(&sb, one->hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);
strbuf_addstr(&sb, (fast_backward || fast_forward) ? ".." : "...");
strbuf_addstr(&sb, (fast_backward || fast_forward) ? ".." : "...");
- strbuf_add_unique_abbrev(&sb, two->hash , DEFAULT_ABBREV);
+ strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);
if (message)
strbuf_addf(&sb, " %s\n", message);
else
if (message)
strbuf_addf(&sb, " %s\n", message);
else
char type;
const char *msg;
char type;
const char *msg;
- strbuf_add_unique_abbrev(&quickref, ref->old_oid.hash ,
+ strbuf_add_unique_abbrev(&quickref, &ref->old_oid ,
DEFAULT_ABBREV);
if (ref->forced_update) {
strbuf_addstr(&quickref, "...");
DEFAULT_ABBREV);
if (ref->forced_update) {
strbuf_addstr(&quickref, "...");
type = ' ';
msg = NULL;
}
type = ' ';
msg = NULL;
}
- strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash ,
+ strbuf_add_unique_abbrev(&quickref, &ref->new_oid ,
DEFAULT_ABBREV);
print_ref_status(type, quickref.buf, ref, ref->peer_ref, msg,
DEFAULT_ABBREV);
print_ref_status(type, quickref.buf, ref, ref->peer_ref, msg,
strbuf_trim(split[1]);
if (!get_oid(split[1]->buf, &oid)) {
strbuf_reset(split[1]);
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);
DEFAULT_ABBREV);
strbuf_addch(split[1], ' ');
strbuf_reset(line);
;
else if (!get_oid_hex(sb.buf, &oid)) {
strbuf_reset(&sb);
;
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 */
} else if (!strcmp(sb.buf, "detached HEAD")) /* rebase */
goto got_nothing;
else /* bisect */
if (!strcmp(cb->buf.buf, "HEAD")) {
/* HEAD is relative. Resolve it to the right reflog entry. */
strbuf_reset(&cb->buf);
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);