Junio C Hamano <gitster@xxxxxxxxx> writes: > Greg Troxel <gdt@xxxxxxxxxx> writes: > >> If what I'm doing is an abuse of update-index, do you or anyone else >> have a suggestion to make a directory in the index match a tree object? > > "ls-tree -r HEAD foo" is probably what you meant to say. Thanks very much for the clue - that works. The update-index documentation should probably say that only blobs (or perhaps commits intended to be submodules??) are acceptable, and perhaps say "ls-tree -r" instead of ls-tree. It could easily seem reasonable to someone to pass in a tree and expect that to result in that tree being logically in the index and to appear in the resulting commit. For anyone else who is trying to do something like this, here's a revised script that (I think) correctly reverts a directory to another commit. #!/bin/sh if [ -d .git ]; then echo "existing .git" exit 1 fi set -x git init mkdir foo touch foo/bar git add foo git commit -m'initial content' git tag initial touch foo/baz git add foo/baz git commit -m 'add baz' git cat-file -p initial git cat-file -p initial: git rm --cached -r foo git ls-tree initial foo git ls-tree -r initial foo git ls-tree -r initial foo | git update-index --index-info git diff git diff --staged git commit -m'munged foo' git cat-file -p HEAD git cat-file -p HEAD:
Attachment:
pgpXhVrmdHiNC.pgp
Description: PGP signature