Skip to content

nd/sha1-name-c-wo-the-repository updates

Nguyễn Thái Ngọc Duy git 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest34 patches 0 repliesNew
  2. v333 patches 11 repliesSuperseded
  3. v232 patches 6 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/34builtin rebase: use FREE_AND_NULLbuiltin/rebase.c+1 -20 replies
2/34builtin rebase: use oideq()builtin/rebase.c+1 -10 replies
3/34packfile.c: add repo_approximate_object_count()packfile.c packfile.h+9 -80 replies
4/34refs.c: add refs_ref_exists()refs.c+6 -10 replies
5/34refs.c: add refs_shorten_unambiguous_ref()refs.c refs.h+11 -20 replies
6/34refs.c: remove the_repo from substitute_branch_name()cache.h refs.c sha1-name.c+17 -80 replies
7/34refs.c: remove the_repo from expand_ref()refs.c refs.h upload-pack.c+8 -60 replies
8/34refs.c: add repo_dwim_ref()refs.c refs.h+10 -30 replies
9/34refs.c: add repo_dwim_log()refs.c refs.h+16 -60 replies
10/34refs.c: remove the_repo from read_ref_at()builtin/show-branch.c refs.c refs.h +1 more+12 -70 replies
11/34commit.cocci: refactor code, avoid double rewritecommit-graph.c commit.c contrib/coccinelle/commit.cocci +1 more+33 -120 replies
12/34commit.c: add repo_get_commit_tree()commit.c commit.h contrib/coccinelle/commit.cocci+9 -70 replies
13/34sha1-name.c: remove the_repo from sort_ambiguous()sha1-name.c+12 -30 replies
14/34sha1-name.c: remove the_repo from find_abbrev_len_packed()sha1-name.c+4 -20 replies
15/34sha1-name.c: add repo_find_unique_abbrev_r()cache.h sha1-name.c+13 -80 replies
16/34sha1-name.c: store and use repo in struct disambiguate_statesha1-name.c+59 -360 replies
17/34sha1-name.c: add repo_for_each_abbrev()cache.h sha1-name.c+5 -30 replies
18/34sha1-name.c: remove the_repo from get_short_oid()sha1-name.c+10 -70 replies
19/34sha1-name.c: remove the_repo from interpret_nth_prior_checkout()sha1-name.c+10 -70 replies
20/34sha1-name.c: remove the_repo from interpret_branch_mark()sha1-name.c+7 -60 replies
21/34sha1-name.c: add repo_interpret_branch_name()sha1-name.c+8 -90 replies
22/34sha1-name.c: remove the_repo from get_oid_oneline()sha1-name.c+7 -60 replies
23/34sha1-name.c: remove the_repo from get_describe_name()sha1-name.c+5 -30 replies
24/34sha1-name.c: remove the_repo from get_oid_basic()sha1-name.c+12 -130 replies
25/34sha1-name.c: remove the_repo from get_oid_1()cache.h sha1-name.c+36 -300 replies
26/34sha1-name.c: remove the_repo from handle_one_ref()sha1-name.c+14 -50 replies
27/34sha1-name.c: remove the_repo from diagnose_invalid_index_path()dir.c dir.h sha1-name.c+15 -40 replies
28/34sha1-name.c: remove the_repo from resolve_relative_path()sha1-name.c+4 -40 replies
29/34sha1-name.c: remove the_repo from get_oid_with_context_1()sha1-name.c+10 -10 replies
30/34sha1-name.c: add repo_get_oid()cache.h sha1-name.c+4 -30 replies
31/34submodule-config.c: use repo_get_oid for reading .gitmodulessubmodule-config.c t/t7814-grep-recurse-submodules.sh+8 -180 replies
32/34sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_namecache.h setup.c sha1-name.c+11 -60 replies
33/34sha1-name.c: remove the_repo from other get_oid_*cache.h sha1-name.c+32 -210 replies
34/34sha1-name.c: remove the_repo from get_oid_mb()cache.h sha1-name.c+13 -80 replies

Reviews trailers per patch

None of the 34 patches has a Reviewed-by or Acked-by.

PatchSZEDER GáborJohannes Schindelin
1/34
2/34
3/34
4/34
5/34
6/34
7/34
8/34
9/34
10/34
11/34Helped-by Helped-by
12/34
13/34
14/34
15/34
16/34
17/34
18/34
19/34
20/34
21/34
22/34
23/34
24/34
25/34
26/34
27/34
28/34
29/34
30/34
31/34
32/34
33/34
34/34

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 00/34] nd/sha1-name-c-wo-the-repository updates

v4 is all about updating commit.c and commit.cocci 11/33. I think I have incorporated all changes from v3 discussion. The changes are separated to a new patch 11/34 though, the old 11/33 is now 12/34.

Diff

commit-graph.c +7 -2
index 47e9be0a3a..155a270457 100644
@@ -343,6 +343,11 @@ static void fill_commit_graph_info(struct commit *item, struct commit_graph *g,
 	item->generation = get_be32(commit_data + g->hash_len + 8) >> 2;
 }
 
+static inline void set_commit_tree(struct commit *c, struct tree *t)
+{
+	c->maybe_tree = t;
+}
+
 static int fill_commit_in_graph(struct repository *r,
 				struct commit *item,
 				struct commit_graph *g, uint32_t pos)
@@ -356,7 +361,7 @@ static int fill_commit_in_graph(struct repository *r,
 	item->object.parsed = 1;
 	item->graph_pos = pos;
 
-	item->maybe_tree = NULL;
+	set_commit_tree(item, NULL);
 
 	date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;
 	date_low = get_be32(commit_data + g->hash_len + 12);
@@ -442,7 +447,7 @@ static struct tree *load_tree_for_commit(struct repository *r,
 					   GRAPH_DATA_WIDTH * (c->graph_pos);
 
 	hashcpy(oid.hash, commit_data);
-	c->maybe_tree = lookup_tree(r, &oid);
+	set_commit_tree(c, lookup_tree(r, &oid));
 
 	return c->maybe_tree;
 }
commit.c +7 -2
index f0a5506f04..a9e74647dc 100644
@@ -340,6 +340,11 @@ void free_commit_buffer(struct parsed_object_pool *pool, struct commit *commit)
 	}
 }
 
+static inline void set_commit_tree(struct commit *c, struct tree *t)
+{
+	c->maybe_tree = t;
+}
+
 struct tree *repo_get_commit_tree(struct repository *r,
 				  const struct commit *commit)
 {
@@ -359,7 +364,7 @@ struct object_id *get_commit_tree_oid(const struct commit *commit)
 
 void release_commit_memory(struct parsed_object_pool *pool, struct commit *c)
 {
-	c->maybe_tree = NULL;
+	set_commit_tree(c, NULL);
 	c->index = 0;
 	free_commit_buffer(pool, c);
 	free_commit_list(c->parents);
@@ -407,7 +412,7 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b
 	if (get_oid_hex(bufptr + 5, &parent) < 0)
 		return error("bad tree pointer in commit %s",
 			     oid_to_hex(&item->object.oid));
-	item->maybe_tree = lookup_tree(r, &parent);
+	set_commit_tree(item, lookup_tree(r, &parent));
 	bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
 	pptr = &item->parents;
 
contrib/coccinelle/commit.cocci +15 -10
index 57c8f71479..d03453341e 100644
@@ -10,20 +10,25 @@ expression c;
 - c->maybe_tree->object.oid.hash
 + get_commit_tree_oid(c)->hash
 
+@@
+identifier f !~ "^set_commit_tree$";
+expression c;
+expression s;
+@@
+  f(...) {<...
+- c->maybe_tree = s
++ set_commit_tree(c, s)
+  ...>}
+
 // These excluded functions must access c->maybe_tree direcly.
+// Note that if c->maybe_tree is written somewhere outside of these
+// functions, then the recommended transformation will be bogus with
+// repo_get_commit_tree() on the LHS.
 @@
-identifier f !~ "^(repo_get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit)$";
+identifier f !~ "^(repo_get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit|set_commit_tree)$";
 expression c;
 @@
   f(...) {<...
 - c->maybe_tree
-+ repo_get_commit_tree(the_repository, c)
++ repo_get_commit_tree(specify_the_right_repo_here, c)
   ...>}
-
-@@
-expression c;
-expression r;
-expression s;
-@@
-- repo_get_commit_tree(r, c) = s
-+ c->maybe_tree = s
merge-recursive.c +6 -1
index 6c40c61c47..ca4731a719 100644
@@ -163,6 +163,11 @@ static struct tree *shift_tree_object(struct repository *repo,
 	return lookup_tree(repo, &shifted);
 }
 
+static inline void set_commit_tree(struct commit *c, struct tree *t)
+{
+	c->maybe_tree = t;
+}
+
 static struct commit *make_virtual_commit(struct repository *repo,
 					  struct tree *tree,
 					  const char *comment)
@@ -170,7 +175,7 @@ static struct commit *make_virtual_commit(struct repository *repo,
 	struct commit *commit = alloc_commit_node(repo);
 
 	set_merge_remote_desc(commit, comment, (struct object *)commit);
-	commit->maybe_tree = tree;
+	set_commit_tree(commit, tree);
 	commit->object.parsed = 1;
 	return commit;
 }

Nguyễn Thái Ngọc Duy (32):
packfile.c: add repo_approximate_object_count()
refs.c: add refs_ref_exists()
refs.c: add refs_shorten_unambiguous_ref()
refs.c: remove the_repo from substitute_branch_name() refs.c: remove the_repo from expand_ref()
refs.c: add repo_dwim_ref()
refs.c: add repo_dwim_log()
refs.c: remove the_repo from read_ref_at()
commit.cocci: refactor code, avoid double rewrite commit.c: add repo_get_commit_tree()
sha1-name.c: remove the_repo from sort_ambiguous() sha1-name.c: remove the_repo from find_abbrev_len_packed() sha1-name.c: add repo_find_unique_abbrev_r() sha1-name.c: store and use repo in struct disambiguate_state sha1-name.c: add repo_for_each_abbrev()
sha1-name.c: remove the_repo from get_short_oid() sha1-name.c: remove the_repo from interpret_nth_prior_checkout() sha1-name.c: remove the_repo from interpret_branch_mark() sha1-name.c: add repo_interpret_branch_name() sha1-name.c: remove the_repo from get_oid_oneline() sha1-name.c: remove the_repo from get_describe_name() sha1-name.c: remove the_repo from get_oid_basic() sha1-name.c: remove the_repo from get_oid_1() sha1-name.c: remove the_repo from handle_one_ref() sha1-name.c: remove the_repo from diagnose_invalid_index_path() sha1-name.c: remove the_repo from resolve_relative_path() sha1-name.c: remove the_repo from get_oid_with_context_1() sha1-name.c: add repo_get_oid()
submodule-config.c: use repo_get_oid for reading .gitmodules sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_name sha1-name.c: remove the_repo from other get_oid_* sha1-name.c: remove the_repo from get_oid_mb()

SZEDER Gábor (2):
builtin rebase: use FREE_AND_NULL
builtin rebase: use oideq()

 builtin/rebase.c                   |   5 +-
 builtin/show-branch.c              |   6 +-
 cache.h                            |  50 ++--
 commit-graph.c                     |   9 +-
 commit.c                           |  14 +-
 commit.h                           |   5 +-
 contrib/coccinelle/commit.cocci    |  20 +-
 dir.c                              |   8 +
 dir.h                              |   4 +-
 merge-recursive.c                  |   7 +-
 packfile.c                         |  14 +-
 packfile.h                         |   3 +-
 refs.c                             |  71 ++++--
 refs.h                             |   9 +-
 setup.c                            |   7 +-
 sha1-name.c                        | 388 ++++++++++++++++++-----------
 submodule-config.c                 |  20 +-
 t/t7814-grep-recurse-submodules.sh |   6 +-
 upload-pack.c                      |   2 +-
 19 files changed, 407 insertions(+), 241 deletions(-)
Signature · 1 line
2.21.0.682.g30d2204636