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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 20, 2007, 22:31 UTC
Message-ID
<7v4pedov6c.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200712202145.lBKLj7Fu015050@mi0.bluebottle.com>
しらいしななこ  <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.
Show 5 quoted lines
> +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.

Show 8 quoted lines
> +		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.

Show 10 quoted lines
> +	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.

Show 17 quoted lines
> @@ -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.

Previous: しらいしななこNext: Wincent Colaiuta
Message 24 of 33 in “git-stash: RFC: Adopt the default behavior to other commands”
  1. Sebastian HarlDec 17, 2007
  2. Benoit SigoureDec 17, 2007
  3. Junio C HamanoDec 17, 2007
  4. Benoit SigoureDec 17, 2007
  5. Junio C HamanoDec 18, 2007
  6. Sebastian HarlDec 18, 2007
  7. Johannes SchindelinDec 18, 2007
  8. Andreas EricssonDec 18, 2007
  9. Johannes SchindelinDec 18, 2007
  10. Andreas EricssonDec 18, 2007
  11. Johannes SchindelinDec 18, 2007
  12. Andreas EricssonDec 18, 2007
  13. Jakub NarebskiDec 18, 2007
  14. Andreas EricssonDec 18, 2007
  15. Johannes SchindelinDec 18, 2007
  16. Sergei OrganovDec 18, 2007
  17. Johannes SchindelinDec 18, 2007
  18. Martin LanghoffDec 18, 2007
  19. Wincent ColaiutaDec 18, 2007
  20. Jörg SommerDec 18, 2007
  21. Johannes SchindelinDec 18, 2007
  22. Junio C HamanoDec 18, 2007
  23. しらいしななこDec 20, 2007
  24. Junio C HamanoDec 20, 2007
  25. Wincent ColaiutaDec 21, 2007
  26. しらいしななこDec 21, 2007
  27. André Goddard RosaDec 18, 2007
  28. Martin LanghoffDec 18, 2007
  29. Wincent ColaiutaDec 19, 2007
  30. Martin LanghoffDec 19, 2007
  31. Andreas EricssonDec 19, 2007
  32. Johannes SchindelinDec 19, 2007
  33. Wincent ColaiutaDec 19, 2007

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.