From deec8de709a933763e7344c3a7be54ae0be5577c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dato=20Sim=C3=B3?= <dato@net.com.org.es>
Date: Mon, 23 Sep 2013 21:47:43 +0100
Subject: [PATCH] vcsh: don't allow `clone` to choke on filenames with spaces

By replacing the "for" loop with a "while" loop, it is easy to read
line-oriented output without worrying about spaces. However, now the
loop executes in a subshell, and VCSH_CONFLICT won't be available in
the parent shell. In this case, a trivial, portable solution is to
have the comparison as the last command in the subshell.
---
 vcsh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/vcsh b/vcsh
index 5d5628e..6ce5320 100755
--- a/vcsh
+++ b/vcsh
@@ -152,12 +152,12 @@ clone() {
 		exit
 	fi
 	git fetch
-	for object in $(git ls-tree -r origin/master | awk '{print $4}'); do
+	git ls-tree -r --name-only origin/master | (while read object; do
 		[ -e "$object" ] &&
 			error "'$object' exists." &&
 			VCSH_CONFLICT=1
 	done
-	[ "$VCSH_CONFLICT" = '1' ] &&
+	[ "$VCSH_CONFLICT" = '1' ]) &&
 		fatal "will stop after fetching and not try to merge!
   Once this situation has been resolved, run 'vcsh run $VCSH_REPO_NAME git pull' to finish cloning." 17
 	git merge origin/master
-- 
GitLab