git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] stash: allow ref of a stash by index

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 7, 2016, 17:50 UTC
Message-ID
<xmqqbmzzoazy.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAFaJEqu-JUcwLjrQBk_huSa3DZfCf8O4eAZ=UgcXHzN=CLgtpw@mail.gmail.com>
Øystein Walle <oystwa@gmail.com> writes:
Show 20 quoted lines
> 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]*)
> +            :
OK, so you ignore anything that has a non-digit here, to ensure that...
> +        ;;
> +        *)
> +            set -- "${ref_stash}@{$1}"

... this one triggers only for a string $1 that consists solely of digits.

> +        ;;
> +    esac

Makes sense. I notice that both of the two existing case/esac statements in this function indent case arms and their bodies one level too deep, which you follwed with the above addition. That may be something we would want to fix in a follow-up patch.

>      REV=$(git rev-parse --symbolic --verify --quiet "$1") || {
>          reference="$1"
>          die "$(eval_gettext "\$reference is not a valid reference")"

I agree with Peff that the change in error message he noticed is probably an improvement ;-)

Want to do a final log message to make it a real patch?
Thanks.
Previous: Jeff King
Message 9 of 9 in “stash: allow ref of a stash by index”
  1. stash: allow ref of a stash by indexAaron M Watson, Sep 3, 2016
  2. Jeff KingSep 4, 2016
  3. Junio C HamanoSep 4, 2016
  4. Johannes SchindelinSep 4, 2016
  5. Philip OakleySep 4, 2016
  6. Øystein WalleSep 5, 2016
  7. Øystein WalleSep 5, 2016
  8. Jeff KingSep 5, 2016
  9. Junio C HamanoSep 7, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.