From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Karl Chen <quarl@cs.berkeley.edu>, git@vger.kernel.org
Subject: Re: [PATCH v3] Expand ~ and ~user in core.excludesfile, commit.template
Date: Thu, 28 Aug 2008 21:08:37 -0700 [thread overview]
Message-ID: <7vod3ca2ey.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20080829032630.GA7024@coredump.intra.peff.net
Jeff King <peff@peff.net> writes:
> On Thu, Aug 28, 2008 at 02:09:38AM -0700, Karl Chen wrote:
>
>> builtin-commit.c | 2 +-
>> cache.h | 2 +
>> config.c | 13 +++++++-
>> path.c | 88 +++++++++++++++++++++++++++++++++--------------------
>> 4 files changed, 69 insertions(+), 36 deletions(-)
>
> Documentation?
>
>> if (!strcmp(k, "commit.template"))
>> - return git_config_string(&template_file, k, v);
>> + return git_config_userdir(&template_file, k, v);
>
> I like this.
Likewise, except for the name. It is more like "pathname"; "userdir" is
stressing only one aspect of the magic we would do to a value that is a
pathname compared to a value that is a string without any magic.
>> +int git_config_userdir(const char **dest, const char *var, const char *value) {
>> + if (!value)
>> + return config_error_nonbool(var);
>> + *dest = expand_user_path(NULL, value, 0);
>> + if (!*dest || !**dest) die("Failed to expand user dir in: '%s'", value);
>> + return 0;
>> +}
>
> I am not sure about !**dest here. This precludes somebody from using "".
> While it might not matter here, if there are other users of
> git_config_userdir(), they might want to allow a blank entry.
True again.
>> + if (begin_username == end_username) {
>> + return getpwuid(getuid());
>> + } else {
>
> Style: omit braces on one-liner conditionals:
... except in cases like this where "else" side is a multi-statement
block, in which case the above is fine. But as you pointed out, the early
return from here makes the else block unnecessary so you do not need the
braces around "if" side.
>> + char *username = alloca(username_len + 1);
>
> I don't think we use alloca() anywhere else. I don't know if there are
> portability issues.
Avoidance of alloca() and c99 dynamic array on stack is deliberate in the
current codebase. Portable use of alloca() is quite hard to get right.
>> +static inline const char *strchr_or_end(const char *str, char c)
>> +{
>> + while (*str && *str != c) ++str;
>> + return str;
>> +}
>
> This really seems like premature optimization to me.
So is overuse of inline, it seems.
next prev parent reply other threads:[~2008-08-29 4:12 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-22 4:14 [PATCH] Support "core.excludesfile = ~/.gitignore" Karl Chen
2008-08-22 16:58 ` Eric Raible
2008-08-22 17:56 ` Bert Wesarg
2008-08-22 21:10 ` Junio C Hamano
2008-08-24 8:40 ` Karl Chen
2008-08-24 18:11 ` Junio C Hamano
2008-08-24 22:08 ` Jeff King
2008-08-24 22:59 ` Junio C Hamano
2008-08-24 23:13 ` Jeff King
2008-08-24 23:40 ` Junio C Hamano
2008-08-24 23:51 ` limiting relationship of git dir and worktree (was Re: [PATCH] Support "core.excludesfile = ~/.gitignore") Jeff King
2008-08-25 0:30 ` Dropping core.worktree and GIT_WORK_TREE support (was Re: limiting relationship of git dir and worktree) Junio C Hamano
2008-08-25 2:00 ` Miklos Vajna
2008-08-25 3:05 ` Dropping core.worktree and GIT_WORK_TREE support Junio C Hamano
2008-08-25 12:52 ` Miklos Vajna
2008-08-25 13:52 ` Nguyen Thai Ngoc Duy
2008-08-25 14:43 ` [PATCH] git diff/diff-index/diff-files: call setup_work_tree() Miklos Vajna
2008-08-25 14:46 ` Nguyen Thai Ngoc Duy
2008-08-25 14:50 ` Miklos Vajna
2008-08-25 15:11 ` Miklos Vajna
2008-08-25 15:26 ` Nguyen Thai Ngoc Duy
2008-08-26 23:58 ` Junio C Hamano
2008-08-28 13:02 ` [PATCH] diff*: fix worktree setup Nguyễn Thái Ngọc Duy
2008-08-25 21:21 ` Dropping core.worktree and GIT_WORK_TREE support Junio C Hamano
2008-08-25 21:37 ` Miklos Vajna
2008-08-26 7:35 ` Dropping core.worktree and GIT_WORK_TREE support (was Re: limiting relationship of git dir and worktree) Michael J Gruber
2008-08-27 0:49 ` Jeff King
2008-08-25 19:07 ` [PATCH v2] Support "core.excludesfile = ~/.gitignore" Karl Chen
2008-08-26 6:42 ` Johannes Sixt
2008-08-27 0:25 ` Jeff King
2008-08-27 3:12 ` Karl Chen
2008-08-27 5:01 ` Junio C Hamano
2008-08-28 9:09 ` [PATCH v3] Expand ~ and ~user in core.excludesfile, commit.template Karl Chen
2008-08-29 3:26 ` Jeff King
2008-08-29 4:08 ` Junio C Hamano [this message]
2008-08-29 9:29 ` [PATCH v4] " Karl Chen
2008-08-29 16:08 ` Junio C Hamano
2008-08-29 19:01 ` Karl Chen
2008-08-29 19:28 ` Junio C Hamano
2008-08-29 22:34 ` Karl Chen
2008-08-30 5:31 ` Junio C Hamano
2008-08-30 6:02 ` Jeff King
2008-08-29 7:00 ` [PATCH v3] " Johannes Sixt
2008-08-27 3:18 ` [PATCH v2] Support "core.excludesfile = ~/.gitignore" Karl Chen
2008-08-27 4:50 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2009-11-17 17:24 [PATCH v2] Expand ~ and ~user in core.excludesfile, commit.template Matthieu Moy
2009-11-18 7:29 ` [PATCH v3] " Matthieu Moy
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=7vod3ca2ey.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=quarl@cs.berkeley.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.