Skip to contentSkip to conversation

describe: bail of --contains --all is used with --exclude or --match

PATCH In review Jacob Keller 4 participants 4 messages Feb 26, 2019 – May 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 describe: bail of --contains --all is used with --exclude or --match

From: Jacob Keller <[email protected]>

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.

---

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(+)
builtin/describe.c +3 -0
index 1409cedce2fb..1bf4b6e3d0ae 100644
@@ -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);
Signature · 1 line
2.18.0.219.gaf81d287a9da
#1 lore raw
Quoted 1 line · Jacob Keller

describe: bail of --contains --all is used with --exclude or --match

s/of/if/

builtin/describe.c int cmd_describe(int argc, const char **argv, const char *prefix) · line 594

Quoted 10 lines

---

builtin/describe.c +3 -0
@@ -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.

#2 lore raw
In reply to Jacob Keller
Quoted 8 lines · Jacob Keller

From: Jacob Keller <[email protected]>

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.

I got just bitten by that, and yes, it was quite unexpected.

Quoted 11 lines

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

---

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.

Would you like to resurrect the patch? It seems it was never merged, nor the underlying problem fixed:

```
$ git describe --contains --all --match=bogus
master
$ git describe --contains --all --exclude="*"
master
```
Quoted 4 lines
 builtin/describe.c | 3 +++
 1 file changed, 3 insertions(+)

[...]

--Tuomas

#3 lore raw
Quoted 29 lines · Tuomas Ahola
Quoted 8 lines · Jacob Keller

From: Jacob Keller <[email protected]>

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.

I got just bitten by that, and yes, it was quite unexpected.

Quoted 11 lines

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

---

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.

Would you like to resurrect the patch? It seems it was never merged, nor the underlying problem fixed:

Quoted 7 lines
```
$ git describe --contains --all --match=bogus
master
$ git describe --contains --all --exclude="*"
master
```

Apologies for a delayed response. I'll try to look into reviving this tomorrow.