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

Re: StGIT refreshes all added files - limitation of git-write-tree?

From
Shawn Pearce <spearce@spearce.org>
Date
Feb 15, 2006, 06:28 UTC
Message-ID
<20060215062814.GA26632@spearce.org>
In-Reply-To
<1139978528.28292.41.camel@dv>
Pavel Roskin <proski@gnu.org> wrote:
> Or maybe git-write-tree and other utilities could be changed to work on
> a copy of the index file?  I would prefer not to move the
> actual .git/index away, but to make a copy for the current "stg refresh"
> operation.

git-write-tree pays attention to the GIT_INDEX_FILE environment variable; if this, GIT_DIR and GIT_OBJECT_DIRECTORY are set you can redirect git-write-tree to look at a different index. One way to create a tree from a mixture of your current index and the current HEAD's tree is to set GIT_INDEX_FILE to a temporary file name (which doesn't exist), use git-read-tree to load the current tree unmodified into that index, copy the modified records of interest from the current index to the temporary index, then git-write-tree from the temporary index. But now you need to update your current index with the real SHA1s of the written files.

Somewhat convoluted. I think that git-commit.sh and cg-commit.sh play such games to do partial commits based on what the user has passed on the command line or modified in their editor (which is actually a rather cool feature of Cogito). I'm using a similar trick in pg to load binary objects from a patch directory (for a specific use case that I have). git-am.sh uses a similar trick to perform a 3 way merge if git-apply fails.

-- 
Shawn.
Previous: Pavel Roskin
Message 4 of 4 in “StGIT refreshes all added files - limitation of git-write-tree?”
  1. Pavel RoskinFeb 15, 2006
  2. Junio C HamanoFeb 15, 2006
  3. Pavel RoskinFeb 15, 2006
  4. Shawn PearceFeb 15, 2006

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.