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

Re: update-index --index-info producing spurious submodule commits

From
GTGreg Troxel <gdt@ir.bbn.com>
Date
Aug 19, 2011, 11:00 UTC
Message-ID
<rmi39gxacp1.fsf@fnord.ir.bbn.com>
In-Reply-To
<7vpqk2593g.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> Greg Troxel <gdt@ir.bbn.com> 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:

Previous: Junio C HamanoNext: Jonathan Nieder
Message 5 of 7 in “update-index --index-info producing spurious submodule commits”
  1. Greg TroxelAug 18, 2011
  2. Junio C HamanoAug 18, 2011
  3. Greg TroxelAug 19, 2011
  4. Junio C HamanoAug 19, 2011
  5. Greg TroxelAug 19, 2011
  6. Jonathan NiederAug 20, 2011
  7. Junio C HamanoAug 19, 2011

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.