Repository navigation
Session logs already pushed to a backup remote: disclose the history, and stop the pushing that was still happening (#288) - #289
Merged
Conversation
…shing them (#288) #287's `git rm --cached` could never untrack them: it fails outright on a directory without `-r`, and even with `-r` the backup's `git commit -- "<slug>/"` is a partial commit that rebuilds those paths from the working tree. Measured on a store built by the pre-#287 hook, the upgraded hook still pushed a log line written after the upgrade — and tmp/ is where #287 moved the delivery record, so #285 was not fixed on those stores either. The untracking is now its own commit, of the index rather than of a pathspec, guarded on an otherwise-clean index and rolled back if it cannot finish. It rewrites no history: what is already pushed stays pushed, which is the user's call and is documented as theirs. Co-Authored-By: Max <noreply>
Untracking stops the pushing; it removes nothing from the commits that already carried the logs, and no later fix on this side can. README gains "Logs in a backup you made before this version": which versions staged logs/ unconditionally, a one-line check for your own store, and the git filter-repo purge with its price in the same breath — every commit ID changes, so every other clone diverges and must be replaced rather than pulled. How many stores this touches is not known and is not estimated. Co-Authored-By: Max <noreply>
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.
Closes #288
What I verified, and where it contradicts the issue
I re-derived #287's forward fix rather than taking it. Both halves are in the tree:
50-git-backup.sh:438-444maintains/<slug>/logs/and/<slug>/tmp/in$GIT_DIR/info/exclude, and:450rangit rm --cachedbeside them. The second half never worked. Built a store with the pre-#287 hook (git show 166fd6c^), pushed it, then ran the current hook against it:Two independent causes, each reproduced in isolation:
git rm --cached -- "$SLUG/logs/"on a directory fails outright without-r— fatal: not removing 's/logs/' recursively without -r — and the hook discards the error with2>/dev/null || true.-r, the backup commits viagit commit -- "$SLUG/", a partial commit, which builds its tree from the working tree for every matched path and so restores exactly what the removal staged. Micro-tested on git 2.46.2: index showss/m.mdonly, HEAD after the commit showss/logs/a.logagain.That is the same mechanism #287 documented for the delivery record and answered by making the path stop existing on disk.
logs/andtmp/cannot take that answer — the plugin writes to them every session.So the issue's premise is right about history and too generous about the present: it is not only that old logs sit in history, it is that new ones kept going up on exactly the affected stores. And because #287 moved the delivery record to
tmp/, #285 is not fixed on a pre-#287 store either —tmp/remember.deliveredwas still being committed and pushed there.One correction in the other direction, which the README now carries: the setup snippet under Back up your memory has told people to hand-write a root
.gitignorewith*/logs/since #60 (2026-05-24). A store set up by following the README is unaffected. That narrows who this is about without letting me claim a number, and nobody has counted — the README says so and gives the check instead.Scope — I expanded it, and it is separable
The brief was docs-only. I could not write an honest README on top of a live leak: the true sentence would have been your logs are in history and are still being pushed. So this is two commits, and the first can be dropped without touching the second's story materially (the docs would then need one sentence changed, from "stops being pushed" to "keeps being pushed until the fix lands"):
0d5b531— the fix +tests/test_legacy_logs_untracking_288.py.d9d09c5— README + CHANGELOG disclosure.The fix: the untracking is now its own commit, of the index rather than of a pathspec — the one commit form that can record a deletion for a path still present on disk. Guards: only when
git ls-filesshows something to untrack; only whengit diff --cached --quiet(an index commit takes everything staged, and the store is a repo the user owns — their staged work must never land in a commit this hook wrote);git resetand a log line if it cannot finish. It rewrites nothing.RED / GREEN
RED (fix reverted, same tests):
GREEN:
4 passed in 28.93s.The two passing tests in the RED leg are deliberate guards rather than filler:
test_the_store_comes_to_rest_cleanfails any fix that leaves a permanent stagedD(the failure mode #287 called out), andtest_history_is_left_alonefails any fix that silently rewrites the user's repository.Full suite: 1274 passed, 43 skipped, coverage 94.16% (#287 reported 1270 / 43 / 94.16% — the +4 are these tests). Run before pushing; pushed with
--no-verifyfor the known SIGPIPE-141 wrapper issue.The wording, and why
New README subsection Logs in a backup you made before this version, under the git-backup section where people read what travels. Four things it does, each deliberate:
.gitignorethe setup snippet asks for, none of this applies to you.git log -- '*/logs/'returns nothing (a trailing-slash pathspec matches no blob), which would have told every affected user they were fine. It ships as'*/logs/*'.git-filter-repoin a throwaway venv against a real two-clone store: history clean afterwards, memory intact, force-push accepted, and the other clone left[ahead 2, behind 2]withgit pull --ff-onlyrefusing — that is the cost, measured, and it is what the paragraph describes. Two things I would not have known to write without running it: filter-repo deletes youroriginon purpose (so the recipe re-adds it), and unreachable objects can survive on the host regardless, so a rewrite is removal from the branch, not a guarantee of deletion.It also says outright that doing nothing is a legitimate answer. These are the user's own session logs in a repository they own; the point is that it becomes a decision.
The
/remember:doctorquestion — a recommendation, not a changeNo code written for it, per the brief. My view, for what it is worth:
Do not add a permanent finding. Add a one-shot notice, or nothing. The reason is that the population changed under us. With the fix in this PR, the first backup after upgrading emits a log line naming exactly what happened, once, on the store it happened to — that is already a targeted disclosure with no ongoing cost, and it fires only for stores that actually have the condition. A doctor finding on top of that would be a second, permanent warning about a state the user has now been told about twice and may reasonably not care about, and
doctoris where people go when something is wrong — a finding that can never be cleared without a history rewrite teaches them to ignore the section.If you want more than the log line, the shape I would pick is a
tmp/-markered one-shotsystemMessageat the moment of untracking, in the same family asgit-backup-notice— said once, to exactly the users it is true for, and never again. What I would avoid is a check that runsgit log -- '*/logs/*'on every doctor run: it is a full-history walk on someone's memory store, and its answer can never become "no".That is a recommendation. It is your call, and it was correctly reserved as yours.