git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH 06/14] tempfile: add several functions for creating temporary files
Date: Mon, 10 Aug 2015 05:08:46 +0200	[thread overview]
Message-ID: <55C815BE.4070309@alum.mit.edu> (raw)
In-Reply-To: <xmqqmw07laio.fsf@gitster.dls.corp.google.com>

On 06/10/2015 07:48 PM, Junio C Hamano wrote:
> Michael Haggerty <mhagger@alum.mit.edu> writes:
> 
>> Add several functions for creating temporary files with
>> automatically-generated names, analogous to mkstemps(), but also
>> arranging for the files to be deleted on program exit.
>>
>> The functions are named according to a pattern depending how they
>> operate. They will be used to replace many places in the code where
>> temporary files are created and cleaned up ad-hoc.
>>
>> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
>> ---
>>  tempfile.c | 55 ++++++++++++++++++++++++++++++++++-
>>  tempfile.h | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 150 insertions(+), 1 deletion(-)
>>
>> diff --git a/tempfile.c b/tempfile.c
>> index f76bc07..890075f 100644
>> --- a/tempfile.c
>> +++ b/tempfile.c
>> @@ -48,7 +48,7 @@ static void register_tempfile_object(struct tempfile *tempfile, const char *path
>>  		tempfile->fp = NULL;
>>  		tempfile->active = 0;
>>  		tempfile->owner = 0;
>> -		strbuf_init(&tempfile->filename, strlen(path));
>> +		strbuf_init(&tempfile->filename, 0);
>>  		tempfile->next = tempfile_list;
>>  		tempfile_list = tempfile;
>>  		tempfile->on_list = 1;
> 
> This probably could have been part of the previous step.  Regardless
> of where in the patch series this change is done, I think it makes
> sense, as this function does not even know how long the final filename
> would be, and strlen(path) is almost always wrong as path is likely to
> be relative.
> 
> I notice this change makes "path" almost unused in this function,
> and the only remaining use is for assert(!tempfile->filename.len).
> Perhaps it is not worth passing the "path" parameter?

These are both good points. I will implement them in the upcoming v2.

Thanks,
Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu

  reply	other threads:[~2015-08-10  3:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-08  9:07 [PATCH 00/14] Introduce a tempfile module Michael Haggerty
2015-06-08  9:07 ` [PATCH 01/14] Move lockfile API documentation to lockfile.h Michael Haggerty
2015-06-08  9:07 ` [PATCH 02/14] tempfile: a new module for handling temporary files Michael Haggerty
2015-06-10 17:36   ` Junio C Hamano
2015-06-10 20:56     ` Michael Haggerty
2015-06-10 21:35       ` Junio C Hamano
2015-06-08  9:07 ` [PATCH 03/14] lockfile: remove some redundant functions Michael Haggerty
2015-06-10 17:40   ` Junio C Hamano
2015-06-10 18:27     ` Johannes Sixt
2015-06-08  9:07 ` [PATCH 04/14] commit_lock_file(): use get_locked_file_path() Michael Haggerty
2015-06-08  9:07 ` [PATCH 05/14] register_tempfile_object(): new function, extracted from create_tempfile() Michael Haggerty
2015-06-08  9:07 ` [PATCH 06/14] tempfile: add several functions for creating temporary files Michael Haggerty
2015-06-10 17:48   ` Junio C Hamano
2015-08-10  3:08     ` Michael Haggerty [this message]
2015-06-08  9:07 ` [PATCH 07/14] register_tempfile(): new function to handle an existing temporary file Michael Haggerty
2015-06-10 17:55   ` Junio C Hamano
2015-08-10  3:40     ` Michael Haggerty
2015-06-08  9:07 ` [PATCH 08/14] write_shared_index(): use tempfile module Michael Haggerty
2015-06-10 17:56   ` Junio C Hamano
2015-06-08  9:07 ` [PATCH 09/14] setup_temporary_shallow(): " Michael Haggerty
2015-06-08  9:07 ` [PATCH 10/14] diff: " Michael Haggerty
2015-06-08  9:07 ` [PATCH 11/14] lock_repo_for_gc(): compute the path to "gc.pid" only once Michael Haggerty
2015-06-08  9:07 ` [PATCH 12/14] gc: use tempfile module to handle gc.pid file Michael Haggerty
2015-06-08  9:07 ` [PATCH 13/14] credential-cache--daemon: delete socket from main() Michael Haggerty
2015-06-08  9:07 ` [PATCH 14/14] credential-cache--daemon: use tempfile module Michael Haggerty
2015-06-10 18:34 ` [PATCH 00/14] Introduce a " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55C815BE.4070309@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).