bamaer opened a new pull request, #8004: URL: https://github.com/apache/hop/pull/8004
Fixes #8001 ### What happened `GitCommitPerspective.commitFiles()` reset the whole index before staging the checked files: ```java // Reset all staged files git.reset().setMode(ResetCommand.ResetType.MIXED).call(); ``` JGit's `ResetCommand` calls `resetMerge()` for any mode other than `SOFT` when `MERGE_HEAD` exists, which clears both `MERGE_HEAD` and `MERGE_MSG`. So the normal sequence — merge a branch, resolve the conflicts `UIGit.mergeBranch()` sets up with the `.ours`/`.theirs` files, switch to the commit perspective, commit — produced an **ordinary single-parent commit**. Git no longer considered the branch merged and replayed everything on the next merge. Cherry-pick and revert state were cleared the same way. The same reset also rebuilt the staging from scratch, so a commit that failed part-way (a malformed author identity, a hook, a locked index) left the index in a state the user had not asked for. ### What changed The staging moves into a new `UIGit.commitPaths()`, which: - unstages only the paths that have to stay out of the commit, one path at a time, so `MERGE_HEAD` survives; - derives that set from the live `git status` rather than from what the caller last read, so a file staged in the meantime is not swept into the commit either; - leaves the index alone entirely while a merge, cherry-pick or revert is in progress, since git commits the whole index there. `GitCommitPerspective` refuses a partial commit during one of those operations rather than silently dropping the unchecked files, matching git's own `cannot do a partial commit during a merge`. This also lifts the git calls out of the SWT class, which is what makes the behaviour testable. ### Tests Four tests added to `UIGitTest`, against a real JGit repository: - `testCommitPathsAfterAMergeRecordsBothParents` — the regression test. Fails on `main` with `expected:<2> but was:<1>` parents. - `testCommitPathsDuringAMergeKeepsTheRestOfTheIndexStaged` — also fails on `main`. - `testCommitPathsCommitsOnlyTheGivenPaths` — the selection guarantee is preserved, including for files staged outside the perspective. - `testCommitPathsLeavesTheSelectionStagedWhenTheCommitFails` — a failed commit leaves the selection staged, so a retry needs no re-staging. `mvn test -pl plugins/misc/git`: 139 tests, 0 failures. `spotless:check` passes. New message keys are in `messages_en_US.properties` only; the other locales fall back as usual. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
