fix(terminal): git reads real files, and every output matches Git 2.56 - #399
Merged
Merged
Conversation
The simulated git kept a list of names: `git add` accepted missing files and printed `staged:`, `git status` never saw a modified file, and `git diff` always printed the same invented example. - Model: repository path, HEAD tree, index, file modes and stash, read from the simulated filesystem (new commands/gitTree.ts: working tree, .gitignore rules, Myers diff, unified hunks, SHA-1 blob ids). - status (long, -s, -b, --porcelain, -u), add, rm, restore, commit, diff (HEAD, --staged, --name-only/-status, --numstat, --shortstat, -U), check-ignore, reset, stash and init follow git's wording, exit codes and option parsing (`-rf`, `-am`, `-uno`, `--source HEAD~1`). - Lesson repositories have .git/, a .gitignore that keeps .env out, and index.html; the git diff lesson starts from a real change. - Lesson and reference examples no longer add missing files or run `git remote` outside the cloned directory. Theory gaps: 158 -> 148. - A deleted diff line is stdout shown red (new line type `removed`); the lesson terminal restarts when the environment changes. Expected values in src/test/gitFidelity.test.ts come from real Git 2.56. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Sorry @thierryvm, your pull request is larger than the review limit of 150,000 diff characters
thierryvm
added a commit
that referenced
this pull request
Sep 29, 2026
… 2.56 (#400) A branch was only a name: switching changed no file, git merge recorded a fake merge commit, and the conflicts lesson never showed a conflict. Git is now a commit graph with refs, real object ids, three-way merges and conflict states. - gitHistory.ts: commit graph, merge base, log order, three-way merge with conflict markers, the --stat graph, tree/commit/tag ids as git computes - gitUsage.ts: usage texts generated from Git 2.56 - branch/switch/checkout move the working tree, carry or refuse local changes; merge fast-forwards, commits, squashes or stops on conflicts; status/add/rm/restore/reset/commit handle the merge state - log/show/diff/tag/cherry-pick/rebase work on the graph (ranges, paths, --graph on a straight history, A...B, tag filters, rebase <up> <branch>) - options git knows but the simulator does not do say "not simulated" - lessons: gitRepoWithBranch is one commit ahead, new gitRepoWithConflict gives the conflicts lesson a real conflict; replayable theory examples - 60 tests in gitBranches.test.ts, every expected value from real git - CHANGELOG/STORY, and the #399 entries dated 29 September, not 30 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The simulated git kept a list of file names. That produced three visible faults:
git addaccepted files that do not exist and printedstaged:, which real git never writes.git statusnever saw a modified or deleted file.git diffalways printed the same invented example.The Git lessons and the reference page taught against that simulation.
Git now works on the simulated files themselves. Every expected value in the new tests was printed by Git 2.56 on a copy of the lesson project.
Model (
src/app/data/commands/gitTree.tsis new):gitTree.tsprovides:.gitignorerules, including!patterns and directory rules;index 7d825c5..6827029matches real git byte for byte.wcalready uses. Git reads each file with that newline.Commands. These follow git's wording, exit codes and option parsing (
-rf,-am,-uno,--source HEAD~1):status: long,-s,-b,--porcelain,-u.add:., paths,-A,-u,-f,-n,-v. Ignored and missing paths are refused.rm: refuses to lose work, and removes the directories it empties.restore:--staged,--source.commit: root commit, stats,createanddeletemode lines,-a,-q,--allow-empty,-mwithout a value.diff:HEAD,--staged,--name-only,--name-status,--numstat,--shortstat,-U.check-ignore:-v,-q,-n.reset:--soft,--mixed,--hard. Paths only change the index;--hardand--softwith paths are refused.stash:-m, pop and apply the delta, overwrite conflicts,drop,clear.init -bandinit -q, andclone -b.Commands that are still not simulated say so explicitly:
add -p,diff --stat, branch-to-branch diff,commit --amend,stash -u.Lessons and reference
~/projetsin Git lessons is now a real repository, with.git/, a.gitignorethat keeps.envout, andindex.html. The lesson warns thatgit add .takes.env; the prepared repository now protects it.git diff & .gitignorestarts from a real change (newgitRepoWithChangesetup).status -sand diff;check-ignore -v;cd projetbeforegit remote add.alice/site.git.UI
removed: standard output rendered in--github-red, used for deleted diff lines and unstaged or untracked paths. It is routed to stdout, so pipes and redirections keep it..git/config, and the state is only read on mount (ui-auditor W1).Gates
-prefix anddeleted:carry the meaning in text.logoptions, renames, mode changes, nested.gitignore, pathspec globs,branch/checkout/configwording,lson empty directories,grep -c.code index.htmlin a real shell and opened two VS Code windows. The agent's deny rules will be tightened in a follow-updocs(agents)commit.infowere lost in pipes;reset <commit> -- <path>moved HEAD;git init -b dev devlost the branch name;check-ignorereported tracked files;git rm -rleft empty directories.Test plan
tsc,eslint src, fullvitest,vite build.src/test/gitFidelity.test.ts(52 tests, real Git 2.56 values), updated engine and setup tests.git difflesson with red/green lines and exercise validated;git status,git add .envrefused,check-ignore -v,.gitinls -a.script.shcommitted as 100644.🤖 Generated with Claude Code