|
72 | 72 | shift
|
73 | 73 | done
|
74 | 74 |
|
| 75 | +error_on_no_merge_candidates () { |
| 76 | + exec >&2 |
| 77 | + for opt |
| 78 | + do |
| 79 | + case "$opt" in |
| 80 | + -t|--t|--ta|--tag|--tags) |
| 81 | + echo "Fetching tags only, you probably meant:" |
| 82 | + echo " git fetch --tags" |
| 83 | + exit 1 |
| 84 | + esac |
| 85 | + done |
| 86 | + |
| 87 | + curr_branch=${curr_branch#refs/heads/} |
| 88 | + |
| 89 | + echo "You asked me to pull without telling me which branch you" |
| 90 | + echo "want to merge with, and 'branch.${curr_branch}.merge' in" |
| 91 | + echo "your configuration file does not tell me either. Please" |
| 92 | + echo "name which branch you want to merge on the command line and" |
| 93 | + echo "try again (e.g. 'git pull <repository> <refspec>')." |
| 94 | + echo "See git-pull(1) for details on the refspec." |
| 95 | + echo |
| 96 | + echo "If you often merge with the same branch, you may want to" |
| 97 | + echo "configure the following variables in your configuration" |
| 98 | + echo "file:" |
| 99 | + echo |
| 100 | + echo " branch.${curr_branch}.remote = <nickname>" |
| 101 | + echo " branch.${curr_branch}.merge = <remote-ref>" |
| 102 | + echo " remote.<nickname>.url = <url>" |
| 103 | + echo " remote.<nickname>.fetch = <refspec>" |
| 104 | + echo |
| 105 | + echo "See git-config(1) for details." |
| 106 | + exit 1 |
| 107 | +} |
| 108 | + |
75 | 109 | orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
|
76 | 110 | git-fetch --update-head-ok "$@" || exit 1
|
77 | 111 |
|
@@ -105,33 +139,13 @@ merge_head=$(sed -e '/ not-for-merge /d' \
|
105 | 139 | case "$merge_head" in
|
106 | 140 | '')
|
107 | 141 | case $? in
|
108 |
| - 0) ;; |
109 |
| - 1) echo >&2 "You are not currently on a branch; you must explicitly" |
110 |
| - echo >&2 "specify which branch you wish to merge:" |
111 |
| - echo >&2 " git pull <remote> <branch>" |
112 |
| - exit 1;; |
113 |
| - *) exit $?;; |
| 142 | + 0) error_on_no_merge_candidates "$@";; |
| 143 | + 1) echo >&2 "You are not currently on a branch; you must explicitly" |
| 144 | + echo >&2 "specify which branch you wish to merge:" |
| 145 | + echo >&2 " git pull <remote> <branch>" |
| 146 | + exit 1;; |
| 147 | + *) exit $?;; |
114 | 148 | esac
|
115 |
| - curr_branch=${curr_branch#refs/heads/} |
116 |
| - |
117 |
| - echo >&2 "You asked me to pull without telling me which branch you" |
118 |
| - echo >&2 "want to merge with, and 'branch.${curr_branch}.merge' in" |
119 |
| - echo >&2 "your configuration file does not tell me either. Please" |
120 |
| - echo >&2 "name which branch you want to merge on the command line and" |
121 |
| - echo >&2 "try again (e.g. 'git pull <repository> <refspec>')." |
122 |
| - echo >&2 "See git-pull(1) for details on the refspec." |
123 |
| - echo >&2 |
124 |
| - echo >&2 "If you often merge with the same branch, you may want to" |
125 |
| - echo >&2 "configure the following variables in your configuration" |
126 |
| - echo >&2 "file:" |
127 |
| - echo >&2 |
128 |
| - echo >&2 " branch.${curr_branch}.remote = <nickname>" |
129 |
| - echo >&2 " branch.${curr_branch}.merge = <remote-ref>" |
130 |
| - echo >&2 " remote.<nickname>.url = <url>" |
131 |
| - echo >&2 " remote.<nickname>.fetch = <refspec>" |
132 |
| - echo >&2 |
133 |
| - echo >&2 "See git-config(1) for details." |
134 |
| - exit 1 |
135 | 149 | ;;
|
136 | 150 | ?*' '?*)
|
137 | 151 | if test -z "$orig_head"
|
|
0 commit comments