threads / patch / 39757

patchrev-list: add --count to usage guide

Subject: [PATCH] rev-list: add --count to usage guide

## tl;dr

4 messages between Jul 1, 2015 and Jul 1, 2015. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Lawrence Siebert· Jul 1, 2015, 09:24 UTC · lore

--count should be mentioned in the usage guide, this updates code and documentation.

Signed-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>
---
 Documentation/git-rev-list.txt | 1 +
 builtin/rev-list.c             | 1 +
 2 files changed, 2 insertions(+)
Show changes to 2 files +2 −0

Documentation/git-rev-list.txt, builtin/rev-list.c

diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index b10ea60..7b49c85 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -56,6 +56,7 @@ SYNOPSIS
 	     [ --reverse ]
 	     [ --walk-reflogs ]
 	     [ --no-walk ] [ --do-walk ]
+	     [ --count ]
 	     [ --use-bitmap-index ]
 	     <commit>... [ \-- <paths>... ]
 
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index ff84a82..ee9e872 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -42,6 +42,7 @@ static const char rev_list_usage[] =
 "    --abbrev=<n> | --no-abbrev\n"
 "    --abbrev-commit\n"
 "    --left-right\n"
+"    --count\n"
 "  special purpose:\n"
 "    --bisect\n"
 "    --bisect-vars\n"
-- 
1.9.1
Junio C Hamano· Jul 1, 2015, 15:19 UTC · re: Lawrence Siebert · lore

Re: [PATCH] rev-list: add --count to usage guide

Lawrence Siebert <lawrencesiebert@gmail.com> writes:
Show 5 quoted lines
> --count should be mentioned in the usage guide, this updates code and
> documentation.
>
> Signed-off-by: Lawrence Siebert <lawrencesiebert@gmail.com>
> ---

Sounds good. While at it, perhaps add a mention (perhaps by creating a BUGS section at the end of the file) that --count with --use-bitmap-index ignores pathspec silently?

Show 28 quoted lines
>  Documentation/git-rev-list.txt | 1 +
>  builtin/rev-list.c             | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
> index b10ea60..7b49c85 100644
> --- a/Documentation/git-rev-list.txt
> +++ b/Documentation/git-rev-list.txt
> @@ -56,6 +56,7 @@ SYNOPSIS
>  	     [ --reverse ]
>  	     [ --walk-reflogs ]
>  	     [ --no-walk ] [ --do-walk ]
> +	     [ --count ]
>  	     [ --use-bitmap-index ]
>  	     <commit>... [ \-- <paths>... ]
>  
> diff --git a/builtin/rev-list.c b/builtin/rev-list.c
> index ff84a82..ee9e872 100644
> --- a/builtin/rev-list.c
> +++ b/builtin/rev-list.c
> @@ -42,6 +42,7 @@ static const char rev_list_usage[] =
>  "    --abbrev=<n> | --no-abbrev\n"
>  "    --abbrev-commit\n"
>  "    --left-right\n"
> +"    --count\n"
>  "  special purpose:\n"
>  "    --bisect\n"
>  "    --bisect-vars\n"
Jeff King· Jul 1, 2015, 18:42 UTC · re: Junio C Hamano · lore

[PATCH] rev-list: disable --use-bitmap-index when pruning commits

On Wed, Jul 01, 2015 at 08:19:40AM -0700, Junio C Hamano wrote:
> Sounds good.  While at it, perhaps add a mention (perhaps by
> creating a BUGS section at the end of the file) that --count
> with --use-bitmap-index ignores pathspec silently?
I think we can just fix it rather than documenting the problem. :)
-- >8 --
Subject: rev-list: disable --use-bitmap-index when pruning commits

The reachability bitmaps do not have enough information to tell us which commits might have changed path "foo", so the current code produces wrong answers for:

  git rev-list --use-bitmap-index --count HEAD -- foo

(it silently ignores the "foo" limiter). Instead, we should fall back to doing a normal traversal (it is OK to fall back rather than complain, because --use-bitmap-index is a pure optimization, and might not kick in for other reasons, such as there being no bitmaps in the repository).

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/rev-list.c      | 2 +-
 t/t5310-pack-bitmaps.sh | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
Show changes to 2 files +7 −1

builtin/rev-list.c, t/t5310-pack-bitmaps.sh

diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index ff84a82..88eddbd 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -355,7 +355,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 	if (bisect_list)
 		revs.limited = 1;
 
-	if (use_bitmap_index) {
+	if (use_bitmap_index && !revs.prune) {
 		if (revs.count && !revs.left_right && !revs.cherry_mark) {
 			uint32_t commit_count;
 			if (!prepare_bitmap_walk(&revs)) {
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 6003490..d446706 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -53,6 +53,12 @@ rev_list_tests() {
 		test_cmp expect actual
 	'
 
+	test_expect_success "counting commits with limiting ($state)" '
+		git rev-list --count HEAD -- 1.t >expect &&
+		git rev-list --use-bitmap-index --count HEAD -- 1.t >actual &&
+		test_cmp expect actual
+	'
+
 	test_expect_success "enumerate --objects ($state)" '
 		git rev-list --objects --use-bitmap-index HEAD >tmp &&
 		cut -d" " -f1 <tmp >tmp2 &&
-- 
2.5.0.rc0.336.g8460790
Junio C Hamano· Jul 1, 2015, 19:00 UTC · re: Jeff King · lore

Re: [PATCH] rev-list: disable --use-bitmap-index when pruning commits

Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> On Wed, Jul 01, 2015 at 08:19:40AM -0700, Junio C Hamano wrote:
>
>> Sounds good.  While at it, perhaps add a mention (perhaps by
>> creating a BUGS section at the end of the file) that --count
>> with --use-bitmap-index ignores pathspec silently?
>
> I think we can just fix it rather than documenting the problem. :)
;-)  Good.
Will queue; thanks.
Show 52 quoted lines
>
> -- >8 --
> Subject: rev-list: disable --use-bitmap-index when pruning commits
>
> The reachability bitmaps do not have enough information to
> tell us which commits might have changed path "foo", so the
> current code produces wrong answers for:
>
>   git rev-list --use-bitmap-index --count HEAD -- foo
>
> (it silently ignores the "foo" limiter). Instead, we should
> fall back to doing a normal traversal (it is OK to fall
> back rather than complain, because --use-bitmap-index is a
> pure optimization, and might not kick in for other reasons,
> such as there being no bitmaps in the repository).
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  builtin/rev-list.c      | 2 +-
>  t/t5310-pack-bitmaps.sh | 6 ++++++
>  2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/rev-list.c b/builtin/rev-list.c
> index ff84a82..88eddbd 100644
> --- a/builtin/rev-list.c
> +++ b/builtin/rev-list.c
> @@ -355,7 +355,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
>  	if (bisect_list)
>  		revs.limited = 1;
>  
> -	if (use_bitmap_index) {
> +	if (use_bitmap_index && !revs.prune) {
>  		if (revs.count && !revs.left_right && !revs.cherry_mark) {
>  			uint32_t commit_count;
>  			if (!prepare_bitmap_walk(&revs)) {
> diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
> index 6003490..d446706 100755
> --- a/t/t5310-pack-bitmaps.sh
> +++ b/t/t5310-pack-bitmaps.sh
> @@ -53,6 +53,12 @@ rev_list_tests() {
>  		test_cmp expect actual
>  	'
>  
> +	test_expect_success "counting commits with limiting ($state)" '
> +		git rev-list --count HEAD -- 1.t >expect &&
> +		git rev-list --use-bitmap-index --count HEAD -- 1.t >actual &&
> +		test_cmp expect actual
> +	'
> +
>  	test_expect_success "enumerate --objects ($state)" '
>  		git rev-list --objects --use-bitmap-index HEAD >tmp &&
>  		cut -d" " -f1 <tmp >tmp2 &&

← back to recent threads