| 239 | } |
| 240 | |
| 241 | static 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 | |
| 271 | out: |
| 272 | strbuf_release(&unused_referent); |
| 273 | return ret; |
| 274 | } |
| 275 | |
| 276 | static int hash_callback(const struct option *opt, const char *arg, int unset) |
| 277 | { |
no test coverage detected