2
# to set up some variables pointing at the normal git directories and
3
# a few helper shell functions.
4
5
+# Source git-sh-i18n for gettext support.
6
+. git-sh-i18n
7
+
8
# Having this variable in your environment would break scripts because
9
# you would cause "cd" to be taken to unexpected places. If you
10
# like CDPATH, define it for your interactive shell sessions without
86
else
87
dashless=$(basename -- "$0" | sed -e 's/-/ /')
88
usage() {
86
- die "usage: $dashless $USAGE"
89
+ die "$(eval_gettext "usage: \$dashless \$USAGE")"
90
}
91
92
if [ -z "$LONG_USAGE" ]
93
then
91
- LONG_USAGE="usage: $dashless $USAGE"
94
+ LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE")"
95
else
93
- LONG_USAGE="usage: $dashless $USAGE
96
+ LONG_USAGE="$(eval_gettext "usage: \$dashless \$USAGE
97
95
-$LONG_USAGE"
98
+$LONG_USAGE")"
99
fi
100
101
case "$1" in
185
cd_to_toplevel () {
186
cdup=$(git rev-parse --show-toplevel) &&
187
cd "$cdup" || {
185
- echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
188
+ gettextln "Cannot chdir to \$cdup, the toplevel of the working tree" >&2
189
exit 1
190
}
191
}
193
require_work_tree_exists () {
194
if test "z$(git rev-parse --is-bare-repository)" != zfalse
195
then
193
- die "fatal: $0 cannot be used without a working tree."
196
+ program_name=$0
197
+ die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
198
fi
199
}
200
201
require_work_tree () {
198
- test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
199
- die "fatal: $0 cannot be used without a working tree."
202
+ test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true || {
203
+ program_name=$0
204
+ die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
205
+ }
206
}
207
208
require_clean_work_tree () {
212
213
if ! git diff-files --quiet --ignore-submodules
214
then
209
- echo >&2 "Cannot $1: You have unstaged changes."
215
+ action=$1
216
+ case "$action" in
217
+ rebase)
218
+ gettextln "Cannot rebase: You have unstaged changes." >&2
219
+ ;;
220
+ "rewrite branches")
221
+ gettextln "Cannot rewrite branches: You have unstaged changes." >&2
222
+ ;;
223
+ "pull with rebase")
224
+ gettextln "Cannot pull with rebase: You have unstaged changes." >&2
225
+ ;;
226
+ *)
227
+ eval_gettextln "Cannot \$action: You have unstaged changes." >&2
228
+ ;;
229
+ esac
230
err=1
231
fi
232
233
if ! git diff-index --cached --quiet --ignore-submodules HEAD --
234
then
215
- if [ $err = 0 ]
235
+ if test $err = 0
236
then
217
- echo >&2 "Cannot $1: Your index contains uncommitted changes."
237
+ action=$1
238
+ case "$action" in
239
+ rebase)
240
+ gettextln "Cannot rebase: Your index contains uncommitted changes." >&2
241
+ ;;
242
+ "pull with rebase")
243
+ gettextln "Cannot pull with rebase: Your index contains uncommitted changes." >&2
244
+ ;;
245
+ *)
246
+ eval_gettextln "Cannot \$action: Your index contains uncommitted changes." >&2
247
+ ;;
248
+ esac
249
else
219
- echo >&2 "Additionally, your index contains uncommitted changes."
250
+ gettextln "Additionally, your index contains uncommitted changes." >&2
251
fi
252
err=1
253
fi
254
224
- if [ $err = 1 ]
255
+ if test $err = 1
256
then
226
- test -n "$2" && echo >&2 "$2"
257
+ test -n "$2" && echo "$2" >&2
258
exit 1
259
fi
260
}
367
then
368
test -z "$(git rev-parse --show-cdup)" || {
369
exit=$?
339
- echo >&2 "You need to run this command from the toplevel of the working tree."
370
+ gettextln "You need to run this command from the toplevel of the working tree." >&2
371
exit $exit
372
}
373
fi
374
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
344
- echo >&2 "Unable to determine absolute path of git directory"
375
+ gettextln "Unable to determine absolute path of git directory" >&2
376
exit 1
377
}
378
: ${GIT_OBJECT_DIRECTORY="$(git rev-parse --git-path objects)"}