git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v3 1/3] Add tests for describe with --work-tree
@ 2019-01-29  5:18 Sebastian Staudt
  2019-01-29  5:18 ` [PATCH v3 2/3] Setup working tree in describe Sebastian Staudt
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Sebastian Staudt @ 2019-01-29  5:18 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Jeff King, Duy Nguyen, Sebastian Staudt

The dirty ones are already passing, but just because describe is comparing
with the wrong working tree.

Signed-off-by: Sebastian Staudt <koraktor@gmail.com>
---
 t/t6120-describe.sh | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index d639d94696..c863c4f600 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -145,14 +145,38 @@ check_describe A-* HEAD
 
 check_describe "A-*[0-9a-f]" --dirty
 
+test_expect_success 'describe --dirty with --work-tree' "
+	(
+		cd '$TEST_DIRECTORY' &&
+		git --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty >'$TRASH_DIRECTORY/out'
+	) &&
+	grep 'A-\d\+-g[0-9a-f]\+' '$TRASH_DIRECTORY/out'
+"
+
 test_expect_success 'set-up dirty work tree' '
 	echo >>file
 '
 
 check_describe "A-*[0-9a-f]-dirty" --dirty
 
+test_expect_success 'describe --dirty with --work-tree' "
+	(
+		cd '$TEST_DIRECTORY' &&
+		git --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty >'$TRASH_DIRECTORY/out'
+	) &&
+	grep 'A-\d\+-g[0-9a-f]\+-dirty' '$TRASH_DIRECTORY/out'
+"
+
 check_describe "A-*[0-9a-f].mod" --dirty=.mod
 
+test_expect_success 'describe --dirty=.mod with --work-tree' "
+	(
+		cd '$TEST_DIRECTORY' &&
+		git --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty=.mod >'$TRASH_DIRECTORY/out'
+	) &&
+	grep 'A-\d\+-g[0-9a-f]\+.mod' '$TRASH_DIRECTORY/out'
+"
+
 test_expect_success 'describe --dirty HEAD' '
 	test_must_fail git describe --dirty HEAD
 '
@@ -303,12 +327,21 @@ test_expect_success 'describe chokes on severely broken submodules' '
 	mv .git/modules/sub1/ .git/modules/sub_moved &&
 	test_must_fail git describe --dirty
 '
+
 test_expect_success 'describe ignoring a broken submodule' '
 	git describe --broken >out &&
 	test_when_finished "mv .git/modules/sub_moved .git/modules/sub1" &&
 	grep broken out
 '
 
+test_expect_success 'describe with --work-tree ignoring a broken submodule' "
+	(
+		cd '$TEST_DIRECTORY' &&
+		git --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --broken >'$TRASH_DIRECTORY/out'
+	) &&
+	grep broken '$TRASH_DIRECTORY/out'
+"
+
 test_expect_success 'describe a blob at a directly tagged commit' '
 	echo "make it a unique blob" >file &&
 	git add file && git commit -m "content in file" &&
-- 
2.20.1


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

* [PATCH v3 2/3] Setup working tree in describe
  2019-01-29  5:18 [PATCH v3 1/3] Add tests for describe with --work-tree Sebastian Staudt
@ 2019-01-29  5:18 ` Sebastian Staudt
  2019-01-29 13:11   ` Jeff King
  2019-01-29  5:18 ` [PATCH v3 3/3] Add test for describe with a bare repository Sebastian Staudt
  2019-01-29 13:00 ` [PATCH v3 1/3] Add tests for describe with --work-tree Jeff King
  2 siblings, 1 reply; 15+ messages in thread
From: Sebastian Staudt @ 2019-01-29  5:18 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Jeff King, Duy Nguyen, Sebastian Staudt

This ensures the given working tree is used for --dirty.

The implementation of --broken uses diff-index which calls
setup_work_tree() itself.

Signed-off-by: Sebastian Staudt <koraktor@gmail.com>
---
 builtin/describe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/describe.c b/builtin/describe.c
index cc118448ee..b5b7abdc8f 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -629,6 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 			struct argv_array args = ARGV_ARRAY_INIT;
 			int fd, result;
 
+			setup_work_tree();
 			read_cache();
 			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
 				      NULL, NULL, NULL);
-- 
2.20.1


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

* [PATCH v3 3/3] Add test for describe with a bare repository
  2019-01-29  5:18 [PATCH v3 1/3] Add tests for describe with --work-tree Sebastian Staudt
  2019-01-29  5:18 ` [PATCH v3 2/3] Setup working tree in describe Sebastian Staudt
@ 2019-01-29  5:18 ` Sebastian Staudt
  2019-01-29 13:12   ` Jeff King
  2019-01-29 13:00 ` [PATCH v3 1/3] Add tests for describe with --work-tree Jeff King
  2 siblings, 1 reply; 15+ messages in thread
From: Sebastian Staudt @ 2019-01-29  5:18 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Jeff King, Duy Nguyen, Sebastian Staudt

This ensures that nothing breaks the basic functionality of describe for
bare repositories. Please note that --broken and --dirty need a working
tree.

Signed-off-by: Sebastian Staudt <koraktor@gmail.com>
---
 t/t6120-describe.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index c863c4f600..f7539a2650 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -418,4 +418,9 @@ test_expect_success 'describe complains about missing object' '
 	test_must_fail git describe $ZERO_OID
 '
 
+test_expect_success 'describe works from outside repo using --git-dir' "
+  git clone --bare '$TRASH_DIRECTORY' '$TRASH_DIRECTORY/bare' &&
+  git --git-dir '$TRASH_DIRECTORY/bare' describe
+"
+
 test_done
-- 
2.20.1


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

* Re: [PATCH v3 1/3] Add tests for describe with --work-tree
  2019-01-29  5:18 [PATCH v3 1/3] Add tests for describe with --work-tree Sebastian Staudt
  2019-01-29  5:18 ` [PATCH v3 2/3] Setup working tree in describe Sebastian Staudt
  2019-01-29  5:18 ` [PATCH v3 3/3] Add test for describe with a bare repository Sebastian Staudt
@ 2019-01-29 13:00 ` Jeff King
  2019-01-29 17:47   ` Junio C Hamano
  2 siblings, 1 reply; 15+ messages in thread
From: Jeff King @ 2019-01-29 13:00 UTC (permalink / raw)
  To: Sebastian Staudt; +Cc: Git Mailing List, Junio C Hamano, Duy Nguyen

On Tue, Jan 29, 2019 at 06:18:57AM +0100, Sebastian Staudt wrote:

> The dirty ones are already passing, but just because describe is comparing
> with the wrong working tree.
> 
> Signed-off-by: Sebastian Staudt <koraktor@gmail.com>
> ---
>  t/t6120-describe.sh | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
> index d639d94696..c863c4f600 100755
> --- a/t/t6120-describe.sh
> +++ b/t/t6120-describe.sh
> @@ -145,14 +145,38 @@ check_describe A-* HEAD
>  
>  check_describe "A-*[0-9a-f]" --dirty
>  
> +test_expect_success 'describe --dirty with --work-tree' "

This should be marked as test_expect_failure, I think, because it does
not yet pass (and then flipped s/failure/success/ in the next patch).

> +	(
> +		cd '$TEST_DIRECTORY' &&
> +		git --git-dir '$TRASH_DIRECTORY/.git' --work-tree '$TRASH_DIRECTORY' describe --dirty >'$TRASH_DIRECTORY/out'
> +	) &&

The quoting you've done here is unusual for our test suite, and not
quite as robust. You've put the whole test snippet into double-quotes,
which means that $TRASH_DIRECTORY, etc, will be expanded before we eval
the code.

By putting single-quotes around $TRASH_DIRECTORY, that makes it work
when the path contains a space. But it would fail if somebody's
filesystem path contains a single-quote.

The usual style is to put the whole snippet into single-quotes, and then
double-quote as appropriate within it. Like:

  test_expect_failure 'describe --dirty with --work-tree' '
	(
		cd "$TEST_DIRECTORY" &&
		git --git-dir "$TRASH_DIRECTORY/.git" ...etc

Those variables will be expanded when test_expect_failure eval's the
snippet.

> +	grep 'A-\d\+-g[0-9a-f]\+' '$TRASH_DIRECTORY/out'

Using "\d" isn't portable.

This regex is pretty broad. What are we checking here? If I understand
the previous discussion, we just care that it doesn't have "dirty" in
it, right? I don't think this regex does that, because it doesn't anchor
the end of string.

If that's indeed what we're checking, then an easier check is perhaps:

  ! grep dirty ...

As a side note, you can also shorten your references to "out" by
referring to it from the trash directory itself. I.e.:

  (
	cd "$TEST_DIRECTORY" &&
	git --git-dir="$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" \
	  describe --dirty
  ) >out &&
  ! grep dirty out

Same thing, but IMHO a little easier to read.

>  check_describe "A-*[0-9a-f]-dirty" --dirty
>  
> +test_expect_success 'describe --dirty with --work-tree' "
> [...]

Same comments apply to the other blocks you added.

Other than those mechanical things, though, what the tests are actually
trying to do seems quite reasonable to me.

-Peff

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

* Re: [PATCH v3 2/3] Setup working tree in describe
  2019-01-29  5:18 ` [PATCH v3 2/3] Setup working tree in describe Sebastian Staudt
@ 2019-01-29 13:11   ` Jeff King
  2019-01-29 17:39     ` Junio C Hamano
  2019-01-29 20:53     ` Eric Sunshine
  0 siblings, 2 replies; 15+ messages in thread
From: Jeff King @ 2019-01-29 13:11 UTC (permalink / raw)
  To: Sebastian Staudt; +Cc: Git Mailing List, Junio C Hamano, Duy Nguyen

On Tue, Jan 29, 2019 at 06:18:58AM +0100, Sebastian Staudt wrote:

> Subject: Re: [PATCH v3 2/3] Setup working tree in describe

We usually write subjects as "area: do some thing" which is a little
easier when scanning big lists of "git log --oneline".

I think it's key, too, that we only do this for the --dirty case, not
always. So maybe:

  describe: setup working tree for --dirty

or something?

> This ensures the given working tree is used for --dirty.

There's been a lot of digging and discussion on the list about what
happens if we don't do this. Could we summarize it here?

Perhaps:

  We don't use NEED_WORK_TREE when running the git-describe builtin,
  since you should be able to describe a commit even in a bare
  repository. However, the --dirty flag does need a working tree. Since
  we don't call setup_work_tree(), it uses whatever directory we happen
  to be in. That's unlikely to match our index, meaning we'd say "dirty"
  even when the real working tree is clean.

  We can fix that by calling setup_work_tree() once we know that the
  user has asked for --dirty.

> The implementation of --broken uses diff-index which calls
> setup_work_tree() itself.

If I hadn't just read the rest of the thread, I'd probably wonder why we
are talking about --broken at all. Maybe:

  The --broken option similarly needs a working tree. But because the
  current implementation calls an external diff-index to do the work,
  we don't have to bother setting up the working tree in the
  git-describe process.

> diff --git a/builtin/describe.c b/builtin/describe.c
> index cc118448ee..b5b7abdc8f 100644
> --- a/builtin/describe.c
> +++ b/builtin/describe.c
> @@ -629,6 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
>  			struct argv_array args = ARGV_ARRAY_INIT;
>  			int fd, result;
>  
> +			setup_work_tree();
>  			read_cache();
>  			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
>  				      NULL, NULL, NULL);

The patch itself looks good. :)

-Peff

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

* Re: [PATCH v3 3/3] Add test for describe with a bare repository
  2019-01-29  5:18 ` [PATCH v3 3/3] Add test for describe with a bare repository Sebastian Staudt
@ 2019-01-29 13:12   ` Jeff King
  2019-01-30 10:23     ` Sebastian Staudt
  0 siblings, 1 reply; 15+ messages in thread
From: Jeff King @ 2019-01-29 13:12 UTC (permalink / raw)
  To: Sebastian Staudt; +Cc: Git Mailing List, Junio C Hamano, Duy Nguyen

On Tue, Jan 29, 2019 at 06:18:59AM +0100, Sebastian Staudt wrote:

> This ensures that nothing breaks the basic functionality of describe for
> bare repositories. Please note that --broken and --dirty need a working
> tree.

Makes sense.

> +test_expect_success 'describe works from outside repo using --git-dir' "
> +  git clone --bare '$TRASH_DIRECTORY' '$TRASH_DIRECTORY/bare' &&
> +  git --git-dir '$TRASH_DIRECTORY/bare' describe
> +"

What the test is doing seems sane, but the same quoting comments from
the earlier patch apply.

-Peff

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

* Re: [PATCH v3 2/3] Setup working tree in describe
  2019-01-29 13:11   ` Jeff King
@ 2019-01-29 17:39     ` Junio C Hamano
  2019-01-29 20:53     ` Eric Sunshine
  1 sibling, 0 replies; 15+ messages in thread
From: Junio C Hamano @ 2019-01-29 17:39 UTC (permalink / raw)
  To: Jeff King; +Cc: Sebastian Staudt, Git Mailing List, Duy Nguyen

Jeff King <peff@peff.net> writes:

> On Tue, Jan 29, 2019 at 06:18:58AM +0100, Sebastian Staudt wrote:
>
>> Subject: Re: [PATCH v3 2/3] Setup working tree in describe
>
> We usually write subjects as "area: do some thing" which is a little
> easier when scanning big lists of "git log --oneline".
>
> I think it's key, too, that we only do this for the --dirty case, not
> always. So maybe:
>
>   describe: setup working tree for --dirty
>
> or something?

Thanks as always for being an excellent reviewer who not just
reviews but also gives good suggestions.

>> This ensures the given working tree is used for --dirty.
>
> There's been a lot of digging and discussion on the list about what
> happens if we don't do this. Could we summarize it here?
>
> Perhaps:
>
>   We don't use NEED_WORK_TREE when running the git-describe builtin,
>   since you should be able to describe a commit even in a bare
>   repository. However, the --dirty flag does need a working tree. Since
>   we don't call setup_work_tree(), it uses whatever directory we happen
>   to be in. That's unlikely to match our index, meaning we'd say "dirty"
>   even when the real working tree is clean.
>
>   We can fix that by calling setup_work_tree() once we know that the
>   user has asked for --dirty.
>
>> The implementation of --broken uses diff-index which calls
>> setup_work_tree() itself.
>
> If I hadn't just read the rest of the thread, I'd probably wonder why we
> are talking about --broken at all. Maybe:
>
>   The --broken option similarly needs a working tree. But because the
>   current implementation calls an external diff-index to do the work,
>   we don't have to bother setting up the working tree in the
>   git-describe process.
>
>> diff --git a/builtin/describe.c b/builtin/describe.c
>> index cc118448ee..b5b7abdc8f 100644
>> --- a/builtin/describe.c
>> +++ b/builtin/describe.c
>> @@ -629,6 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
>>  			struct argv_array args = ARGV_ARRAY_INIT;
>>  			int fd, result;
>>  
>> +			setup_work_tree();
>>  			read_cache();
>>  			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
>>  				      NULL, NULL, NULL);
>
> The patch itself looks good. :)
>
> -Peff

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

* Re: [PATCH v3 1/3] Add tests for describe with --work-tree
  2019-01-29 13:00 ` [PATCH v3 1/3] Add tests for describe with --work-tree Jeff King
@ 2019-01-29 17:47   ` Junio C Hamano
  2019-01-30 10:23     ` Sebastian Staudt
  0 siblings, 1 reply; 15+ messages in thread
From: Junio C Hamano @ 2019-01-29 17:47 UTC (permalink / raw)
  To: Jeff King; +Cc: Sebastian Staudt, Git Mailing List, Duy Nguyen

Jeff King <peff@peff.net> writes:

> The usual style is to put the whole snippet into single-quotes, and then
> double-quote as appropriate within it. Like:
>
>   test_expect_failure 'describe --dirty with --work-tree' '
> 	(
> 		cd "$TEST_DIRECTORY" &&
> 		git --git-dir "$TRASH_DIRECTORY/.git" ...etc
>
> Those variables will be expanded when test_expect_failure eval's the
> snippet.

Good.

>> +	grep 'A-\d\+-g[0-9a-f]\+' '$TRASH_DIRECTORY/out'
>
> Using "\d" isn't portable.

True, but not just \d.  I think using \ before special characters to
force an otherwise basic regular expression to be ERE (i.e. \+ at
the end) is a GNUism.

> This regex is pretty broad. What are we checking here? If I understand
> the previous discussion, we just care that it doesn't have "dirty" in
> it, right? I don't think this regex does that, because it doesn't anchor
> the end of string.
>
> If that's indeed what we're checking, then an easier check is perhaps:
>
>   ! grep dirty ...

Good.

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

* Re: [PATCH v3 2/3] Setup working tree in describe
  2019-01-29 13:11   ` Jeff King
  2019-01-29 17:39     ` Junio C Hamano
@ 2019-01-29 20:53     ` Eric Sunshine
  2019-01-29 22:35       ` Jeff King
  1 sibling, 1 reply; 15+ messages in thread
From: Eric Sunshine @ 2019-01-29 20:53 UTC (permalink / raw)
  To: Jeff King; +Cc: Sebastian Staudt, Git Mailing List, Junio C Hamano, Duy Nguyen

On Tue, Jan 29, 2019 at 8:12 AM Jeff King <peff@peff.net> wrote:
> On Tue, Jan 29, 2019 at 06:18:58AM +0100, Sebastian Staudt wrote:
> > This ensures the given working tree is used for --dirty.
>
> There's been a lot of digging and discussion on the list about what
> happens if we don't do this. Could we summarize it here?
>
> Perhaps:
>
>   We don't use NEED_WORK_TREE when running the git-describe builtin,
>   since you should be able to describe a commit even in a bare
>   repository. However, the --dirty flag does need a working tree. Since
>   we don't call setup_work_tree(), it uses whatever directory we happen
>   to be in. That's unlikely to match our index, meaning we'd say "dirty"
>   even when the real working tree is clean.
>
>   We can fix that by calling setup_work_tree() once we know that the
>   user has asked for --dirty.

I have not particularly been following this thread, but this proposed
commit message does an excellent job of summarizing and explaining the
issue and making the fix obvious (so, now I don't have to go back and
read the entire thread).

> > The implementation of --broken uses diff-index which calls
> > setup_work_tree() itself.
>
> If I hadn't just read the rest of the thread, I'd probably wonder why we
> are talking about --broken at all. Maybe:
>
>   The --broken option similarly needs a working tree. But because the
>   current implementation calls an external diff-index to do the work,
>   we don't have to bother setting up the working tree in the
>   git-describe process.

This rewrite left me slightly in the dark since I had to infer that
git-diff-index calls setup_work_tree() itself. Perhaps:

    ...an external diff-index to do the work, which itself calls
    setup_work_tree(), we don't have to bother...

But that's minor.

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

* Re: [PATCH v3 2/3] Setup working tree in describe
  2019-01-29 20:53     ` Eric Sunshine
@ 2019-01-29 22:35       ` Jeff King
  2019-01-30 10:31         ` Sebastian Staudt
  0 siblings, 1 reply; 15+ messages in thread
From: Jeff King @ 2019-01-29 22:35 UTC (permalink / raw)
  To: Eric Sunshine
  Cc: Sebastian Staudt, Git Mailing List, Junio C Hamano, Duy Nguyen

On Tue, Jan 29, 2019 at 03:53:40PM -0500, Eric Sunshine wrote:

> > > The implementation of --broken uses diff-index which calls
> > > setup_work_tree() itself.
> >
> > If I hadn't just read the rest of the thread, I'd probably wonder why we
> > are talking about --broken at all. Maybe:
> >
> >   The --broken option similarly needs a working tree. But because the
> >   current implementation calls an external diff-index to do the work,
> >   we don't have to bother setting up the working tree in the
> >   git-describe process.
> 
> This rewrite left me slightly in the dark since I had to infer that
> git-diff-index calls setup_work_tree() itself. Perhaps:
> 
>     ...an external diff-index to do the work, which itself calls
>     setup_work_tree(), we don't have to bother...
> 
> But that's minor.

Yeah, my reasoning was that we handed off to diff-index, so if it
doesn't work, then it has its own bug. ;) But I agree it is probably
better to just be explicit.

-Peff

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

* Re: [PATCH v3 1/3] Add tests for describe with --work-tree
  2019-01-29 17:47   ` Junio C Hamano
@ 2019-01-30 10:23     ` Sebastian Staudt
  2019-01-30 12:43       ` Jeff King
  0 siblings, 1 reply; 15+ messages in thread
From: Sebastian Staudt @ 2019-01-30 10:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jeff King, Git Mailing List, Duy Nguyen

Am Di., 29. Jan. 2019 um 18:47 Uhr schrieb Junio C Hamano <gitster@pobox.com>:
>
> Jeff King <peff@peff.net> writes:
>
> > The usual style is to put the whole snippet into single-quotes, and then
> > double-quote as appropriate within it. Like:
> >
> >   test_expect_failure 'describe --dirty with --work-tree' '
> >       (
> >               cd "$TEST_DIRECTORY" &&
> >               git --git-dir "$TRASH_DIRECTORY/.git" ...etc
> >
> > Those variables will be expanded when test_expect_failure eval's the
> > snippet.
>
> Good.

Ok, thanks. I’ll change this in the next reroll.

>
> >> +    grep 'A-\d\+-g[0-9a-f]\+' '$TRASH_DIRECTORY/out'
> >
> > Using "\d" isn't portable.
>
> True, but not just \d.  I think using \ before special characters to
> force an otherwise basic regular expression to be ERE (i.e. \+ at
> the end) is a GNUism.
>

I guess I’ll use the even broader but apparently more portable A-*[0-9a-f]
then. It’s used in the other checks, so this should be OK?

> > This regex is pretty broad. What are we checking here? If I understand
> > the previous discussion, we just care that it doesn't have "dirty" in
> > it, right? I don't think this regex does that, because it doesn't anchor
> > the end of string.
> >
> > If that's indeed what we're checking, then an easier check is perhaps:
> >
> >   ! grep dirty ...
>
> Good.

This was copied and pasted from the existing check for describe with a
clean working tree. So this should be changed, too.

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

* Re: [PATCH v3 3/3] Add test for describe with a bare repository
  2019-01-29 13:12   ` Jeff King
@ 2019-01-30 10:23     ` Sebastian Staudt
  0 siblings, 0 replies; 15+ messages in thread
From: Sebastian Staudt @ 2019-01-30 10:23 UTC (permalink / raw)
  To: Jeff King; +Cc: Git Mailing List, Junio C Hamano, Duy Nguyen

Am Di., 29. Jan. 2019 um 14:12 Uhr schrieb Jeff King <peff@peff.net>:
>
> On Tue, Jan 29, 2019 at 06:18:59AM +0100, Sebastian Staudt wrote:
>
> > This ensures that nothing breaks the basic functionality of describe for
> > bare repositories. Please note that --broken and --dirty need a working
> > tree.
>
> Makes sense.
>
> > +test_expect_success 'describe works from outside repo using --git-dir' "
> > +  git clone --bare '$TRASH_DIRECTORY' '$TRASH_DIRECTORY/bare' &&
> > +  git --git-dir '$TRASH_DIRECTORY/bare' describe
> > +"
>
> What the test is doing seems sane, but the same quoting comments from
> the earlier patch apply.
>

Ok, thanks.

> -Peff

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

* Re: [PATCH v3 2/3] Setup working tree in describe
  2019-01-29 22:35       ` Jeff King
@ 2019-01-30 10:31         ` Sebastian Staudt
  2019-01-30 12:44           ` Jeff King
  0 siblings, 1 reply; 15+ messages in thread
From: Sebastian Staudt @ 2019-01-30 10:31 UTC (permalink / raw)
  To: Jeff King; +Cc: Eric Sunshine, Git Mailing List, Junio C Hamano, Duy Nguyen

Am Di., 29. Jan. 2019 um 23:35 Uhr schrieb Jeff King <peff@peff.net>:
>
> On Tue, Jan 29, 2019 at 03:53:40PM -0500, Eric Sunshine wrote:
>
> > > > The implementation of --broken uses diff-index which calls
> > > > setup_work_tree() itself.
> > >
> > > If I hadn't just read the rest of the thread, I'd probably wonder why we
> > > are talking about --broken at all. Maybe:
> > >
> > >   The --broken option similarly needs a working tree. But because the
> > >   current implementation calls an external diff-index to do the work,
> > >   we don't have to bother setting up the working tree in the
> > >   git-describe process.
> >
> > This rewrite left me slightly in the dark since I had to infer that
> > git-diff-index calls setup_work_tree() itself. Perhaps:
> >
> >     ...an external diff-index to do the work, which itself calls
> >     setup_work_tree(), we don't have to bother...
> >
> > But that's minor.
>
> Yeah, my reasoning was that we handed off to diff-index, so if it
> doesn't work, then it has its own bug. ;) But I agree it is probably
> better to just be explicit.

Thanks for that valuable feedback.
Is there some trailer like "Co-authored-commit-message-by:"? ;)

>
> -Peff

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

* Re: [PATCH v3 1/3] Add tests for describe with --work-tree
  2019-01-30 10:23     ` Sebastian Staudt
@ 2019-01-30 12:43       ` Jeff King
  0 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2019-01-30 12:43 UTC (permalink / raw)
  To: Sebastian Staudt; +Cc: Junio C Hamano, Git Mailing List, Duy Nguyen

On Wed, Jan 30, 2019 at 11:23:14AM +0100, Sebastian Staudt wrote:

> > >> +    grep 'A-\d\+-g[0-9a-f]\+' '$TRASH_DIRECTORY/out'
> > >
> > > Using "\d" isn't portable.
> >
> > True, but not just \d.  I think using \ before special characters to
> > force an otherwise basic regular expression to be ERE (i.e. \+ at
> > the end) is a GNUism.
> >
> 
> I guess I’ll use the even broader but apparently more portable A-*[0-9a-f]
> then. It’s used in the other checks, so this should be OK?

Yeah, that is OK, as long as you use it with `case` like check_describe
does. Because it's a glob and not a regex, you do not have to worry
about the anchoring issue.

Or if you mean to do an anchored but more general regex like:

  ^A-.*[0-9a-f]$

that is OK, too.

> > > If that's indeed what we're checking, then an easier check is perhaps:
> > >
> > >   ! grep dirty ...
> >
> > Good.
> 
> This was copied and pasted from the existing check for describe with a
> clean working tree. So this should be changed, too.

I do think that makes what we're checking more obvious, so I wouldn't
mind seeing the other tests converted to use this. But it may be hard if
they are relying on check_describe().

I'm OK with anything that works and is robust. :)

-Peff

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

* Re: [PATCH v3 2/3] Setup working tree in describe
  2019-01-30 10:31         ` Sebastian Staudt
@ 2019-01-30 12:44           ` Jeff King
  0 siblings, 0 replies; 15+ messages in thread
From: Jeff King @ 2019-01-30 12:44 UTC (permalink / raw)
  To: Sebastian Staudt
  Cc: Eric Sunshine, Git Mailing List, Junio C Hamano, Duy Nguyen

On Wed, Jan 30, 2019 at 11:31:15AM +0100, Sebastian Staudt wrote:

> > Yeah, my reasoning was that we handed off to diff-index, so if it
> > doesn't work, then it has its own bug. ;) But I agree it is probably
> > better to just be explicit.
> 
> Thanks for that valuable feedback.
> Is there some trailer like "Co-authored-commit-message-by:"? ;)

We often say "Helped-by", but I am OK with or without that in this case.
To me, making suggestions like this is all just part of review. :)

-Peff

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

end of thread, other threads:[~2019-01-30 12:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29  5:18 [PATCH v3 1/3] Add tests for describe with --work-tree Sebastian Staudt
2019-01-29  5:18 ` [PATCH v3 2/3] Setup working tree in describe Sebastian Staudt
2019-01-29 13:11   ` Jeff King
2019-01-29 17:39     ` Junio C Hamano
2019-01-29 20:53     ` Eric Sunshine
2019-01-29 22:35       ` Jeff King
2019-01-30 10:31         ` Sebastian Staudt
2019-01-30 12:44           ` Jeff King
2019-01-29  5:18 ` [PATCH v3 3/3] Add test for describe with a bare repository Sebastian Staudt
2019-01-29 13:12   ` Jeff King
2019-01-30 10:23     ` Sebastian Staudt
2019-01-29 13:00 ` [PATCH v3 1/3] Add tests for describe with --work-tree Jeff King
2019-01-29 17:47   ` Junio C Hamano
2019-01-30 10:23     ` Sebastian Staudt
2019-01-30 12:43       ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).