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

Sanity checking request

From
Junio C Hamano <junkio@cox.net>
Date
Mar 28, 2007, 09:57 UTC
Message-ID
<7vwt11itbz.fsf@assigned-by-dhcp.cox.net>
We've been saying that:
	git read-tree -m $tree

is a quicker way to do "git read-tree $tree" (i.e. populate the index from a given tree), and except for the reuse of cached stat info to gain performance, there is no difference.

Well, I think I broke it with fcc387d on May 17 2006, and I am wondering what the correct way to fix that should be. It depends on how -u and -i options to git-read-tree are meant to be used.

On one hand, one could argue that "git read-tree -m $tree" should behave the same way as "git read-tree -m -u $tree" except that it does not do the checkout part. The in-code comment for the -i option says "a merge will not even look at the working tree", implying that it will without the option, so running verify_update() and verify_absense() even though update option is not explicitly passed (hence read-tree itself does not do the checkout) might be the right thing to do. Admittedly, when I introduced the above breakage, I wasn't consciously making such design decision (I was more interested in making two- and three-tree case work). Then "git read-tree -i -m $tree" would become the new right way to do a quicker "git read-tree $tree" if we take this route.

The only in-tree user of single-tree merge is in git-commit. We could do this:

diff --git a/git-commit.sh b/git-commit.sh
index 3656d60..292cf96 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -371,7 +371,7 @@ t,)
 		if test -z "$initial_commit"
 		then
 			cp "$THIS_INDEX" "$TMP_INDEX"
-			GIT_INDEX_FILE="$TMP_INDEX" git-read-tree -m HEAD
+			GIT_INDEX_FILE="$TMP_INDEX" git-read-tree -i -m HEAD
 		else
 			rm -f "$TMP_INDEX"
 		fi || exit


Alternatively, we could make -i implied for one-tree merge
unless -u is given, which is the attached.

What do you think?

-- >8 --
read-tree -m $TREE: do not look at working tree.

A merging single-tree read-tree has been advertised as a quicker
way to do the equivalent single-tree read-tree without any other
difference, but currently it looks at the working tree and does
bogus checks to detect if the paths have local changes and
such.  Disable them.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 793eae0..2a1d3c8 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -236,6 +236,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 		switch (stage - 1) {
 		case 1:
 			opts.fn = opts.prefix ? bind_merge : oneway_merge;
+			if (!opts.update)
+				opts.index_only = 1;
 			break;
 		case 2:
 			opts.fn = twoway_merge;
Next: Linus Torvalds
Message 1 of 7 in “Sanity checking request”
  1. Junio C HamanoMar 28, 2007
  2. Linus TorvaldsMar 28, 2007
  3. Junio C HamanoMar 28, 2007
  4. 0/2 Alternate index output fileJunio C Hamano, Apr 1, 2007
  5. 1/2 _GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index file.Junio C Hamano, Apr 1, 2007
  6. 2/2 git-read-tree --index-output=<file>Junio C Hamano, Apr 1, 2007
  7. Linus TorvaldsApr 1, 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.