summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bashrc/main.sh15
1 files changed, 8 insertions, 7 deletions
diff --git a/bashrc/main.sh b/bashrc/main.sh
index 01ca309..9883ca9 100644
--- a/bashrc/main.sh
+++ b/bashrc/main.sh
@@ -44,12 +44,13 @@ _self_update() {
echo -ne "\033[31m*\033[0m dotfile updates found, merge now? (Y/n) "
read _merge;
if [[ $_merge != 'n' ]]; then
- _local_commits="$(git rev-list old-origin..HEAD | xargs echo)"
_local_changes="$(git status | grep '^# Change')"
+ _old_origin="$(git rev-list old-origin | head -n1)"
+ _old_head="$(git rev-list HEAD | head -n1)"
- if [[ -n "$_local_commits" ]]; then
- echo -e "\033[31m*\033[0m You have some local commits. I will now try to use the new origin/master"
- echo " and apply the extra commits afterwards."
+ if [[ "$_old_origin" != "$_old_head" ]]; then
+ echo -e "\033[31m*\033[0m You have some local commits. I will now try to rebase them"
+ echo " onto the new origin/master."
fi
if [[ -n "$_local_changes" ]]; then
@@ -64,9 +65,9 @@ _self_update() {
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
+ if [[ "$_old_origin" != "$_old_head" ]]; then
+ echo -e "\033[33m*\033[0m git rebase --onto HEAD $_old_origin $_old_head"
+ git rebase --onto origin/master $_old_origin $_old_head || return
fi
if [[ -n "$_local_changes" ]]; then