Hi, guys

I like this idea. It makes stash easier and quicker to use, and it
"hides" the fact that it uses the reflog for keeping track of the made
stashes. *Not* to say I discourage interested people from peeking under
the hood. I just think it's nice to sometimes think of the stash as a
separate concept instead of being built on top of strange merge
commits constructed in temporary indexes :)

The bash-specific code is a no-go, so here's a way to do it in a way
that I think is in line with Git's code style for shell scripts. I took
the liberty of removing the '|| exit 1' since the rev is verified later
on anyway, as can be seen in the last piece of context. That way the
argument munging can be done at a later stage where we don't have to
loop over multiple ones. The first rev-parse's purpose is just to apply
--sq.

(Besides, the only way to do it at the top like in the original patch
was   for arg in bleh "$@"   where bleh is a marker to indicate that the
positional arguments should be cleared in a separate case branch so that
they can be rebuilt with multiple invocations of set later. Not pretty,
in my opinion.)

Regards,
Øsse

diff --git a/git-stash.sh b/git-stash.sh
index 826af18..b026288 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -384,7 +384,7 @@ parse_flags_and_rev()
     i_tree=
     u_tree=

-    REV=$(git rev-parse --no-flags --symbolic --sq "$@") || exit 1
+    REV=$(git rev-parse --no-flags --symbolic --sq "$@" 2>/dev/null)

     FLAGS=
     for opt
@@ -422,6 +422,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")"

Reply via email to