diff --git a/dotprofile.org b/dotprofile.org index b624074..0287037 100644 --- a/dotprofile.org +++ b/dotprofile.org @@ -242,7 +242,7 @@ try_git() if [ ! -d "${repo}" ]; then if git ls-remote "${rrepo}" > /dev/null 2>&1; then - mkdir -p "${repo}" + install -dm755 "${repo}" echo "git clone ${rrepo} ${repo}" git clone --recursive "${rrepo}" "${repo}" else @@ -252,13 +252,16 @@ try_git() if [ "${branch}" != "master" ]; then wtdir="${repo}@${branch}" - if [ -d "${wtdir}" ]; then - cd "${wtdir}" - else + if [ ! -d "${wtdir}" ]; then if git branch -r --list 'origin/*' | grep -E "^\s+origin/${branch}$" > /dev/null 2>&1; then - git worktree add ${repo}@${branch} ${branch} && cd "${wtdir}" + git worktree add ${repo}@${branch} ${branch} + else + echo "${wtdir} branch ${branch} not present in ${rrepo}" + return fi fi + echo "${wtdir}" | sed -e "s|$HOME|~|" + cd "${wtdir}" else if [ -d "${repo}" ]; then echo "${repo}" | sed -e "s|$HOME|~|"