From 4c3a070eefded48a4828423095362b691cb1a8f4 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sat, 12 May 2012 23:58:08 +0200 Subject: bashrc/main: use tag instead of branch to track old origin use tag to track the base of the current "rebase" and update tag before cherry-pick and stash to be the real base --- bashrc/main.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bashrc/main.sh b/bashrc/main.sh index 5ed9b15..0552035 100644 --- a/bashrc/main.sh +++ b/bashrc/main.sh @@ -17,9 +17,13 @@ _self_update() { pushd ${_DOTFILES_DIR} &>/dev/null # save the origin, the current master is based of - if ! git branch | grep old-origin -q; then - git branch --no-track old-origin origin/master >/dev/null 2>&1 - fi + if ! git tag | grep old-origin -q; then + if git branch | grep old-origin -q; then + git branch -D old-origin >/dev/null 2>&1 + fi + + git tag old-origin origin/master >/dev/null 2>&1 + fi if hash timeout >/dev/null 2>&1; then timeout 3s git fetch origin 2>/dev/null @@ -52,6 +56,10 @@ _self_update() { git reset --hard origin/master >/dev/null + # update old-origin + git tag -d old-origin >/dev/null 2>&1 + git tag old-origin origin-master >/dev/null 2>&1 + if [[ -n "$_local_commits" ]]; then echo -e "\033[33m*\033[0m cherry-pick: $_local_commits" git cherry-pick $_local_commits >/dev/null || return @@ -61,10 +69,6 @@ _self_update() { git stash pop >/dev/null || return fi - # all done, update old-origin - git branch -D old-origin >/dev/null 2>&1 - git branch --no-track old-origin origin/master >/dev/null 2>&1 - if [[ -e management/symlinks.md5 ]]; then if hash md5sum 2> /dev/null ; then md5sum -c management/symlinks.md5 --status 2>/dev/null -- cgit v1.2.3