[PATCH 3/8] Better Error Handling for add

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "David A. Greene" <greened@xxxxxxxxxxxxx>

Check refspecs for validity before passing them on to other commands.
This lets us generate more helpful error messages.

Signed-off-by: David A. Greene <greened@xxxxxxxxxxxxx>
---
 contrib/subtree/git-subtree.sh |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 7ceb413..b8a807a 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -509,8 +509,20 @@ cmd_add()
 	ensure_clean
 	
 	if [ $# -eq 1 ]; then
+	        ref=$(git check-ref-format --normalize "refs/heads/$1") ||
+                die "'$1' is not a valid refspec.  Are you missing a branch?"
+
+	        rev=$(git rev-parse --verify $1) ||
+                die "'$1' is not a valid refspec.  Are you missing a branch?"
+
 		"cmd_add_commit" "$@"
 	elif [ $# -eq 2 ]; then
+	        ref=$(git check-ref-format --normalize "refs/heads/$2") ||
+                die "'$2' is not a valid refspec."
+
+	        rev=$(git rev-parse --verify $2) ||
+                die "'$2' is not a valid refspec."
+
 		"cmd_add_repository" "$@"
 	else
 	    say "error: parameters were '$@'"
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]