Skip to content

Commit

Permalink
Allow resolving unprefixed refs
Browse files Browse the repository at this point in the history
When using a pinned dependency the refs might not have a prefix (e.g.
`HEAD` is a plain ref) thus they wouldn't have been found when
attempting to resolve the refs.

Closes tarides#326
  • Loading branch information
Leonidas-from-XIV committed Aug 30, 2022
1 parent 9262e7f commit 806477b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/git.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ module Ls_remote = struct
let result = search_ref (prefix ^ ref) parsed_lines in
interpret_search_result result
in
match (search "refs/tags/", search "refs/heads/") with
| Some _, Some _ -> Error `Multiple_such_refs
| Some commit, None | None, Some commit -> Ok commit
| None, None when is_commit ref parsed_lines -> Ok ref
| None, None when looks_like_commit ref -> log_approx ()
| None, None -> Error `No_such_ref)
match (search "", search "refs/tags/", search "refs/heads/") with
| Some _, Some _, Some _
| Some _, Some _, None
| Some _, None, Some _
| None, Some _, Some _ ->
Error `Multiple_such_refs
| Some commit, None, None
| None, Some commit, None
| None, None, Some commit ->
Ok commit
| None, None, None when is_commit ref parsed_lines -> Ok ref
| None, None, None when looks_like_commit ref -> log_approx ()
| None, None, None -> Error `No_such_ref)

let parse_ref_output_line ~symref line =
match String.extract_blank_separated_words line with
Expand Down

0 comments on commit 806477b

Please sign in to comment.