Add Ignore-whitespace toggle to compare and apply to git diff #69
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
state: Done
state: New
state: To Do
type: Bug
type: Feature
type: Task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Christoph/Gitty!69
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/diff-ignore-whitespace"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change adds an "Ignore whitespace" option to the Compare dialog, threads that option through the front-end -> Tauri invoke layer into the Rust backend, and applies a corresponding git diff flag when generating diffs.
Summary of changes
CompareDialog.sveltelabelledcompare.ignoreWhitespace(stored under localStorage keygitlite.diffIgnoreWhitespace) and a smallactivestyle insrc/app.css. The button is only rendered when a reload handler is provided and updates the currently visible comparison in-place by reloading the comparison data.src/lib/git.tscompare/diff functions (compareCommits,diffFileAgainstWorkingTree,compareFileToHead,compareFileToParent) now accept an optionalignoreWhitespaceboolean and pass it to the Tauri invocations.App.svelteintroduces areloadComparisonloader andloadComparison/toggleDiffIgnoreWhitespacehelpers to persist the toggle and refresh the displayed comparison.src-tauri/src/git/compare.rsnow acceptignore_whitespace: Option<bool>and insert an appropriate git argument via the new helperwhitespace_flag(ignore_whitespace). The helper returns--ignore-all-spacewhen requested, otherwise--no-ext-diffas a neutral placeholder so the argument list remains stable across invocations.compare_commits_can_ignore_indentation_only_changeswas added insrc-tauri/src/git/tests.rswhich creates two commits differing only in tabs vs spaces and asserts the strict vs relaxed diffs.src/lib/locales/en.tsandde.ts.Why this matters (evidence-backed)
--ignore-all-space, which hides those changes in both the summary (--numstat) and the full patch outputs used by the UI.--ignore-all-space, and the UI updates the dialog in-place to reflect that there are no textual changes for files that only differ by whitespace.Testing
No test execution results were provided.
Recommended checks for reviewers:
cargo test --manifest-path src-tauri/Cargo.toml
to verify the newly added test compiles and passes locally.
Compatibility, risks and reviewer notes
ignore_whitespaceparameter. The front-end now sends this parameter; calls that omit it will behave as before (the helper treatsNone/falseas not ignoring whitespace).whitespace_flagreturns"--ignore-all-space"when enabled and"--no-ext-diff"when disabled.--no-ext-diffis used as a neutral placeholder so the injected argument spot remains present in the git argument lists. This results in some command arrays containing two occurrences of--no-ext-diff(one original, plus the placeholder) in the non-ignore case — please verify that this is acceptable and harmless for all git invocations in this file.localStorageundergitlite.diffIgnoreWhitespace. If localStorage is unavailable the code swallows storage errors.Files/areas to review closely
src-tauri/src/git/compare.rs— ensure the inserted argument in each git invocation is correct for that invocation context.src/lib/components/CompareDialog.svelteandsrc/App.svelte— verify the reload logic (reloadComparison) correctly captures the active comparison call and that selected file highlighting is preserved after reload.compare_commits_can_ignore_indentation_only_changesinsrc-tauri/src/git/tests.rs— confirm the test covers the intended behavior and is stable across platforms.If you want, I can highlight the exact hunks that add the toggle and the helper or prepare a short demo script to exercise the new UI flow.