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

Re: [PATCH 0/2] Support `git reset --stdin`

From
Jeff King <peff@peff.net>
Date
Oct 11, 2016, 21:47 UTC
Message-ID
<20161011214713.y2fpjkrx6sspks4a@sigill.intra.peff.net>
In-Reply-To
<xmqqoa2q7elc.fsf@gitster.mtv.corp.google.com>
On Tue, Oct 11, 2016 at 02:36:31PM -0700, Junio C Hamano wrote:
Show 21 quoted lines
> > True. I'd have done something more like:
> >
> >   git ls-tree -r $paths | git update-index --index-info
> >
> > but there are some corner cases around deleting paths from the index.
> 
> Ah, I would think read-tree has the exact same issue, even if we
> added pathspec support, around removal.
> 
> So it is more like
> 
> 	(
> 		printf "0 0000000000000000000000000000000000000000\t%s\n" $paths
> 		git --literal-pathspecs ls-tree -r --ignore-missing $paths
> 	) | git update-index --index-info
> 
> which does not look too bad, even though this
> 
> 	printf "%s\n" $paths | git reset --stdin
> 
> does look shorter.

Of course neither of ours solutions works when "$paths" is coming on stdin, rather than in a variable, which I suspect was Dscho's original motivation. :)

One reason not to do the unconditional $z40 in yours is that without it, I would hope that update-index is smart enough not to discard the stat information for entries which are unchanged.

I suspect the best answer is more like:
  git diff-index --cached HEAD | git update-index --index-info

except that you have to munge the data in between, because update-index does not know how to pick the correct data out of the --raw diff output. But that's probably closer to what git-reset does internally.

Anyway, the existence of this discussion is probably a good argument in favor of Dscho's patch. I was mostly curious how close our plumbing tools could come.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 23 in “Support `git reset --stdin`”
  1. 0/2 Support `git reset --stdin`Johannes Schindelin, Oct 11, 2016
  2. 1/2 reset: fix usageJohannes Schindelin, Oct 11, 2016
  3. 2/2 reset: support the --stdin optionJohannes Schindelin, Oct 11, 2016
  4. Junio C HamanoOct 11, 2016
  5. Johannes SchindelinOct 12, 2016
  6. Jakub NarębskiOct 11, 2016
  7. Johannes SchindelinOct 12, 2016
  8. Jeff KingOct 11, 2016
  9. Junio C HamanoOct 11, 2016
  10. Jeff KingOct 11, 2016
  11. Junio C HamanoOct 11, 2016
  12. Jeff KingOct 11, 2016
  13. Junio C HamanoOct 11, 2016
  14. 0/1 Support `git reset --stdin`Johannes Schindelin, Jan 27, 2017
  15. 1/1 reset: support the --stdin optionJohannes Schindelin, Jan 27, 2017
  16. Jeff KingJan 27, 2017
  17. Johannes SchindelinJan 27, 2017
  18. Jeff KingJan 27, 2017
  19. Junio C HamanoJan 27, 2017
  20. Jeff KingJan 27, 2017
  21. Junio C HamanoJan 28, 2017
  22. 0/1 Support `git reset --stdin`Johannes Schindelin, Jan 27, 2017
  23. 1/1 reset: support the --stdin optionJohannes Schindelin, Jan 27, 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.