From: Junio C Hamano <gitster@pobox.com>
To: Erick Mattos <erick.mattos@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 2/5] refs: split log_ref_write logic into log_ref_setup
Date: Tue, 25 May 2010 22:07:03 -0700 [thread overview]
Message-ID: <7v632bs13c.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 1274488119-6989-3-git-send-email-erick.mattos@gmail.com
Erick Mattos <erick.mattos@gmail.com> writes:
> -static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
> - const unsigned char *new_sha1, const char *msg)
> +int log_ref_setup(const char *ref_name, char **log_file)
> {
> - int logfd, written, oflags = O_APPEND | O_WRONLY;
> - unsigned maxlen, len;
> - int msglen;
> - char log_file[PATH_MAX];
> - char *logrec;
> - const char *committer;
> -
> - if (log_all_ref_updates < 0)
> - log_all_ref_updates = !is_bare_repository();
> -
> - git_snpath(log_file, sizeof(log_file), "logs/%s", ref_name);
> + int logfd, oflags = O_APPEND | O_WRONLY;
> + char logfile[PATH_MAX];
> + git_snpath(logfile, sizeof(logfile), "logs/%s", ref_name);
> + *log_file = logfile;
> ...
I have a slight suspicion that it would have made the patch smaller and
easier to read if you kept the name of the on-stack log_file[] as-is, and
named the retval parameter logfile_p or soemthing. Also you would need to
make this buffer "static char log_file[]", no? Otherwise you would be
returning a pointer to a dead buffer to the caller.
> +static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
> + const unsigned char *new_sha1, const char *msg)
> +{
> + ...
> + result = log_ref_setup(ref_name, &log_file);
> + if (result)
> + return result;
> +
> + logfd = open(log_file, oflags);
Yuck, the caller needs to call "setup" which discards the file descriptor
opened for writing and then open it again itself?
next prev parent reply other threads:[~2010-05-26 5:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-22 0:28 [PATCH 0/5] checkout --orphan improvements Erick Mattos
2010-05-22 0:28 ` [PATCH 1/5] Documentation: alter checkout --orphan description Erick Mattos
2010-05-22 0:28 ` [PATCH 2/5] refs: split log_ref_write logic into log_ref_setup Erick Mattos
2010-05-26 5:07 ` Junio C Hamano [this message]
2010-05-26 18:11 ` Erick Mattos
2010-06-02 18:14 ` Junio C Hamano
2010-06-02 23:16 ` Erick Mattos
2010-05-22 0:28 ` [PATCH 3/5] checkout --orphan: respect -l option always Erick Mattos
2010-05-26 5:07 ` Junio C Hamano
2010-05-26 14:52 ` Erick Mattos
2010-05-26 15:13 ` Erik Faye-Lund
2010-05-26 16:01 ` Erick Mattos
2010-06-03 16:28 ` Erick Mattos
2010-05-26 15:31 ` Michael J Gruber
2010-05-26 18:04 ` Erick Mattos
2010-05-27 7:50 ` Michael J Gruber
2010-05-22 0:28 ` [PATCH 4/5] t3200: test -l with core.logAllRefUpdates options Erick Mattos
2010-05-22 0:43 ` [PATCH 5/5] bash completion: add --orphan to 'git checkout' Erick Mattos
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=7v632bs13c.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=erick.mattos@gmail.com \
--cc=git@vger.kernel.org \
/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).