From: W. Trevor King Date: Thu, 1 Dec 2011 18:28:28 +0000 (-0500) Subject: Break out git_fetch and only pull when there is a remote. X-Git-Tag: v0.3~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cbfb18aca58fa9be9e787e993e272b60e5e2bbbe;p=dotfiles-framework.git Break out git_fetch and only pull when there is a remote. --- diff --git a/dotfiles.sh b/dotfiles.sh index 7386fc4..63d0ade 100755 --- a/dotfiles.sh +++ b/dotfiles.sh @@ -163,6 +163,17 @@ function get_repo_source() fi } +function git_fetch() +{ + REPO=$(nonempty_option 'git_fetch' 'REPO' "${1}") || return 1 + REMOTES=$(cd "${REPO}" && "${GIT}" remote) || return 1 + if [ -n "${REMOTES}" ]; then + (cd "${REPO}" && "${GIT}" pull) || return 1 + else + echo "no remote repositories found for ${REPO}" + fi +} + function wget_fetch() { REPO=$(nonempty_option 'wget_fetch' 'REPO' "${1}") || return 1 @@ -202,6 +213,7 @@ function wget_fetch() fi } + # usage: link_file REPO FILE # # Create the symbolic link to the version of FILE in the REPO @@ -336,7 +348,7 @@ function fetch() TRANSFER='git' fi if [ "${TRANSFER}" = 'git' ]; then - (cd "${REPO}" && "${GIT}" pull) || return 1 + git_fetch "${REPO}" || return 1 elif [ "${TRANSFER}" = 'wget' ]; then wget_fetch "${REPO}" || return 1 else