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

[PATCH 3/6] Stop producing index version 2

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 6, 2012, 05:48 UTC
Message-ID
<1328507319-24687-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1328507319-24687-1-git-send-email-pclouds@gmail.com>
read-cache.c learned to produce version 2 or 3 depending on whether
extended cache entries exist in 06aaaa0 (Extend index to save more flags
- 2008-10-01), first released in 1.6.1. The purpose is to keep
compatibility with older git. It's been more than three years since
then and git has reached 1.7.9. Drop support for older git.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 read-cache.c                          |    8 +++-----
 t/t2104-update-index-skip-worktree.sh |   12 ------------
 2 files changed, 3 insertions(+), 17 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index e9a20b6..fe6b0e0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1532,26 +1532,24 @@ int write_index(struct index_state *istate, int newfd)
 {
 	struct sha1file *f;
 	struct cache_header hdr;
-	int i, err, removed, extended;
+	int i, err, removed;
 	struct cache_entry **cache = istate->cache;
 	int entries = istate->cache_nr;
 	struct stat st;
 
-	for (i = removed = extended = 0; i < entries; i++) {
+	for (i = removed = 0; i < entries; i++) {
 		if (cache[i]->ce_flags & CE_REMOVE)
 			removed++;
 
 		/* reduce extended entries if possible */
 		cache[i]->ce_flags &= ~CE_EXTENDED;
 		if (cache[i]->ce_flags & CE_EXTENDED_FLAGS) {
-			extended++;
 			cache[i]->ce_flags |= CE_EXTENDED;
 		}
 	}
 
 	hdr.hdr_signature = htonl(CACHE_SIGNATURE);
-	/* for extended format, increase version so older git won't try to read it */
-	hdr.hdr_version = htonl(extended ? 3 : 2);
+	hdr.hdr_version = htonl(3);
 	hdr.hdr_entries = htonl(entries - removed);
 
 	f = sha1fd(newfd, NULL);
diff --git a/t/t2104-update-index-skip-worktree.sh b/t/t2104-update-index-skip-worktree.sh
index 1d0879b..8221ffa 100755
--- a/t/t2104-update-index-skip-worktree.sh
+++ b/t/t2104-update-index-skip-worktree.sh
@@ -28,19 +28,11 @@ test_expect_success 'setup' '
 	git ls-files -t | test_cmp expect.full -
 '
 
-test_expect_success 'index is at version 2' '
-	test "$(test-index-version < .git/index)" = 2
-'
-
 test_expect_success 'update-index --skip-worktree' '
 	git update-index --skip-worktree 1 sub/1 &&
 	git ls-files -t | test_cmp expect.skip -
 '
 
-test_expect_success 'index is at version 3 after having some skip-worktree entries' '
-	test "$(test-index-version < .git/index)" = 3
-'
-
 test_expect_success 'ls-files -t' '
 	git ls-files -t | test_cmp expect.skip -
 '
@@ -50,8 +42,4 @@ test_expect_success 'update-index --no-skip-worktree' '
 	git ls-files -t | test_cmp expect.full -
 '
 
-test_expect_success 'index version is back to 2 when there is no skip-worktree entry' '
-	test "$(test-index-version < .git/index)" = 2
-'
-
 test_done
-- 
1.7.8.36.g69ee2
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 3 of 20 in “read-cache: use sha1file for sha1 calculation”
  1. 1/6 read-cache: use sha1file for sha1 calculationNguyễn Thái Ngọc Duy, Feb 6, 2012
  2. 2/6 csum-file: make sha1 calculation optionalNguyễn Thái Ngọc Duy, Feb 6, 2012
  3. 3/6 Stop producing index version 2Nguyễn Thái Ngọc Duy, Feb 6, 2012
  4. Junio C HamanoFeb 6, 2012
  5. Shawn PearceFeb 7, 2012
  6. Nguyen Thai Ngoc DuyFeb 7, 2012
  7. Nguyen Thai Ngoc DuyFeb 7, 2012
  8. Junio C HamanoFeb 7, 2012
  9. Thomas RastFeb 7, 2012
  10. 4/6 Introduce index version 4 with global flagsNguyễn Thái Ngọc Duy, Feb 6, 2012
  11. 5/6 Allow to use crc32 as a lighter checksum on indexNguyễn Thái Ngọc Duy, Feb 6, 2012
  12. Shawn PearceFeb 7, 2012
  13. Dave ZarzyckiFeb 7, 2012
  14. Dave ZarzyckiFeb 7, 2012
  15. 6/6 Automatically switch to crc32 checksum for index when it's too largeNguyễn Thái Ngọc Duy, Feb 6, 2012
  16. Dave ZarzyckiFeb 6, 2012
  17. Nguyen Thai Ngoc DuyFeb 6, 2012
  18. Dave ZarzyckiFeb 6, 2012
  19. Junio C HamanoFeb 6, 2012
  20. Nguyen Thai Ngoc DuyFeb 6, 2012

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.