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

Re: [RFC/PATCH] shortstatus v1

From
Jeff King <peff@peff.net>
Date
Feb 12, 2009, 00:49 UTC
Message-ID
<20090212004921.GD30231@coredump.intra.peff.net>
In-Reply-To
<7v3aellwoa.fsf@gitster.siamese.dyndns.org>
On Tue, Feb 10, 2009 at 03:05:57PM -0800, Junio C Hamano wrote:
> There is an obvious optimization you can do to "diff-index --cached" using
> cache-tree.  If your index is really clean, computing the tree object the
> index would represent (without writing the tree object out) and comparing
> it against HEAD^{tree} may be a tad faster.

Clever, but I think you may just be trading one scenario for "worst case" versus another (i.e., now when you _do_ have a difference to do an early return, you still have to touch everything in the cache).

Just for fun, I timed a quick and dirty implementation. It looks like generating the tree actually ends up taking just a little bit longer, even with an unchanged index (which should be the case it speeds up).

But maybe I just did it wrong. My implementation was basically just:
  t = cache_tree();
  if (!cache_tree_fully_valid(t))
    cache_tree_update(t, active_cache, active_nr, 0, 0);
  get_sha1("HEAD", sha1);
  return hashcmp(t->sha1, sha1);
-Peff
Previous: Junio C HamanoNext: Nanako Shiraishi
Message 23 of 25 in “shortstatus v1”
  1. shortstatus v1Tuncer Ayaz, Feb 10, 2009
  2. Junio C HamanoFeb 10, 2009
  3. Sitaram ChamartyFeb 10, 2009
  4. Spending time in PS1, was Re: [RFC/PATCH] shortstatus v1Johannes Schindelin, Feb 10, 2009
  5. Sitaram ChamartyFeb 10, 2009
  6. Tuncer AyazFeb 10, 2009
  7. Jeff KingFeb 10, 2009
  8. Michael J GruberFeb 10, 2009
  9. Tuncer AyazFeb 10, 2009
  10. Jeff KingFeb 10, 2009
  11. Michael J GruberFeb 10, 2009
  12. Jeff KingFeb 10, 2009
  13. Junio C HamanoFeb 10, 2009
  14. Jeff KingFeb 10, 2009
  15. Jeff KingFeb 10, 2009
  16. Jeff KingFeb 10, 2009
  17. Tuncer AyazFeb 10, 2009
  18. Jeff KingFeb 10, 2009
  19. Junio C HamanoFeb 10, 2009
  20. Tuncer AyazFeb 10, 2009
  21. Jeff KingFeb 10, 2009
  22. Junio C HamanoFeb 10, 2009
  23. Jeff KingFeb 12, 2009
  24. Nanako ShiraishiFeb 10, 2009
  25. Junio C HamanoFeb 11, 2009

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.