git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Thomas Gummerer <t.gummerer@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	sunny@sunbase.org, "Jakub Narębski" <jnareb@gmail.com>,
	"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
	"Thomas Gummerer" <t.gummerer@gmail.com>
Subject: [PATCH v7 1/6] stash: introduce push verb
Date: Sat, 25 Feb 2017 21:33:01 +0000	[thread overview]
Message-ID: <20170225213306.2410-2-t.gummerer@gmail.com> (raw)
In-Reply-To: <20170225213306.2410-1-t.gummerer@gmail.com>

Introduce a new git stash push verb in addition to git stash save.  The
push verb is used to transition from the current command line arguments
to a more conventional way, in which the message is given as an argument
to the -m option.

This allows us to have pathspecs at the end of the command line
arguments like other Git commands do, so that the user can say which
subset of paths to stash (and leave others behind).

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---
 Documentation/git-stash.txt |  3 +++
 git-stash.sh                | 46 ++++++++++++++++++++++++++++++++++++++++++---
 t/t3903-stash.sh            |  9 +++++++++
 3 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 2e9e344cd7..d240df4af7 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -15,6 +15,8 @@ SYNOPSIS
 'git stash' branch <branchname> [<stash>]
 'git stash' [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
 	     [-u|--include-untracked] [-a|--all] [<message>]]
+'git stash' push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
+	     [-u|--include-untracked] [-a|--all] [-m|--message <message>]]
 'git stash' clear
 'git stash' create [<message>]
 'git stash' store [-m|--message <message>] [-q|--quiet] <commit>
@@ -46,6 +48,7 @@ OPTIONS
 -------
 
 save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::
+push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>]::
 
 	Save your local modifications to a new 'stash' and roll them
 	back to HEAD (in the working tree and in the index).
diff --git a/git-stash.sh b/git-stash.sh
index 10c284d1aa..8365ebba2a 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -9,6 +9,8 @@ USAGE="list [<options>]
    or: $dashless branch <branchname> [<stash>]
    or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
 		       [-u|--include-untracked] [-a|--all] [<message>]]
+   or: $dashless push [--patch] [-k|--[no-]keep-index] [-q|--quiet]
+		      [-u|--include-untracked] [-a|--all] [-m <message>]
    or: $dashless clear"
 
 SUBDIRECTORY_OK=Yes
@@ -189,10 +191,11 @@ store_stash () {
 	return $ret
 }
 
-save_stash () {
+push_stash () {
 	keep_index=
 	patch_mode=
 	untracked=
+	stash_msg=
 	while test $# != 0
 	do
 		case "$1" in
@@ -216,6 +219,11 @@ save_stash () {
 		-a|--all)
 			untracked=all
 			;;
+		-m|--message)
+			shift
+			test -z ${1+x} && usage
+			stash_msg=$1
+			;;
 		--help)
 			show_help
 			;;
@@ -251,8 +259,6 @@ save_stash () {
 		die "$(gettext "Can't use --patch and --include-untracked or --all at the same time")"
 	fi
 
-	stash_msg="$*"
-
 	git update-index -q --refresh
 	if no_changes
 	then
@@ -291,6 +297,36 @@ save_stash () {
 	fi
 }
 
+save_stash () {
+	push_options=
+	while test $# != 0
+	do
+		case "$1" in
+		--)
+			shift
+			break
+			;;
+		-*)
+			# pass all options through to push_stash
+			push_options="$push_options $1"
+			;;
+		*)
+			break
+			;;
+		esac
+		shift
+	done
+
+	stash_msg="$*"
+
+	if test -z "$stash_msg"
+	then
+		push_stash $push_options
+	else
+		push_stash $push_options -m "$stash_msg"
+	fi
+}
+
 have_stash () {
 	git rev-parse --verify --quiet $ref_stash >/dev/null
 }
@@ -617,6 +653,10 @@ save)
 	shift
 	save_stash "$@"
 	;;
+push)
+	shift
+	push_stash "$@"
+	;;
 apply)
 	shift
 	apply_stash "$@"
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 2de3e18ce6..3577115807 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -775,4 +775,13 @@ test_expect_success 'stash is not confused by partial renames' '
 	test_path_is_missing file
 '
 
+test_expect_success 'push -m shows right message' '
+	>foo &&
+	git add foo &&
+	git stash push -m "test message" &&
+	echo "stash@{0}: On master: test message" >expect &&
+	git stash list -1 >actual &&
+	test_cmp expect actual
+'
+
 test_done
-- 
2.11.0.301.g275aeb250c.dirty


  reply	other threads:[~2017-02-25 20:29 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailto:20170205202642.14216-1-t.gummerer@gmail.com>
2017-02-12 21:54 ` [PATCH v4 0/7] stash: support pathspec argument Thomas Gummerer
2017-02-12 21:54   ` [PATCH v4 1/7] Documentation/stash: remove mention of git reset --hard Thomas Gummerer
2017-02-12 21:54   ` [PATCH v4 2/7] stash: introduce push verb Thomas Gummerer
2017-02-12 21:54   ` [PATCH v4 3/7] stash: add test for the create command line arguments Thomas Gummerer
2017-02-12 21:54   ` [PATCH v4 4/7] stash: introduce new format create Thomas Gummerer
     [not found]     ` <vpqefz0ohub.fsf@anie.imag.fr>
2017-02-14 21:40       ` Thomas Gummerer
2017-02-12 21:54   ` [PATCH v4 5/7] stash: teach 'push' (and 'create') to honor pathspec Thomas Gummerer
2017-02-12 21:54   ` [PATCH v4 6/7] stash: use stash_push for no verb form Thomas Gummerer
2017-02-12 21:54   ` [PATCH v4 7/7] stash: allow pathspecs in the " Thomas Gummerer
2017-02-12 22:07   ` [PATCH v4 0/7] stash: support pathspec argument Thomas Gummerer
2017-02-17 22:41   ` [PATCH v5 0/6] " Thomas Gummerer
2017-02-17 22:41     ` [PATCH v5 1/6] stash: introduce push verb Thomas Gummerer
2017-02-17 22:41     ` [PATCH v5 2/6] stash: add test for the create command line arguments Thomas Gummerer
2017-02-17 22:41     ` [PATCH v5 3/6] stash: refactor stash_create Thomas Gummerer
2017-02-17 23:48       ` Jeff King
2017-02-19  9:17         ` Thomas Gummerer
2017-02-17 22:41     ` [PATCH v5 4/6] stash: teach 'push' (and 'create_stash') to honor pathspec Thomas Gummerer
2017-02-17 22:41     ` [PATCH v5 5/6] stash: use stash_push for no verb form Thomas Gummerer
2017-02-17 22:41     ` [PATCH v5 6/6] stash: allow pathspecs in the " Thomas Gummerer
2017-02-17 23:46       ` Jeff King
2017-02-19  9:18         ` Thomas Gummerer
2017-02-17 23:01     ` [PATCH v5 0/6] stash: support pathspec argument Junio C Hamano
2017-02-17 23:12       ` Thomas Gummerer
2017-02-17 23:14         ` Junio C Hamano
     [not found]     ` <xmqqr32wph97.fsf@gitster.mtv.corp.google.com>
2017-02-17 23:06       ` Thomas Gummerer
2017-02-19 11:03     ` [PATCH v6 " Thomas Gummerer
2017-02-19 11:03       ` [PATCH v6 1/6] stash: introduce push verb Thomas Gummerer
2017-02-19 11:03       ` [PATCH v6 2/6] stash: add test for the create command line arguments Thomas Gummerer
2017-02-19 11:03       ` [PATCH v6 3/6] stash: refactor stash_create Thomas Gummerer
2017-02-19 11:03       ` [PATCH v6 4/6] stash: teach 'push' (and 'create_stash') to honor pathspec Thomas Gummerer
2017-02-21 16:55         ` Junio C Hamano
2017-02-25 20:27           ` Thomas Gummerer
2017-02-19 11:03       ` [PATCH v6 5/6] stash: use stash_push for no verb form Thomas Gummerer
2017-02-19 11:03       ` [PATCH v6 6/6] stash: allow pathspecs in the " Thomas Gummerer
2017-02-20  7:57       ` [PATCH v6 0/6] stash: support pathspec argument Jeff King
2017-02-20  8:22       ` Junio C Hamano
2017-02-20 19:39       ` Junio C Hamano
2017-02-25 15:57         ` Thomas Gummerer
2017-02-25 21:33       ` [PATCH v7 " Thomas Gummerer
2017-02-25 21:33         ` Thomas Gummerer [this message]
2017-02-25 21:33         ` [PATCH v7 2/6] stash: add test for the create command line arguments Thomas Gummerer
2017-02-25 21:33         ` [PATCH v7 3/6] stash: refactor stash_create Thomas Gummerer
2017-02-25 21:33         ` [PATCH v7 4/6] stash: teach 'push' (and 'create_stash') to honor pathspec Thomas Gummerer
2017-02-27 20:32           ` Junio C Hamano
2017-02-27 20:35           ` Junio C Hamano
2017-02-27 21:56             ` Thomas Gummerer
2017-02-27 22:58               ` Junio C Hamano
2017-02-27 21:09           ` Junio C Hamano
2017-02-27 21:53             ` Thomas Gummerer
2017-02-25 21:33         ` [PATCH v7 5/6] stash: use stash_push for no verb form Thomas Gummerer
2017-02-25 21:33         ` [PATCH v7 6/6] stash: allow pathspecs in the " Thomas Gummerer
2017-02-28 20:33         ` [PATCH v8 0/6] stash: support pathspec argument Thomas Gummerer
2017-02-28 20:33           ` [PATCH v8 1/6] stash: introduce push verb Thomas Gummerer
2017-02-28 20:33           ` [PATCH v8 2/6] stash: add test for the create command line arguments Thomas Gummerer
2017-02-28 20:33           ` [PATCH v8 3/6] stash: refactor stash_create Thomas Gummerer
2017-02-28 20:33           ` [PATCH v8 4/6] stash: teach 'push' (and 'create_stash') to honor pathspec Thomas Gummerer
2017-02-28 22:15             ` Junio C Hamano
2017-03-01 21:57               ` Thomas Gummerer
2017-03-01 22:43                 ` Junio C Hamano
2017-02-28 20:33           ` [PATCH v8 5/6] stash: use stash_push for no verb form Thomas Gummerer
2017-02-28 20:33           ` [PATCH v8 6/6] stash: allow pathspecs in the " Thomas Gummerer

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=20170225213306.2410-2-t.gummerer@gmail.com \
    --to=t.gummerer@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    --cc=peff@peff.net \
    --cc=sunny@sunbase.org \
    /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).