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

Re: [PATCH v6 4/6] stash: teach 'push' (and 'create_stash') to honor pathspec

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 21, 2017, 16:55 UTC
Message-ID
<xmqqmvdfh4az.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170219110313.24070-5-t.gummerer@gmail.com>
Thomas Gummerer <t.gummerer@gmail.com> writes:
> -		git reset --hard ${GIT_QUIET:+-q}

This hunk is probably the most important one to review in the whole series, in the sense that these are entirely new code that didn't exist in the original.

> +		if test $# != 0
> +		then
> +			saved_untracked=
> +			if test -n "$(git ls-files --others -- "$@")"

I notice that "ls-files -o" used in the code before this series are almost always used with --exclude-standard but we do not set up the standard exclude pattern here. Is there a good reason to use (or not to use) it here as well?

Show 5 quoted lines
> +			then
> +				saved_untracked=$(
> +					git ls-files -z --others -- "$@" |
> +					    xargs -0 git stash create -u all --)
> +			fi
Running the same ls-files twice look somewhat wasteful.

I suspect that we avoid "xargs -0" in our code from portability concern (isn't it a GNU invention?)

> +			git ls-files -z -- "$@" | xargs -0 git reset ${GIT_QUIET:+-q} --

Hmm, am I being naive to suspect that the above is a roundabout way to say:

	git reset ${GIT_QUIET:+-q} -- "$@"
or is an effect quite different from that intended here?
> +			git ls-files -z --modified -- "$@" | xargs -0 git checkout ${GIT_QUIET:+-q} HEAD --
Likewise.  Wouldn't the above be equivalent to:
	git checkout ${GIT_QUIET:+-q} HEAD -- "$@"

Or is this trying to preserve paths modified in the working tree and fully added to the index?

> +			if test -n "$(git ls-files -z --others -- "$@")"
> +			then
> +				git ls-files -z --others -- "$@" | xargs -0 git clean --force -d ${GIT_QUIET:+-q} --

Likewise. "ls-files --others" being the major part of what "clean" is about, I suspect the "ls-files piped to clean" is redundant. Do you even need a test? IOW, doesn't "git clean" with a pathspec that does not match anything silently succeed without doing anything harmful?

> +			fi
> +			if test -n "$saved_untracked"
> +			then
> +				git stash pop -q $saved_untracked

I see this thing was "created", and the whole point of "create" is to be different from "save/push" that automatically adds the result to the stash reflog. Should we be "pop"ing it, or did you mean to just call apply_stash on it?

> +			fi
> +		else
> +			git reset --hard ${GIT_QUIET:+-q}
> +		fi
Previous: Thomas GummererNext: Thomas Gummerer
Message 30 of 61 in “stash: support pathspec argument”
  1. 0/7 stash: support pathspec argumentThomas Gummerer, Feb 12, 2017
  2. 1/7 Documentation/stash: remove mention of git reset --hardThomas Gummerer, Feb 12, 2017
  3. 2/7 stash: introduce push verbThomas Gummerer, Feb 12, 2017
  4. 6/7 stash: use stash_push for no verb formThomas Gummerer, Feb 12, 2017
  5. 5/7 stash: teach 'push' (and 'create') to honor pathspecThomas Gummerer, Feb 12, 2017
  6. 4/7 stash: introduce new format createThomas Gummerer, Feb 12, 2017
  7. 3/7 stash: add test for the create command line argumentsThomas Gummerer, Feb 12, 2017
  8. 7/7 stash: allow pathspecs in the no verb formThomas Gummerer, Feb 12, 2017
  9. Thomas GummererFeb 12, 2017
  10. 0/6 stash: support pathspec argumentThomas Gummerer, Feb 17, 2017
  11. 2/6 stash: add test for the create command line argumentsThomas Gummerer, Feb 17, 2017
  12. 4/6 stash: teach 'push' (and 'create_stash') to honor pathspecThomas Gummerer, Feb 17, 2017
  13. 5/6 stash: use stash_push for no verb formThomas Gummerer, Feb 17, 2017
  14. 6/6 stash: allow pathspecs in the no verb formThomas Gummerer, Feb 17, 2017
  15. Jeff KingFeb 17, 2017
  16. Thomas GummererFeb 19, 2017
  17. 1/6 stash: introduce push verbThomas Gummerer, Feb 17, 2017
  18. 3/6 stash: refactor stash_createThomas Gummerer, Feb 17, 2017
  19. Jeff KingFeb 17, 2017
  20. Thomas GummererFeb 19, 2017
  21. Junio C HamanoFeb 17, 2017
  22. Thomas GummererFeb 17, 2017
  23. Junio C HamanoFeb 17, 2017
  24. 0/6 stash: support pathspec argumentThomas Gummerer, Feb 19, 2017
  25. 5/6 stash: use stash_push for no verb formThomas Gummerer, Feb 19, 2017
  26. 2/6 stash: add test for the create command line argumentsThomas Gummerer, Feb 19, 2017
  27. 3/6 stash: refactor stash_createThomas Gummerer, Feb 19, 2017
  28. 1/6 stash: introduce push verbThomas Gummerer, Feb 19, 2017
  29. 4/6 stash: teach 'push' (and 'create_stash') to honor pathspecThomas Gummerer, Feb 19, 2017
  30. Junio C HamanoFeb 21, 2017
  31. Thomas GummererFeb 25, 2017
  32. 6/6 stash: allow pathspecs in the no verb formThomas Gummerer, Feb 19, 2017
  33. Jeff KingFeb 20, 2017
  34. Junio C HamanoFeb 20, 2017
  35. Junio C HamanoFeb 20, 2017
  36. Thomas GummererFeb 25, 2017
  37. 0/6 stash: support pathspec argumentThomas Gummerer, Feb 25, 2017
  38. 2/6 stash: add test for the create command line argumentsThomas Gummerer, Feb 25, 2017
  39. 3/6 stash: refactor stash_createThomas Gummerer, Feb 25, 2017
  40. 6/6 stash: allow pathspecs in the no verb formThomas Gummerer, Feb 25, 2017
  41. 1/6 stash: introduce push verbThomas Gummerer, Feb 25, 2017
  42. 4/6 stash: teach 'push' (and 'create_stash') to honor pathspecThomas Gummerer, Feb 25, 2017
  43. Junio C HamanoFeb 27, 2017
  44. Thomas GummererFeb 27, 2017
  45. Junio C HamanoFeb 27, 2017
  46. Junio C HamanoFeb 27, 2017
  47. Junio C HamanoFeb 27, 2017
  48. Thomas GummererFeb 27, 2017
  49. 5/6 stash: use stash_push for no verb formThomas Gummerer, Feb 25, 2017
  50. 0/6 stash: support pathspec argumentThomas Gummerer, Feb 28, 2017
  51. 3/6 stash: refactor stash_createThomas Gummerer, Feb 28, 2017
  52. 6/6 stash: allow pathspecs in the no verb formThomas Gummerer, Feb 28, 2017
  53. 1/6 stash: introduce push verbThomas Gummerer, Feb 28, 2017
  54. 4/6 stash: teach 'push' (and 'create_stash') to honor pathspecThomas Gummerer, Feb 28, 2017
  55. Junio C HamanoFeb 28, 2017
  56. Thomas GummererMar 1, 2017
  57. Junio C HamanoMar 1, 2017
  58. 2/6 stash: add test for the create command line argumentsThomas Gummerer, Feb 28, 2017
  59. 5/6 stash: use stash_push for no verb formThomas Gummerer, Feb 28, 2017
  60. Thomas GummererFeb 14, 2017
  61. Thomas GummererFeb 17, 2017

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.