Skip to content

Commit b5a79d1

Browse files
committed
fix(shared): git config edits and --help keep their console
1 parent a9a702a commit b5a79d1

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎packages/shared/src/shell.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,9 @@ describe("runsGitWithoutConsole", () => {
611611
expect(runs(["--git-dir=X", "rev-parse", "HEAD"])).toBe(true);
612612
expect(runs(["-c", "k=v", "for-each-ref", "refs/heads"])).toBe(true);
613613
expect(runs(["-C", "dir", "config", "--get", "k"])).toBe(true);
614+
expect(runs(["config", "--get-regexp", "^remote\\."])).toBe(true);
615+
expect(runs(["config", "get", "user.name"])).toBe(true);
616+
expect(runs(["config", "--list"])).toBe(true);
614617
expect(runs(["symbolic-ref", "--quiet", "--short", "HEAD"])).toBe(true);
615618
expect(runs(["remote", "-v"])).toBe(true);
616619
expect(runs(["remote", "get-url", "origin"])).toBe(true);
@@ -625,6 +628,11 @@ describe("runsGitWithoutConsole", () => {
625628
expect(runs(["remote", "add", "origin", "url"])).toBe(false);
626629
expect(runs(["config", "--edit"])).toBe(false);
627630
expect(runs(["config", "edit", "--global"])).toBe(false);
631+
expect(runs(["config", "--edi"])).toBe(false);
632+
expect(runs(["config", "--edi", "user.name"])).toBe(false);
633+
expect(runs(["config", "branch.x.gh-merge-base", "main"])).toBe(false);
634+
expect(runs(["rev-parse", "--help"])).toBe(false);
635+
expect(runs(["--help", "rev-parse"])).toBe(false);
628636
expect(runs(["symbolic-ref", "--delete", "refs/remotes/origin/HEAD"])).toBe(false);
629637
expect(runs(["-C", "rev-parse", "status"])).toBe(false);
630638
});

‎packages/shared/src/shell.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,12 @@ const GIT_READ_SUBCOMMANDS = new Map<string, (args: ReadonlyArray<string>) => bo
746746
["show-ref", () => true],
747747
[
748748
"config",
749-
(args) => !args.includes("--edit") && !args.includes("-e") && positionals(args)[0] !== "edit",
749+
(args) =>
750+
args[0] === "get" ||
751+
args[0] === "list" ||
752+
args.some(
753+
(arg) => arg === "--get" || arg.startsWith("--get-") || arg === "--list" || arg === "-l",
754+
),
750755
],
751756
[
752757
"symbolic-ref",
@@ -780,6 +785,7 @@ export function runsGitWithoutConsole(
780785
if (path.basename(binDirectory).toLowerCase() !== "bin") return false;
781786
const build = path.basename(path.dirname(binDirectory)).toLowerCase();
782787
if (!GIT_FOR_WINDOWS_BUILDS.some((candidate) => candidate === build)) return false;
788+
if (args.includes("--help")) return false;
783789
let index = 0;
784790
for (let arg = args[0]; arg?.startsWith("-"); arg = args[index]) {
785791
index += GIT_GLOBAL_OPTIONS_WITH_VALUE.has(arg) ? 2 : 1;

0 commit comments

Comments
 (0)