add NORETURN_PTR for function pointers
[gitweb.git] / git-pull.sh
index 0f24182974fe2040c950b846decf360c1c22dbb1..edf3ce33bf073c67f65cba0b796e0f9a178b810b 100755 (executable)
@@ -89,6 +89,7 @@ error_on_no_merge_candidates () {
        done
 
        curr_branch=${curr_branch#refs/heads/}
+       upstream=$(git config "branch.$curr_branch.merge")
 
        if [ -z "$curr_branch" ]; then
                echo "You are not currently on a branch, so I cannot use any"
@@ -96,7 +97,7 @@ error_on_no_merge_candidates () {
                echo "Please specify which branch you want to merge on the command"
                echo "line and try again (e.g. 'git pull <repository> <refspec>')."
                echo "See git-pull(1) for details."
-       else
+       elif [ -z "$upstream" ]; then
                echo "You asked me to pull without telling me which branch you"
                echo "want to merge with, and 'branch.${curr_branch}.merge' in"
                echo "your configuration file does not tell me either.  Please"
@@ -114,16 +115,28 @@ error_on_no_merge_candidates () {
                echo "    remote.<nickname>.fetch = <refspec>"
                echo
                echo "See git-config(1) for details."
+       else
+               echo "Your configuration specifies to merge the ref"
+               echo "'${upstream#refs/heads/}' from the remote, but no such ref"
+               echo "was fetched."
        fi
        exit 1
 }
 
 test true = "$rebase" && {
-       git update-index --ignore-submodules --refresh &&
-       git diff-files --ignore-submodules --quiet &&
-       git diff-index --ignore-submodules --cached --quiet HEAD -- ||
-       die "refusing to pull with rebase: your working tree is not up-to-date"
-
+       if ! git rev-parse -q --verify HEAD >/dev/null
+       then
+               # On an unborn branch
+               if test -f "$GIT_DIR/index"
+               then
+                       die "updating an unborn branch with changes added to the index"
+               fi
+       else
+               git update-index --ignore-submodules --refresh &&
+               git diff-files --ignore-submodules --quiet &&
+               git diff-index --ignore-submodules --cached --quiet HEAD -- ||
+               die "refusing to pull with rebase: your working tree is not up-to-date"
+       fi
        oldremoteref= &&
        . git-parse-remote &&
        remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&