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

clarification on git-update-index --remove

From
DTDavid Tweed <david.tweed@gmail.com>
Date
Jan 4, 2007, 19:29 UTC
Message-ID
<e1dab3980701041129l3944df8ep985141d8f436d0a7@mail.gmail.com>

Hi, can someone who understands the index in git please clarify something for me? Looking at the documentation it's not totally clear which entites are referred to by "removed" and what that then implies.

from git-1.4.4.3/Documentation/git-update-index.txt <<<<<<<<<<<
--remove::
	If a specified file is in the index but is missing then it's
	removed.
	Default behavior is to ignore removed file.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
I currently take this to mean

"With --remove, if there is a filepath in the index and that filepath is in the list of files being fed to this instance of git-update-index but in the working directory tree that filepath does not currently exist, then upon termination remove the filepath's record from the index. [This means at the next commit it will not be present at all in the set of files recorded via this commit.]

Default behaviour in that situation is to leave the index's current record unaltered. [This means that that filename will be, upon a commit, recorded as having whatever sha-content the index currently records it as having.]"

If this reading is right, this means that I have to pass the names of files that have been removed otherwise they'll stay with their "last contents before removal"? I'm currently finding removed files "stay around in snapshots with their ultimate contents", and I now _think_ this is the reason but I'm not sure.

(In case anyone's wants to know the context, I traced through and distilled git-commit.sh to what I think I need (rexpressed in python) with the core "make snapshot" code being

<<<<<<<<<<<<<<<<
    p1=loggedPopen(["git-update-index","-z","--add","--remove","--stdin"],
                   stdin=PIPE)
    for (d,fs) in files.iteritems(): # enters only "to be recorded" items
        for f in fs:
            p1.stdin.write(os.path.join(d,f)+"\0")
    p1.stdin.close()
    p1.wait()
    tree=loggedPopen(["git-write-tree"],stdout=PIPE).communicate()[0].rstrip()
    commit=loggedPopen(["git-commit-tree",tree,"-p","HEAD"],
                       stdin=PIPE,stdout=PIPE).communicate("cv")[0].rstrip()
<<<<<<<<<<<<<<<<<

Here files contains the set of files to be recorded in the current snapshot, structured as (directory,set of files in directory).)

Many thanks for any insight,
-- 
cheers, dave tweed__________________________
david "DOT" tweed "AT" gmail "DOT" com
Rm 124, School of Systems Engineering, University of Reading.
Details are all that matters; God dwells there, and you never get to
see Him if you don't struggle to get them right. -- Stephen Jay Gould
Next: Junio C Hamano
Message 1 of 2 in “clarification on git-update-index --remove”
  1. David TweedJan 4, 2007
  2. Junio C HamanoJan 4, 2007

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.