MCPcopy Create free account
hub / github.com/git/git / cmd_show_ref__exists

Function cmd_show_ref__exists

builtin/show-ref.c:241–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241static int cmd_show_ref__exists(const char **refs)
242{
243 struct strbuf unused_referent = STRBUF_INIT;
244 struct object_id unused_oid;
245 unsigned int unused_type;
246 int failure_errno = 0;
247 const char *ref;
248 int ret = 0;
249
250 if (!refs || !*refs)
251 die("--exists requires a reference");
252 ref = *refs++;
253 if (*refs)
254 die("--exists requires exactly one reference");
255
256 if (refs_read_raw_ref(get_main_ref_store(the_repository), ref,
257 &unused_oid, &unused_referent, &unused_type,
258 &failure_errno)) {
259 if (failure_errno == ENOENT || failure_errno == EISDIR) {
260 error(_("reference does not exist"));
261 ret = 2;
262 } else {
263 errno = failure_errno;
264 error_errno(_("failed to look up reference"));
265 ret = 1;
266 }
267
268 goto out;
269 }
270
271out:
272 strbuf_release(&unused_referent);
273 return ret;
274}
275
276static int hash_callback(const struct option *opt, const char *arg, int unset)
277{

Callers 1

cmd_show_refFunction · 0.85

Calls 6

refs_read_raw_refFunction · 0.85
get_main_ref_storeFunction · 0.85
errorFunction · 0.85
error_errnoFunction · 0.85
strbuf_releaseFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected