From: Junio C Hamano <gitster@pobox.com>
To: しらいしななこ <nanako3@bluebottle.com>
Cc: git@vger.kernel.org, "Jörg Sommer" <joerg@alea.gnuu.de>
Subject: Re: git-stash: RFC: Adopt the default behavior to other commands
Date: Thu, 20 Dec 2007 14:31:07 -0800 [thread overview]
Message-ID: <7v4pedov6c.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <200712202145.lBKLj7Fu015050@mi0.bluebottle.com> (nanako3@bluebottle.com's message of "Wed, 21 Dec 2007 06:40:38 +0900")
しらいしななこ <nanako3@bluebottle.com> writes:
> How about making this behavior configurable?
First, as a general principle, I'd like to avoid having commands that
changes their behaviour drastically depending on who the user is. It
makes it harder for people experienced a bit more than totally new to
help others. If they are truly experts and are familiar about the
configuration stash.quick, then they will be fine, but others would say
"Well, it works for me -- 'git stash' itself won't stash but list. Why
isn't it working for you, I don't know" and scratch head.
Having said that, I reserve rights to change my mind later and start
liking this approach as a compromise.
There are a few suggestions and comments.
> +allow_quick_stash () {
> +
> + quick=$(git config stash.quick)
> + if test $? != 0
> + then
I think this is not a per-repository but per-person configuration (I
already said I do not want per-person configuration to affect the
fundamental behaviour of commands, but let's put that objection on hold
for now). "git config --global" would be more appropriate.
So if the user hasn't seen this behaviour before, then...
> + if ! test -t 0 || ! test -t 1
> + then
> + return 0
> + fi
If it is not interactively called, allow "git stash" sans parameters as
before. Nice attention to the details.
> + echo '
> +*** First time users ***
> ...
> + git config stash.quick $quick
> + echo '
> +You can reconfigure this by editing your $HOME/.gitconfig file'
> +
> + fi
Again, you would want --global here. Also hint about explicit "save"
and "list" in addition to "you can reconfigure" might be helpful.
> + case "$quick" in
> + true) return 0 ;;
> + false) return 1 ;;
> + ask) : do not return ;;
> + esac
> +
> + if ! test -t 0 || ! test -t 1
> + then
> + return 0
> + fi
Even if it is configured to 'ask', we allow it for non-interactive
session (aka scripts). Although I would agree with this logic, it could
be debatable.
> @@ -226,11 +289,16 @@ create)
> create_stash "$*" && echo "$w_commit"
> ;;
> *)
> - if test $# -eq 0
> + if test $# -ne 0
> + then
> + usage
> + fi
> + if allow_quick_stash
> then
> save_stash && git-reset --hard
> else
> - usage
> + echo "*** Stash List ***"
> + list_stash
> fi
I was scratching my head about this extra "echo" and tried your version
after removing it, to realize this is another nice attention to the
details. Without it, what's output from the command is not very clear
to people who do not know what "git stash" is configured to do for the
session.
next prev parent reply other threads:[~2007-12-20 22:31 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-17 11:03 git-stash: RFC: Adopt the default behavior to other commands Sebastian Harl
2007-12-17 22:32 ` Benoit Sigoure
2007-12-17 23:00 ` Junio C Hamano
2007-12-17 23:32 ` Benoit Sigoure
2007-12-18 0:31 ` Junio C Hamano
2007-12-18 10:59 ` Sebastian Harl
2007-12-18 12:33 ` Johannes Schindelin
2007-12-18 14:22 ` Andreas Ericsson
2007-12-18 14:47 ` Johannes Schindelin
2007-12-18 15:00 ` Andreas Ericsson
2007-12-18 15:15 ` Johannes Schindelin
2007-12-18 15:28 ` Andreas Ericsson
2007-12-18 15:40 ` Jakub Narebski
2007-12-18 16:06 ` Andreas Ericsson
2007-12-18 16:11 ` Johannes Schindelin
2007-12-18 17:40 ` Sergei Organov
2007-12-18 18:03 ` Johannes Schindelin
2007-12-18 23:31 ` Martin Langhoff
2007-12-18 15:28 ` Wincent Colaiuta
2007-12-18 15:42 ` Jörg Sommer
2007-12-18 22:13 ` Johannes Schindelin
2007-12-18 22:22 ` Junio C Hamano
2007-12-20 21:40 ` しらいしななこ
2007-12-20 22:31 ` Junio C Hamano [this message]
2007-12-21 7:59 ` Wincent Colaiuta
2007-12-21 8:40 ` しらいしななこ
2007-12-18 23:32 ` André Goddard Rosa
2007-12-18 23:41 ` Martin Langhoff
2007-12-19 7:33 ` Wincent Colaiuta
2007-12-19 7:46 ` Martin Langhoff
2007-12-19 8:29 ` Andreas Ericsson
2007-12-19 12:01 ` Johannes Schindelin
2007-12-19 12:07 ` Wincent Colaiuta
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v4pedov6c.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=joerg@alea.gnuu.de \
--cc=nanako3@bluebottle.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.
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 NNTP newsgroup(s).