git/list[1] front-page[2] threads[3] people[4] search[5] about
 

smudge filters during checkout & crash consistency

From
Derek Moore <derek.p.moore@gmail.com>
Date
Nov 12, 2014, 17:46 UTC
Message-ID
<CAMsgyKbox7e2pv4+_=jG6Ywh3Km2gPsw+Qf6qj-28GWrVg7RZQ@mail.gmail.com>

I have a case where I would like to smudge files according to the reflog information of the switching-to branch.

This is difficult to achieve because updating HEAD to the new switched-to refname or commit hash is the last step performed in a checkout prior to calling the post-checkout hook, and smudge filters process content during the rewriting of the index and work-tree before HEAD is updated.

I believe this weakness of checkout & filters also exposes a crash consistency concern. Suppose power is lost during a long-running checkout while the index/worktree is being updated but before the new HEAD file is written.

Upon coming back up, your git status will show edits against your switching-from branch, and possibilities of recovery would rely on your memory of what you were doing (instead of git-status reporting "Incomplete checkout to {branch,commit}, 'git checkout --continue' to continue").

Maybe git could record a CHECKOUT_HEAD at the start of a checkout, then at the end of the commit update_refs_for_switch() would move CHECKOUT_HEAD over top HEAD instead of rewriting HEAD (but, presumably, a lot of logic in update_refs_for_switch() would have to be relocated to when CHECKOUT_HEAD is written, other implications notwithstanding).

Crash consistency aside, my workaround for filtering will probably be to use a fake smudge filter that records the file paths of all to-be-smudged files to a file under .git/, and then use a post-commit hook that will process those files from within the newly checked-out branch (where I'll be using git-archive to overwrite files).

Seems git could fix these two concerns in one fell swoop.
Thanks,
Derek
Next: Junio C Hamano
Message 1 of 5 in “smudge filters during checkout & crash consistency”
  1. Derek MooreNov 12, 2014
  2. Junio C HamanoNov 12, 2014
  3. Derek MooreNov 12, 2014
  4. Derek MooreNov 12, 2014
  5. Junio C HamanoNov 12, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.