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

[PATCH] More useful/hinting error messages in git-checkout

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Feb 15, 2006, 19:22 UTC
Message-ID
<200602152022.11162.Josef.Weidendorfer@gmx.de>
In-Reply-To
<7v3bilr2zr.fsf@assigned-by-dhcp.cox.net>
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
---
On Tuesday 14 February 2006 23:26, you wrote:
Show 8 quoted lines
>
> 	$ git checkout -b test v2.6.10
> 
> The user wanted to create a new branch test based on tag
> v2.6.10, alas that tag does not exist.  We give quite confusing
> error message because we are confused that the user meant to
> checkout only "./v2.6.10" file and that operation and switching
> branches are incompatible.
Does this patch clarify the error condition?
Josef
 git-checkout.sh |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
d15e024c0bd07a2f0dad6e2729e2681df374c8e6
diff --git a/git-checkout.sh b/git-checkout.sh
index 6a87c71..b7d892d 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -22,7 +22,7 @@ while [ "$#" != "0" ]; do
 		[ -e "$GIT_DIR/refs/heads/$newbranch" ] &&
 			die "git checkout: branch $newbranch already exists"
 		git-check-ref-format "heads/$newbranch" ||
-			die "we do not like '$newbranch' as a branch name."
+			die "git checkout: we do not like '$newbranch' as a branch name."
 		;;
 	"-f")
 		force=1
@@ -75,9 +75,15 @@ done
 
 if test "$#" -ge 1
 then
+	hint=
+	if test "$#" -eq 1
+	then
+		hint="
+Did you intend to checkout '$@' which can not be resolved as commit?"
+	fi
 	if test '' != "$newbranch$force$merge"
 	then
-		die "updating paths and switching branches or forcing are incompatible."
+		die "git checkout: updating paths is incompatible with switching branches/forcing$hint"
 	fi
 	if test '' != "$new"
 	then
@@ -117,7 +123,8 @@ fi
 
 [ -z "$branch$newbranch" ] &&
 	[ "$new" != "$old" ] &&
-	die "git checkout: you need to specify a new branch name"
+	die "git checkout: to checkout the requested commit you need to specify 
+              a name for a new branch which is created and switched to"
 
 if [ "$force" ]
 then
-- 
1.2.0.g719b
Previous: Junio C HamanoNext: Andreas Ericsson
Message 34 of 57 in “several quick questions”
  1. Nicolas Vilz 'niv'Feb 14, 2006
  2. Andreas EricssonFeb 14, 2006
  3. Nicolas Vilz 'niv'Feb 14, 2006
  4. Linus TorvaldsFeb 14, 2006
  5. Kenneth JohanssonFeb 14, 2006
  6. Andreas EricssonFeb 14, 2006
  7. Kenneth JohanssonFeb 14, 2006
  8. Linus TorvaldsFeb 14, 2006
  9. Carl WorthFeb 14, 2006
  10. Linus TorvaldsFeb 14, 2006
  11. Carl WorthFeb 14, 2006
  12. Petr BaudisFeb 14, 2006
  13. Johannes SchindelinFeb 14, 2006
  14. Junio C HamanoFeb 14, 2006
  15. Johannes SchindelinFeb 14, 2006
  16. Petr BaudisFeb 14, 2006
  17. Linus TorvaldsFeb 14, 2006
  18. Petr BaudisFeb 14, 2006
  19. Carl WorthFeb 14, 2006
  20. Junio C HamanoFeb 14, 2006
  21. New git-seek command with documentation and test.Carl Worth, Feb 23, 2006
  22. J. Bruce FieldsFeb 24, 2006
  23. git-seek: Eliminate spurious warning. Fix errant reference to git-bisect in docs.Carl Worth, Feb 24, 2006
  24. Junio C HamanoFeb 24, 2006
  25. Andreas EricssonFeb 24, 2006
  26. Junio C HamanoFeb 24, 2006
  27. Carl WorthFeb 24, 2006
  28. Johannes SchindelinFeb 24, 2006
  29. J. Bruce FieldsFeb 24, 2006
  30. Josef WeidendorferFeb 14, 2006
  31. Junio C HamanoFeb 14, 2006
  32. Josef WeidendorferFeb 14, 2006
  33. Junio C HamanoFeb 14, 2006
  34. More useful/hinting error messages in git-checkoutJosef Weidendorfer, Feb 15, 2006
  35. Andreas EricssonFeb 14, 2006
  36. Johannes SchindelinFeb 14, 2006
  37. Andreas EricssonFeb 15, 2006
  38. Junio C HamanoFeb 15, 2006
  39. Junio C HamanoFeb 15, 2006
  40. Andreas EricssonFeb 15, 2006
  41. Junio C HamanoFeb 15, 2006
  42. Petr BaudisFeb 14, 2006
  43. Carl WorthFeb 14, 2006
  44. Linus TorvaldsFeb 14, 2006
  45. Andreas EricssonFeb 14, 2006
  46. Johannes SchindelinFeb 14, 2006
  47. Carl WorthFeb 14, 2006
  48. Keith PackardFeb 14, 2006
  49. Linus TorvaldsFeb 14, 2006
  50. Keith PackardFeb 14, 2006
  51. Martin LanghoffFeb 15, 2006
  52. Keith PackardFeb 15, 2006
  53. Carl WorthFeb 15, 2006
  54. Junio C HamanoFeb 14, 2006
  55. Petr BaudisFeb 14, 2006
  56. Cogito turbo-introductionPetr Baudis, Feb 15, 2006
  57. Petr BaudisFeb 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.