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

Iterate on next/previous commits navigation #1960

Merged
merged 7 commits into from
Dec 10, 2024
Merged

Iterate on next/previous commits navigation #1960

merged 7 commits into from
Dec 10, 2024

Conversation

kaste
Copy link
Collaborator

@kaste kaste commented Dec 10, 2024

Internally we switch to short_hashes. This can be a temporary switch as we gain more information of the places where we actually uses hashes or allow also revs (e.g. branch names). After all, if we mark all places we could implement an internal map from short to long hashes (e.g. whenever we draw the graph), and switch to long hashes without a big cost. Note: we switch to short hashes here but it actually was wild, no-rules before, so we basically normalize our usages and get a sense of it.

Other than that: there is obviously no simple solution to which is the best newer or older commit of a given commit (as there might be many), so it is likely there are some decision made I don't remember right now.

When we need to guess which commit line we should follow, prefer
the checked out branch before choosing the newest, freshest ref.
This is likely (or hopefully) the better choice.
@kaste kaste enabled auto-merge December 10, 2024 13:01
In most views we use and show short hashes, e.g. the graph.  Since we
extract these hashes and pass them along, normalize and switch to short
hashes (for now) for the purpose of the caches.

This would be a good and cheap move *if* we only ever used actual
"hashes" when we type "commit_hash".  But we might use "refs" here as
well under some circumstances which we can't shorten.

Either a) find these places where we might introduce "refs" and resolve
them or b) maintain a big mapping from short to long hashes, populated
during graph and blame parsing.
To what I know, only the `gs_diff` view also gets invoked with branch
names.  (E.g. from the branches view, or when comparing two branches
from the graph view.)

From there, its `target_commit` can spread to other views, namely
`gs_show_file_at_commit` and the `gs_inline_diff`.

Fix that by calling `resolve_commitish` on the caller side.
The main goal is that `[n|p]` must be stable under all circumstances
although their implementation differs.

Introduce `get_previous_commit` which stores its navigation in the
view's `next_commits`.  Just like `get_next_commit` does.
For `next_commits`, when we use `git_streaming` we abort the process
as soon as we find our needle.

The other usages exhaust the iterator but already limit the number of
commits git yields.
@kaste kaste force-pushed the iter-next-commits branch from 62f661b to 6e886cf Compare December 10, 2024 13:18
@kaste kaste merged commit 5ae4e38 into master Dec 10, 2024
8 checks passed
@kaste kaste deleted the iter-next-commits branch December 10, 2024 13:19
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