Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/commands/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions test/commands/commit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,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");
});
});
});