Git fork

Merge branch 'rs/get-oid-with-flags-cleanup'

Code clean-up.

* rs/get-oid-with-flags-cleanup:
use repo_get_oid_with_flags()

+17 -50
+2 -5
builtin/ls-tree.c
··· 373 373 OPT_END() 374 374 }; 375 375 struct ls_tree_cmdmode_to_fmt *m2f = ls_tree_cmdmode_format; 376 - struct object_context obj_context = {0}; 377 376 int ret; 378 377 379 378 repo_config(the_repository, git_default_config, NULL); ··· 405 404 ls_tree_usage, ls_tree_options); 406 405 if (argc < 1) 407 406 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)) 411 409 die("Not a valid object name %s", argv[0]); 412 410 413 411 /* ··· 447 445 448 446 ret = !!read_tree(the_repository, tree, &options.pathspec, fn, &options); 449 447 clear_pathspec(&options.pathspec); 450 - object_context_release(&obj_context); 451 448 return ret; 452 449 }
+2 -5
builtin/rev-parse.c
··· 708 708 struct object_id oid; 709 709 unsigned int flags = 0; 710 710 const char *name = NULL; 711 - struct object_context unused; 712 711 struct strbuf buf = STRBUF_INIT; 713 712 int seen_end_of_options = 0; 714 713 enum format_type format = FORMAT_DEFAULT; ··· 1141 1140 name++; 1142 1141 type = REVERSED; 1143 1142 } 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)) { 1147 1145 if (output_algo) 1148 1146 repo_oid_to_algop(the_repository, &oid, 1149 1147 output_algo, &oid); ··· 1153 1151 show_rev(type, &oid, name); 1154 1152 continue; 1155 1153 } 1156 - object_context_release(&unused); 1157 1154 if (verify) 1158 1155 die_no_single_rev(quiet); 1159 1156 if (has_dashdash)
+5 -9
builtin/stash.c
··· 1089 1089 int quiet = 0; 1090 1090 const char *stash_msg = NULL; 1091 1091 struct object_id obj; 1092 - struct object_context dummy = {0}; 1093 1092 struct option options[] = { 1094 1093 OPT__QUIET(&quiet, N_("be quiet")), 1095 1094 OPT_STRING('m', "message", &stash_msg, "message", ··· 1109 1108 return -1; 1110 1109 } 1111 1110 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)) { 1115 1113 if (!quiet) 1116 1114 fprintf_ln(stderr, _("Cannot update %s with %s"), 1117 1115 ref_stash, argv[0]); ··· 1122 1120 ret = do_store_stash(&obj, stash_msg, quiet); 1123 1121 1124 1122 out: 1125 - object_context_release(&dummy); 1126 1123 return ret; 1127 1124 } 1128 1125 ··· 2238 2235 const char **argv) 2239 2236 { 2240 2237 struct object_id base; 2241 - struct object_context unused; 2242 2238 struct commit *prev; 2243 2239 struct commit_list *items = NULL, **iter = &items, *cur; 2244 2240 int res = 0; ··· 2272 2268 struct commit *stash; 2273 2269 2274 2270 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)) { 2278 2274 res = error(_("unable to find stash entry %s"), argv[i]); 2279 2275 goto out; 2280 2276 }
+3 -6
list-objects-filter.c
··· 524 524 struct filter *filter) 525 525 { 526 526 struct filter_sparse_data *d = xcalloc(1, sizeof(*d)); 527 - struct object_context oc; 528 527 struct object_id sparse_oid; 529 528 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)) 533 532 die(_("unable to access sparse blob in '%s'"), 534 533 filter_options->sparse_oid_name); 535 534 if (add_patterns_from_blob_to_list(&sparse_oid, "", 0, &d->pl) < 0) ··· 544 543 filter->filter_data = d; 545 544 filter->filter_object_fn = filter_sparse; 546 545 filter->free_fn = filter_sparse_free; 547 - 548 - object_context_release(&oc); 549 546 } 550 547 551 548 /*
+5 -25
object-name.c
··· 1857 1857 const char *name, 1858 1858 struct object_id *oid) 1859 1859 { 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); 1865 1861 } 1866 1862 1867 1863 int repo_get_oid_treeish(struct repository *r, 1868 1864 const char *name, 1869 1865 struct object_id *oid) 1870 1866 { 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); 1876 1868 } 1877 1869 1878 1870 int repo_get_oid_commit(struct repository *r, 1879 1871 const char *name, 1880 1872 struct object_id *oid) 1881 1873 { 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); 1887 1875 } 1888 1876 1889 1877 int repo_get_oid_tree(struct repository *r, 1890 1878 const char *name, 1891 1879 struct object_id *oid) 1892 1880 { 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); 1898 1882 } 1899 1883 1900 1884 int repo_get_oid_blob(struct repository *r, 1901 1885 const char *name, 1902 1886 struct object_id *oid) 1903 1887 { 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); 1909 1889 } 1910 1890 1911 1891 /* Must be called only when object_name:filename doesn't exist. */