diff --git a/src/features/vcs/CommitView.tsx b/src/features/vcs/CommitView.tsx index 0f54eb2d6..c88155ce1 100644 --- a/src/features/vcs/CommitView.tsx +++ b/src/features/vcs/CommitView.tsx @@ -67,7 +67,7 @@ import { import { applyStash, commitChanges, deleteFiles, dropStash, showUnstashDialog, stashChanges } from "./changeOps"; import { CommitOptionsPopup } from "./CommitOptions"; import { DEFAULT_LIST_NAME, useChangelists, withListDefaults } from "./changelists"; -import { inclusionChecks, isCommitAll, useStagingArea } from "./staging"; +import { inclusionChecks, isCommitAll, stagingAreaOn, useStagingArea } from "./staging"; import { addToChangelist, commitFiles } from "./changelistsUi"; import { acceptSide } from "./conflictsUi"; import { copyChangesAsPatch } from "./patches"; @@ -345,13 +345,18 @@ export function nodeMenu( { kind: "separator" as const }, ] : []), - { - label: "Commit File…", - icon: "commit", - disabled: !files.some((f) => groupOf(f) === "changes"), - run: () => commitFiles(paths), - }, - { kind: "separator" }, + // With the staging area a commit takes the whole index: there is no committing one file. + ...(stagingAreaOn() + ? [] + : [ + { + label: "Commit File…", + icon: "commit" as const, + disabled: !files.some((f) => groupOf(f) === "changes"), + run: () => commitFiles(paths), + }, + { kind: "separator" as const }, + ]), // Under the modal interface the node itself, like double-click, in the front window. vcsDiffInFront() && opts?.roots && first ? { diff --git a/src/features/vcs/__tests__/stagingArea.test.tsx b/src/features/vcs/__tests__/stagingArea.test.tsx index df87bf93a..cf72b11df 100644 --- a/src/features/vcs/__tests__/stagingArea.test.tsx +++ b/src/features/vcs/__tests__/stagingArea.test.tsx @@ -129,6 +129,15 @@ describe("staging operations of the tree's nodes", () => { enabled(nodeMenu([underUnstaged], []), "Unstage"), ]).toEqual([true, false]); }); + + it("has no Commit File…: a commit takes the whole index", () => { + useSettings(true); + const labels = (items: MenuItem[]) => items.map((i) => ("label" in i ? i.label : null)); + for (const node of [group("staged").children![0]!, group("unstaged").children![0]!]) + expect(labels(nodeMenu([node], []))).not.toContain("Commit File…"); + useSettings(false); + expect(labels(nodeMenu([group("unstaged").children![0]!], []))).toContain("Commit File…"); + }); }); describe("the Commit tool window with the staging area", () => {