Tutorial: adjust merge example to recursive strategy.
[gitweb.git] / git-parse-remote.sh
index 4d8a572a9903179494c7cc4f8a72729a47f1c12b..5f158c613f333026ed42eac1c059b01500ba5e53 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
-. git-sh-setup || die "Not a git archive"
+# git-ls-remote could be called from outside a git managed repository;
+# this would fail in that case and would issue an error message.
+GIT_DIR=$(git-rev-parse --git-dir 2>/dev/null) || :;
 
 get_data_source () {
        case "$1" in
@@ -94,6 +96,12 @@ canon_refs_list_for_fetch () {
                heads/* | tags/* ) local="refs/$local" ;;
                *) local="refs/heads/$local" ;;
                esac
+
+               if local_ref_name=$(expr "$local" : 'refs/\(.*\)')
+               then
+                  git-check-ref-format "$local_ref_name" ||
+                  die "* refusing to create funny ref '$local_ref_name' locally"
+               fi
                echo "${dot_prefix}${force}${remote}:${local}"
                dot_prefix=.
        done