Re: git-stash: RFC: Adopt the default behavior to other commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



しらいしななこ  <nanako3@xxxxxxxxxxxxxx> 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.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux