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

Re: [PATCH] Documentation/git-update-index: caution about tree objects

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 21, 2012, 02:56 UTC
Message-ID
<7vvcbw2jut.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1356053738-14926-1-git-send-email-gdt@ir.bbn.com>
Greg Troxel <gdt@ir.bbn.com> writes:
Show 23 quoted lines
> While one can add tree objects to the index, this is not currently
> useful.  Therefore, use "git ls-tree -r" as the example to be fed to
> --index-info.  Add a section explaining about expected index contents.
> (Thanks to Junio for explaining this to me in August of 2011.)
>
> Signed-off-by: Greg Troxel <gdt@ir.bbn.com>
> ---
>  Documentation/git-update-index.txt | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
> index 9d0b151..6ce65fa 100644
> --- a/Documentation/git-update-index.txt
> +++ b/Documentation/git-update-index.txt
> @@ -29,6 +29,11 @@ Modifies the index or directory cache. Each file mentioned is updated
>  into the index and any 'unmerged' or 'needs updating' state is
>  cleared.
>  
> +Note that update-index does not check that the modifications preserve
> +the expected invariants.  In particular, an index normally holds
> +regular blobs, executable blobs, symlink blobs, and gitlinks.
> +Therefore, adding a tree object is not likely useful.
> +

I find this unnecessarily alarmist as a description meant for general audiences. For the normal mode of operations of the command (e.g. "git update-index --add --remove hello.c"), whatever you mean by "expected invariants" are fully preserved.

I think you meant this for --cacheinfo and --index-info options, which are primarily meant for people who know what they are doing (that includes the use of this command in scripted Porceains) or Git developers who want to work on enhancing the index (and to them, being able to record anything is more convenient).

Show 7 quoted lines
> @@ -210,7 +215,7 @@ back on 3-way merge.
>  
>      . mode SP type SP sha1          TAB path
>  +
> -The second format is to stuff 'git ls-tree' output
> +The second format is to stuff 'git ls-tree -r' output
>  into the index file.
This hunk is good.
Thanks.
Previous: Greg Troxel
Message 2 of 2 in “Documentation/git-update-index: caution about tree objects”
  1. Documentation/git-update-index: caution about tree objectsGreg Troxel, Dec 21, 2012
  2. Junio C HamanoDec 21, 2012

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.