From 9909fff8bebea03091a4ec7781ac966ab012a384 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 22 Feb 2022 18:16:38 +0900 Subject: [PATCH] tools/upgrade: Use "--git-dir" and "--work-tree" to specify the OMB directory to git (Fix #311) --- tools/upgrade.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 52e1dfc..a4d0d9d 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -25,10 +25,14 @@ function _omb_upgrade { printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Bash" - if ! command git -C "$OSH" pull --rebase --stat origin master; then + # Note: The git option "-C PATH" is only supported from git-1.8.5 + # (https://github.com/git/git/commit/44e1e4d6 2013-09). On the other hand, + # the synonym "--git-dir=PATH/.git --work-tree=PATH" is supported from + # git-1.5.3 (https://github.com/git/git/commit/892c41b9 2007-06). + if ! command git --git-dir="$OSH/.git" --work-tree="$OSH" pull --rebase --stat origin master; then # In case it enters the rebasing mode printf '%s\n' "oh-my-bash: running 'git rebase --abort'..." - command git -C "$OSH" rebase --abort + command git --git-dir="$OSH/.git" --work-tree="$OSH" rebase --abort printf "${RED}%s${NORMAL}\n" \ 'There was an error updating.' \ "If you have uncommited changes in '$BOLD$OSH$NORMAL$RED', please commit, stash or discard them and retry updating." \