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

[PATCH 4/4] Teach git-reset to use index BASE extension.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 9, 2007, 06:13 UTC
Message-ID
<7vlkh23wj4.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vps6e5b93.fsf_-_@assigned-by-dhcp.cox.net>

After resetting the HEAD to point at a different commit, the user obviously intends to make the next commit a child of the updated HEAD commit. Record it in the index so that we can detect the case where somebody else updates the tip of the current branch while we are looking the other way.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git-reset.sh |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/git-reset.sh b/git-reset.sh
index fee6d98..982c726 100755
--- a/git-reset.sh
+++ b/git-reset.sh
@@ -71,7 +71,7 @@ then
 		die "Cannot do a soft reset in the middle of a merge."
 	fi
 else
-	git-read-tree --reset $update "$rev" || exit
+	git-read-tree --reset $update --set-base="$rev" "$rev" || exit
 fi
 
 # Any resets update HEAD to the head being switched to.
@@ -93,10 +93,11 @@ case "$reset_type" in
 	}
 	;;
 --soft )
-	;; # Nothing else to do
+	git-update-index --set-base "$rev"
+	;;
 --mixed )
 	# Report what has not been updated.
-	git-update-index --refresh
+	git-update-index --set-base "$rev" --refresh
 	;;
 esac
 
-- 
1.5.1.730.g0d43be
Previous: Junio C Hamano
Message 7 of 7 in “What's cooking in git.git (topics)”
  1. Junio C HamanoApr 3, 2007
  2. Junio C HamanoApr 5, 2007
  3. The index is based on blah, however, the HEAD points at different commit.Junio C Hamano, Apr 9, 2007
  4. 1/4 Move check_base() shell function to git-sh-setupJunio C Hamano, Apr 9, 2007
  5. 2/4 Use BASE index extension in git-am.Junio C Hamano, Apr 9, 2007
  6. 3/4 git-read-tree --set-base=<commit>Junio C Hamano, Apr 9, 2007
  7. 4/4 Teach git-reset to use index BASE extension.Junio C Hamano, Apr 9, 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.