git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix revision walk for commits with the same dates
@ 2013-03-07 18:03 Kacper Kornet
  2013-03-22 18:38 ` [PATCH v2] " Kacper Kornet
  0 siblings, 1 reply; 5+ messages in thread
From: Kacper Kornet @ 2013-03-07 18:03 UTC (permalink / raw)
  To: git

git rev-list A^! --not B provides wrong answer if all commits in the
range A..B had the same commit times and there are more then 8 of them.
This commits fixes the logic in still_interesting function to prevent
this error.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
---
 revision.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/revision.c b/revision.c
index ef60205..cf620c6 100644
--- a/revision.c
+++ b/revision.c
@@ -709,7 +709,7 @@ static int still_interesting(struct commit_list *src, unsigned long date, int sl
 	 * Does the destination list contain entries with a date
 	 * before the source list? Definitely _not_ done.
 	 */
-	if (date < src->item->date)
+	if (date <= src->item->date)
 		return SLOP;
 
 	/*
-- 
1.8.2.rc2

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

* [PATCH v2] Fix revision walk for commits with the same dates
  2013-03-07 18:03 [PATCH] Fix revision walk for commits with the same dates Kacper Kornet
@ 2013-03-22 18:38 ` Kacper Kornet
  2013-03-22 20:45   ` Junio C Hamano
  2013-03-24  2:18   ` Eric Sunshine
  0 siblings, 2 replies; 5+ messages in thread
From: Kacper Kornet @ 2013-03-22 18:38 UTC (permalink / raw)
  To: git

Logic in still_interesting function allows to stop the commits
traversing if the oldest processed commit is not older then the
youngest commit on the list to process and the list contains only
commits marked as not interesting ones. It can be premature when dealing
with a set of coequal commits. For example git rev-list A^! --not B
provides wrong answer if all commits in the range A..B had the same
commit time and there are more then 7 of them.

To fix this problem the relevant part of the logic in still_interesting
is changed to: the walk can be stopped if the oldest processed commit is
younger then the youngest commit on the list to processed.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
---

I don't know whether the first version was overlooked or deemed as not
worthy. So just in case I resend it. Changes since the first version:

1. The test has been added
2. The commit log has been rewritten


 revision.c                 |  2 +-
 t/t6009-rev-list-parent.sh | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/revision.c b/revision.c
index ef60205..cf620c6 100644
--- a/revision.c
+++ b/revision.c
@@ -709,7 +709,7 @@ static int still_interesting(struct commit_list *src, unsigned long date, int sl
 	 * Does the destination list contain entries with a date
 	 * before the source list? Definitely _not_ done.
 	 */
-	if (date < src->item->date)
+	if (date <= src->item->date)
 		return SLOP;
 
 	/*
diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
index 3050740..66cda17 100755
--- a/t/t6009-rev-list-parent.sh
+++ b/t/t6009-rev-list-parent.sh
@@ -133,4 +133,17 @@ test_expect_success 'dodecapus' '
 	check_revlist "--min-parents=13" &&
 	check_revlist "--min-parents=4 --max-parents=11" tetrapus
 '
+
+test_expect_success 'ancestors with the same commit time' '
+
+	test_tick_keep=$test_tick &&
+	for i in 1 2 3 4 5 6 7 8; do
+		test_tick=$test_tick_keep
+		test_commit t$i
+	done &&
+	git rev-list t1^! --not t$i >result &&
+	>expect &&
+	test_cmp expect result
+'
+
 test_done
-- 
1.8.2

-- 
  Kacper Kornet

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

* Re: [PATCH v2] Fix revision walk for commits with the same dates
  2013-03-22 18:38 ` [PATCH v2] " Kacper Kornet
@ 2013-03-22 20:45   ` Junio C Hamano
  2013-03-22 21:07     ` Kacper Kornet
  2013-03-24  2:18   ` Eric Sunshine
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2013-03-22 20:45 UTC (permalink / raw)
  To: Kacper Kornet; +Cc: git

Kacper Kornet <draenog@pld-linux.org> writes:

> Logic in still_interesting function allows to stop the commits
> traversing if the oldest processed commit is not older then the
> youngest commit on the list to process and the list contains only
> commits marked as not interesting ones. It can be premature when dealing
> with a set of coequal commits. For example git rev-list A^! --not B
> provides wrong answer if all commits in the range A..B had the same
> commit time and there are more then 7 of them.
>
> To fix this problem the relevant part of the logic in still_interesting
> is changed to: the walk can be stopped if the oldest processed commit is
> younger then the youngest commit on the list to processed.

Is the made-up test case to freeze the clock even interesting?  The
slop logic is merely a heuristic to compensate for effects caused by
skewed or non-monototic clocks, so in a different repository you may
even need to fuzz the timestamp comparison further

	if (date - 10 < src->item->date)

or something silly like that.



> Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
> ---
>
> I don't know whether the first version was overlooked or deemed as not
> worthy. So just in case I resend it. Changes since the first version:
>
> 1. The test has been added
> 2. The commit log has been rewritten
>
>
>  revision.c                 |  2 +-
>  t/t6009-rev-list-parent.sh | 13 +++++++++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/revision.c b/revision.c
> index ef60205..cf620c6 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -709,7 +709,7 @@ static int still_interesting(struct commit_list *src, unsigned long date, int sl
>  	 * Does the destination list contain entries with a date
>  	 * before the source list? Definitely _not_ done.
>  	 */
> -	if (date < src->item->date)
> +	if (date <= src->item->date)
>  		return SLOP;
>  
>  	/*
> diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
> index 3050740..66cda17 100755
> --- a/t/t6009-rev-list-parent.sh
> +++ b/t/t6009-rev-list-parent.sh
> @@ -133,4 +133,17 @@ test_expect_success 'dodecapus' '
>  	check_revlist "--min-parents=13" &&
>  	check_revlist "--min-parents=4 --max-parents=11" tetrapus
>  '
> +
> +test_expect_success 'ancestors with the same commit time' '
> +
> +	test_tick_keep=$test_tick &&
> +	for i in 1 2 3 4 5 6 7 8; do
> +		test_tick=$test_tick_keep
> +		test_commit t$i
> +	done &&
> +	git rev-list t1^! --not t$i >result &&
> +	>expect &&
> +	test_cmp expect result
> +'
> +
>  test_done
> -- 
> 1.8.2

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

* Re: [PATCH v2] Fix revision walk for commits with the same dates
  2013-03-22 20:45   ` Junio C Hamano
@ 2013-03-22 21:07     ` Kacper Kornet
  0 siblings, 0 replies; 5+ messages in thread
From: Kacper Kornet @ 2013-03-22 21:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Fri, Mar 22, 2013 at 01:45:47PM -0700, Junio C Hamano wrote:
> Kacper Kornet <draenog@pld-linux.org> writes:

> > Logic in still_interesting function allows to stop the commits
> > traversing if the oldest processed commit is not older then the
> > youngest commit on the list to process and the list contains only
> > commits marked as not interesting ones. It can be premature when dealing
> > with a set of coequal commits. For example git rev-list A^! --not B
> > provides wrong answer if all commits in the range A..B had the same
> > commit time and there are more then 7 of them.

> > To fix this problem the relevant part of the logic in still_interesting
> > is changed to: the walk can be stopped if the oldest processed commit is
> > younger then the youngest commit on the list to processed.

> Is the made-up test case to freeze the clock even interesting?  The
> slop logic is merely a heuristic to compensate for effects caused by
> skewed or non-monototic clocks, so in a different repository you may
> even need to fuzz the timestamp comparison further

> 	if (date - 10 < src->item->date)

> or something silly like that.

I don't think it is a made-up test case. For example it is easy to get a
number of coequal commits by using git rebase -i. So I argue that git
should treat correctly ranges of such commits.

-- 
  Kacper Kornet

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

* Re: [PATCH v2] Fix revision walk for commits with the same dates
  2013-03-22 18:38 ` [PATCH v2] " Kacper Kornet
  2013-03-22 20:45   ` Junio C Hamano
@ 2013-03-24  2:18   ` Eric Sunshine
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Sunshine @ 2013-03-24  2:18 UTC (permalink / raw)
  To: Kacper Kornet; +Cc: Git List

On Fri, Mar 22, 2013 at 2:38 PM, Kacper Kornet <draenog@pld-linux.org> wrote:
> Logic in still_interesting function allows to stop the commits
> traversing if the oldest processed commit is not older then the

s/then/than/

> youngest commit on the list to process and the list contains only
> commits marked as not interesting ones. It can be premature when dealing
> with a set of coequal commits. For example git rev-list A^! --not B
> provides wrong answer if all commits in the range A..B had the same
> commit time and there are more then 7 of them.

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

end of thread, other threads:[~2013-03-24  2:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-07 18:03 [PATCH] Fix revision walk for commits with the same dates Kacper Kornet
2013-03-22 18:38 ` [PATCH v2] " Kacper Kornet
2013-03-22 20:45   ` Junio C Hamano
2013-03-22 21:07     ` Kacper Kornet
2013-03-24  2:18   ` Eric Sunshine

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