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

Re: git reset --hard include/linux/config.h

From
Junio C Hamano <junkio@cox.net>
Date
Jul 6, 2006, 02:45 UTC
Message-ID
<7vhd1va1so.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060705165801.GA11822@mars.ravnborg.org>
Sam Ravnborg <sam@ravnborg.org> writes:
> Now git reset is maybe supposed to work on commit level only, but it
> would have been nice if it erroroed out when it saw an argument that
> it did not know about. In this case I assume git reset used
> "include/linux/config.h" as <commitish>.

There is an attempt to have that check, but obviously it is busted. Thanks for noticing.

Maybe something like this is needed instead.

-- >8 -- git-reset: complain and exit upon seeing an unknown parameter.

The check to use "rev-parse --verify" was defeated by the use of "--default HEAD". "git reset --hard bogus-committish" just defaulted to reset to the HEAD without complaining.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/git-reset.sh b/git-reset.sh
index 46451d0..5c02240 100755
--- a/git-reset.sh
+++ b/git-reset.sh
@@ -17,7 +17,11 @@ case "$1" in
         usage ;;
 esac
 
-rev=$(git-rev-parse --verify --default HEAD "$@") || exit
+case $# in
+0) rev=HEAD ;;
+1) rev=$(git-rev-parse --verify "$1") || exit ;;
+*) usage ;;
+esac
 rev=$(git-rev-parse --verify $rev^0) || exit
 
 # We need to remember the set of paths that _could_ be left
Previous: Alex Riesen
Message 5 of 5 in “git reset --hard include/linux/config.h”
  1. Sam RavnborgJul 5, 2006
  2. Alex RiesenJul 5, 2006
  3. Sam RavnborgJul 5, 2006
  4. Alex RiesenJul 5, 2006
  5. Junio C HamanoJul 6, 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.