From befd42063f8c1738b58241fdf8830b649cd8d236 Mon Sep 17 00:00:00 2001 From: Jeremy Geros Date: Tue, 29 Sep 2026 08:22:28 -0600 Subject: [PATCH 1/2] Support git commit -quiet / -q --- docs/CLI.md | 1 + src/commands/commit.ts | 2 ++ test/commands/commit.test.ts | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/docs/CLI.md b/docs/CLI.md index 61dc3eb9..c1ac6d9d 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -396,6 +396,7 @@ Options: --amend Amend the previous commit --no-edit Use the previous commit message without editing -a, --all Auto-stage modified and deleted tracked files + -q, --quiet Suppress commit summary ``` ## git config diff --git a/src/commands/commit.ts b/src/commands/commit.ts index 173d3dff..3d799ae2 100644 --- a/src/commands/commit.ts +++ b/src/commands/commit.ts @@ -62,6 +62,7 @@ export function registerCommitCommand(parent: Command, ext?: GitExtensions) { amend: f().describe("Amend the previous commit"), noEdit: f().describe("Use the previous commit message without editing"), all: f().alias("a").describe("Auto-stage modified and deleted tracked files"), + quiet: f().alias("q").describe("Suppress commit summary"), }, handler: async (args, ctx) => { const messages = args.message as string[]; @@ -440,6 +441,7 @@ export function registerCommitCommand(parent: Command, ext?: GitExtensions) { parents, author, }); + if (args.quiet) return { stdout: "", stderr: "", exitCode: 0 }; // Format output — for amend, diff against the amended commit's parent const branchRef = head?.type === "symbolic" ? head.target : null; diff --git a/test/commands/commit.test.ts b/test/commands/commit.test.ts index 7b8f17cc..290e9ad0 100644 --- a/test/commands/commit.test.ts +++ b/test/commands/commit.test.ts @@ -34,6 +34,23 @@ describe("git commit", () => { }); }); + test("-q and -qm commit without printing the summary", async () => { + const bash = createTestBash({ files: BASIC_REPO, env: TEST_ENV }); + await bash.exec("git init"); + await bash.exec("git add README.md"); + const first = await bash.exec('git commit -q -m "first"'); + expect(first.exitCode).toBe(0); + expect(first.stdout).toBe(""); + expect(first.stderr).toBe(""); + + await bash.exec("git add src/main.ts"); + const second = await bash.exec('git commit -qm "second"'); + expect(second.exitCode).toBe(0); + expect(second.stdout).toBe(""); + expect(second.stderr).toBe(""); + expect((await bash.exec("git log --format=%s -2")).stdout).toContain("second\nfirst"); + }); + describe("multiple -m flags", () => { test("joins multiple -m values with double newline", async () => { const bash = createTestBash({ files: EMPTY_REPO, env: TEST_ENV }); From 46a7463b57e424ec957398f7a6036ce0dcec56b5 Mon Sep 17 00:00:00 2001 From: Jeremy Geros Date: Tue, 29 Sep 2026 08:30:50 -0600 Subject: [PATCH 2/2] Move to standard describe block for commit -q test --- test/commands/commit.test.ts | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/commands/commit.test.ts b/test/commands/commit.test.ts index 290e9ad0..f7620394 100644 --- a/test/commands/commit.test.ts +++ b/test/commands/commit.test.ts @@ -34,23 +34,6 @@ describe("git commit", () => { }); }); - test("-q and -qm commit without printing the summary", async () => { - const bash = createTestBash({ files: BASIC_REPO, env: TEST_ENV }); - await bash.exec("git init"); - await bash.exec("git add README.md"); - const first = await bash.exec('git commit -q -m "first"'); - expect(first.exitCode).toBe(0); - expect(first.stdout).toBe(""); - expect(first.stderr).toBe(""); - - await bash.exec("git add src/main.ts"); - const second = await bash.exec('git commit -qm "second"'); - expect(second.exitCode).toBe(0); - expect(second.stdout).toBe(""); - expect(second.stderr).toBe(""); - expect((await bash.exec("git log --format=%s -2")).stdout).toContain("second\nfirst"); - }); - describe("multiple -m flags", () => { test("joins multiple -m values with double newline", async () => { const bash = createTestBash({ files: EMPTY_REPO, env: TEST_ENV }); @@ -750,4 +733,23 @@ describe("git commit", () => { expect(results[2].stdout).toContain("relative path message"); }); }); + + describe("--quiet", () => { + test("-q and -qm commit without printing the summary", async () => { + const bash = createTestBash({ files: BASIC_REPO, env: TEST_ENV }); + await bash.exec("git init"); + await bash.exec("git add README.md"); + const first = await bash.exec('git commit -q -m "first"'); + expect(first.exitCode).toBe(0); + expect(first.stdout).toBe(""); + expect(first.stderr).toBe(""); + + await bash.exec("git add src/main.ts"); + const second = await bash.exec('git commit -qm "second"'); + expect(second.exitCode).toBe(0); + expect(second.stdout).toBe(""); + expect(second.stderr).toBe(""); + expect((await bash.exec("git log --format=%s -2")).stdout).toContain("second\nfirst"); + }); + }); });