]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-stash.sh
quote-stress-test: offer to test quoting arguments for MSYS2 sh
[thirdparty/git.git] / git-stash.sh
index 2fb651b2b8d9d91a130b1cbd11c3c2b6b1cf961b..328cd80d83a03a674e0541bddb6bce0532c682b7 100755 (executable)
@@ -19,6 +19,7 @@ OPTIONS_SPEC=
 START_DIR=$(pwd)
 . git-sh-setup
 require_work_tree
+prefix=$(git rev-parse --show-prefix) || exit 1
 cd_to_toplevel
 
 TMP="$GIT_DIR/.git-stash.$$"
@@ -42,9 +43,16 @@ no_changes () {
 }
 
 untracked_files () {
+       if test "$1" = "-z"
+       then
+               shift
+               z=-z
+       else
+               z=
+       fi
        excl_opt=--exclude-standard
        test "$untracked" = "all" && excl_opt=
-       git ls-files -o -z $excl_opt -- "$@"
+       git ls-files -o $z $excl_opt -- "$@"
 }
 
 clear_stash () {
@@ -113,7 +121,7 @@ create_stash () {
                # Untracked files are stored by themselves in a parentless commit, for
                # ease of unpacking later.
                u_commit=$(
-                       untracked_files "$@" | (
+                       untracked_files -z "$@" | (
                                GIT_INDEX_FILE="$TMPindex" &&
                                export GIT_INDEX_FILE &&
                                rm -f "$TMPindex" &&
@@ -273,6 +281,8 @@ push_stash () {
                shift
        done
 
+       eval "set $(git rev-parse --sq --prefix "$prefix" -- "$@")"
+
        if test -n "$patch_mode" && test -n "$untracked"
        then
                die "$(gettext "Can't use --patch and --include-untracked or --all at the same time")"
@@ -481,7 +491,7 @@ parse_flags_and_rev()
 
        case $# in
                0)
-                       have_stash || die "$(gettext "No stash found.")"
+                       have_stash || die "$(gettext "No stash entries found.")"
                        set -- ${ref_stash}@{0}
                ;;
                1)
@@ -570,10 +580,10 @@ apply_stash () {
 
        if test -n "$u_tree"
        then
-               GIT_INDEX_FILE="$TMPindex" git-read-tree "$u_tree" &&
+               GIT_INDEX_FILE="$TMPindex" git read-tree "$u_tree" &&
                GIT_INDEX_FILE="$TMPindex" git checkout-index --all &&
                rm -f "$TMPindex" ||
-               die "$(gettext "Could not restore untracked files from stash")"
+               die "$(gettext "Could not restore untracked files from stash entry")"
        fi
 
        eval "
@@ -627,7 +637,7 @@ pop_stash() {
                drop_stash "$@"
        else
                status=$?
-               say "$(gettext "The stash is kept in case you need it again.")"
+               say "$(gettext "The stash entry is kept in case you need it again.")"
                exit $status
        fi
 }