Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracking branch #1181

Merged
merged 10 commits into from
Dec 18, 2023
Merged

tracking branch #1181

merged 10 commits into from
Dec 18, 2023

Conversation

Byron
Copy link
Member

@Byron Byron commented Dec 13, 2023

Related to #1180 .

Make it easy to obtain the tracking branches.

Tasks

  • research
  • update branch_remote_ref_name(kind) with push branch capabilities
  • implementation of remote_tracking_ref_name(kind) or similar on Reference
  • implementation of remote_ref_name(kind) or similar on Reference
  • add branch_remote_tracking_ref_name(kind) to Repository
  • the above on Head - it's easy to get a reference from Head.
  • Don't forget to generously link these methods among each other.
  • integrate into revparse impl in gix
  • rev parse --reference

Research

  • the direction decides if one gets the push or fetch tracking branch, it's based on the remote we get refspecs from
  • the direction choses the fetch or push specs, where push == fetch if unset.
  • only specs with destination part are used for matching, first one wins
  • how does the push ref resolution truly work?
    • local branch name to remote using push refspecs, then remote ref to local tracking using fetch refspecs
    • affected by push.default only if there is no explicit push spec
  • what happens to ambiguous mappings? ✅
    • push ignores ambiguity, takes the first match
    • fetch the same

@Byron Byron force-pushed the tracking-branch branch 7 times, most recently from ab58fd5 to 72af6c7 Compare December 17, 2023 19:54
…Cow<'_, BStr>` instead of `Cow<'_, str>`.

That way information won't degenerate due to enforcement of UTF-8.
…_remote_ref_name()`, add `direction` argument (also to `Repository::branch_remote_name()` and `Repository::branch_remote()`).

This better differentiates the return value from the corresponding ref objects,
which would require the named ref to exist in the repository.

The `direction` argument allows to get the reference to push to as well.
Further, it now takes a full ref name to support deriving the name of branches
to push to.

Regarding `Repository::branch_remote()`,  previously, this functionality
was only available from a `Reference`,
but now it's more generally available with just a branch name.

The method was also adjusted to permit looking up non-symbolic remote
names, like remotes that are specified by their URL.
…name()`.

These methods mirror their respective `Repository::branch_*` prefixed versions.
…u|p}`.

Previously it would be parsed, but always error as the implementation didn't exist.
Now it will return the fetch and push tracking branches respectively.
It's similar to `git rev-parse --symbolic-full-name`.
@Byron Byron merged commit 0fe20e8 into main Dec 18, 2023
18 checks passed
@Byron Byron deleted the tracking-branch branch December 18, 2023 20:49
@Byron Byron mentioned this pull request Dec 19, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant