git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] describe: bail of --contains --all is used with --exclude or --match
@ 2019-02-26 21:53 Jacob Keller
  2019-02-26 23:34 ` Eric Sunshine
  0 siblings, 1 reply; 2+ messages in thread
From: Jacob Keller @ 2019-02-26 21:53 UTC (permalink / raw)
  To: git; +Cc: Jacob Keller

From: Jacob Keller <jacob.keller@gmail.com>

If you try to use git describe --contains with --all, the exclude and
match patterns are silently ignored.

This results in unexpected behavior, as you may try to provide patterns
and expect it to change the result.

Check for this, and have describe die when it encounters this, instead
of silently ignoring the provided options.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
---

I just found this while trying to use it, the patterns weren't being applied
properly.

This is pretty quick/dirty, I haven't had time to write a test, or anything.

 builtin/describe.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/builtin/describe.c b/builtin/describe.c
index 1409cedce2fb..1bf4b6e3d0ae 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -589,6 +589,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 				argv_array_pushf(&args, "--refs=refs/tags/%s", item->string);
 			for_each_string_list_item(item, &exclude_patterns)
 				argv_array_pushf(&args, "--exclude=refs/tags/%s", item->string);
+		} else {
+			if (patterns.nr || exclude_patterns.nr)
+				die(_("--contains with --all does not support --match or --exclude"));
 		}
 		if (argc)
 			argv_array_pushv(&args, argv);
-- 
2.18.0.219.gaf81d287a9da


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

* Re: [PATCH] describe: bail of --contains --all is used with --exclude or --match
  2019-02-26 21:53 [PATCH] describe: bail of --contains --all is used with --exclude or --match Jacob Keller
@ 2019-02-26 23:34 ` Eric Sunshine
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sunshine @ 2019-02-26 23:34 UTC (permalink / raw)
  To: Jacob Keller; +Cc: Git List, Jacob Keller

On Tue, Feb 26, 2019 at 4:54 PM Jacob Keller <jacob.e.keller@intel.com> wrote:
> describe: bail of --contains --all is used with --exclude or --match

s/of/if/

> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
> ---
> diff --git a/builtin/describe.c b/builtin/describe.c
> @@ -589,6 +589,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
>                         for_each_string_list_item(item, &exclude_patterns)
>                                 argv_array_pushf(&args, "--exclude=refs/tags/%s", item->string);
> +               } else {
> +                       if (patterns.nr || exclude_patterns.nr)
> +                               die(_("--contains with --all does not support --match or --exclude"));
>                 }

Could be folded into an 'else if':

    } else if (patterns.nr || exclude_patterns.nr) {
        die(...);
    }

but not worth a re-roll.

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

end of thread, other threads:[~2019-02-26 23:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-26 21:53 [PATCH] describe: bail of --contains --all is used with --exclude or --match Jacob Keller
2019-02-26 23:34 ` Eric Sunshine

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