Re: [PATCH 14/40] sha1_file: prepare for external odbs
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Jan 16, 2018, 07:23 UTC
- Message-ID
- <CAP8UFD0wOo56dtqzhY8CHw=0+miQ1fPaJZJiTtLatgf_gmrQUw@mail.gmail.com>
- In-Reply-To
- <33af3206-b15d-3b01-e121-796cd31eb743@jeffhostetler.com>
On Thu, Jan 4, 2018 at 7:00 PM, Jeff Hostetler <git@jeffhostetler.com> wrote:
> > > On 1/3/2018 11:33 AM, Christian Couder wrote:
Show 19 quoted lines
>> diff --git a/sha1_file.c b/sha1_file.c
>> index 261baf800f..785e8dda03 100644
>> --- a/sha1_file.c
>> +++ b/sha1_file.c
>> @@ -322,17 +322,22 @@ static void fill_sha1_path(struct strbuf *buf, const
>> unsigned char *sha1)
>> }
>> }
>> -const char *sha1_file_name(const unsigned char *sha1)
>> +const char *sha1_file_name_alt(const char *objdir, const unsigned char
>> *sha1)
>> {
>> static struct strbuf buf = STRBUF_INIT;
>
> While we are refactoring sha1_file_name() and adding
> sha1_file_name_alt(), could we also change the API and
> pass in the strbuf so we can get rid of the static buffer?
> Granted, it is a little off topic, but it will help out
> in the long run.Ok, but I prefer to do that in a separate patch series, so I just sent:
https://public-inbox.org/git/20180116071814.19884-1-chriscool@tuxfamily.org
Show 15 quoted lines
>> @@ -1551,7 +1562,7 @@ static inline int directory_size(const char
>> *filename)
>> * We want to avoid cross-directory filename renames, because those
>> * can have problems on various filesystems (FAT, NFS, Coda).
>> */
>> -static int create_tmpfile(struct strbuf *tmp, const char *filename)
>> +int create_object_tmpfile(struct strbuf *tmp, const char *filename)
>> {
>> int fd, dirlen = directory_size(filename);
>> @@ -1591,7 +1602,7 @@ static int write_loose_object(const unsigned char
>> *sha1, char *hdr, int hdrlen,
>> static struct strbuf tmp_file = STRBUF_INIT;
>
> Same thing here, since we are renaming the function anyway, could we
> add a strbuf arg and get rid of the static one?I will see how it goes with the above patch to remove the static buffer in sha1_file_name() before preparing a patch to remove the static buffer in create_tmpfile().
Thanks, Christian.