* [PATCH 1/1] ui-plain: show directory listing for top of repo in plain view
@ 2016-02-16 7:57 jea-signup-cgit
2016-02-16 9:33 ` john
0 siblings, 1 reply; 2+ messages in thread
From: jea-signup-cgit @ 2016-02-16 7:57 UTC (permalink / raw)
unsigned to signed comparison was always false when at the root of the
tree
---
ui-plain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ui-plain.c b/ui-plain.c
index ff85113..b4e3bef 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -143,7 +143,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
walk_tree_ctx->match = 2;
return READ_TREE_RECURSIVE;
}
- } else if (base->len > walk_tree_ctx->match_baselen) {
+ } else if ((int)base->len > walk_tree_ctx->match_baselen) {
print_dir_entry(sha1, base->buf, base->len, pathname, mode);
walk_tree_ctx->match = 2;
} else if (S_ISDIR(mode)) {
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] ui-plain: show directory listing for top of repo in plain view
2016-02-16 7:57 [PATCH 1/1] ui-plain: show directory listing for top of repo in plain view jea-signup-cgit
@ 2016-02-16 9:33 ` john
0 siblings, 0 replies; 2+ messages in thread
From: john @ 2016-02-16 9:33 UTC (permalink / raw)
On Mon, Feb 15, 2016 at 11:57:39PM -0800, Joe Anakata wrote:
> unsigned to signed comparison was always false when at the root of the
> tree
Missing sign-off (see [1] for what this means).
It would also be helpful if the commit message explains that in the
"root of the tree" case match_baselen is -1.
More below...
[1] http://elinux.org/Developer_Certificate_Of_Origin
> ---
> ui-plain.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ui-plain.c b/ui-plain.c
> index ff85113..b4e3bef 100644
> --- a/ui-plain.c
> +++ b/ui-plain.c
> @@ -143,7 +143,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
> walk_tree_ctx->match = 2;
> return READ_TREE_RECURSIVE;
> }
> - } else if (base->len > walk_tree_ctx->match_baselen) {
> + } else if ((int)base->len > walk_tree_ctx->match_baselen) {
nit: we prefer a space after casts (see Git's
Documentation/CodingGuidelines which we follow).
I also think we should be casting "len" to ssize_t here (for those who
haven't looked in the code, "len" is a size_t and "match_baselen" is an
int).
This changed in commit 7358f63 (git: update for v2.3.0, 2015-02-07) when
walk_tree() changed from taking a "const char *" with an "int" length to
taking a "struct strbuf". So when "match_baselen" was originally added
it matched the type of the length parameter to which it is compared
here.
> print_dir_entry(sha1, base->buf, base->len, pathname, mode);
> walk_tree_ctx->match = 2;
> } else if (S_ISDIR(mode)) {
> --
> 1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-16 9:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-16 7:57 [PATCH 1/1] ui-plain: show directory listing for top of repo in plain view jea-signup-cgit
2016-02-16 9:33 ` john
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).