From 2164a9ccaca4a15a18d0fef51fe8d86c1b5412cf Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Mon, 11 Jun 2018 23:53:20 +0200 Subject: [PATCH] local/bin/homesync: Properly error out when current branch has no remote --- .local/bin/homesync | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.local/bin/homesync b/.local/bin/homesync index fca2aada..0a9f4553 100755 --- a/.local/bin/homesync +++ b/.local/bin/homesync @@ -58,8 +58,13 @@ project_status() { for i in ~/dotfiles ~/.password-store ~/personal ~/projects/* ~/.local/share/emacs/site-lisp/* "$@"; do [ ! -d "$i/.git" ] && continue CHANGED=true - unmerged=$(git -C "$i" log --oneline origin/master..) - project_status "$i" "Unmerged commits" "$unmerged" + upstream=$(git -C "$i" rev-parse --abbrev-ref --symbolic-full-name @{u} 2>&1) + if [ $? -eq 0 ]; then + unmerged=$(git -C "$i" log --oneline "$upstream"..) + project_status "$i" "Unmerged commits" "$unmerged" + else + project_status "$i" "Unmerged commits" "$upstream" + fi project_status "$i" "Unstaged files" "$(git -C "$i" diff --name-only)" project_status "$i" "Staged files" "$(git -C "$i" diff --name-only --cached)" if $OPT_UPDATE && [ -n "$unmerged" ]; then