From cbfb18aca58fa9be9e787e993e272b60e5e2bbbe Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 1 Dec 2011 13:28:28 -0500 Subject: [PATCH] Break out git_fetch and only pull when there is a remote. --- dotfiles.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 -- 2.26.2