Thread (7 messages) 7 messages, 3 authors, 2017-08-17

Re: [PATCH] check-ref-format: require a repository for --branch

flat view

From: Jonathan Nieder <hidden>
Date: 2017-07-17 17:27:18

Hi,

Jeff King wrote:
On Fri, Jul 14, 2017 at 02:03:13PM -0400, Jeff King wrote:
quoted
So I think the patch below is probably the right direction.
And here it is with a real commit message, if this is what we want to
do.
[...]
quoted hunk ↗ jump to hunk
--- a/t/t1402-check-ref-format.sh
+++ b/t/t1402-check-ref-format.sh
@@ -161,6 +161,10 @@ test_expect_success 'check-ref-format --branch from subdir' '
 	test "$refname" = "$sha1"
 '
 
+test_expect_success 'check-ref-format --branch from non-repo' '
+	test_must_fail nongit git check-ref-format --branch @{-1}
+'
+
 valid_ref_normalized() {
 	prereq=
 	case $1 in
I don't think it's right.  Today I can do

	$ cd /tmp
	$ git check-ref-format --branch master
	master

You might wonder why I'd ever do such a thing.  But that's what "git
check-ref-format --branch" is for --- it is for taking a <branch>
argument and turning it into a branch name.  For example, if you have
a script with an $opt_branch variable that defaults to "master", it
may do

	resolved_branch=$(git check-ref-format --branch "$opt_branch")

even though it is in a mode that not going to have to use
$resolved_branch and it is not running from a repository.

Thanks and hope that helps,
Jonathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help