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

[PATCH 1/9] sha1_file: provide real packed type in object_info_extended

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Oct 9, 2013, 14:46 UTC
Message-ID
<1381329976-32082-2-git-send-email-pclouds@gmail.com>
In-Reply-To
<1381329976-32082-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 cache.h     | 2 +-
 sha1_file.c | 3 +--
 streaming.c | 9 ++++++++-
 3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/cache.h b/cache.h
index 20c2d6d..5028ded 100644
--- a/cache.h
+++ b/cache.h
@@ -1168,7 +1168,7 @@ struct object_info {
 		struct {
 			struct packed_git *pack;
 			off_t offset;
-			unsigned int is_delta;
+			unsigned int real_type;
 		} packed;
 	} u;
 };
diff --git a/sha1_file.c b/sha1_file.c
index ef6ecc8..5848008 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2557,8 +2557,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi)
 		oi->whence = OI_PACKED;
 		oi->u.packed.offset = e.offset;
 		oi->u.packed.pack = e.p;
-		oi->u.packed.is_delta = (rtype == OBJ_REF_DELTA ||
-					 rtype == OBJ_OFS_DELTA);
+		oi->u.packed.real_type = rtype;
 	}
 
 	return 0;
diff --git a/streaming.c b/streaming.c
index c7edebb..2cc4c03 100644
--- a/streaming.c
+++ b/streaming.c
@@ -104,6 +104,12 @@ ssize_t read_istream(struct git_istream *st, void *buf, size_t sz)
 	return st->vtbl->read(st, buf, sz);
 }
 
+static int is_canonical(int type)
+{
+	return type != OBJ_COMMIT && type != OBJ_TREE &&
+		type != OBJ_BLOB && type != OBJ_TAG;
+}
+
 static enum input_source istream_source(const unsigned char *sha1,
 					enum object_type *type,
 					struct object_info *oi)
@@ -121,7 +127,8 @@ static enum input_source istream_source(const unsigned char *sha1,
 	case OI_LOOSE:
 		return loose;
 	case OI_PACKED:
-		if (!oi->u.packed.is_delta && big_file_threshold < size)
+		if (is_canonical(oi->u.packed.real_type) &&
+		    big_file_threshold < size)
 			return pack_non_delta;
 		/* fallthru */
 	default:
-- 
1.8.2.83.gc99314b
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 2 of 15 in “v4-aware tree walker API”
  1. 0/9 v4-aware tree walker APINguyễn Thái Ngọc Duy, Oct 9, 2013
  2. 1/9 sha1_file: provide real packed type in object_info_extendedNguyễn Thái Ngọc Duy, Oct 9, 2013
  3. 2/9 pack v4: move v2 tree entry generation code out of decode_entriesNguyễn Thái Ngọc Duy, Oct 9, 2013
  4. 3/9 pv4_tree_desc: introduce new struct for pack v4 tree walkerNguyễn Thái Ngọc Duy, Oct 9, 2013
  5. 4/9 pv4_tree_desc: use struct tree_desc from pv4_tree_descNguyễn Thái Ngọc Duy, Oct 9, 2013
  6. 5/9 pv4_tree_desc: allow decode_entries to return v4 trees, one at a timeNguyễn Thái Ngọc Duy, Oct 9, 2013
  7. 6/9 pv4_tree_desc: complete interfaceNguyễn Thái Ngọc Duy, Oct 9, 2013
  8. 7/9 pv4_tree_desc: don't bother looking for v4 trees if no v4 packs are presentNguyễn Thái Ngọc Duy, Oct 9, 2013
  9. 8/9 pv4_tree_desc: avoid lookup_object() when possibleNguyễn Thái Ngọc Duy, Oct 9, 2013
  10. 9/9 list-object.c: take "advantage" of new pv4_tree_desc interfaceNguyễn Thái Ngọc Duy, Oct 9, 2013
  11. Nicolas PitreOct 9, 2013
  12. Duy NguyenOct 11, 2013
  13. Duy NguyenOct 11, 2013
  14. Nicolas PitreOct 12, 2013
  15. Duy NguyenOct 12, 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.