Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 3/8] Better Error Handling for add

From: <hidden>
Date: 2016-06-15 22:55:38

Junio C Hamano [off-list ref] writes:
quoted
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?"
Is a user forbidden from passing a commit that is not at the tip of
an existing branch?  In other words, is

	$ subtree add origin/next~4^2

forbidden?
Good point.  It probably shouldn't be.  I think rev-parse should be
enough of a check.
quoted
+	        rev=$(git rev-parse --verify $1) ||
+                die "'$1' is not a valid refspec.  Are you missing a branch?"
+
 		"cmd_add_commit" "$@"
If you want to make sure you give a comit to add_commit, you can
probably say something like this:

	git rev-parse -q --verify "$1^{commit}" >/dev/null ||
        die "'$1' does not refer to a commit"
What does $1^{commit} mean?  I think your suggestion is what I want but
I don't know what it means yet.  :)

                           -David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help