Audit and overhaul virtual shell's git command

Fix critical bugs, add extensive missing flags, and add 8 new subcommands
to bring the browser-side git command closer to parity with real git.

Critical bug fixes:
- git commit: file-count classification used impossible stageStatus=1
  comparisons, always reporting 0 files changed
- git status --porcelain: untracked files could clobber staged indicators
- git add: directory walker skipped all dotfiles (including .gitignore
  itself), ignoring real git's .gitignore-based filtering
- git pull: untracked files incorrectly blocked pulls
- git reset: target regex rejected valid refs like branch names
- git diff: path filter used substring matching; --cached read working
  directory instead of index; <commit> and <commit>..<commit> forms were
  stubbed/unimplemented; used fake JS hashes instead of git.hashBlob

Implemented git reset --soft (was returning "not implemented").

New flags added across existing subcommands:
- commit: --signoff, --no-verify, -F/--file, --author, -C/--reuse-message,
  multiple -m support
- add: -u/--update, -f/--force, -n/--dry-run, absolute paths inside repo
- log: --stat, -p/--patch, --name-only, --name-status, --author, --grep,
  --since, --until, --no-merges, --reverse, --follow, custom
  --pretty=format:, proper timezone in output
- push: -u/--set-upstream (now wired to config), --tags, --delete,
  --dry-run, refspec (local:remote)
- fetch: --all, --tags, --prune now actually passed through
- branch: -a/--all, -r/--remotes, -m/-M (rename), --show-current, -v
- checkout: -B, -f/--force, commit-hash support (detached HEAD)
- config: --unset, --get-all, --add, --local, proper --list that reads
  the whole config file
- tag: real annotated tags via git.annotatedTag, -m, -f, -n, glob patterns
- clone: -b/--branch, -o/--origin, --bare
- init: -b/--initial-branch
- show: --stat, --name-only, --name-status
- diff: --stat, --name-only, --name-status
- remote: set-url, get-url, rename, show subcommands

New subcommands:
- git rm: remove files from index (and optionally worktree)
- git mv: rename/move files with index updates
- git restore: modern replacement for checkout of files
- git switch: modern replacement for branch checkout
- git merge: wrapper over git.merge (including --abort, --ff-only)
- git revert: create an inverse commit
- git rev-parse: resolve refs, --short, --abbrev-ref, --show-toplevel,
  --git-dir, HEAD~N / HEAD^N
- git ls-files: list tracked/modified/deleted/untracked files

All existing tests updated where behavior intentionally changed; new
subcommands have dedicated test suites. Final suite: 1392 passing.
This commit is contained in:
Alex Gleason committed 2026-04-27 00:42:10 -05:00
1 parent 376a982449
commit b3fddf6cb3
41 files changed
+4384 -796

No files matched your search

+26 -1
View File
@@ -23,6 +23,14 @@ import { GitDiffCommand } from "./git/diff";
import { GitTagCommand } from "./git/tag";
import { GitShowCommand } from "./git/show";
import { GitStashCommand } from "./git/stash";
import { GitRmCommand } from "./git/rm";
import { GitMvCommand } from "./git/mv";
import { GitRestoreCommand } from "./git/restore";
import { GitSwitchCommand } from "./git/switch";
import { GitMergeCommand } from "./git/merge";
import { GitRevertCommand } from "./git/revert";
import { GitRevParseCommand } from "./git/rev-parse";
import { GitLsFilesCommand } from "./git/ls-files";
export interface GitSubcommand {
name: string;
@@ -91,6 +99,14 @@ export class GitCommand implements ShellCommand {
this.registerSubcommand(new GitTagCommand(subcommandOptions));
this.registerSubcommand(new GitShowCommand(subcommandOptions));
this.registerSubcommand(new GitStashCommand(subcommandOptions));
this.registerSubcommand(new GitRmCommand(subcommandOptions));
this.registerSubcommand(new GitMvCommand(subcommandOptions));
this.registerSubcommand(new GitRestoreCommand(subcommandOptions));
this.registerSubcommand(new GitSwitchCommand(subcommandOptions));
this.registerSubcommand(new GitMergeCommand(subcommandOptions));
this.registerSubcommand(new GitRevertCommand(subcommandOptions));
this.registerSubcommand(new GitRevParseCommand(subcommandOptions));
this.registerSubcommand(new GitLsFilesCommand(subcommandOptions));
}
private registerSubcommand(subcommand: GitSubcommand): void {
@@ -138,11 +154,15 @@ start a working area (see also: git help tutorial)
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index
reset Reset current HEAD to the specified state
stash Stash the changes in a dirty working directory away
examine the history and state (see also: git help revisions)
log Show commit logs
ls-files Show information about files in the index and the working tree
show Show various types of objects
status Show the working tree status
diff Show changes between commits, commit and working tree, etc
@@ -151,6 +171,10 @@ grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip (not implemented)
revert Revert some existing commits
switch Switch branches
tag Create, list, delete or verify a tag object
collaborate (see also: git help workflows)
@@ -159,8 +183,9 @@ collaborate (see also: git help workflows)
push Update remote refs along with associated objects
remote Manage set of tracked repositories
configuration
configuration and low-level
config Get and set repository or global options
rev-parse Pick out and massage parameters
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'