Re: [PATCH] worktree: allow "-" short-hand for @{-1} in add command

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

 



>> +test_expect_success '"add" using shorthand - fails when no previous branch' '
>> +	test_must_fail git worktree add existing -
>> +'
> 
> Just an observation, but the error message we would see here might
> be interesting.

Of course, that’s useful to be sure of the error, I will do in next preroll.

> 
>> +	branch=$(cd short-hand && git rev-parse --symbolic-full-name HEAD) &&
>> +	test "$branch" = refs/heads/newbranch &&
>> +	cd ..
> 
> If any of the command between "cd short-hand" and "cd .." failed,
> after correcting the broken &&-chain, the next test will end up
> running in short-hand directory, which it is not expecting.  A
> canonical way to avoid this problem is to replace the above with:
> 
> 	...
>        git worktree add short-hand - &&
>        (
> 		cd short-hand &&
>                ...
>                test "$branch" = refs/heads/newbranch
> 	)
> 
> In this particular case, alternatively, you could also do something
> like this:
> 
>        git worktree add short-hand - &&
> 	echo refs/heads/newbranch >expect &&
> 	git -C short-hand rev-parse --symbolic-full-name HEAD >actual &&
> 	test_cmp expect actual
Yes, that’s a good idea. I take these lines. 

--
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]