diff mbox series

[v2,2/3] Setup working tree in describe

Message ID 20190126204951.42455-2-koraktor@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/3] Add tests for describe with --work-tree | expand

Commit Message

Sebastian Staudt Jan. 26, 2019, 8:49 p.m. UTC
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(+)

Comments

Duy Nguyen Jan. 27, 2019, 12:21 a.m. UTC | #1
On Sun, Jan 27, 2019 at 3:51 AM Sebastian Staudt <koraktor@gmail.com> wrote:
>
> This ensures the given working tree is used for --dirty.
>
> The implementation of --broken uses diff-index which calls
> setup_work_tree() itself.

It would be nice to have a test case covering --broken even if no fix
is needed (so that somebody else will not accidentally break it
later). I did a quick test and thought it was broken, but it turns out
I tested it wrong :P

> 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
>
Sebastian Staudt Jan. 27, 2019, 7:19 a.m. UTC | #2
Am So., 27. Jan. 2019 um 01:22 Uhr schrieb Duy Nguyen <pclouds@gmail.com>:
>
> On Sun, Jan 27, 2019 at 3:51 AM Sebastian Staudt <koraktor@gmail.com> wrote:
> >
> > This ensures the given working tree is used for --dirty.
> >
> > The implementation of --broken uses diff-index which calls
> > setup_work_tree() itself.
>
> It would be nice to have a test case covering --broken even if no fix
> is needed (so that somebody else will not accidentally break it
> later). I did a quick test and thought it was broken, but it turns out
> I tested it wrong :P
>

Thereā€˜s only one test ("describe ignoring a broken submodule") which
effectively tests --broken.
I could reuse this.

BTW, is "describe ignoring a broken submodule" the right description here?
In fact, this should probably be named "describe detects a broken submodule".

> > 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
> >
>
>
> --
> Duy
diff mbox series

Patch

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