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

[PATCH 1/3] packed_git: convert pack_local flag into generic bit mask

From
drafnel@gmail.com <drafnel@gmail.com>
Date
Nov 2, 2008, 16:31 UTC
Message-ID
<6141358.1225643400587.JavaMail.teamon@b303.teamon.com>
In-Reply-To
<14536526.1225596838300.JavaMail.teamon@b301.teamon.com>
From: Brandon Casey <drafnel@gmail.com>

This converts the pack_local flag of the packed_git structure into a generic bit mask and introduces a PACK_LOCAL mask and an ispacklocal() access macro.

So instead of this:
   if (p->pack_local)
      do_something
you would do this:
   if (ispacklocal(p))
      do_something

This is in preparation for adding a flag indicating whether a .keep file is present.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 builtin-count-objects.c |    2 +-
 builtin-gc.c            |    2 +-
 builtin-pack-objects.c  |    2 +-
 cache.h                 |    5 ++++-
 pack-redundant.c        |    4 ++--
 server-info.c           |    4 ++--
 sha1_file.c             |    5 +++--
 7 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index ab35b65..3f981d6 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -108,7 +108,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
 		if (!packed_git)
 			prepare_packed_git();
 		for (p = packed_git; p; p = p->next) {
-			if (!p->pack_local)
+			if (!ispacklocal(p))
 				continue;
 			if (open_pack_index(p))
 				continue;
diff --git a/builtin-gc.c b/builtin-gc.c
index 7af65bb..0473158 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -135,7 +135,7 @@ static int too_many_packs(void)
 		size_t len;
 		int keep;
 
-		if (!p->pack_local)
+		if (!ispacklocal(p))
 			continue;
 		len = strlen(p->pack_name);
 		if (PATH_MAX <= len + 1)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 59c30d1..6a8b9bf 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -701,7 +701,7 @@ static int add_object_entry(const unsigned char *sha1, enum object_type type,
 				break;
 			if (incremental)
 				return 0;
-			if (local && !p->pack_local)
+			if (local && !ispacklocal(p))
 				return 0;
 		}
 	}
diff --git a/cache.h b/cache.h
index b0edbf9..0cb9350 100644
--- a/cache.h
+++ b/cache.h
@@ -679,12 +679,15 @@ extern struct packed_git {
 	int index_version;
 	time_t mtime;
 	int pack_fd;
-	int pack_local;
+	unsigned int flags;
 	unsigned char sha1[20];
 	/* something like ".git/objects/pack/xxxxx.pack" */
 	char pack_name[FLEX_ARRAY]; /* more */
 } *packed_git;
 
+#define PACK_LOCAL	1
+#define ispacklocal(p) ((p)->flags & PACK_LOCAL)
+
 struct pack_entry {
 	off_t offset;
 	unsigned char sha1[20];
diff --git a/pack-redundant.c b/pack-redundant.c
index 25b81a4..964f18f 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -544,7 +544,7 @@ static struct pack_list * add_pack(struct packed_git *p)
 	unsigned long off = 0, step;
 	const unsigned char *base;
 
-	if (!p->pack_local && !(alt_odb || verbose))
+	if (!ispacklocal(p) && !(alt_odb || verbose))
 		return NULL;
 
 	l.pack = p;
@@ -562,7 +562,7 @@ static struct pack_list * add_pack(struct packed_git *p)
 	}
 	/* this list will be pruned in cmp_two_packs later */
 	l.unique_objects = llist_copy(l.all_objects);
-	if (p->pack_local)
+	if (ispacklocal(p))
 		return pack_list_insert(&local_packs, &l);
 	else
 		return pack_list_insert(&altodb_packs, &l);
diff --git a/server-info.c b/server-info.c
index c1c073b..2eb20f5 100644
--- a/server-info.c
+++ b/server-info.c
@@ -168,14 +168,14 @@ static void init_pack_info(const char *infofile, int force)
 		/* we ignore things on alternate path since they are
 		 * not available to the pullers in general.
 		 */
-		if (!p->pack_local)
+		if (!ispacklocal(p))
 			continue;
 		i++;
 	}
 	num_pack = i;
 	info = xcalloc(num_pack, sizeof(struct pack_info *));
 	for (i = 0, p = packed_git; p; p = p->next) {
-		if (!p->pack_local)
+		if (!ispacklocal(p))
 			continue;
 		info[i] = xcalloc(1, sizeof(struct pack_info));
 		info[i]->p = p;
diff --git a/sha1_file.c b/sha1_file.c
index ab2b520..e4141c9 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -851,7 +851,8 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
 	 * actually mapping the pack file.
 	 */
 	p->pack_size = st.st_size;
-	p->pack_local = local;
+	if (local)
+		p->flags |= PACK_LOCAL;
 	p->mtime = st.st_mtime;
 	if (path_len < 40 || get_sha1_hex(path + path_len - 40, p->sha1))
 		hashclr(p->sha1);
@@ -941,7 +942,7 @@ static int sort_pack(const void *a_, const void *b_)
 	 * remote ones could be on a network mounted filesystem.
 	 * Favor local ones for these reasons.
 	 */
-	st = a->pack_local - b->pack_local;
+	st = ispacklocal(a) - ispacklocal(b);
 	if (st)
 		return -st;
 
-- 
1.6.0.2.588.g3102
Previous: drafnel@gmail.comNext: Shawn O. Pearce
Message 9 of 61 in “getting list of objects for packing”
  1. Brandon CaseyOct 31, 2008
  2. Nicolas PitreOct 31, 2008
  3. Brandon CaseyOct 31, 2008
  4. Junio C HamanoOct 31, 2008
  5. Brandon CaseyOct 31, 2008
  6. Jakub NarebskiOct 31, 2008
  7. Brandon CaseyNov 1, 2008
  8. t7700: demonstrate mishandling of objects in packs with a .keep filedrafnel@gmail.com, Nov 2, 2008
  9. 1/3 packed_git: convert pack_local flag into generic bit maskdrafnel@gmail.com, Nov 2, 2008
  10. Shawn O. PearceNov 3, 2008
  11. Brandon CaseyNov 3, 2008
  12. 1/3 t7700: demonstrate mishandling of objects in packs with a .keep fileBrandon Casey, Nov 3, 2008
  13. 2/3 packed_git: convert pack_local flag into a bitfield and add pack_keepBrandon Casey, Nov 3, 2008
  14. 3/3 pack-objects: honor '.keep' filesBrandon Casey, Nov 3, 2008
  15. Shawn O. PearceNov 3, 2008
  16. Brandon CaseyNov 5, 2008
  17. Brandon CaseyNov 6, 2008
  18. Junio C HamanoNov 7, 2008
  19. Brandon CaseyNov 7, 2008
  20. Andreas EricssonNov 7, 2008
  21. Shawn O. PearceNov 7, 2008
  22. recognize loose local objects during repackdrafnel@gmail.com, Nov 10, 2008
  23. Junio C HamanoNov 10, 2008
  24. 1/4 pack-objects: new option --honor-pack-keepBrandon Casey, Nov 7, 2008
  25. 2/4 repack: don't repack local objects in packs with .keep fileBrandon Casey, Nov 7, 2008
  26. 3/4 repack: do not fall back to incremental repacking with [-a|-A]Brandon Casey, Nov 7, 2008
  27. 4/4 builtin-gc.c: use new pack_keep bitfield to detect .keep file existenceBrandon Casey, Nov 7, 2008
  28. Andreas EricssonNov 7, 2008
  29. Andreas EricssonNov 7, 2008
  30. t7700: demonstrate mishandling of objects in packs with a .keep fileBrandon Casey, Nov 3, 2008
  31. Andreas EricssonNov 4, 2008
  32. Brandon CaseyNov 4, 2008
  33. Junio C HamanoNov 4, 2008
  34. Brandon CaseyNov 4, 2008
  35. Andreas EricssonNov 4, 2008
  36. Junio C HamanoNov 4, 2008
  37. Jeff KingNov 12, 2008
  38. Junio C HamanoNov 12, 2008
  39. Jeff KingNov 12, 2008
  40. Brandon CaseyNov 12, 2008
  41. repack and .keep seriesBrandon Casey, Nov 12, 2008
  42. 1/6 t7700: demonstrate mishandling of objects in packs with a .keep fileBrandon Casey, Nov 12, 2008
  43. 2/6 packed_git: convert pack_local flag into a bitfield and add pack_keepBrandon Casey, Nov 12, 2008
  44. 3/6 pack-objects: new option --honor-pack-keepBrandon Casey, Nov 12, 2008
  45. 4/6 repack: don't repack local objects in packs with .keep fileBrandon Casey, Nov 12, 2008
  46. 5/6 repack: do not fall back to incremental repacking with [-a|-A]Brandon Casey, Nov 12, 2008
  47. 6/6 builtin-gc.c: use new pack_keep bitfield to detect .keep file existenceBrandon Casey, Nov 12, 2008
  48. t7700: test that 'repack -a' packs alternate packed objectsBrandon Casey, Nov 13, 2008
  49. Junio C HamanoNov 12, 2008
  50. Junio C HamanoNov 12, 2008
  51. Andreas EricssonNov 3, 2008
  52. Brandon CaseyNov 3, 2008
  53. Andreas EricssonNov 3, 2008
  54. Brandon CaseyNov 3, 2008
  55. Andreas EricssonNov 4, 2008
  56. 2/3 packed_git: add new PACK_KEEP flag and haspackkeep() access macrodrafnel@gmail.com, Nov 2, 2008
  57. 3/3 pack-objects: honor '.keep' filesdrafnel@gmail.com, Nov 2, 2008
  58. Shawn O. PearceNov 3, 2008
  59. 1/3 t7700: demonstrate mishandling of loose objects in an alternate ODBdrafnel@gmail.com, Nov 10, 2008
  60. 2/3 sha1_file.c: split has_loose_object() into local and non-local counterpartsdrafnel@gmail.com, Nov 10, 2008
  61. 3/3 pack-objects: extend --local to mean ignore non-local loose objects toodrafnel@gmail.com, Nov 10, 2008

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.