git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Øystein Walle" <oystwa@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Aaron M Watson" <watsona4@gmail.com>, Git <git@vger.kernel.org>,
	"Jon Seymour" <jon.seymour@gmail.com>,
	"David Caldwell" <david@porkrind.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"David Aguilar" <davvid@gmail.com>,
	"Alex Henrie" <alexhenrie24@gmail.com>
Subject: Re: [PATCH] stash: allow ref of a stash by index
Date: Mon, 5 Sep 2016 23:46:34 +0200	[thread overview]
Message-ID: <CAFaJEqu-JUcwLjrQBk_huSa3DZfCf8O4eAZ=UgcXHzN=CLgtpw@mail.gmail.com> (raw)
In-Reply-To: <20160904015209.ba6arov46ntr2ouq@sigill.intra.peff.net>

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")"

  parent reply	other threads:[~2016-09-05 21:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03 23:21 [PATCH] stash: allow ref of a stash by index Aaron M Watson
2016-09-04  1:52 ` Jeff King
2016-09-04  7:01   ` Junio C Hamano
2016-09-04  7:21   ` Johannes Schindelin
2016-09-04 10:57     ` Philip Oakley
2016-09-05 21:46   ` Øystein Walle [this message]
2016-09-05 21:58     ` Øystein Walle
2016-09-05 23:52     ` Jeff King
2016-09-07 17:50     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFaJEqu-JUcwLjrQBk_huSa3DZfCf8O4eAZ=UgcXHzN=CLgtpw@mail.gmail.com' \
    --to=oystwa@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=avarab@gmail.com \
    --cc=david@porkrind.org \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jon.seymour@gmail.com \
    --cc=peff@peff.net \
    --cc=watsona4@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).