Skip to content

Commit aab9583

Browse files
bk2204gitster
authored andcommitted
Convert find_unique_abbrev* to struct object_id
Convert find_unique_abbrev and find_unique_abbrev_r to each take a pointer to struct object_id. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 40f5555 commit aab9583

28 files changed

+61
-59
lines changed

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ static int read_ancestry(const char *graft_file)
499499

500500
static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect)
501501
{
502-
const char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash,
502+
const char *uniq = find_unique_abbrev(&suspect->commit->object.oid,
503503
auto_abbrev);
504504
int len = strlen(uniq);
505505
if (auto_abbrev < len)

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
273273
bname.buf,
274274
(flags & REF_ISBROKEN) ? "broken"
275275
: (flags & REF_ISSYMREF) ? target
276-
: find_unique_abbrev(oid.hash, DEFAULT_ABBREV));
276+
: find_unique_abbrev(&oid, DEFAULT_ABBREV));
277277
}
278278
delete_branch_config(bname.buf);
279279

builtin/checkout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,10 @@ static void describe_detached_head(const char *msg, struct commit *commit)
405405
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
406406
if (print_sha1_ellipsis()) {
407407
fprintf(stderr, "%s %s... %s\n", msg,
408-
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
408+
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
409409
} else {
410410
fprintf(stderr, "%s %s %s\n", msg,
411-
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
411+
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV), sb.buf);
412412
}
413413
strbuf_release(&sb);
414414
}
@@ -778,7 +778,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
778778
" git branch <new-branch-name> %s\n\n",
779779
/* Give ngettext() the count */
780780
lost),
781-
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
781+
find_unique_abbrev(&commit->object.oid, DEFAULT_ABBREV));
782782
}
783783

784784
/*

builtin/describe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void append_name(struct commit_name *n, struct strbuf *dst)
285285

286286
static void append_suffix(int depth, const struct object_id *oid, struct strbuf *dst)
287287
{
288-
strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid->hash, abbrev));
288+
strbuf_addf(dst, "-%d-g%s", depth, find_unique_abbrev(oid, abbrev));
289289
}
290290

291291
static void describe_commit(struct object_id *oid, struct strbuf *dst)
@@ -383,7 +383,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
383383
if (!match_cnt) {
384384
struct object_id *cmit_oid = &cmit->object.oid;
385385
if (always) {
386-
strbuf_add_unique_abbrev(dst, cmit_oid->hash, abbrev);
386+
strbuf_add_unique_abbrev(dst, cmit_oid, abbrev);
387387
if (suffix)
388388
strbuf_addstr(dst, suffix);
389389
return;

builtin/log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,12 +1873,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
18731873
{
18741874
if (!verbose) {
18751875
fprintf(file, "%c %s\n", sign,
1876-
find_unique_abbrev(commit->object.oid.hash, abbrev));
1876+
find_unique_abbrev(&commit->object.oid, abbrev));
18771877
} else {
18781878
struct strbuf buf = STRBUF_INIT;
18791879
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
18801880
fprintf(file, "%c %s %s\n", sign,
1881-
find_unique_abbrev(commit->object.oid.hash, abbrev),
1881+
find_unique_abbrev(&commit->object.oid, abbrev),
18821882
buf.buf);
18831883
strbuf_release(&buf);
18841884
}

builtin/ls-files.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
240240
printf("%s%06o %s %d\t",
241241
tag,
242242
ce->ce_mode,
243-
find_unique_abbrev(ce->oid.hash, abbrev),
243+
find_unique_abbrev(&ce->oid, abbrev),
244244
ce_stage(ce));
245245
}
246246
write_eolinfo(repo->index, ce, fullname);
@@ -271,7 +271,7 @@ static void show_ru_info(const struct index_state *istate)
271271
if (!ui->mode[i])
272272
continue;
273273
printf("%s%06o %s %d\t", tag_resolve_undo, ui->mode[i],
274-
find_unique_abbrev(ui->oid[i].hash, abbrev),
274+
find_unique_abbrev(&ui->oid[i], abbrev),
275275
i + 1);
276276
write_name(path);
277277
}

builtin/ls-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ static int show_tree(const struct object_id *oid, struct strbuf *base,
103103
} else
104104
xsnprintf(size_text, sizeof(size_text), "-");
105105
printf("%06o %s %s %7s\t", mode, type,
106-
find_unique_abbrev(oid->hash, abbrev),
106+
find_unique_abbrev(oid, abbrev),
107107
size_text);
108108
} else
109109
printf("%06o %s %s\t", mode, type,
110-
find_unique_abbrev(oid->hash, abbrev));
110+
find_unique_abbrev(oid, abbrev));
111111
}
112112
baselen = base->len;
113113
strbuf_addstr(base, pathname);

builtin/merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
13271327

13281328
check_commit_signature(commit, &signature_check);
13291329

1330-
find_unique_abbrev_r(hex, commit->object.oid.hash, DEFAULT_ABBREV);
1330+
find_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV);
13311331
switch (signature_check.result) {
13321332
case 'G':
13331333
break;
@@ -1420,9 +1420,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
14201420

14211421
if (verbosity >= 0) {
14221422
printf(_("Updating %s..%s\n"),
1423-
find_unique_abbrev(head_commit->object.oid.hash,
1423+
find_unique_abbrev(&head_commit->object.oid,
14241424
DEFAULT_ABBREV),
1425-
find_unique_abbrev(remoteheads->item->object.oid.hash,
1425+
find_unique_abbrev(&remoteheads->item->object.oid,
14261426
DEFAULT_ABBREV));
14271427
}
14281428
strbuf_addstr(&msg, "Fast-forward");

builtin/name-rev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static void show_name(const struct object *obj,
328328
else if (allow_undefined)
329329
printf("undefined\n");
330330
else if (always)
331-
printf("%s\n", find_unique_abbrev(oid->hash, DEFAULT_ABBREV));
331+
printf("%s\n", find_unique_abbrev(oid, DEFAULT_ABBREV));
332332
else
333333
die("cannot describe '%s'", oid_to_hex(oid));
334334
strbuf_release(&buf);

builtin/receive-pack.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,11 +1242,11 @@ static void check_aliased_update(struct command *cmd, struct string_list *list)
12421242
rp_error("refusing inconsistent update between symref '%s' (%s..%s) and"
12431243
" its target '%s' (%s..%s)",
12441244
cmd->ref_name,
1245-
find_unique_abbrev(cmd->old_oid.hash, DEFAULT_ABBREV),
1246-
find_unique_abbrev(cmd->new_oid.hash, DEFAULT_ABBREV),
1245+
find_unique_abbrev(&cmd->old_oid, DEFAULT_ABBREV),
1246+
find_unique_abbrev(&cmd->new_oid, DEFAULT_ABBREV),
12471247
dst_cmd->ref_name,
1248-
find_unique_abbrev(dst_cmd->old_oid.hash, DEFAULT_ABBREV),
1249-
find_unique_abbrev(dst_cmd->new_oid.hash, DEFAULT_ABBREV));
1248+
find_unique_abbrev(&dst_cmd->old_oid, DEFAULT_ABBREV),
1249+
find_unique_abbrev(&dst_cmd->new_oid, DEFAULT_ABBREV));
12501250

12511251
cmd->error_string = dst_cmd->error_string =
12521252
"inconsistent aliased update";

0 commit comments

Comments
 (0)