Skip to main content

ensure_origin_head

Function ensure_origin_head 

Source
pub fn ensure_origin_head(
    root: &Path,
    branch: &str,
    fetch: &FetchDefault,
) -> Result<()>
Expand description

Point origin/HEAD at origin/<branch>. Fetch that one ref only when it is missing. The fetch gets the branch’s history instead of a depth-1 tip, because off_default_history walks parents.

An empty branch, no repository, and no origin remote are each a no-op.

§Errors

Returns an error when:

  • the fetch fails (remote unreachable, credentials rejected, or the branch absent on the remote);
  • origin/<branch> is still missing afterwards;
  • origin/HEAD cannot be updated.