List for cgit developers and users
 help / color / mirror / Atom feed
* section-from-path > 1
@ 2013-06-26 20:36 mricon
  2013-06-28  9:06 ` [PATCH] Fix " cgit
  2013-08-12 18:41 ` Jason
  0 siblings, 2 replies; 5+ messages in thread
From: mricon @ 2013-06-26 20:36 UTC (permalink / raw)


Hi, all:

It appears that section-from-path > 1 has the same affect as 1.
E.g. setting it to 2 or 3 makes no difference.


Cheers,
-- 
Konstantin Ryabitsev
Senior Systems Administrator
Linux Foundation Collab Projects
Montr?al, Qu?bec

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 730 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20130626/973a2bd3/attachment.asc>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Fix section-from-path > 1
  2013-06-26 20:36 section-from-path > 1 mricon
@ 2013-06-28  9:06 ` cgit
  2013-06-28 13:50   ` mricon
  2013-08-12 18:41 ` Jason
  1 sibling, 1 reply; 5+ messages in thread
From: cgit @ 2013-06-28  9:06 UTC (permalink / raw)


When having found the first path separator occurrence at position i, we
invoked strchr() on the same position i in subsequent iterations
resulting in the same path separator being returned by strchr() over and
over again. Increase the position by one to skip the occurrence that has
just been found and advance to the next separator.

Reported-by: Konstantin Ryabitsev <mricon at kernel.org>
Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
Completely untested but I think something like this might fix it.

 scan-tree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scan-tree.c b/scan-tree.c
index 2684b44..7cd8f08 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -148,14 +148,14 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
 	}
 
 	if (ctx.cfg.section_from_path) {
-		n  = ctx.cfg.section_from_path;
+		n = ctx.cfg.section_from_path;
 		if (n > 0) {
-			slash = rel.buf;
-			while (slash && n && (slash = strchr(slash, '/')))
+			slash = rel.buf - 1;
+			while (slash && n && (slash = strchr(slash + 1, '/')))
 				n--;
 		} else {
 			slash = rel.buf + rel.len;
-			while (slash && n && (slash = xstrrchr(rel.buf, slash, '/')))
+			while (slash && n && (slash = xstrrchr(rel.buf, slash - 1, '/')))
 				n++;
 		}
 		if (slash && !n) {
-- 
1.8.3.1.764.g8b6e9d8



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Fix section-from-path > 1
  2013-06-28  9:06 ` [PATCH] Fix " cgit
@ 2013-06-28 13:50   ` mricon
  0 siblings, 0 replies; 5+ messages in thread
From: mricon @ 2013-06-28 13:50 UTC (permalink / raw)


On 28/06/13 05:06 AM, Lukas Fleischer wrote:
> When having found the first path separator occurrence at position i, we
> invoked strchr() on the same position i in subsequent iterations
> resulting in the same path separator being returned by strchr() over and
> over again. Increase the position by one to skip the occurrence that has
> just been found and advance to the next separator.
> 
> Reported-by: Konstantin Ryabitsev <mricon at kernel.org>
> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
> ---
> Completely untested but I think something like this might fix it.

It appears to work correctly in my tests. Thanks!

Best,
-- 
Konstantin Ryabitsev
Senior Systems Administrator
Linux Foundation Collab Projects
Montr?al, Qu?bec

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 730 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20130628/8b73e5d8/attachment.asc>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* section-from-path > 1
  2013-06-26 20:36 section-from-path > 1 mricon
  2013-06-28  9:06 ` [PATCH] Fix " cgit
@ 2013-08-12 18:41 ` Jason
  2013-08-12 18:42   ` Jason
  1 sibling, 1 reply; 5+ messages in thread
From: Jason @ 2013-08-12 18:41 UTC (permalink / raw)


The relevant code is here:

        if (ctx.cfg.section_from_path) {
                n  = ctx.cfg.section_from_path;
                if (n > 0) {
                        slash = rel.buf;
                        while (slash && n && (slash = strchr(slash, '/')))
                                n--;
                } else {
                        slash = rel.buf + rel.len;
                        while (slash && n && (slash = xstrrchr(rel.buf,
slash, '/')))
                                n++;
                }
                if (slash && !n) {
                        *slash = '\0';
                        repo->section = xstrdup(rel.buf);
                        *slash = '/';
                        if (!prefixcmp(repo->name, repo->section)) {
                                repo->name += strlen(repo->section);
                                if (*repo->name == '/')
                                        repo->name++;
                        }
                }
        }

I haven't looked at this closely, but do you see a bug that resembles the
issue you're seeing? Currently on vacation and I can look in more depth
when I return.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20130812/a687edfb/attachment.html>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* section-from-path > 1
  2013-08-12 18:41 ` Jason
@ 2013-08-12 18:42   ` Jason
  0 siblings, 0 replies; 5+ messages in thread
From: Jason @ 2013-08-12 18:42 UTC (permalink / raw)


Caught up to mailing list posts. Thanks for the fix Lukas. Disregard prior
message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20130812/aa54401a/attachment.html>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-12 18:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-26 20:36 section-from-path > 1 mricon
2013-06-28  9:06 ` [PATCH] Fix " cgit
2013-06-28 13:50   ` mricon
2013-08-12 18:41 ` Jason
2013-08-12 18:42   ` Jason

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).