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

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

From: Matthieu Moy <hidden>
Date: 2016-06-16 02:19:37

Junio C Hamano [off-list ref] writes:
Jordan DE GEA [off-list ref] writes:
quoted
+	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
	)
Actually, $(...) implicitly does a subshell, so the "cd .." was just
useless.
	git -C short-hand rev-parse --symbolic-full-name HEAD >actual &&
Indeed, git -C is an even better way to say "cd .. && git ..."

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help