Skip to content

Kill manual ref parsing code in worktree.c

Nguyễn Thái Ngọc Duy git 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest6 patches 1 replyIn review
  2. v45 patches 6 repliesSuperseded
  3. v34 patches 7 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v25 patches0 repliesSuperseded
v1 RFC2 patches10 repliesSuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6environment.c: fix potential segfault by get_git_common_dir()environment.c+2 -00 replies
2/6refs.c: make submodule ref store hashmap genericrefs.c+32 -320 replies
3/6refs: add REFS_STORE_ALL_CAPSrefs.c refs/refs-internal.h+5 -50 replies
4/6refs: introduce get_worktree_ref_store()refs.c refs.h+32 -00 replies
5/6worktree.c: kill parse_ref() in favor of refs_resolve_ref_unsafe()branch.c t/helper/test-ref-store.c t/t1407-worktree-ref-store.sh +2 more+88 -770 replies
6/6refs: kill set_worktree_head_symref()branch.c refs.h refs/files-backend.c +1 more+18 -600 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/6] Kill manual ref parsing code in worktree.c

v5 chanes are mostly cosmetic:

refs.c +3 -10
index 5d31fb6bcf..7972720256 100644
@@ -1530,11 +1530,7 @@ struct ref_store *get_main_ref_store(void)
 	if (main_ref_store)
 		return main_ref_store;
 
-	main_ref_store = ref_store_init(get_git_dir(),
-					(REF_STORE_READ |
-					 REF_STORE_WRITE |
-					 REF_STORE_ODB |
-					 REF_STORE_MAIN));
+	main_ref_store = ref_store_init(get_git_dir(), REF_STORE_ALL_CAPS);
 	return main_ref_store;
 }
 
@@ -1597,9 +1593,6 @@ struct ref_store *get_submodule_ref_store(const char *submodule)
 struct ref_store *get_worktree_ref_store(const struct worktree *wt)
 {
 	struct ref_store *refs;
-	unsigned int refs_all_capabilities =
-		REF_STORE_READ | REF_STORE_WRITE |
-		REF_STORE_ODB | REF_STORE_MAIN;
 	const char *id;
 
 	if (wt->is_current)
@@ -1612,10 +1605,10 @@ struct ref_store *get_worktree_ref_store(const struct worktree *wt)
 
 	if (wt->id)
 		refs = ref_store_init(git_common_path("worktrees/%s", wt->id),
-				      refs_all_capabilities);
+				      REF_STORE_ALL_CAPS);
 	else
 		refs = ref_store_init(get_git_common_dir(),
-				      refs_all_capabilities);
+				      REF_STORE_ALL_CAPS);
 
 	if (refs)
 		register_ref_store_map(&worktree_ref_stores, "worktree",
refs/refs-internal.h +4 -0
index 690498698e..b26f7e41ce 100644
@@ -467,6 +467,10 @@ struct ref_store;
 #define REF_STORE_WRITE		(1 << 1) /* can perform update operations */
 #define REF_STORE_ODB		(1 << 2) /* has access to object database */
 #define REF_STORE_MAIN		(1 << 3)
+#define REF_STORE_ALL_CAPS	(REF_STORE_READ | \
+				 REF_STORE_WRITE | \
+				 REF_STORE_ODB | \
+				 REF_STORE_MAIN)
 
 /*
  * Initialize the ref_store for the specified gitdir. These functions

Nguyễn Thái Ngọc Duy (6):
environment.c: fix potential segfault by get_git_common_dir() refs.c: make submodule ref store hashmap generic
refs: add REFS_STORE_ALL_CAPS
refs: introduce get_worktree_ref_store()
worktree.c: kill parse_ref() in favor of refs_resolve_ref_unsafe()
refs: kill set_worktree_head_symref()

 branch.c                               |  15 ++---
 environment.c                          |   2 +
 refs.c                                 | 100 ++++++++++++++++++++------------
 refs.h                                 |  12 +---
 refs/files-backend.c                   |  44 --------------
 refs/refs-internal.h                   |   4 ++
 t/helper/test-ref-store.c              |  18 ++++++
 t/t1407-worktree-ref-store.sh (new +x) |  52 +++++++++++++++++
 worktree.c                             | 102 +++++++++------------------------
 worktree.h                             |   2 +-
 10 files changed, 177 insertions(+), 174 deletions(-)
 create mode 100755 t/t1407-worktree-ref-store.sh
Signature · 1 line
2.11.0.157.gd943d85