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

Clarify and fix when an inline diff view is historical, when it is dynamic, and when interactive #1888

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

kaste
Copy link
Collaborator

@kaste kaste commented Apr 5, 2024

No description provided.

kaste added 3 commits April 6, 2024 01:30
We used `is_historical_diff` diff here to decide if the shown
`actual_line` can be used directly.  This is incorrect as it is also
true when only the `base_commit` is not None.  In that case we actually
have a dynamic diff that compares against the working dir
("<base_commit>..WORKING DIR") and we need to fix the `actual_line`
accordingly.

It is, on contraire, when `target_commit` is set, that the underlying
diff of the "inline_diff"-view already has the correct value.

Note that we also start the line history from `commit_hash` so there
is a simple match here.
Note that `is_historical_diff` was also wrong as for a "historical"
diff it is enough that `target_commit` is set.  If only `base_commit`
is set we still have the comparison "<base_commit>..WORKING DIR" which
is obviously a dynamic diff that merges or combines a range of
revisions.

The notion "historical" usually refers to a static, cacheable(!)
"<commit>~1..<commit>" diff.  E.g. it matches what `show_file_at_commit`
shows with the help of the gutter marks.
`is_interactive_diff` refers to a view for which staging and unstaging
is applicable.  Basically it captures the functionality of the inline
diff *before* we introduced the "historical" feature in d6af915
(Implement historical "inline diff", June 2020).

But a diff is always dynamic just if `target_commit` is not set as it
then essentially compares against the working dir.  Fix that here!
@kaste kaste enabled auto-merge April 5, 2024 23:32
@kaste kaste merged commit 2eeca0c into master Apr 5, 2024
8 checks passed
@kaste kaste deleted the when-is-an-inline-diff-historical branch April 5, 2024 23:33
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