summaryrefslogtreecommitdiff
path: root/git-stash.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-stash.sh')
-rwxr-xr-xgit-stash.sh32
1 files changed, 21 insertions, 11 deletions
diff --git a/git-stash.sh b/git-stash.sh
index c7c65e2..10c284d 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -15,7 +15,6 @@ SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
START_DIR=$(pwd)
. git-sh-setup
-. git-sh-i18n
require_work_tree
cd_to_toplevel
@@ -101,7 +100,7 @@ create_stash () {
u_tree=$(git write-tree) &&
printf 'untracked files on %s\n' "$msg" | git commit-tree $u_tree &&
rm -f "$TMPindex"
- ) ) || die "Cannot save the untracked files"
+ ) ) || die "$(gettext "Cannot save the untracked files")"
untracked_commit_option="-p $u_commit";
else
@@ -116,7 +115,7 @@ create_stash () {
git read-tree --index-output="$TMPindex" -m $i_tree &&
GIT_INDEX_FILE="$TMPindex" &&
export GIT_INDEX_FILE &&
- git diff --name-only -z HEAD -- >"$TMP-stagenames" &&
+ git diff-index --name-only -z HEAD -- >"$TMP-stagenames" &&
git update-index -z --add --remove --stdin <"$TMP-stagenames" &&
git write-tree &&
rm -f "$TMPindex"
@@ -185,7 +184,7 @@ store_stash () {
git update-ref --create-reflog -m "$stash_msg" $ref_stash $w_commit
ret=$?
- test $ret != 0 && test -z $quiet &&
+ test $ret != 0 && test -z "$quiet" &&
die "$(eval_gettext "Cannot update \$ref_stash with \$w_commit")"
return $ret
}
@@ -249,7 +248,7 @@ save_stash () {
if test -n "$patch_mode" && test -n "$untracked"
then
- die "Can't use --patch and --include-untracked or --all at the same time"
+ die "$(gettext "Can't use --patch and --include-untracked or --all at the same time")"
fi
stash_msg="$*"
@@ -266,7 +265,7 @@ save_stash () {
create_stash "$stash_msg" $untracked
store_stash -m "$stash_msg" -q $w_commit ||
die "$(gettext "Cannot save the current status")"
- say Saved working directory and index state "$stash_msg"
+ say "$(eval_gettext "Saved working directory and index state \$stash_msg")"
if test -z "$patch_mode"
then
@@ -277,7 +276,7 @@ save_stash () {
git clean --force --quiet -d $CLEAN_X_OPTION
fi
- if test "$keep_index" = "t" && test -n $i_tree
+ if test "$keep_index" = "t" && test -n "$i_tree"
then
git read-tree --reset -u $i_tree
fi
@@ -385,9 +384,8 @@ parse_flags_and_rev()
i_tree=
u_tree=
- REV=$(git rev-parse --no-flags --symbolic --sq "$@") || exit 1
-
FLAGS=
+ REV=
for opt
do
case "$opt" in
@@ -405,6 +403,9 @@ parse_flags_and_rev()
die "$(eval_gettext "unknown option: \$opt")"
FLAGS="${FLAGS}${FLAGS:+ }$opt"
;;
+ *)
+ REV="${REV}${REV:+ }'$opt'"
+ ;;
esac
done
@@ -423,6 +424,15 @@ parse_flags_and_rev()
;;
esac
+ case "$1" in
+ *[!0-9]*)
+ :
+ ;;
+ *)
+ set -- "${ref_stash}@{$1}"
+ ;;
+ esac
+
REV=$(git rev-parse --symbolic --verify --quiet "$1") || {
reference="$1"
die "$(eval_gettext "\$reference is not a valid reference")"
@@ -495,7 +505,7 @@ apply_stash () {
GIT_INDEX_FILE="$TMPindex" git-read-tree "$u_tree" &&
GIT_INDEX_FILE="$TMPindex" git checkout-index --all &&
rm -f "$TMPindex" ||
- die 'Could not restore untracked files from stash'
+ die "$(gettext "Could not restore untracked files from stash")"
fi
eval "
@@ -549,7 +559,7 @@ pop_stash() {
drop_stash "$@"
else
status=$?
- say "The stash is kept in case you need it again."
+ say "$(gettext "The stash is kept in case you need it again.")"
exit $status
fi
}