repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

refactor(git): converge autostash=false via bootstripper instead of an includeIf glob

8ab1a8a370d83f1bff55fd62bd5db25db3a5c6cd

Oliver Krylow <o.krylow@isp-insoft.de> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (11)

AGENTS.md

Modified
53 53 ## Git operations in this repo
55 -Autostash is off here (`git/gitconfig.dotfiles`, included via `[includeIf]` in `git/gitconfig`).
56 -Never run `git pull`, `git rebase`, or `git merge` with a dirty worktree: commit the work first, or stash it explicitly and pop it yourself.
57 -After any pull/rebase/merge, check `git stash list`; an entry named `autostash` means an operation was interrupted and your changes are in that stash, not in the worktree.
58 -Files that suddenly show as `deleted` after a failed Git operation are almost always that case, not real deletions; recover with `git stash apply` before doing anything else.
59 -Hooks (`pre-commit`, `pre-push` → `bootstripper.java` → mise) and the required `dotfiles-aes` filter can abort mid-operation; never pass `--no-verify` to work around them.
55 +`bootstripper.java` converges `rebase.autostash` and `merge.autostash` to `false` in `.git/config`; `mise run check` asserts it.
56 +So Git refuses to pull, rebase, or merge here while the worktree is dirty: commit first, or stash explicitly and pop it yourself.
57 +The required `dotfiles-aes` filter and the `pre-commit`/`pre-push` hooks (`bootstripper.java` → mise) can abort a Git operation midway; never pass `--no-verify` to get around them.
61 59 ## Symlink manifests

ArchLinux-dev.symlinks

Modified
5 5 ~/.pi
7 7 git/gitconfig
8 8 ~/.config/git/config
10 -git/gitconfig.dotfiles
11 -~/.config/git/.gitconfig.dotfiles
13 10 git/gitattributes
14 11 ~/.config/git/gitattributes

NB-00718.symlinks

Modified
40 40 git/gitconfig
41 41 ~/.config/git/config
43 -git/gitconfig.dotfiles
44 -~/.config/git/.gitconfig.dotfiles
46 43 git/gitattributes
47 44 ~/.config/git/gitattributes

bootstripper.java

Modified
71 71 if ("check".equals(command)) {
72 72 setup_crypto(root);
73 + install_repo_settings(root);
73 74 check(root);
74 75 return;
98 99 var symlinks_file = symlinks_file(root);
99 100 check_symlink_sources(root);
100 101 converge_crypto(root);
102 + install_repo_settings(root);
101 103 install_hooks(root);
102 104 create_symlinks(root, symlinks_file);
103 105 print_attention(false);
111 113 var symlinks_file = symlinks_file(root);
112 114 check_symlink_sources(root);
113 115 converge_crypto(root);
116 + install_repo_settings(root);
114 117 install_hooks(root);
115 118 check(root);
116 119 create_symlinks(root, symlinks_file);
261 264 set_local_config(root, "merge." + filter_name + ".driver", merge_filter_command(root));
267 + // Autostash is a trap in this repository: the worktree is nearly always dirty, so
268 + // every rebase or merge stashes first, and the required crypto filter plus the Git
269 + // hooks can abort the operation before the stash is restored. The changes then sit
270 + // in a silent `autostash` stash entry while the files look deleted. Refuse instead.
271 + static void install_repo_settings(Path root) throws Throwable {
272 + set_local_config(root, "rebase.autostash", "false");
273 + set_local_config(root, "merge.autostash", "false");
276 + static void check_repo_settings(Path root) throws Throwable {
277 + check_local_config(root, "rebase.autostash", "false");
278 + check_local_config(root, "merge.autostash", "false");
281 + static void check_local_config(Path root, String name, String value) throws Throwable {
282 + var current = run(root, List.of("git", "config", "--local", "--get", name), null, false, false);
283 + if (current.exit != 0 || !current.text().strip().equals(value))
284 + throw fail("Local Git setting {0} must be {1}. Run `mise run link`.", name, value);
264 287 static void set_local_config(Path root, String name, String value) throws Throwable {
265 288 var current = run(root, List.of("git", "config", "--local", "--get", name), null, false, false);
266 289 if (current.exit != 0 || !current.text().strip().equals(value))
613 636 check_key_not_tracked(root);
614 637 check_staged_secrets(root, secrets);
639 + check_repo_settings(root);
616 640 check_symlink_sources(root);
617 641 log("OK bootstripper check passed.");

desktop.symlinks

Modified
37 37 git/gitconfig
38 38 ~/.config/git/config
40 -git/gitconfig.dotfiles
41 -~/.config/git/.gitconfig.dotfiles
43 40 git/gitattributes
44 41 ~/.config/git/gitattributes

git/gitconfig

Modified
240 240 # On each host a different file might be symlinked into '.gitconfig.include'.
241 241 [include]
242 242 path = .gitconfig.include
244 -# The dotfiles repo itself needs stricter settings than everything else, because
245 -# it is always dirty and carries required content filters plus hooks.
246 -[includeIf "gitdir/i:**/dotfiles/"]
247 - path = .gitconfig.dotfiles

git/gitconfig.dotfiles

Deleted
deleted file mode 100644
1 -# Settings that only apply to this dotfiles repository.
2 -# Symlinked to '~/.config/git/.gitconfig.dotfiles' and pulled in by the
3 -# [includeIf] section in 'git/gitconfig'.
5 -# Autostash is convenient in normal repos, but harmful here: this worktree is
6 -# almost always dirty, 'secrets.nu' needs the required 'dotfiles-aes' filter,
7 -# and the pre-push hook shells out to Java/mise. When any of those fail (or an
8 -# agent aborts the command), the rebase stops before restoring the autostash:
9 -# the changes end up in a silent 'autostash' stash entry while the files look
10 -# deleted in the worktree. Refusing loudly is cheaper to recover from.
11 -[rebase]
12 - autostash = false
14 -[merge]
15 - autostash = false

pi/agent/skills/git/git-sync/SKILL.md

Modified
32 32 If rejected, fetch, rebase, and test once more, then retry once.
33 33 If a hook fails, preserve its edits and stop with the failing command and evidence.
34 34 10. Report branch, target, remote, whether a rebase occurred, checks, publication authorization, and any pushed commit.
36 +## Interrupted rebases and autostash
38 +With `rebase.autostash` or `merge.autostash` enabled, Git stashes a dirty tree before rebasing and restores it afterwards.
39 +When the operation is interrupted between those steps — failing hook, failing content filter, aborted or timed-out command — the restore never happens.
40 +The result is silent: an unexpected stash entry named `autostash` holds the work while the affected files look modified or deleted in the worktree.
42 +- After any interrupted or failed fetch, rebase, merge, or pull, run `git stash list` before touching the worktree.
43 +- Treat an `autostash` entry you did not create as unrestored work: inspect it with `git stash show -p`, restore it with `git stash apply`, and only drop it once its content is confirmed present.
44 +- Never resolve files that Git reports as deleted after such a failure by committing the deletion; recover the stash first.
45 +- Prefer committing the work before synchronizing, so autostash never triggers.

scripts/dotfiles_integration_test.java

Modified
339 339 Files.delete(key);
341 341 boot(fixture, realEnv, "link");
342 + if (!run(repo, realEnv, "git", "config", "--local", "--get", "rebase.autostash").strip().equals("false")) fail("link-did-not-disable-rebase-autostash");
343 + if (!run(repo, realEnv, "git", "config", "--local", "--get", "merge.autostash").strip().equals("false")) fail("link-did-not-disable-merge-autostash");
342 344 if (!Arrays.equals(Files.readAllBytes(repo.resolve("secret.txt")), plain)) fail("link-fresh-checkout-not-decrypted");
343 345 if (!Arrays.equals(Files.readAllBytes(repo.resolve(".git/index")), index)) fail("link-fresh-checkout-changed-index");
344 346 var keyModified = Files.getLastModifiedTime(repo.resolve(".git/dotfiles-aes.key"));

termux.symlinks

Modified
7 7 git/gitconfig
8 8 ~/.config/git/config
10 -git/gitconfig.dotfiles
11 -~/.config/git/.gitconfig.dotfiles
13 10 git/gitattributes
14 11 ~/.config/git/gitattributes

x230.symlinks

Modified
37 37 git/gitconfig
38 38 ~/.config/git/config
40 -git/gitconfig.dotfiles
41 -~/.config/git/.gitconfig.dotfiles
43 40 git/gitattributes
44 41 ~/.config/git/gitattributes