New post: A guide to the adjusted branch (unlocked) #17

Open
wjm wants to merge 7 commits from wjm/datalad-blog:adjusted-branch-guide into main
Contributor

I wrote up a comprehensive guide on adjusted branch behavior with the intention to help other Windows users with their DataLad experience, and to help maintainers to better understand how DataLad/git-annex works on Windows. Hopefully this provides some incentive for you to increase the test coverage on Windows, and to finally start welcoming the reset command that is waiting to be reviewed since ... oh it's been so long, I don't even remember ;)

I wrote up a comprehensive guide on adjusted branch behavior with the intention to help other Windows users with their DataLad experience, and to help maintainers to better understand how DataLad/git-annex works on Windows. Hopefully this provides some incentive for you to increase the test coverage on Windows, and to finally start welcoming the reset command that is waiting to be reviewed since ... oh it's been so long, I don't even remember ;)
cols/col render two code columns next to each other (one full-width
column with single="true"); details/md give a collapsible block whose
content may hold both markdown and shortcodes. PaperMod's collapse
markdownifies its content and so drops the HTML of nested shortcodes.
add new post: a guide to the adjusted branch (unlocked)
All checks were successful
Codespell / Check for spelling errors (pull_request) Successful in 27s
991fe4bd1e
How git-annex's adjusted branch works on Windows, where resetting it
breaks, and how to test for it. Every example comes from one story run
on Linux and on Windows; story-linux.sh and story-windows.sh let readers
replay it.
wjm requested reviews from mih, yarikoptic 2026-11-05 12:33:35 +00:00
Member

Very nice. I am a bit lost in argumentation in "They are skipped because Windows has no normal branch:" as branch is there, just not checked out... might even not have locked files in it and could be checked out...

Anyways, here is some feedback from my "corporate friend" (claude code) with slight tune ups from me:

on shortcodes

They work well: all four are used, along with all of their parameters, and they do not affect any existing post. Building the site with and without them gave byte-identical output for the older posts. The suggestions below are small, and only the first is worth doing before merging.

  1. Hugo ships a built-in details shortcode (since v0.140.0), and our local file replaces it for the whole site. Why not to just use that instead? if there is a reason for a custom one, rename to e.g. dldetails (see more on that below).

  2. Please add a short comment to md.html. It looks like a no-op, but it is needed: details uses the standard {{< >}} notation, so its inner text is not rendered as Markdown, and {{% md %}} uses the Markdown notation to get it rendered. Without the wrappers, raw Markdown shows up in that section. Using {{% details %}} instead makes the whole section disappear, also without a build error, so a comment would save the next person from trying that simplification.

  3. single could accept an unquoted value. {{< cols single=true >}} builds fine but silently gives two columns, because the template only matches the string "true". This one-word change in cols.html handles both forms, and I confirmed the output is unchanged:

    {{ if eq (string (.Get "single")) "true" }}
    
Optional: move the CSS out of the shortcode

The <style> block in cols.html is repeated for each of the 13 uses on the page. PaperMod bundles everything in assets/css/extended/, so moving it to assets/css/extended/cols.css keeps a single copy and saves about 4.5 KB on this page. The trade-off is that the rules then load on every page of the site, so either way is fine.

The names cols, col and md are fine as they are (as not conflicting, tested all of this with Hugo 0.169.) But since names are quite short and have a potential to collide potentially in future with built in hugo shortcodes, making them more "unique" would be of better practice. What about dlcols, dlcol, dlmd?

on content

Since the CI runner is unavailable at the moment, I built the site locally and ran your scripts. The post is in very good shape: I would merge it after a few small corrections below. None of them touch the core explanation. The ones worth the most attention are 1 and 2, which are both about what the simulation can and cannot do.

Build: clean with Hugo 0.169. Shortcodes, tables, footnotes, anchors, both scripts and both SVGs all render, on desktop and phone and in light and dark themes, and the deep link opens the collapsed section. codespell passes. cover.webp is already on hub, so there is nothing to do there.

Small factual corrections

I ran story-linux.sh, and story-windows.sh under your annex.crippledfilesystem simulation, with git-annex 10.20261026, DataLad 1.8.0, and git 2.43.0 and 2.47.3. As L852 predicts, story-windows.sh stops at the failing datalad update, so I also ran it without set -e and ran the puzzle on its own. Line numbers refer to index.md.

  1. The simulation can play the puzzle as written (L864). All its commands succeeded under both git versions, ending in the history your three update steps describe. The switch back only works because the puzzle's fresh dataset has no annexed content yet. With a content-present annexed file saved beforehand, the switch fails after any index refresh on master, and the puzzle's own datalad save is enough to trigger that. So L864 holds for datasets with content, but not for the puzzle as written.
  2. The false "modified" looks like a clean-filter effect, not a compile-time switch (L851).
    • I found no such switch in the git-annex source. With core.symlinks=false, the path text on master is a regular file, so git runs the clean filter on it. getMoveRaceRecovery in Command/Smudge.hs then populates the file.
    • It reproduces on plain Linux with core.symlinks=false alone, without annex.crippledfilesystem. So a FAT drive would probably fail the same way, although I have not tested that.
    • "Whenever" and "No setting changes that" are too strong. A bare swap passes until something refreshes the index, and the failing adjust passes if the index is newer than the file, or with core.symlinks=true (which no longer simulates path text).
    • I could not determine why Windows behaves differently. If you get a chance, GIT_TRACE=1 git status on master on Windows would show whether the filter runs there at all.
  3. core.symlinks=false is not always set by git-annex (L234). git-annex only sets it if git has not already done so. checkCrippledFileSystem in Annex/Init.hs says: "Normally git disables core.symlinks itself". Your Windows output has no Disabling core.symlinks line, while the simulation output does.
  4. DataLad already tests on a real VFAT filesystem on Linux (L851, L858, L776). test_crippled.yml runs datalad.core, datalad.local and datalad.distributed on a VFAT mount, on real adjusted branches. That is worth a mention next to "we have not tested that" and the "simulated" table cell, and it softens "end up as the ones without tests" a little. Your point still stands for update, because datalad.distribution is not in that job.
  5. get_corresponding_branch() returns None on a normal branch (L787). So on its own it does not "hold on every branch". The idiom already used in DataLad is repo.get_corresponding_branch() or repo.get_active_branch().
  6. test_unlock.py does a bit more than skip (L791). test_unlock_directory does assert the adjusted-branch behaviour, while test_unlock skips its lock-state checks, so naming test_unlock would make the sentence accurate.
  7. A save with nothing to save does not sync (L349). After a plain git commit, a no-op datalad save left master unchanged, in the simulation and on a real adjusted branch. A save that commits something, push and update --how=merge all carry it over.
  8. Whether git status restores the content depends on timing (L850). On Linux, git reset --hard writes the file and the index at the same moment, so git status re-reads the file and git-annex restores it, both in the simulation and on a normal adjusted branch. So anyone replaying the Windows order (status, then cat) normally sees content rather than the pointer. When I forced the index to be newer than the file with touch .git/index, the pointer survived git status, git diff and datalad status, just as in your Windows column. That may be what happens on Windows, but I could not check.
Tiny wording suggestions and optional polish

Wording:

  • L796: "takes its Windows code path" conflicts with L851; "crippled-filesystem code path" fits better.
  • L788: "brick" is an internal term; "example" reads better.
  • L24: "every DataLad dataset" could be "every annex-enabled dataset", since a --no-annex dataset stays on master.
  • L36: git-annex treats Windows as crippled unconditionally, so "git-annex doesn't use symlinks there" is more exact than "symlinks don't work".

Polish, entirely up to you:

  • Some long comments in the side-by-side columns need sideways scrolling, for example L176.
  • The "dashed: only if master moved on its own" label in sync-update.svg runs about 3px past the edge.
  • The scripts assume master. With init.defaultBranch=main, story-linux.sh aborts at fatal: ambiguous argument 'master', so a short note could help readers who run them.
What I checked and found correct
  • story-linux.sh runs to the end, including the expected failure, and its output matches the post's Linux columns.
  • Under the simulation, the object hashes, the adjusting commit, basis, the swallowed save, the failing adjust and the failing update all match.
  • The save and push sync, update --how=merge, the --force semantics, the update --how=reset steps and the 1.6.5 version match the sources.
  • The June 2026 fix and datalad#7772 are right. The uncessary in the footnote URL is the real page name, so please keep it.

Nothing ran on real Windows, so Windows-only results, such as the data loss on update, were checked against the source and the simulation only.

Thanks again for writing this up. It is a real contribution to the project!

Very nice. I am a bit lost in argumentation in "They are skipped because Windows has no normal branch:" as branch is there, just not checked out... might even not have locked files in it and could be checked out... Anyways, here is some feedback from my "corporate friend" (claude code) with slight tune ups from me: ### on shortcodes They work well: all four are used, along with all of their parameters, and they do not affect any existing post. Building the site with and without them gave byte-identical output for the older posts. The suggestions below are small, and only the first is worth doing before merging. 1. Hugo ships a [built-in `details` shortcode](https://gohugo.io/shortcodes/details/) (since v0.140.0), and our local file replaces it for the whole site. Why not to just use that instead? if there is a reason for a custom one, rename to e.g. `dldetails` (see more on that below). 2. **Please add a short comment to `md.html`.** It looks like a no-op, but it is needed: `details` uses the [standard `{{< >}}` notation](https://gohugo.io/content-management/shortcodes/#standard-notation), so its inner text is not rendered as Markdown, and `{{% md %}}` uses the [Markdown notation](https://gohugo.io/content-management/shortcodes/#markdown-notation) to get it rendered. Without the wrappers, raw Markdown shows up in that section. Using `{{% details %}}` instead makes the whole section disappear, also without a build error, so a comment would save the next person from trying that simplification. 3. **`single` could accept an unquoted value.** `{{< cols single=true >}}` builds fine but silently gives two columns, because the template only matches the string `"true"`. This one-word change in `cols.html` handles both forms, and I confirmed the output is unchanged: ```go-html-template {{ if eq (string (.Get "single")) "true" }} ``` <details><summary>Optional: move the CSS out of the shortcode</summary> The `<style>` block in `cols.html` is repeated for each of the 13 uses on the page. PaperMod [bundles everything in `assets/css/extended/`](https://github.com/adityatelange/hugo-PaperMod/wiki/FAQs), so moving it to `assets/css/extended/cols.css` keeps a single copy and saves about 4.5 KB on this page. The trade-off is that the rules then load on every page of the site, so either way is fine. </details> The names `cols`, `col` and `md` are fine as they are (as not conflicting, tested all of this with Hugo 0.169.) But since names are quite short and have a potential to collide potentially in future with built in hugo shortcodes, making them more "unique" would be of better practice. What about `dlcols, dlcol, dlmd`? ### on content Since the CI runner is unavailable at the moment, I built the site locally and ran your scripts. The post is in very good shape: **I would merge it after a few small corrections below.** None of them touch the core explanation. The ones worth the most attention are 1 and 2, which are both about what the simulation can and cannot do. **Build:** clean with Hugo 0.169. Shortcodes, tables, footnotes, anchors, both scripts and both SVGs all render, on desktop and phone and in light and dark themes, and the deep link opens the collapsed section. codespell passes. `cover.webp` is already on `hub`, so there is nothing to do there. ## Small factual corrections I ran `story-linux.sh`, and `story-windows.sh` under your `annex.crippledfilesystem` simulation, with git-annex 10.20261026, DataLad 1.8.0, and git 2.43.0 and 2.47.3. As L852 predicts, `story-windows.sh` stops at the failing `datalad update`, so I also ran it without `set -e` and ran the puzzle on its own. Line numbers refer to `index.md`. 1. **The simulation can play the puzzle as written (L864).** All its commands succeeded under both git versions, ending in the history your three `update` steps describe. The switch back only works because the puzzle's fresh dataset has no annexed content yet. With a content-present annexed file saved beforehand, the switch fails after any index refresh on `master`, and the puzzle's own `datalad save` is enough to trigger that. So L864 holds for datasets with content, but not for the puzzle as written. 2. **The false "modified" looks like a clean-filter effect, not a compile-time switch (L851).** - I found no such switch in the git-annex source. With `core.symlinks=false`, the path text on `master` is a regular file, so git runs the clean filter on it. `getMoveRaceRecovery` in `Command/Smudge.hs` then populates the file. - It reproduces on plain Linux with `core.symlinks=false` alone, without `annex.crippledfilesystem`. So a FAT drive would probably fail the same way, although I have not tested that. - "Whenever" and "No setting changes that" are too strong. A bare swap passes until something refreshes the index, and the failing `adjust` passes if the index is newer than the file, or with `core.symlinks=true` (which no longer simulates path text). - I could not determine why Windows behaves differently. If you get a chance, `GIT_TRACE=1 git status` on `master` on Windows would show whether the filter runs there at all. 3. **`core.symlinks=false` is not always set by git-annex (L234).** git-annex only sets it if git has not already done so. `checkCrippledFileSystem` in `Annex/Init.hs` says: "Normally git disables core.symlinks itself". Your Windows output has no `Disabling core.symlinks` line, while the simulation output does. 4. **DataLad already tests on a real VFAT filesystem on Linux (L851, L858, L776).** [`test_crippled.yml`](https://github.com/datalad/datalad/blob/master/.github/workflows/test_crippled.yml) runs `datalad.core`, `datalad.local` and `datalad.distributed` on a VFAT mount, on real adjusted branches. That is worth a mention next to "we have not tested that" and the "simulated" table cell, and it softens "end up as the ones without tests" a little. Your point still stands for `update`, because `datalad.distribution` is not in that job. 5. **`get_corresponding_branch()` returns `None` on a normal branch (L787).** So on its own it does not "hold on every branch". The idiom already used in DataLad is `repo.get_corresponding_branch() or repo.get_active_branch()`. 6. **`test_unlock.py` does a bit more than skip (L791).** `test_unlock_directory` does assert the adjusted-branch behaviour, while `test_unlock` skips its lock-state checks, so naming `test_unlock` would make the sentence accurate. 7. **A `save` with nothing to save does not sync (L349).** After a plain `git commit`, a no-op `datalad save` left `master` unchanged, in the simulation and on a real adjusted branch. A `save` that commits something, `push` and `update --how=merge` all carry it over. 8. **Whether `git status` restores the content depends on timing (L850).** On Linux, `git reset --hard` writes the file and the index at the same moment, so `git status` re-reads the file and git-annex restores it, both in the simulation and on a normal adjusted branch. So anyone replaying the Windows order (status, then `cat`) normally sees `content` rather than the pointer. When I forced the index to be newer than the file with `touch .git/index`, the pointer survived `git status`, `git diff` and `datalad status`, just as in your Windows column. That may be what happens on Windows, but I could not check. <details><summary>Tiny wording suggestions and optional polish</summary> Wording: - L796: "takes its Windows code path" conflicts with L851; "crippled-filesystem code path" fits better. - L788: "brick" is an internal term; "example" reads better. - L24: "every DataLad dataset" could be "every annex-enabled dataset", since a `--no-annex` dataset stays on `master`. - L36: git-annex treats Windows as crippled unconditionally, so "git-annex doesn't use symlinks there" is more exact than "symlinks don't work". Polish, entirely up to you: - Some long comments in the side-by-side columns need sideways scrolling, for example L176. - The "dashed: only if master moved on its own" label in `sync-update.svg` runs about 3px past the edge. - The scripts assume `master`. With `init.defaultBranch=main`, `story-linux.sh` aborts at `fatal: ambiguous argument 'master'`, so a short note could help readers who run them. </details> <details><summary>What I checked and found correct</summary> - `story-linux.sh` runs to the end, including the expected failure, and its output matches the post's Linux columns. - Under the simulation, the object hashes, the adjusting commit, `basis`, the swallowed `save`, the failing `adjust` and the failing `update` all match. - The `save` and `push` sync, `update --how=merge`, the `--force` semantics, the `update --how=reset` steps and the 1.6.5 version match the sources. - The June 2026 fix and datalad#7772 are right. The `uncessary` in the footnote URL is the real page name, so please keep it. Nothing ran on real Windows, so Windows-only results, such as the data loss on `update`, were checked against the source and the simulation only. </details> Thanks again for writing this up. It is a real contribution to the project!
cols, col, md and details become dlcols, dlcol, dlmd and dldetails, so that
they cannot collide with shortcodes Hugo adds later: Hugo has shipped its own
details since v0.140.0, which ours replaced site-wide.
dlcols only matched the string "true", so single=true without quotes built
fine but gave two columns. Its style block was repeated with every use; in
assets/css/extended/ PaperMod bundles it into the site stylesheet once.
dlmd and dldetails get a comment on why dlmd is needed and why dldetails
is not Hugo's built-in details, which drops the id that a link points to.
The label ran about 3px past the right edge of the 720px frame.
The post now builds on one distinction: reading should cost nothing, writing
must leave the stored version intact. A locked file serves both through a
symlink; on Windows git-annex does not use symlinks, so master holds
path-text files there, and the adjusted branch provides an unlocked copy of
every annexed file instead. git's records (a symlink with the path, or a
regular file with a pointer) are named as such and kept apart from what
lands in the work tree.

Corrections from review:
- The simulation's false "modified" is no compile-time switch.
  core.symlinks=false alone reproduces it, so the no-symlink test leg sets
  just that. On Linux git-annex's filter fills master's path-text files
  with their content; on Windows the same replacement fails because git
  holds the file open, and git-annex ignores the error.
- core.symlinks=false is simply the setting on Windows; who sets it is not
  the point.
- A plain git commit reaches master at the next update, push, or save that
  commits something.
- get_corresponding_branch() is paired with get_active_branch().
- test_unlock is named as the test that skips its checks.
- When git status puts the content back after a plain reset is a matter of
  timing on Linux and never happens on Windows; that detail moved to a
  footnote, and the main text gives git checkout -- . as the reliable way.

Also: shortcodes renamed in the post, "normal branch" and "crippled"
replaced by what is meant, the testing section opens with the properties
tests rely on, and strategy 3 is about reproducing Windows on Linux.

Examples: a cat in the first example shows that a locked file is readable,
git checkout replaces git switch, example 14 names its files kept.bin and
discarded.bin after their role, and column comments are shorter. The
downloadable scripts start new repositories on master whatever
init.defaultBranch says.
post: add answers to the puzzle
All checks were successful
Codespell / Check for spelling errors (pull_request) Successful in 48s
95158c9f7e
The answers sit in a collapsed block, without explanations. Question 1 now
names the work tree's checked-out branch and asks separately whether the
sibling has each file's content, where the surprise lies.
Author
Contributor

Thanks a lot for the thorough review! It made me rethink the post's core, so beyond the fixes it now builds on one idea: reading should cost nothing, writing must keep the stored version intact. A locked file does both through a symlink; on Windows master holds path-text files instead (the link target as plain text), which is why the adjusted branch exists.

"Windows has no normal branch": right, master can be checked out; what Windows lacks are locked files. "Normal branch" is gone, and the test legs are now locked, adjusted and no-symlink.

Shortcodes: renamed to dlcols, dlcol, dlmd, dldetails. dldetails stays our own because Hugo's built-in details drops the id the post links to. dlmd has the comment, single=true works unquoted, and the CSS moved to assets/css/extended/.

1 and 2: confirmed. core.symlinks=false alone reproduces it, so the no-symlink leg sets just that. Why Windows differs:

  • git keeps the file open while the clean filter runs (ce_compare_data → index_fd closes it only afterwards).
  • getMoveRaceRecovery then renames the content over that open file. Linux allows that, Windows refuses: the same rename inside git's filter call fails with PermissionError: [WinError 5], while outside git it succeeds on Windows too.
  • tryNonAsync swallows the error, so the file silently stays path text.

3–8: corrected; 8 (timing) is now a footnote, the main text gives git checkout -- . as the reliable way.

Commits: shortcodes (2), an SVG fix, the revised post, and the puzzle's answers, now in a collapsed block.

Thanks a lot for the thorough review! It made me rethink the post's core, so beyond the fixes it now builds on one idea: reading should cost nothing, writing must keep the stored version intact. A locked file does both through a symlink; on Windows `master` holds **path-text files** instead (the link target as plain text), which is why the adjusted branch exists. **"Windows has no normal branch"**: right, `master` can be checked out; what Windows lacks are locked files. "Normal branch" is gone, and the test legs are now locked, adjusted and no-symlink. **Shortcodes**: renamed to `dlcols`, `dlcol`, `dlmd`, `dldetails`. `dldetails` stays our own because Hugo's built-in `details` drops the `id` the post links to. `dlmd` has the comment, `single=true` works unquoted, and the CSS moved to `assets/css/extended/`. **1 and 2**: confirmed. `core.symlinks=false` alone reproduces it, so the no-symlink leg sets just that. Why Windows differs: - git keeps the file open while the clean filter runs (`ce_compare_data` → `index_fd` closes it only afterwards). - `getMoveRaceRecovery` then renames the content over that open file. Linux allows that, Windows refuses: the same rename inside git's filter call fails with `PermissionError: [WinError 5]`, while outside git it succeeds on Windows too. - `tryNonAsync` swallows the error, so the file silently stays path text. **3–8**: corrected; 8 (timing) is now a footnote, the main text gives `git checkout -- .` as the reliable way. Commits: shortcodes (2), an SVG fix, the revised post, and the puzzle's answers, now in a collapsed block.
wjm force-pushed adjusted-branch-guide from 95158c9f7e
All checks were successful
Codespell / Check for spelling errors (pull_request) Successful in 48s
to 3f02337fe1
All checks were successful
Codespell / Check for spelling errors (pull_request) Successful in 31s
2026-11-24 14:47:43 +00:00
Compare
Author
Contributor

rebased, i think it's ready to be merged @yarikoptic

rebased, i think it's ready to be merged @yarikoptic
All checks were successful
Codespell / Check for spelling errors (pull_request) Successful in 31s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'adjusted-branch-guide:wjm-adjusted-branch-guide'
git switch 'wjm-adjusted-branch-guide'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'wjm-adjusted-branch-guide'
git switch 'wjm-adjusted-branch-guide'
git rebase 'main'
git switch 'main'
git merge --ff-only 'wjm-adjusted-branch-guide'
git switch 'wjm-adjusted-branch-guide'
git rebase 'main'
git switch 'main'
git merge --no-ff 'wjm-adjusted-branch-guide'
git switch 'main'
git merge --squash 'wjm-adjusted-branch-guide'
git switch 'main'
git merge --ff-only 'wjm-adjusted-branch-guide'
git switch 'main'
git merge 'wjm-adjusted-branch-guide'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
www/datalad-blog!17
No description provided.