]> git.madduck.net Git - code/vcsh.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

vcsh: don't allow `clone` to choke on filenames with spaces
authorDato Simó <dato@net.com.org.es>
Mon, 23 Sep 2013 20:47:43 +0000 (21:47 +0100)
committerRichard Hartmann <richih@debian.org>
Tue, 4 Feb 2014 22:10:41 +0000 (23:10 +0100)
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

diff --git a/vcsh b/vcsh
index 5d5628e236368e7d11addeedc57c60c8f87fa8a6..6ce5320a620e098d2907c127261c65a0a334a939 100755 (executable)
--- a/vcsh
+++ b/vcsh
@@ -152,12 +152,12 @@ clone() {
                exit
        fi
        git fetch
                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
                [ -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
                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