Skip to content

commit hunk selections #7893

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

Merged
merged 3 commits into from
Apr 3, 2025
Merged

commit hunk selections #7893

merged 3 commits into from
Apr 3, 2025

Conversation

Byron
Copy link
Collaborator

@Byron Byron commented Mar 30, 2025

Add V3 facilities for discarding changes in the worktree or index, this time it's about hunks specifically.

Follow-up of #7807.

Tasks

  • gitoxide informs about diff-filter changes and this information is passed to the frontend
    • differentiate binary-to-text , otherwise it applies worktree conversions (which is fine). We ignore external diff programs anyway.
  • use latest gix from main
  • hunk-selections for committing
    • trivial selections
    • assure multiple selections per hunk actually work like they should (which won't work out of the box for sure)
    • A UI-style selections with lots of one-liners - result should be the same no matter what (high-level)
    • test for discarding only hunks that aren't matching, but commit the hunks that matched.
  • but-cli supports committing hunk headers

Next PR

  • Fix an issue with v3 comitting #7952 (comment)
    • Why does it do the wrong thing once these lines are removed.
    • problem is that the passed workspace commit is already only having one parent only, even though it should have two.
      - Once that is clear, it should fail as it needs a base-substitute.
  • See what happens if one tries to commit these special cases (i.e. the 'pretend there is no index' changes)
  • Discard hunk logic can probably use the context-window = 0 upgrade, right now splits are computed even though I doubt this is always correct.

Copy link

vercel bot commented Mar 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitbutler-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2025 11:56am

Copy link

vercel bot commented Mar 30, 2025

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@@ -140,6 +140,9 @@ pub enum UnifiedDiff {
Patch {
/// All non-overlapping hunks, including their context lines.
hunks: Vec<unified_diff::DiffHunk>,
/// If `true`, a binary to text filter (`textconv` in Git config) was used to obtain the `hunks` in the diff.
/// This means hunk-based operations must be disabled.
is_result_of_binary_to_text_conversion: bool,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @estib-vega , here is the promised flag that the UI would use to determine if hunk-selections of any kind should be allowed. That's the case only if this is false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a serde rename to that it's camelCased, please? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, right, we didn't notice before because it was naturally camelCase.
Should be fixed now.

@Byron Byron force-pushed the commit-hunks branch 2 times, most recently from 949b2f0 to 10c61e3 Compare March 31, 2025 12:44
@Byron Byron marked this pull request as ready for review April 3, 2025 11:55
@Byron Byron enabled auto-merge April 3, 2025 11:56
@Byron Byron merged commit 3a5dfad into gitbutlerapp:master Apr 3, 2025
18 of 19 checks passed
@Byron Byron deleted the commit-hunks branch April 3, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants