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

[PATCH 0/3] Optimizing "ls-files -k"

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 15, 2013, 21:28 UTC
Message-ID
<1376602090-19142-1-git-send-email-gitster@pobox.com>
In-Reply-To
<7v8v02rb2g.fsf@alter.siamese.dyndns.org>

"ls-files -o" and "ls-files -k" both traverse the working tree down to find either all untracked paths or those that will be "killed" (removed from the working tree to make room) when the paths recorded in the index are checked out.

It is necessary to traverse the working tree fully when enumerating all the "other" paths, but when we are only interested in "killed" paths, we can take advantage of the fact that paths that do not overlap with entries in the index can never be killed.

The first one is an independent clean-up. No public API in the working tree traversal takes alternate in-core index, so there is no reason to explicitly use the_index and index_* functions from the in-core index API.

The second one is rerolled from the "something like this" patch I sent earlier, but corrects the "we see a directory, it is not in the index, but a file in it is" case.

And the third one adds a testcase that illustrates why the earlier "something like this" patch is not sufficient.

These are designed to apply on top of v1.8.3, and needs a bit of conflict resolution for the upcoming v1.8.4 codebase; I'll queue them in 'pu' for now.

Note that t3010, especially after merged to 'pu', will use many different ways to create a test file. Some redirect "date" into it, some redirect ":" into it, some "touch" it, and some just redirect with no command.

	date >file1
	: >file2
	touch file3
	>file4

We should consolidate them all to just do ">file4" after making sure the contents do not matter (we kind of know it already, as "date" will output string that is not repeatable). Use of "touch" for anything other than updating the timestamp is especially bad, as it is misleading.

Junio C Hamano (3):
  dir.c: use the cache_* macro to access the current index
  ls-files -k: a directory only can be killed if the index has a non-directory
  t3010: update to demonstrate "ls-files -k" optimization pitfalls
 builtin/ls-files.c                  |  2 ++
 dir.c                               | 40 +++++++++++++++++++++++++++++--------
 dir.h                               |  3 ++-
 t/t3010-ls-files-killed-modified.sh | 12 ++++++++---
 4 files changed, 45 insertions(+), 12 deletions(-)
-- 
1.8.4-rc3-232-ga8053f8
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 15 in “git stash takes excessively long when many untracked files present”
  1. Josh TriplettAug 10, 2013
  2. Anders DaranderAug 13, 2013
  3. Junio C HamanoAug 13, 2013
  4. Anders DaranderAug 13, 2013
  5. Junio C HamanoAug 13, 2013
  6. Junio C HamanoAug 13, 2013
  7. Junio C HamanoAug 15, 2013
  8. Josh TriplettAug 15, 2013
  9. Junio C HamanoAug 15, 2013
  10. Junio C HamanoAug 15, 2013
  11. 0/3 Optimizing "ls-files -k"Junio C Hamano, Aug 15, 2013
  12. 1/3 dir.c: use the cache_* macro to access the current indexJunio C Hamano, Aug 15, 2013
  13. 2/3 ls-files -k: a directory only can be killed if the index has a non-directoryJunio C Hamano, Aug 15, 2013
  14. 3/3 t3010: update to demonstrate "ls-files -k" optimization pitfallsJunio C Hamano, Aug 15, 2013
  15. 4/3 git stash: avoid data loss when "git stash save" kills a directoryJunio C Hamano, Aug 15, 2013

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.