Re: [PATCH v2 07/14] match-trees: convert splice_tree to object_id
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jan 22, 2018, 11:56 UTC
- Message-ID
- <20180122115642.GB5980@ash>
- In-Reply-To
- <b5782b135fb68b645ffea711028bd6024176005a.1516617960.git.patryk.obara@gmail.com>
On Mon, Jan 22, 2018 at 12:04:30PM +0100, Patryk Obara wrote:
Show 22 quoted lines
> Convert the definition of static recursive splice_tree function to use > struct object_id and adjust single caller. > > Signed-off-by: Patryk Obara <patryk.obara@gmail.com> > --- > match-trees.c | 42 ++++++++++++++++++++---------------------- > 1 file changed, 20 insertions(+), 22 deletions(-) > > diff --git a/match-trees.c b/match-trees.c > index 396b7338df..0f899a7212 100644 > --- a/match-trees.c > +++ b/match-trees.c > @@ -161,19 +161,17 @@ static void match_trees(const struct object_id *hash1, > * A tree "hash1" has a subdirectory at "prefix". Come up with a > * tree object by replacing it with another tree "hash2". > */ > -static int splice_tree(const unsigned char *hash1, > - const char *prefix, > - const unsigned char *hash2, > - unsigned char *result) > +static int splice_tree(const struct object_id *hash1, const char *prefix, > + const struct object_id *hash2, struct object_id *result)
Maybe change the names to oid1 and oid2 too. I had a "what?" moment when I read hash1->hash below.
Show 10 quoted lines
> @@ -197,26 +195,26 @@ static int splice_tree(const unsigned char *hash1,
> if (strlen(name) == toplen &&
> !memcmp(name, prefix, toplen)) {
> if (!S_ISDIR(mode))
> - die("entry %s in tree %s is not a tree",
> - name, sha1_to_hex(hash1));
> - rewrite_here = (unsigned char *) oid->hash;
> + die("entry %s in tree %s is not a tree", name,
> + oid_to_hex(hash1));
> + rewrite_here = (struct object_id *)oid;You don't need the typecast here anymore, do you?
-- Duy