aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-26 22:06:46 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-26 22:06:46 +0100
commitf08e57966f6080bf8b0f45ef942efea2e2ae392e (patch)
treec9a949652988da35d9efd171d0922988fa9d2764
parent88cf88263238d14a4bf8bb528f64802cca18b4f1 (diff)
downloadpaludis-f08e57966f6080bf8b0f45ef942efea2e2ae392e.tar.gz
paludis-f08e57966f6080bf8b0f45ef942efea2e2ae392e.tar.xz
More git syncer options
--branch=blah --reset to use a destructive fetch/hard-reset rather than a pull.
-rw-r--r--paludis/syncers/dogit.in31
1 files changed, 29 insertions, 2 deletions
diff --git a/paludis/syncers/dogit.in b/paludis/syncers/dogit.in
index e42b52d..acaa380 100644
--- a/paludis/syncers/dogit.in
+++ b/paludis/syncers/dogit.in
@@ -14,6 +14,10 @@ REMOTE=
GIT_CLONE_OPTIONS=( )
GIT_PULL_OPTIONS=( )
+GIT_FETCH_OPTIONS=( )
+
+GIT_BRANCH=
+GIT_USE_RESET=false
while [[ $# -gt 0 ]]; do
case "${1}" in
@@ -26,6 +30,18 @@ while [[ $# -gt 0 ]]; do
GIT_PULL_OPTIONS[${#GIT_PULL_OPTIONS[@]}]="${1#*=}"
;;
+ --git-fetch-option=*)
+ GIT_FETCH_OPTIONS[${#GIT_FETCH_OPTIONS[@]}]="${1#*=}"
+ ;;
+
+ --branch=*)
+ GIT_BRANCH="${1#*=}"
+ ;;
+
+ --reset)
+ GIT_USE_RESET=true
+ ;;
+
--help)
PROTO="${0##*/do}"
if [[ "${PROTO}" == git ]]; then
@@ -43,8 +59,11 @@ while [[ $# -gt 0 ]]; do
fi
echo " Options:"
+ echo " --branch=BRANCH Specify the branch to use"
echo " --git-clone-option=OPTION Pass OPTION to git clone"
echo " --git-pull-option=OPTION Pass OPTION to git pull"
+ echo " --git-fetch-option=OPTION Pass OPTION to git fetch (if --reset)"
+ echo " --reset Use git fetch and git reset --hard instead of pull"
exit 0
;;
@@ -99,8 +118,16 @@ if [[ -d "${LOCAL}" ]]; then
fi
if [[ -d "${LOCAL}/.git" ]]; then
- cd "${LOCAL}" && ${GIT_WRAPPER} git pull "${GIT_PULL_OPTIONS[@]}" origin
+ if ${GIT_USE_RESET} ; then
+ cd "${LOCAL}"
+ ${GIT_WRAPPER} git fetch "${GIT_FETCH_OPTIONS[@]}" origin || exit $?
+ ${GIT_WRAPPER} git reset --hard origin/${GIT_BRANCH:-master} || exit $?
+ else
+ cd "${LOCAL}"
+ ${GIT_WRAPPER} git pull "${GIT_PULL_OPTIONS[@]}" origin ${GIT_BRANCH} || exit $?
+ fi
else
- ${GIT_WRAPPER} git clone "${GIT_CLONE_OPTIONS[@]}" "${REMOTE}" "${LOCAL}"
+ ${GIT_WRAPPER} git clone "${GIT_CLONE_OPTIONS[@]}" "${REMOTE}" "${LOCAL}" || exit $?
+ cd "${LOCAL}" && ${GIT_WRAPPER} git reset --hard origin${GIT_BRANCH:+/${GIT_BRANCH}} || exit $?
fi