Skip to content

Commit 7c15d99

Browse files
committed
Merge branch 'rs/get-oid-with-flags-cleanup'
Code clean-up. * rs/get-oid-with-flags-cleanup: use repo_get_oid_with_flags()
2 parents 2e8d756 + a66fc22 commit 7c15d99

File tree

5 files changed

+17
-50
lines changed

5 files changed

+17
-50
lines changed

builtin/ls-tree.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ int cmd_ls_tree(int argc,
373373
OPT_END()
374374
};
375375
struct ls_tree_cmdmode_to_fmt *m2f = ls_tree_cmdmode_format;
376-
struct object_context obj_context = {0};
377376
int ret;
378377

379378
repo_config(the_repository, git_default_config, NULL);
@@ -405,9 +404,8 @@ int cmd_ls_tree(int argc,
405404
ls_tree_usage, ls_tree_options);
406405
if (argc < 1)
407406
usage_with_options(ls_tree_usage, ls_tree_options);
408-
if (get_oid_with_context(the_repository, argv[0],
409-
GET_OID_HASH_ANY, &oid,
410-
&obj_context))
407+
if (repo_get_oid_with_flags(the_repository, argv[0], &oid,
408+
GET_OID_HASH_ANY))
411409
die("Not a valid object name %s", argv[0]);
412410

413411
/*
@@ -447,6 +445,5 @@ int cmd_ls_tree(int argc,
447445

448446
ret = !!read_tree(the_repository, tree, &options.pathspec, fn, &options);
449447
clear_pathspec(&options.pathspec);
450-
object_context_release(&obj_context);
451448
return ret;
452449
}

builtin/rev-parse.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ int cmd_rev_parse(int argc,
708708
struct object_id oid;
709709
unsigned int flags = 0;
710710
const char *name = NULL;
711-
struct object_context unused;
712711
struct strbuf buf = STRBUF_INIT;
713712
int seen_end_of_options = 0;
714713
enum format_type format = FORMAT_DEFAULT;
@@ -1141,9 +1140,8 @@ int cmd_rev_parse(int argc,
11411140
name++;
11421141
type = REVERSED;
11431142
}
1144-
if (!get_oid_with_context(the_repository, name,
1145-
flags, &oid, &unused)) {
1146-
object_context_release(&unused);
1143+
if (!repo_get_oid_with_flags(the_repository, name, &oid,
1144+
flags)) {
11471145
if (output_algo)
11481146
repo_oid_to_algop(the_repository, &oid,
11491147
output_algo, &oid);
@@ -1153,7 +1151,6 @@ int cmd_rev_parse(int argc,
11531151
show_rev(type, &oid, name);
11541152
continue;
11551153
}
1156-
object_context_release(&unused);
11571154
if (verify)
11581155
die_no_single_rev(quiet);
11591156
if (has_dashdash)

builtin/stash.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,6 @@ static int store_stash(int argc, const char **argv, const char *prefix,
10891089
int quiet = 0;
10901090
const char *stash_msg = NULL;
10911091
struct object_id obj;
1092-
struct object_context dummy = {0};
10931092
struct option options[] = {
10941093
OPT__QUIET(&quiet, N_("be quiet")),
10951094
OPT_STRING('m', "message", &stash_msg, "message",
@@ -1109,9 +1108,8 @@ static int store_stash(int argc, const char **argv, const char *prefix,
11091108
return -1;
11101109
}
11111110

1112-
if (get_oid_with_context(the_repository,
1113-
argv[0], quiet ? GET_OID_QUIETLY : 0, &obj,
1114-
&dummy)) {
1111+
if (repo_get_oid_with_flags(the_repository, argv[0], &obj,
1112+
quiet ? GET_OID_QUIETLY : 0)) {
11151113
if (!quiet)
11161114
fprintf_ln(stderr, _("Cannot update %s with %s"),
11171115
ref_stash, argv[0]);
@@ -1122,7 +1120,6 @@ static int store_stash(int argc, const char **argv, const char *prefix,
11221120
ret = do_store_stash(&obj, stash_msg, quiet);
11231121

11241122
out:
1125-
object_context_release(&dummy);
11261123
return ret;
11271124
}
11281125

@@ -2238,7 +2235,6 @@ static int do_export_stash(struct repository *r,
22382235
const char **argv)
22392236
{
22402237
struct object_id base;
2241-
struct object_context unused;
22422238
struct commit *prev;
22432239
struct commit_list *items = NULL, **iter = &items, *cur;
22442240
int res = 0;
@@ -2272,9 +2268,9 @@ static int do_export_stash(struct repository *r,
22722268
struct commit *stash;
22732269

22742270
if (parse_stash_revision(&revision, argv[i], 1) ||
2275-
get_oid_with_context(r, revision.buf,
2276-
GET_OID_QUIETLY | GET_OID_GENTLY,
2277-
&oid, &unused)) {
2271+
repo_get_oid_with_flags(r, revision.buf, &oid,
2272+
GET_OID_QUIETLY |
2273+
GET_OID_GENTLY)) {
22782274
res = error(_("unable to find stash entry %s"), argv[i]);
22792275
goto out;
22802276
}

list-objects-filter.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,11 @@ static void filter_sparse_oid__init(
524524
struct filter *filter)
525525
{
526526
struct filter_sparse_data *d = xcalloc(1, sizeof(*d));
527-
struct object_context oc;
528527
struct object_id sparse_oid;
529528

530-
if (get_oid_with_context(the_repository,
531-
filter_options->sparse_oid_name,
532-
GET_OID_BLOB, &sparse_oid, &oc))
529+
if (repo_get_oid_with_flags(the_repository,
530+
filter_options->sparse_oid_name,
531+
&sparse_oid, GET_OID_BLOB))
533532
die(_("unable to access sparse blob in '%s'"),
534533
filter_options->sparse_oid_name);
535534
if (add_patterns_from_blob_to_list(&sparse_oid, "", 0, &d->pl) < 0)
@@ -544,8 +543,6 @@ static void filter_sparse_oid__init(
544543
filter->filter_data = d;
545544
filter->filter_object_fn = filter_sparse;
546545
filter->free_fn = filter_sparse_free;
547-
548-
object_context_release(&oc);
549546
}
550547

551548
/*

object-name.c

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,55 +1857,35 @@ int repo_get_oid_committish(struct repository *r,
18571857
const char *name,
18581858
struct object_id *oid)
18591859
{
1860-
struct object_context unused;
1861-
int ret = get_oid_with_context(r, name, GET_OID_COMMITTISH,
1862-
oid, &unused);
1863-
object_context_release(&unused);
1864-
return ret;
1860+
return repo_get_oid_with_flags(r, name, oid, GET_OID_COMMITTISH);
18651861
}
18661862

18671863
int repo_get_oid_treeish(struct repository *r,
18681864
const char *name,
18691865
struct object_id *oid)
18701866
{
1871-
struct object_context unused;
1872-
int ret = get_oid_with_context(r, name, GET_OID_TREEISH,
1873-
oid, &unused);
1874-
object_context_release(&unused);
1875-
return ret;
1867+
return repo_get_oid_with_flags(r, name, oid, GET_OID_TREEISH);
18761868
}
18771869

18781870
int repo_get_oid_commit(struct repository *r,
18791871
const char *name,
18801872
struct object_id *oid)
18811873
{
1882-
struct object_context unused;
1883-
int ret = get_oid_with_context(r, name, GET_OID_COMMIT,
1884-
oid, &unused);
1885-
object_context_release(&unused);
1886-
return ret;
1874+
return repo_get_oid_with_flags(r, name, oid, GET_OID_COMMIT);
18871875
}
18881876

18891877
int repo_get_oid_tree(struct repository *r,
18901878
const char *name,
18911879
struct object_id *oid)
18921880
{
1893-
struct object_context unused;
1894-
int ret = get_oid_with_context(r, name, GET_OID_TREE,
1895-
oid, &unused);
1896-
object_context_release(&unused);
1897-
return ret;
1881+
return repo_get_oid_with_flags(r, name, oid, GET_OID_TREE);
18981882
}
18991883

19001884
int repo_get_oid_blob(struct repository *r,
19011885
const char *name,
19021886
struct object_id *oid)
19031887
{
1904-
struct object_context unused;
1905-
int ret = get_oid_with_context(r, name, GET_OID_BLOB,
1906-
oid, &unused);
1907-
object_context_release(&unused);
1908-
return ret;
1888+
return repo_get_oid_with_flags(r, name, oid, GET_OID_BLOB);
19091889
}
19101890

19111891
/* Must be called only when object_name:filename doesn't exist. */

0 commit comments

Comments
 (0)