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

[PATCH] read-tree.txt: clarify --reset and worktree changes

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 26, 2019, 12:09 UTC
Message-ID
<20190326120939.31657-1-pclouds@gmail.com>

The description of --reset stays true to the first implementation in 438195cced (git-read-tree: add "--reset" flag, 2005-06-09). That is, --reset discards unmerged entries. Or at least true to the commit message because I can't be sure about read-tree's behavior regarding local changes.

But in fcc387db9b (read-tree -m -u: do not overwrite or remove untracked working tree files., 2006-05-17), it is clear that "-m -u" tries to keep local changes, while --reset is singled out and will keep overwriting worktree files. It's not stated in the commit message, but it's obvious from the patch.

I went this far back not because I had a lot of free time, but because I did not trust my reading of unpack-trees.c code. So far I think the related changes in history agree with my understanding of the current code, that "--reset" loses local changes.

This behavior is not mentioned in git-read-tree.txt, even though old-timers probably can just guess it based on the "reset" name. Update git-read-tree.txt about this.

Side note. There's another change regarding --reset that is not obviously about local changes, b018ff6085 (unpack-trees: fix "read-tree -u --reset A B" with conflicted index, 2012-12-29). But I'm pretty sure this is about the first function of --reset, to discard unmerged entries correctly.

PS. The patch changes one more line than necessary because the first line uses spaces instead of tab.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-read-tree.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt
index 5c70bc2878..12a25bc954 100644
--- a/Documentation/git-read-tree.txt
+++ b/Documentation/git-read-tree.txt
@@ -38,8 +38,9 @@ OPTIONS
 	started.
 
 --reset::
-        Same as -m, except that unmerged entries are discarded
-        instead of failing.
+	Same as -m, except that unmerged entries are discarded
+	instead of failing. If `-u` is used, updates leading to loss
+	of local changes will not abort the operation.
 
 -u::
 	After a successful merge, update the files in the work
-- 
2.21.0.479.g47ac719cd3
Next: Junio C Hamano
Message 1 of 4 in “read-tree.txt: clarify --reset and worktree changes”
  1. read-tree.txt: clarify --reset and worktree changesNguyễn Thái Ngọc Duy, Mar 26, 2019
  2. Junio C HamanoApr 1, 2019
  3. Duy NguyenApr 1, 2019
  4. read-tree.txt: clarify --reset and worktree changesNguyễn Thái Ngọc Duy, Apr 1, 2019

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.