| 700 | } |
| 701 | |
| 702 | static bool gf_resolve(cbm_git_facts_t *facts, const char *ref, char out[65], |
| 703 | cbm_git_facts_error_t *error) { |
| 704 | size_t n = gf_input_length(ref); |
| 705 | if (n == SIZE_MAX || n == 0 || ref[0] == '-') |
| 706 | return gf_error(error, CBM_GIT_FACTS_INVALID, "A bounded commit reference is required"); |
| 707 | char *peel = cbm_arena_alloc(&facts->arena, n + sizeof("^{commit}")); |
| 708 | if (!peel) |
| 709 | return gf_error(error, CBM_GIT_FACTS_OOM, "Cannot retain commit reference"); |
| 710 | memcpy(peel, ref, n); |
| 711 | memcpy(peel + n, "^{commit}", sizeof("^{commit}")); |
| 712 | const char *args[] = {"rev-parse", "--verify", "--end-of-options", peel}; |
| 713 | gf_result_t result; |
| 714 | return gf_run(facts, args, 4, false, &result, error) && |
| 715 | gf_oid_line(facts, &result.out, out, error); |
| 716 | } |
| 717 | |
| 718 | #ifdef _WIN32 |
| 719 | /* MSYS2 and Cygwin git print absolute paths in their own namespace: |
no test coverage detected