Re: [PATCH 07/35] tree: add repository argument to lookup_tree

2018-06-06 Thread Duy Nguyen
On Wed, May 30, 2018 at 2:47 AM, Stefan Beller  wrote:
> Add a repository argument to allow the callers of lookup_tree
> to be more specific about which repository to act on. This is a small
> mechanical change; it doesn't change the implementation to handle
> repositories other than the_repository yet.
>
> As with the previous commits, use a macro to catch callers passing a
> repository other than the_repository at compile time.
>
> Add the cocci patch that converted the callers.

I don't see the cocci patch in diffstat. I don't need to see it, but
this sentence probably should be dropped.

>
> Signed-off-by: Jonathan Nieder 
> Signed-off-by: Stefan Beller 
> ---
>  builtin/am.c| 6 --
>  builtin/diff-tree.c | 2 +-
>  builtin/diff.c  | 3 ++-
>  builtin/reflog.c| 2 +-
>  cache-tree.c| 3 ++-
>  commit-graph.c  | 2 +-
>  commit.c| 2 +-
>  fsck.c  | 2 +-
>  http-push.c | 3 ++-
>  list-objects.c  | 2 +-
>  merge-recursive.c   | 6 +++---
>  object.c| 2 +-
>  reachable.c | 2 +-
>  revision.c  | 4 ++--
>  sequencer.c | 2 +-
>  tag.c   | 2 +-
>  tree.c  | 4 ++--
>  tree.h  | 3 ++-
>  walker.c| 3 ++-
>  19 files changed, 31 insertions(+), 24 deletions(-)
-- 
Duy


[PATCH 07/35] tree: add repository argument to lookup_tree

2018-05-29 Thread Stefan Beller
Add a repository argument to allow the callers of lookup_tree
to be more specific about which repository to act on. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Add the cocci patch that converted the callers.

Signed-off-by: Jonathan Nieder 
Signed-off-by: Stefan Beller 
---
 builtin/am.c| 6 --
 builtin/diff-tree.c | 2 +-
 builtin/diff.c  | 3 ++-
 builtin/reflog.c| 2 +-
 cache-tree.c| 3 ++-
 commit-graph.c  | 2 +-
 commit.c| 2 +-
 fsck.c  | 2 +-
 http-push.c | 3 ++-
 list-objects.c  | 2 +-
 merge-recursive.c   | 6 +++---
 object.c| 2 +-
 reachable.c | 2 +-
 revision.c  | 4 ++--
 sequencer.c | 2 +-
 tag.c   | 2 +-
 tree.c  | 4 ++--
 tree.h  | 3 ++-
 walker.c| 3 ++-
 19 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index d834f9e62b6..f4b510bcc5f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -32,6 +32,7 @@
 #include "apply.h"
 #include "string-list.h"
 #include "packfile.h"
+#include "repository.h"
 
 /**
  * Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -1400,9 +1401,10 @@ static void write_index_patch(const struct am_state 
*state)
FILE *fp;
 
if (!get_oid_tree("HEAD", ))
-   tree = lookup_tree();
+   tree = lookup_tree(the_repository, );
else
-   tree = lookup_tree(the_hash_algo->empty_tree);
+   tree = lookup_tree(the_repository,
+  the_repository->hash_algo->empty_tree);
 
fp = xfopen(am_path(state, "patch"), "w");
init_revisions(_info, NULL);
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index d8db8f682f0..29901515a13 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -46,7 +46,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
struct tree *tree2;
if (!isspace(*p++) || parse_oid_hex(p, , ) || *p)
return error("Need exactly two trees, separated by a space");
-   tree2 = lookup_tree();
+   tree2 = lookup_tree(the_repository, );
if (!tree2 || parse_tree(tree2))
return -1;
printf("%s %s\n", oid_to_hex(>object.oid),
diff --git a/builtin/diff.c b/builtin/diff.c
index ed6092ef1a3..0b7d0d612dd 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -379,7 +379,8 @@ int cmd_diff(int argc, const char **argv, const char 
*prefix)
add_head_to_pending();
if (!rev.pending.nr) {
struct tree *tree;
-   tree = 
lookup_tree(the_hash_algo->empty_tree);
+   tree = lookup_tree(the_repository,
+  
the_repository->hash_algo->empty_tree);
add_pending_object(, >object, 
"HEAD");
}
break;
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 3a751fbaa60..93dabd7ce31 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -66,7 +66,7 @@ static int tree_is_complete(const struct object_id *oid)
int complete;
struct tree *tree;
 
-   tree = lookup_tree(oid);
+   tree = lookup_tree(the_repository, oid);
if (!tree)
return 0;
if (tree->object.flags & SEEN)
diff --git a/cache-tree.c b/cache-tree.c
index 1c338c41f3a..69b214613dd 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -671,7 +671,8 @@ static void prime_cache_tree_rec(struct cache_tree *it, 
struct tree *tree)
cnt++;
else {
struct cache_tree_sub *sub;
-   struct tree *subtree = lookup_tree(entry.oid);
+   struct tree *subtree = lookup_tree(the_repository,
+  entry.oid);
if (!subtree->object.parsed)
parse_tree(subtree);
sub = cache_tree_sub(it, entry.path);
diff --git a/commit-graph.c b/commit-graph.c
index 71125d7cbb6..88a4b0d2a47 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -261,7 +261,7 @@ static int fill_commit_in_graph(struct commit *item, struct 
commit_graph *g, uin
item->graph_pos = pos;
 
hashcpy(oid.hash, commit_data);
-   item->tree = lookup_tree();
+   item->tree = lookup_tree(the_repository, );
 
date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;
date_low = get_be32(commit_data + g->hash_len + 12);
diff --git a/commit.c b/commit.c
index