Git development
 help / color / mirror / Atom feed
* smudge filters during checkout & crash consistency
@ 2014-11-12 17:46 Derek Moore
  2014-11-12 18:30 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Derek Moore @ 2014-11-12 17:46 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-12 20:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12 17:46 smudge filters during checkout & crash consistency Derek Moore
2014-11-12 18:30 ` Junio C Hamano
2014-11-12 19:41   ` Derek Moore
2014-11-12 20:30   ` Derek Moore
2014-11-12 20:51     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox