From: Johannes Sixt <j6t@kdbg.org>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org,
"João Carlos Mendes Luís" <jonny@jonny.eng.br>,
"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH 3/5] Add is_root_path()
Date: Fri, 12 Feb 2010 11:11:23 +0100 [thread overview]
Message-ID: <4B75294B.8080205@kdbg.org> (raw)
In-Reply-To: <1265899403-15904-4-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy schrieb:
> This function returns the length of the root part of a path, or zero if
> there is no root.
That is, the function primarily doesn't act as a predicate, and in fact
you never use it as such.
I just noticed that this function is identical to offset_1st_component()
in sha1_file.c.
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -210,6 +210,17 @@ static inline const char *skip_prefix(const char *str, const char *prefix)
> return strncmp(str, prefix, len) ? NULL : str + len;
> }
>
> +/* path must be canonical */
> +static inline int is_root_path(const char *path)
> +{
> + int len = 0;
> + if (has_dos_drive_prefix(path))
> + len += 2;
> + if (is_dir_sep(path[len]))
> + len++;
> + return len;
> +}
> +
> #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)
This is not a good location for this function because on Windows we get
warnings about implicitly defined function isalpha() (which is hidden in
the macro has_dos_drive_prefix).
I suggest to move offset_1st_component() to path.c, which would not be
inlined anymore.
-- Hannes
next prev parent reply other threads:[~2010-02-12 10:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-11 14:43 [PATCH 0/5 v2] Worktree/Gitdir at root directory Nguyễn Thái Ngọc Duy
2010-02-11 14:43 ` [PATCH 1/5] make_absolute_path(): Do not append redundant slash Nguyễn Thái Ngọc Duy
2010-02-11 14:43 ` [PATCH 2/5] init-db, rev-parse --git-dir: do " Nguyễn Thái Ngọc Duy
2010-02-11 14:43 ` [PATCH 3/5] Add is_root_path() Nguyễn Thái Ngọc Duy
2010-02-12 10:11 ` Johannes Sixt [this message]
2010-02-11 14:43 ` [PATCH 4/5] Support working directory located at root Nguyễn Thái Ngọc Duy
2010-02-11 14:43 ` [PATCH 5/5] Add test for using Git at root directory Nguyễn Thái Ngọc Duy
2010-02-12 10:21 ` [PATCH 0/5 v2] Worktree/Gitdir " Johannes Sixt
2010-02-12 13:05 ` João Carlos Mendes Luís
2010-02-12 16:00 ` Johannes Sixt
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=4B75294B.8080205@kdbg.org \
--to=j6t@kdbg.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jonny@jonny.eng.br \
--cc=pclouds@gmail.com \
/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.