[RFC] Make dot-counting ignore ".1" at the end
- From
Linus Torvalds <torvalds@osdl.org>
- Date
- Mar 23, 2006, 01:50 UTC
- Message-ID
- <Pine.LNX.4.64.0603221746300.26286@g5.osdl.org>
- In-Reply-To
- <Pine.LNX.4.64.0603221723230.9196@g5.osdl.org>
I'm not 100% sure this is appropriate, but in general, I think "<rev>" and "<rev>.1" should be considered the same thing, no? Which implies that "1.1" and "1.1.1.1" are all the same thing, and collapse to just "1", ie a zero dot-count. They are all the same version, after all, no?
This gets rid of the insane (?) special case of "1.1.1.1" that exists there now, since it's now no longer a special case.
I also wonder if trailing ".1" revisions should be ignored when comparing two revisions.
Signed-off-by: Linus Torvalds <torvalds@osdl.org> ---
Yeah, I don't know RCS file logic. This may be completely broken.
diff --git a/cvsps.c b/cvsps.c index 2695a0f..2ad1595 100644 --- a/cvsps.c +++ b/cvsps.c @@ -2357,9 +2357,16 @@ static int revision_affects_branch(CvsFi static int count_dots(const char * p) { int dots = 0; + int len = strlen(p); - while (*p) - if (*p++ == '.') + while (len > 2) { + if (memcmp(p+len-2, ".1", 2)) + break; + len -= 2; + } + + while (len) + if (p[--len] == '.') dots++; return dots; @@ -2613,7 +2620,7 @@ static void determine_branch_ancestor(Pa /* HACK: we sometimes pretend to derive from the import branch. * just don't do that. this is the easiest way to prevent... */ - d2 = (strcmp(rev->rev, "1.1.1.1") == 0) ? 0 : count_dots(rev->rev); + d2 = count_dots(rev->rev); if (d2 > d1) head_ps->ancestor_branch = rev->branch;