Skip to content

git.status

git.status reports the changes in a linked git worktree of a session. If path is a linked worktree of the repository of baseRepo, the reply is the status. Every other request that does not fail gets "isRepo": false. The daemon runs git on a temporary copy of the git files of the worktree. So the status never rewrites the index and never takes index.lock.

An untagged rule on this page matches build 5fd08069 or an earlier build, measured on Linux, macOS and Windows.

Request

{"path": "/repo/.claude/worktrees/w1", "baseRepo": "/repo"}
Parameter Required Meaning
path no The linked worktree. Send an absolute path. Without path, the daemon looks for a registration of its own working directory (not measured). Send path. A relative path gives "isRepo": false or -32603 exit status 128. A . works like no path (from the code). Path handling has the rules for a leading ~.
baseRepo yes The repository that owns the worktree. With a linked worktree as baseRepo, the daemon goes on in the git directory of the main repository. That worktree as path gets the status, also with "shadowDirOff": true, and so does another linked worktree of the repository (be1c1ca5 and b3081b51, measured on Linux). macOS and Windows are claustrum's own, not measured.
shadowDirOff no true turns off the daemon's own read of the repository's git config and its settings copy for this request. Turning the read off.

Response

{"isRepo": true, "clean": true}
{"isRepo": true, "clean": false, "changes": ["M  a.txt", " M b.txt", "?? new"]}
Member Meaning
isRepo If path is a linked worktree of the repository of baseRepo, true.
clean If changes is empty, true. Else false.
changes The entries of the status, in the order of The changes. If there is no entry, the member is absent.

If the request does not name a linked worktree of the repository of baseRepo, the response is not an error. It has both members:

{"isRepo": false, "clean": false}

That holds for:

  • a path that is the repository itself, a plain folder or a subfolder
  • a nested repository, a missing folder or a regular file
  • a worktree of another repository, or a right worktree with the wrong baseRepo
  • a linked worktree as path and baseRepo with no git on PATH (4c111e86, measured), and the main repository as path and baseRepo too (87375cc7, measured on Linux, other repositories, macOS and Windows claustrum's own). On Windows 4c111e86 keeps its failed start test, and 87375cc7 keeps none (rule). On Windows see the git in the working folder

How the daemon finds the worktree has the rules.

Errors

A failure is a JSON-RPC error with no errorCode member. It changes nothing in the repository or worktree.

Shared refusals

Code Text Cause
-32602 Invalid params No params member, or a member that it reads has the wrong type. the rules for params.
-32602 baseRepo is required baseRepo is absent, or empty (from the code).
-32603 the repository's git directory could not be trusted; git not run: … The daemon does not trust the git directory. Git-directory trust check.
-32603 config-defined hooks could not be pinned off; git not run: … A config listing failed or passed a limit of the hook pins. Or the daemon refuses its own git environment, or a daemon GIT_DIR names a gone worktree entry. A listing stopped at 30 seconds has its own text in the error catalogue. Refusal texts and The daemon's own git environment.
-32603 git cannot run on this host; git not run: … A config listing, a call of the start test or the call about the repository failed, and then git version failed too. the error catalogue.
-32603 this repository's git config cannot be used: … or a file in this repository's .git directory cannot be used: … The daemon does not accept the git config or a git directory file. Repository config refusals.
-32603 Claude could not test git on the remote machine (…). Check free disk space and quota there, then try again. The start test of the settings copy failed. The daemon keeps the failure for 10 seconds. The start test.
-32603 git could not check this repository on the remote machine: … or git and Claude disagree about which repository holds this folder: … The call that asks git about the repository failed, ran over 30 seconds, or named another repository. The call about the repository.
-32603 Claude could not prepare its own files on the remote machine: … The daemon cannot prepare the settings copy folder, or .probe. The folders.

Git and copy failures

Code Text Cause
-32603 git took too long: Claude stopped git <subcommand> after 2 minutes; try again A git call ran 2 minutes, and the daemon stopped it. While a "shadowDirOff":true request runs, that one included, the limit is 30 minutes, and the text says so (claustrum's own). Time limits.
-32603 The Go error of the git call, for example exit status 128 git status, git ls-files or git diff-index failed. The text of git does not show. A relative path that matches a registration gets exit status 128, because git takes it as sent.
-32603 config-defined hooks could not be pinned off; git not run: listing the configuration in force: and the start error, for example chdir <path>: no such file or directory path passed the test as a cleaned path, but git cannot start in the path as sent. An example is <dir>/missing/.. outside baseRepo (measured on Linux and macOS).
-32603 <file>: not a regular file (claustrum's own) From the copy into the temporary git folder after the gate passed. An info/sparse-checkout folder or FIFO gets it.
-32603 <file> is larger than <n> bytes (claustrum's own) A copied file is over its bound, also one that grew after the gate. <n> is 1073741824 for index, a sharedindex.<40 or 64 hex> file, info/sparse-checkout and a reftable file, and 1048576 for HEAD and config.worktree.
-32603 An error of the file system, for example openat index: permission denied or stat <dir>: no such file or directory The raw Go error. The daemon cannot copy a file of the registration or make a file of the temporary git folder. The reference is not measured there.

Failed listings and temporary folders: Rare states.

How the daemon finds the worktree

The daemon does not ask git inside path. It reads the registrations of the repository. A registration is the folder <common>/worktrees/<name> that git keeps for each linked worktree. <common> is the git directory that git rev-parse --absolute-git-dir prints in baseRepo. For a linked worktree as baseRepo, it is the git directory of the main repository (be1c1ca5 and b3081b51, measured on Linux). claustrum takes that git directory from the trust check. If git prints a folder that is not the trusted entry, the answer is "isRepo": false (claustrum's own, not measured).

baseRepo

Each of these gives "isRepo": false before any git call:

  • baseRepo has the components .claude/worktrees in it, or is that folder. <dir>/.claude alone passes.
  • A folder above baseRepo holds an entry named .claude-managed-worktrees and no .git. A marker inside baseRepo itself does not count. A marker one or two levels above counts (measured on Linux). Further up the test is claustrum's own.
  • baseRepo does not resolve. For example, it is missing, or a .. after a symbolic link goes up from the target of the link and finds no folder.

Then the git-directory trust check runs on baseRepo, not on path. A refusal answers -32603, also for a good linked worktree as path. If the check finds no repository, the answer is "isRepo": false, with exceptions. A config of baseRepo that the daemon does not accept answers -32603, as in Repository config refusals.

baseRepo can be a symbolic link to the repository, a bare repository, a submodule checkout or a subfolder. If git prints no git directory, or there is no worktrees folder, the answer is "isRepo": false.

path

Each of these gives "isRepo": false:

  • path is not a folder, or it does not exist.
  • path lies inside baseRepo, and a component below baseRepo is a symbolic link. That includes a link at .claude, and a link at the last component (measured on Linux).
  • path lies inside baseRepo and has a .. component. A . component passes (measured on Linux). Outside baseRepo a .. passes.
  • On Windows path cannot be opened, such as a folder with the reparse tag IO_REPARSE_TAG_WIM. The answer comes before the config listing and rev-parse --show-toplevel in the git directory (4c111e86, measured on Windows for that tag). Other open failures and the place of the test are claustrum's own, not measured.

The .git file inside path plays no part. If it is missing, damaged or names another place, the answer is still the status. So is a locked worktree.

The registration match

Exactly one registration must name path. Two that match give "isRepo": false, and so does none. A relative gitdir or commondir value counts from the registration folder.

  • A registration is a real folder. A symbolic link under worktrees does not count.
  • Its gitdir file must be a regular file of at most 1 MiB. The last component of its value must be .git.
  • The folder before .git must equal path as text. Two spellings of path match: as sent, and with its symbolic links resolved. For a path inside baseRepo, the second spelling is the resolved baseRepo. The rest of path follows as sent (claustrum's own) (not measured below a symbolic link).

The matched registration must pass these tests. Each failure gives "isRepo": false.

  • commondir must be a regular file, or a relative symbolic link to a file in the registration folder. Its value must equal <common> as text, in the spelling that git printed.
  • HEAD must hold 40 or 64 hex characters, or a ref: line under refs/ (measured on Linux). A branch that does not exist and a detached commit pass.
  • index must be a regular file of at most 1 GiB, or be missing (measured on Linux and Windows). A symbolic link to a regular file in the registration folder passes too (measured on Linux). A sharedindex.<hex> file that is a regular file has the same 1 GiB bound. The index and all sharedindex.* files together must hold at most 2 GiB (measured on Linux).
  • config.worktree can be missing. If it exists, it must parse and hold only core.sparseCheckout, core.sparseCheckoutCone and index.sparse. user.name gives "isRepo": false. So does core.bare, and core.sparseCheckoutCone passes (measured on Linux). claustrum refuses every other key too (not measured).

What the status reads

The daemon makes a temporary git folder in its own folder under git-shadow. With "shadowDirOff":true, or with no run folder, it is in the temporary directory of the system. It holds copies of HEAD, index, config.worktree, info/sparse-checkout, the sharedindex.* files with hex names and the reftable files of the registration. It also holds a commondir file. The daemon removes the folder before it replies.

The daemon runs four git commands in path. The git directory is that folder, and the work tree is path as sent:

status --porcelain --untracked-files=all --ignore-submodules=all
ls-files -s -z
rev-parse --verify -q HEAD^{commit}
diff-index --cached --raw -z --ignore-submodules=none HEAD --

If HEAD names no commit, diff-index compares with the empty tree.

  • The calls ignore the .gitattributes files, so no clean filter runs, but before git 2.40 the attributes apply.
  • The calls read no replace objects from refs/replace.
  • In the state shadow the status call carries -c lfs.storage=<temporary git folder>/lfs (b3081b51, measured on Linux, macOS and Windows). The other calls carry none (measured on Linux and macOS). It follows --work-tree (4c111e86, measured on Linux and Windows, macOS claustrum's own), also where the user config sets lfs.storage (claustrum's own, not measured).
  • status, ls-files and diff-index carry GIT_OPTIONAL_LOCKS=0. All calls run as hardened git calls.
  • If the user has a global excludes file, the status uses it.

The changes

changes holds three groups, in this order.

  1. The lines of git status --porcelain, verbatim, minus the line end. Warnings on stderr never appear. The XY column is positional, so the leading space of an unstaged change is data: "M a.txt" is staged and " M b.txt" is unstaged. An untracked file in an untracked folder has its own entry, as "?? sub/u.txt".
  2. One entry for each gitlink in the index, unless <name>/.git does not exist (measured on Linux). A gitlink is an index entry of mode 160000. There is one entry for each index stage, so a gitlink in conflict gives three (measured on Linux).
  3. One entry for each staged change whose old or new mode is 160000 (measured on Linux).

One gitlink can have entries in all three groups (measured on Linux).

Submodule entries and limits

A submodule entry is S, the quoted name and one of three texts (measured on Linux):

Text Meaning
(submodule present; contents not inspected) <name>/.git exists, as a file, a folder or a dangling symbolic link. A gitlink path that is a symbolic link to a folder inside the work tree counts as present (measured on Linux).
(submodule; could not be inspected) The daemon cannot look at <name>/.git (measured on Linux). Examples are a gitlink path that is a regular file, a symbolic link out of the work tree, or a folder of mode 000 (measured on Linux).
(submodule change staged; contents not inspected) A staged change of a gitlink (measured on Linux).
  • A porcelain line over 512 bytes is cut to 512 bytes, and … follows (measured on Linux). At most 10000 porcelain lines pass, and no entry marks the cut (measured on Linux). The submodule entries still follow (measured on Linux).
  • A submodule name over 200 bytes is cut to 200 bytes, and … follows (measured on Linux). The name is then quoted with double quotes, \", \n, \t, and \xff for a byte that is not valid UTF-8 (measured on Linux). A printable character outside ASCII stays (measured on Linux).
  • At most 100 submodule entries pass (measured on Linux). Then one entry counts the rest, for example S … (+20 more submodule entries) (measured on Linux).

Differences by system

  • With no user excludes file, the status runs.
  • The junction rules of Windows do not apply.
  • A baseRepo where git cannot start, such as a file, gives "isRepo": false.
  • A repository file gets the repository call, -32603 and the settings copy, also after a 15 s hold. A file link counts in the folder of its target: a target in any repository gets its gate, and a target in none gets no gate. Both give "isRepo": false when the gate passes. A refused config there is not measured. 4c111e86 is measured on Linux, and macOS is claustrum's own.
  • A last path component inside baseRepo that ends in a dot or space, or holds a colon, is not special.
  • Letter case in the registration match is exact.
  • path matches only as sent and as resolved.
  • A gitlink path that is a regular file gives (submodule; could not be inspected) (measured on Linux).
  • Another letter case, the NFD form and /System/Volumes/Data do not match in the registration match.
  • A commondir value under /tmp fails, because git prints /private/tmp.
  • With no global excludes file of the user, the status call passes -c core.excludesFile=NUL. Git 2.55.0.windows.3 refuses it, and the reply is -32603 "exit status 128" (c9125eb8 and 4c111e86, measured on Windows).
  • A baseRepo with a junction before its last component gives the status (4c111e86, measured on Windows). A dangling junction gives "isRepo": false after the read of the user's excludes (measured on Windows). A .. drops the name before it first, whatever it is: a missing name, a file, a junction, or a live, dangling or looping link. So <S>\missing\..\P\repo and <S>\P\..\P\repo, where P is a junction, make the git calls of <S>\P\repo (4c111e86, measured on Windows). A dangling symbolic link as the last name gives "isRepo": false at once (claustrum's own, not measured). A link to a network or device path is refused first (network links).
  • A baseRepo that exists and in which git cannot start, such as a regular file, gives -32603 with the start error of the listing. See Git-directory trust check.
  • A junction below baseRepo in path gives "isRepo": false, as a symbolic link does.
  • A last component of a path inside baseRepo that ends in a dot or a space, or holds a colon, gives "isRepo": false. claustrum refuses such a name at any component (not measured). Outside baseRepo a trailing dot or space passes.
  • The folder compare of the registration match ignores letter case. A gitdir value that ends in .GIT fails.
  • A junction path outside baseRepo gets one rev-parse --show-toplevel. Its --work-tree is the real path, not the junction spelling (4c111e86, measured on Windows).
  • A subst drive, a junction, a \\?\ path and 8.3 short names match path too. A path with short names inside a baseRepo in short names finds no registration.
  • A commondir value with forward or back slashes passes. Another letter case, a short name, a \\?\ prefix and a value with no drive letter fail.
  • A baseRepo that is a junction to the repository gives the status. The daemon goes on with the git directory that git prints.
  • A gitlink path that is a regular file gives no entry. A junction there gives (submodule; could not be inspected).
  • An alternates file of a fault, GIT_ALTERNATE_OBJECT_DIRECTORIES and a baseRepo through 32 or more links give -32603, and only the excludes read runs git. With "shadowDirOff":true the GIT_ALTERNATE_OBJECT_DIRECTORIES test does not run (4c111e86). Object sources.
  • A baseRepo through a link to a network or device path gives -32603, and no git call runs on it. Network links.
  • A \\?\UNC\ baseRepo or a refused share gives -32603. UNC refusals.
  • A .git with IO_REPARSE_TAG_PROJFS is no link, and a baseRepo below an IO_REPARSE_TAG_WIM folder gives -32603 (4c111e86). Reparse tags.

Rare states

A check that finds no repository

A config listing that fails gives the hooks refusal. If git version fails too, it gives the "cannot run" text of Hardened git calls.

A .git file can name a gone git directory that is no registration. The answer is "isRepo": false, with and without "shadowDirOff":true (git 2.56.1, 4c111e86, measured on Linux, macOS and Windows). An older git gives it without the member (4c111e86, measured on Linux).

A failed config listing

The first config listing refuses by these classes. Later listings refuse any failure, in the git directory (measured on Linux) and in the temporary folder (from the code). Over a hook-pin limit the first listing refuses in a repository (from the code), and later ones do not (from the code). The empty-tree listing never refuses (from the code). A stopped listing of config.worktree gives {"isRepo":false,"clean":false} (measured on Linux).

No temporary git folder

If the daemon cannot make its folder under git-shadow, the response is {"isRepo":false,"clean":false} (measured on Linux and Windows). When the folder is in the temporary directory of the system, a failure answers -32603 with the error of the file system (not measured).

Reftable and FIFO files

A repository can have the reftable format. If the reftable folder then holds a tables.list file, it must name at least one table (measured on macOS). Each table must be a regular file (measured on macOS). If reftable is not a real folder, or tables.list is a FIFO, the request goes on (measured on macOS). git then shows every tracked file as added (measured on macOS).

No test waits on a FIFO (measured on Linux and macOS). A FIFO in place of gitdir, commondir or config.worktree fails at once (measured on Linux and macOS). A FIFO at index fails at once too (measured on Linux), and so does one at HEAD (from the code).

A cut inside a multi-byte character

A cut can split a multi-byte character (claustrum's own) (not measured). In a porcelain line, the JSON encoding then sends U+FFFD for each leftover byte (claustrum's own) (not measured). In a submodule name, the quoting writes each leftover byte as \xNN (claustrum's own) (not measured).

Differences from the reference

A rule that names a system is measured there only. A linked rule keeps the marks of its own section.

No entry of the divergence catalog applies to this method.

The measured cells behind each rule are in the tests and in the reference build history.