Re: [PATCH 5/5] commit: rewrite read_graft_line
- From
Stefan Beller <sbeller@google.com>
- Date
- Aug 15, 2017, 17:11 UTC
- Message-ID
- <CAGZ79kbsKLOiLvr8NxRzBDkU44SPtVozUoV7fYUyt3vC=QxWyQ@mail.gmail.com>
- In-Reply-To
- <ee8edaf08864d5983ff1a5150077d29a4ee17796.1502796628.git.patryk.obara@gmail.com>
On Tue, Aug 15, 2017 at 4:49 AM, Patryk Obara <patryk.obara@gmail.com> wrote:
Show 30 quoted lines
> The previous implementation of read_graft_line used calculations based
> on GIT_SHA1_RAWSZ and GIT_SHA1_HEXSZ to determine the number of commit
> ids in a single graft line. New implementation does not depend on these
> constants, so it adapts to any object_id buffer size.
>
> To make this possible, FLEX_ARRAY of object_id in struct was replaced
> by an oid_array.
>
> Code allocating graft now needs to use memset to zero the memory before
> use to start with oid_array in a consistent state.
>
> Updates free_graft function implemented in the previous patch to
> properly cleanup an oid_array storing parents.
>
> Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
> ---
> commit.c | 39 +++++++++++++++++++++------------------
> commit.h | 2 +-
> shallow.c | 1 +
> 3 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/commit.c b/commit.c
> index 6a145f1..75dd45d 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -111,6 +111,7 @@ static int commit_graft_pos(const unsigned char *sha1)
>
> void free_commit_graft(struct commit_graft *graft)
> {
> + oid_array_clear(&graft->parents);Oh patch 4/5 could just say it's in preparation of this patch. Nevermind the comment on patch 4.