Commit 3e518778228e47d131cf8a5aa9eab7284831adea
1 parent
01aae9e3ba
Let antigen-selfupdate works when in submodule
Showing 1 changed file with 6 additions and 1 deletions Side-by-side Diff
antigen.zsh
... | ... | @@ -316,11 +316,16 @@ antigen-revert () { |
316 | 316 | # "what's new" message. |
317 | 317 | antigen-selfupdate () { |
318 | 318 | ( cd $_ANTIGEN_INSTALL_DIR |
319 | - if [[ ! -d .git ]]; then | |
319 | + if [[ ! ( -d .git || -f .git ) ]]; then | |
320 | 320 | echo "Your copy of antigen doesn't appear to be a git clone. " \ |
321 | 321 | "The 'selfupdate' command cannot work in this case." |
322 | 322 | return 1 |
323 | 323 | fi |
324 | + local head="$(git rev-parse --abbrev-ref HEAD)" | |
325 | + if [[ $head == "HEAD" ]]; then | |
326 | + # If current head is detached HEAD, checkout to master branch. | |
327 | + git checkout master | |
328 | + fi | |
324 | 329 | git pull |
325 | 330 | ) |
326 | 331 | } |