From: Eli Schwartz <hidden> Date: 2021-10-24 01:51:14
While discussing adding git archive support to a software versioning
tool, the issue came up that apparently many people (maybe in the python
community specifically?) use lightweight tags for releases.
While it would be nice if the current describe functionality for
export-subst was sufficient to cover the average reasonable use, this is
apparently not the case; at least --tags support will most likely need
to be added. The alternative is documenting a workflow change and having
the versioning tool raise some kind of error if you use the wrong kind
of tag, which is not an exciting requirement for the project maintainer.
In my initial proposal of the %(describe) feature I gave an example
using --tags, but it never ended up in the initial implementation:
https://public-inbox.org/git/7418f1d8-78c2-61a7-4f03-62360b986a41@archlinux.org/
So I figured I'd take a stab at it myself. While I was at it, I looked
at the options available to git describe and came up with a use case for
adding --abbrev support too.
Eli Schwartz (3):
pretty.c: rename describe options variable to more descriptive name
pretty: add tag option to %(describe)
pretty: add abbrev option to %(describe)
Documentation/pretty-formats.txt | 15 ++++++++++-----
pretty.c | 31 +++++++++++++++++++++++--------
t/t4205-log-pretty-formats.sh | 16 ++++++++++++++++
3 files changed, 49 insertions(+), 13 deletions(-)
--
2.33.1
From: Eli Schwartz <hidden> Date: 2021-10-24 01:51:14
It contains option arguments, not options. We would like to add option
support here too.
Signed-off-by: Eli Schwartz <redacted>
---
pretty.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
From: Eli Schwartz <hidden> Date: 2021-10-24 01:51:14
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit hash. This may not be sufficient to
fully describe all git repos, resulting in a placeholder replacement
changing its length because the repository grew in size. This could
cause the output of git-archive to change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
One alternative would be to just always specify --abbrev=40 but this may
be a bit too biased...
Signed-off-by: Eli Schwartz <redacted>
---
Documentation/pretty-formats.txt | 4 ++++
pretty.c | 2 +-
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
@@ -221,6 +221,10 @@ The placeholders are: the same time. + ** 'tags[=<BOOL>]': Also consider lightweight tags.+** 'abbrev=<N>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <n> digits, or as many digits+ as needed to form a unique object name. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
From: Eli Schwartz <hidden> Date: 2021-10-24 01:51:14
The %(describe) placeholder by default, like `git describe`, only
supports annotated tags. However, some people do use lightweight tags
for releases, and would like to describe those anyway. The command line
tool has an option to support this.
Teach the placeholder to support this as well.
Signed-off-by: Eli Schwartz <redacted>
---
Documentation/pretty-formats.txt | 11 ++++++-----
pretty.c | 23 +++++++++++++++++++----
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 33 insertions(+), 9 deletions(-)
@@ -220,6 +220,7 @@ The placeholders are: inconsistent when tags are added or removed at the same time. ++** 'tags[=<BOOL>]': Also consider lightweight tags. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
@@ -273,11 +274,6 @@ endif::git-rev-list[] If any option is provided multiple times the last occurrence wins. +-The boolean options accept an optional value `[=<BOOL>]`. The values-`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"-sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean-option is given with no value, it's enabled.-+ ** 'key=<K>': only show trailers with specified key. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are
@@ -313,6 +309,11 @@ insert an empty string unless we are traversing reflog entries (e.g., by decoration format if `--decorate` was not already provided on the command line.+The boolean options accept an optional value `[=<BOOL>]`. The values+`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"+sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean+option is given with no value, it's enabled.+ If you add a `+` (plus sign) after '%' of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.
From: Eli Schwartz <hidden> Date: 2021-10-26 01:36:15
It contains option arguments only, not options. We would like to add
option support here too, but to do that we need to distinguish between
different types of options.
Lay out the groundwork for distinguishing between bools, strings, etc.
and move the central logic (validating values and pushing new arguments
to *args) into the successful match, because that will be fairly
conditional on what type of argument is being parsed.
Signed-off-by: Eli Schwartz <redacted>
---
pretty.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
From: Eli Schwartz <hidden> Date: 2021-10-26 01:36:15
Here is the reworked implementation and all-new replacement first patch,
as suggested by review comments.
Minor tweaks to documentation in the second patch, otherwise
documentation and test cases are the same.
Eli Schwartz (3):
pretty.c: rework describe options parsing for better extensibility
pretty: add tag option to %(describe)
pretty: add abbrev option to %(describe)
Documentation/pretty-formats.txt | 16 +++++++---
pretty.c | 55 ++++++++++++++++++++++++++------
t/t4205-log-pretty-formats.sh | 16 ++++++++++
3 files changed, 72 insertions(+), 15 deletions(-)
--
2.33.1
From: Eli Schwartz <hidden> Date: 2021-10-26 01:36:15
The %(describe) placeholder by default, like `git describe`, only
supports annotated tags. However, some people do use lightweight tags
for releases, and would like to describe those anyway. The command line
tool has an option to support this.
Teach the placeholder to support this as well.
Signed-off-by: Eli Schwartz <redacted>
---
Documentation/pretty-formats.txt | 12 +++++++-----
pretty.c | 14 +++++++++++++-
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 28 insertions(+), 6 deletions(-)
@@ -220,6 +220,8 @@ The placeholders are: inconsistent when tags are added or removed at the same time. ++** 'tags[=<BOOL>]': Instead of only considering annotated tags,+ consider lightweight tags as well. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
@@ -273,11 +275,6 @@ endif::git-rev-list[] If any option is provided multiple times the last occurrence wins. +-The boolean options accept an optional value `[=<BOOL>]`. The values-`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"-sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean-option is given with no value, it's enabled.-+ ** 'key=<K>': only show trailers with specified key. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are
@@ -313,6 +310,11 @@ insert an empty string unless we are traversing reflog entries (e.g., by decoration format if `--decorate` was not already provided on the command line.+The boolean options accept an optional value `[=<BOOL>]`. The values+`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"+sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean+option is given with no value, it's enabled.+ If you add a `+` (plus sign) after '%' of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.
From: Eli Schwartz <hidden> Date: 2021-10-26 01:36:17
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit object name. This may not be
sufficient to fully describe all commits in a given repository,
resulting in a placeholder replacement changing its length because the
repository grew in size. This could cause the output of git-archive to
change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
One alternative would be to just always specify --abbrev=40 but this may
be a bit too biased...
Signed-off-by: Eli Schwartz <redacted>
---
Notes:
With regard to validating that an integer is passed, I attempt to parse the
result using the same mechanism git-describe itself does in the abbrev
callback, just with slightly different validation of what we have at the end...
because of course here argval is the entire rest of the format string,
including the ")".
While testing that this actually does what it's supposed to do, I noticed that
it doesn't validate junk like leading whitespace or plus signs... this is a
problem for `git describe --abbrev=' +15'` too so I guess it's not my
problem to fix...
Documentation/pretty-formats.txt | 4 ++++
pretty.c | 16 +++++++++++++++-
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
@@ -222,6 +222,10 @@ The placeholders are: + ** 'tags[=<BOOL>]': Instead of only considering annotated tags, consider lightweight tags as well.+** 'abbrev=<N>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <n> digits, or as many digits+ as needed to form a unique object name. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
From: Eric Sunshine <hidden> Date: 2021-10-26 05:18:17
On Mon, Oct 25, 2021 at 9:36 PM Eli Schwartz [off-list ref] wrote:
quoted hunk
It contains option arguments only, not options. We would like to add
option support here too, but to do that we need to distinguish between
different types of options.
Lay out the groundwork for distinguishing between bools, strings, etc.
and move the central logic (validating values and pushing new arguments
to *args) into the successful match, because that will be fairly
conditional on what type of argument is being parsed.
Signed-off-by: Eli Schwartz <redacted>
---
diff --git a/pretty.c b/pretty.c
@@ -1216,28 +1216,37 @@ int format_set_trailers_options(struct process_trailer_options *opts, static size_t parse_describe_args(const char *start, struct strvec *args) {+ struct {+ char *name;+ enum { OPT_STRING } type;+ } option[] = {+ { "exclude", OPT_STRING },+ { "match", OPT_STRING },+ }; const char *arg = start; for (;;) {+ int found = 0; const char *argval; size_t arglen = 0; int i;+ for (i = 0; !found && i < ARRAY_SIZE(option); i++) {+ switch(option[i].type) {+ case OPT_STRING:+ if (match_placeholder_arg_value(arg, option[i].name, &arg,+ &argval, &arglen) && arglen) {+ if (!arglen)+ return 0;
I may be missing something obvious, but how will it be possible for:
if (!arglen)
return 0;
to trigger if the `if` immediately above it:
if (... && arglen) {
has already asserted that `arglen` is not 0?
+ strvec_pushf(args, "--%s=%.*s", option[i].name, (int)arglen, argval);
+ found = 1;
+ }
break;
}
}
+ if (!found)
break;
The use of `found` to break out of a loop from within a `switch` seems
a bit clunky. An alternative would be to `goto` a label...
}
return arg - start;
... which could be introduced just before the `return`. Of course,
this is highly subjective, so not necessarily worth changing.
From: Eric Sunshine <hidden> Date: 2021-10-26 05:25:22
On Mon, Oct 25, 2021 at 9:36 PM Eli Schwartz [off-list ref] wrote:
quoted hunk
The %(describe) placeholder by default, like `git describe`, only
supports annotated tags. However, some people do use lightweight tags
for releases, and would like to describe those anyway. The command line
tool has an option to support this.
Teach the placeholder to support this as well.
Signed-off-by: Eli Schwartz <redacted>
---
diff --git a/pretty.c b/pretty.c
@@ -1229,10 +1230,21 @@ static size_t parse_describe_args(const char *start, struct strvec *args) for (i = 0; !found && i < ARRAY_SIZE(option); i++) { switch(option[i].type) {+ case OPT_BOOL:+ if(match_placeholder_bool_arg(arg, option[i].name, &arg, &optval)) {
We would normally omit the braces for this simple `if`:
if (optval)
strvec_pushf(...);
else
strvec_pushf(...);
... or maybe even use the ternary operator:
strvec_pushf(args, "--%s%s", optval ? "" : "no-", option[i].name);
but it's highly subjective whether or not that's more readable.
From: Eric Sunshine <hidden> Date: 2021-10-26 05:37:27
On Mon, Oct 25, 2021 at 9:36 PM Eli Schwartz [off-list ref] wrote:
quoted hunk
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit object name. This may not be
sufficient to fully describe all commits in a given repository,
resulting in a placeholder replacement changing its length because the
repository grew in size. This could cause the output of git-archive to
change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
One alternative would be to just always specify --abbrev=40 but this may
be a bit too biased...
Signed-off-by: Eli Schwartz <redacted>
---
@@ -222,6 +222,10 @@ The placeholders are:+** 'abbrev=<N>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <n> digits, or as many digits+ as needed to form a unique object name.
Inconsistent mix of `<N>` and `<n>`.
quoted hunk
diff --git a/pretty.c b/pretty.c
@@ -1245,6 +1246,19 @@ static size_t parse_describe_args(const char *start, struct strvec *args)+ case OPT_INTEGER:+ if (match_placeholder_arg_value(arg, option[i].name, &arg,+ &argval, &arglen) && arglen) {+ if (!arglen)+ return 0;
Same question I asked while reviewing the other patch regarding
checking `arglen` in both conditionals: `if (... && arglen)` vs. `if
(!arglen)`
From: Đoàn Trần Công Danh <hidden> Date: 2021-10-26 12:07:05
On 2021-10-25 21:34:52-0400, Eli Schwartz [off-list ref] wrote:
quoted hunk
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit object name. This may not be
sufficient to fully describe all commits in a given repository,
resulting in a placeholder replacement changing its length because the
repository grew in size. This could cause the output of git-archive to
change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
One alternative would be to just always specify --abbrev=40 but this may
be a bit too biased...
Signed-off-by: Eli Schwartz <redacted>
---
Notes:
With regard to validating that an integer is passed, I attempt to parse the
result using the same mechanism git-describe itself does in the abbrev
callback, just with slightly different validation of what we have at the end...
because of course here argval is the entire rest of the format string,
including the ")".
While testing that this actually does what it's supposed to do, I noticed that
it doesn't validate junk like leading whitespace or plus signs... this is a
problem for `git describe --abbrev=' +15'` too so I guess it's not my
problem to fix...
Documentation/pretty-formats.txt | 4 ++++
pretty.c | 16 +++++++++++++++-
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
@@ -222,6 +222,10 @@ The placeholders are: + ** 'tags[=<BOOL>]': Instead of only considering annotated tags, consider lightweight tags as well.+** 'abbrev=<N>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <n> digits, or as many digits+ as needed to form a unique object name. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
Other than the question pointed out by Eric,
with DEVELOPER=1, -Werror=declaration-after-statement
We'll need this change squashed in:
------- 8< -----
From: Eric Sunshine <hidden> Date: 2021-10-26 17:29:05
On Tue, Oct 26, 2021 at 8:07 AM Đoàn Trần Công Danh
[off-list ref] wrote:
On 2021-10-25 21:34:52-0400, Eli Schwartz [off-list ref] wrote:
quoted
+ if (!arglen)
+ return 0;
+ char* endptr;
Other than the question pointed out by Eric,
with DEVELOPER=1, -Werror=declaration-after-statement
We'll need this change squashed in:
+ char* endptr;
if (!arglen)
return 0;
- char* endptr;
This highlights a style nit, as well; should be:
char *endptr;
From: Eli Schwartz <hidden> Date: 2021-10-26 19:12:51
On 10/26/21 8:06 AM, Đoàn Trần Công Danh wrote:
Other than the question pointed out by Eric,
with DEVELOPER=1, -Werror=declaration-after-statement
We'll need this change squashed in:
Thanks for the advice. In v1 of this patchset I attempted to do a
developer build but failed due to preexisting errors:
CC run-command.o
run-command.c: In function ‘async_die_is_recursing’:
run-command.c:1102:9: error: ‘pthread_setspecific’ expecting 1 byte in a
region of size 0 [-Werror=stringop-overread]
1102 | pthread_setspecific(async_die_counter, (void *)1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/openssl/crypto.h:415,
from /usr/include/openssl/comp.h:16,
from /usr/include/openssl/ssl.h:17,
from git-compat-util.h:309,
from cache.h:4,
from run-command.c:1:
/usr/include/pthread.h:1308:12: note: in a call to function
‘pthread_setspecific’ declared with attribute ‘access (none, 2)’
1308 | extern int pthread_setspecific (pthread_key_t __key,
| ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
My system has a custom compiled glibc from git roughly around the 2.34
release (a similar environment could be obtained by using Fedora rawhide
I guess), and this commit looks mighty suspicious:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a1561c3bbe8e72c6e44280d1eb5e529d2da4ecd0
For this reason, I did not bother to try testing v2 under a developer
build, leading to my overlooking this issue. ;)
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
From: Eli Schwartz <hidden> Date: 2021-10-26 20:06:07
On 10/26/21 1:18 AM, Eric Sunshine wrote:
On Mon, Oct 25, 2021 at 9:36 PM Eli Schwartz [off-list ref] wrote:
quoted
It contains option arguments only, not options. We would like to add
option support here too, but to do that we need to distinguish between
different types of options.
Lay out the groundwork for distinguishing between bools, strings, etc.
and move the central logic (validating values and pushing new arguments
to *args) into the successful match, because that will be fairly
conditional on what type of argument is being parsed.
Signed-off-by: Eli Schwartz <redacted>
---
diff --git a/pretty.c b/pretty.c
@@ -1216,28 +1216,37 @@ int format_set_trailers_options(struct process_trailer_options *opts, static size_t parse_describe_args(const char *start, struct strvec *args) {+ struct {+ char *name;+ enum { OPT_STRING } type;+ } option[] = {+ { "exclude", OPT_STRING },+ { "match", OPT_STRING },+ }; const char *arg = start; for (;;) {+ int found = 0; const char *argval; size_t arglen = 0; int i;+ for (i = 0; !found && i < ARRAY_SIZE(option); i++) {+ switch(option[i].type) {+ case OPT_STRING:+ if (match_placeholder_arg_value(arg, option[i].name, &arg,+ &argval, &arglen) && arglen) {+ if (!arglen)+ return 0;
I may be missing something obvious, but how will it be possible for:
if (!arglen)
return 0;
to trigger if the `if` immediately above it:
if (... && arglen) {
has already asserted that `arglen` is not 0?
I don't think you are missing anything here, I simply forgot that
halfway through I added a second check to the if, and later moved the
code from down below.
I think returning 0 is correct here, to avoid pointlessly checking the
rest of option[]. So I'll (re-)remove the first check.
quoted
+ strvec_pushf(args, "--%s=%.*s", option[i].name, (int)arglen, argval);
+ found = 1;
+ }
break;
}
}
+ if (!found)
break;
The use of `found` to break out of a loop from within a `switch` seems
a bit clunky. An alternative would be to `goto` a label...
quoted
}
return arg - start;
... which could be introduced just before the `return`. Of course,
this is highly subjective, so not necessarily worth changing.
Keeping in mind that this for (;;) { .... break; } was there before me
:D I just switched the name/type of the variable it checks...
IMO changing to goto is not my business to change (at least not in this
patch), and given the "common wisdom" is "goto is evil" I'm not strongly
inclined to get into the business of rewriting someone else's code for
that. It's too subjective for my taste.
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
From: Eli Schwartz <hidden> Date: 2021-10-26 20:06:31
On 10/26/21 1:25 AM, Eric Sunshine wrote:
On Mon, Oct 25, 2021 at 9:36 PM Eli Schwartz [off-list ref] wrote:
quoted
The %(describe) placeholder by default, like `git describe`, only
supports annotated tags. However, some people do use lightweight tags
for releases, and would like to describe those anyway. The command line
tool has an option to support this.
Teach the placeholder to support this as well.
Signed-off-by: Eli Schwartz <redacted>
---
diff --git a/pretty.c b/pretty.c
@@ -1229,10 +1230,21 @@ static size_t parse_describe_args(const char *start, struct strvec *args) for (i = 0; !found && i < ARRAY_SIZE(option); i++) { switch(option[i].type) {+ case OPT_BOOL:+ if(match_placeholder_bool_arg(arg, option[i].name, &arg, &optval)) {
Style nit: add space after `if`
Oops, I am not sure how this happened. It's wrong in the switch too.
We would normally omit the braces for this simple `if`:
if (optval)
strvec_pushf(...);
else
strvec_pushf(...);
... or maybe even use the ternary operator:
strvec_pushf(args, "--%s%s", optval ? "" : "no-", option[i].name);
but it's highly subjective whether or not that's more readable.
Although the braces feel more natural to me for clarity purposes, it's a
good point that the git coding style says to omit them for single
statements, and I should have followed that here.
The ternary doesn't feel readable to me, however.
...
Thanks for the style review!
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
From: Eli Schwartz <hidden> Date: 2021-10-29 18:45:43
The %(describe) placeholder by default, like `git describe`, only
supports annotated tags. However, some people do use lightweight tags
for releases, and would like to describe those anyway. The command line
tool has an option to support this.
Teach the placeholder to support this as well.
Signed-off-by: Eli Schwartz <redacted>
---
Documentation/pretty-formats.txt | 12 +++++++-----
pretty.c | 13 ++++++++++++-
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 27 insertions(+), 6 deletions(-)
@@ -220,6 +220,8 @@ The placeholders are: inconsistent when tags are added or removed at the same time. ++** 'tags[=<BOOL>]': Instead of only considering annotated tags,+ consider lightweight tags as well. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
@@ -273,11 +275,6 @@ endif::git-rev-list[] If any option is provided multiple times the last occurrence wins. +-The boolean options accept an optional value `[=<BOOL>]`. The values-`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"-sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean-option is given with no value, it's enabled.-+ ** 'key=<K>': only show trailers with specified key. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are
@@ -313,6 +310,11 @@ insert an empty string unless we are traversing reflog entries (e.g., by decoration format if `--decorate` was not already provided on the command line.+The boolean options accept an optional value `[=<BOOL>]`. The values+`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"+sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean+option is given with no value, it's enabled.+ If you add a `+` (plus sign) after '%' of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.
From: Eli Schwartz <hidden> Date: 2021-10-29 18:45:46
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit object name. This may not be
sufficient to fully describe all commits in a given repository,
resulting in a placeholder replacement changing its length because the
repository grew in size. This could cause the output of git-archive to
change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
One alternative would be to just always specify --abbrev=40 but this may
be a bit too biased...
Signed-off-by: Eli Schwartz <redacted>
---
Documentation/pretty-formats.txt | 4 ++++
pretty.c | 16 +++++++++++++++-
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
@@ -222,6 +222,10 @@ The placeholders are: + ** 'tags[=<BOOL>]': Instead of only considering annotated tags, consider lightweight tags as well.+** 'abbrev=<N>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <n> digits, or as many digits+ as needed to form a unique object name. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
From: Eli Schwartz <hidden> Date: 2021-10-29 18:45:48
It contains option arguments only, not options. We would like to add
option support here too, but to do that we need to distinguish between
different types of options.
Lay out the groundwork for distinguishing between bools, strings, etc.
and move the central logic (validating values and pushing new arguments
to *args) into the successful match, because that will be fairly
conditional on what type of argument is being parsed.
Signed-off-by: Eli Schwartz <redacted>
---
pretty.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
From: Eric Sunshine <hidden> Date: 2021-10-29 18:52:05
On Fri, Oct 29, 2021 at 2:45 PM Eli Schwartz [off-list ref] wrote:
quoted hunk
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit object name. This may not be
sufficient to fully describe all commits in a given repository,
resulting in a placeholder replacement changing its length because the
repository grew in size. This could cause the output of git-archive to
change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
[...]
Signed-off-by: Eli Schwartz <redacted>
---
@@ -222,6 +222,10 @@ The placeholders are:+** 'abbrev=<N>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <n> digits, or as many digits+ as needed to form a unique object name.
There's still an inconsistent mix of `<N>` and `<n>` here (mentioned
in my earlier review). Is that intentional or just a simple oversight?
From: Eli Schwartz <hidden> Date: 2021-10-29 19:04:38
On 10/29/21 2:51 PM, Eric Sunshine wrote:
On Fri, Oct 29, 2021 at 2:45 PM Eli Schwartz [off-list ref] wrote:
quoted
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit object name. This may not be
sufficient to fully describe all commits in a given repository,
resulting in a placeholder replacement changing its length because the
repository grew in size. This could cause the output of git-archive to
change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
[...]
Signed-off-by: Eli Schwartz <redacted>
---
@@ -222,6 +222,10 @@ The placeholders are:+** 'abbrev=<N>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <n> digits, or as many digits+ as needed to form a unique object name.
There's still an inconsistent mix of `<N>` and `<n>` here (mentioned
in my earlier review). Is that intentional or just a simple oversight?
Ah, sorry... I overlooked that. It was originally copied from the
git-describe man page which uses lowercase and I overlooked that part of
your review.
It should be consistently uppercase here for consistency with
pretty-formats.
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
From: Eli Schwartz <hidden> Date: 2021-10-31 17:15:45
It contains option arguments only, not options. We would like to add
option support here too, but to do that we need to distinguish between
different types of options.
Lay out the groundwork for distinguishing between bools, strings, etc.
and move the central logic (validating values and pushing new arguments
to *args) into the successful match, because that will be fairly
conditional on what type of argument is being parsed.
Signed-off-by: Eli Schwartz <redacted>
---
pretty.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
From: Eli Schwartz <hidden> Date: 2021-10-31 17:15:45
The %(describe) placeholder by default, like `git describe`, only
supports annotated tags. However, some people do use lightweight tags
for releases, and would like to describe those anyway. The command line
tool has an option to support this.
Teach the placeholder to support this as well.
Signed-off-by: Eli Schwartz <redacted>
---
I use lowercase "bool" here not "boolean-value" because I don't see
utility in the word "value" here.
Documentation/pretty-formats.txt | 12 +++++++-----
pretty.c | 12 ++++++++++++
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 27 insertions(+), 5 deletions(-)
@@ -220,6 +220,8 @@ The placeholders are: inconsistent when tags are added or removed at the same time. ++** 'tags[=<bool>]': Instead of only considering annotated tags,+ consider lightweight tags as well. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
@@ -273,11 +275,6 @@ endif::git-rev-list[] If any option is provided multiple times the last occurrence wins. +-The boolean options accept an optional value `[=<BOOL>]`. The values-`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"-sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean-option is given with no value, it's enabled.-+ ** 'key=<K>': only show trailers with specified key. Matching is done case-insensitively and trailing colon is optional. If option is given multiple times trailer lines matching any of the keys are
@@ -313,6 +310,11 @@ insert an empty string unless we are traversing reflog entries (e.g., by decoration format if `--decorate` was not already provided on the command line.+The boolean options accept an optional value `[=<bool>]`. The values+`true`, `false`, `on`, `off` etc. are all accepted. See the "boolean"+sub-section in "EXAMPLES" in linkgit:git-config[1]. If a boolean+option is given with no value, it's enabled.+ If you add a `+` (plus sign) after '%' of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.
From: Eli Schwartz <hidden> Date: 2021-10-31 17:15:45
The %(describe) placeholder by default, like `git describe`, uses a
seven-character abbreviated commit object name. This may not be
sufficient to fully describe all commits in a given repository,
resulting in a placeholder replacement changing its length because the
repository grew in size. This could cause the output of git-archive to
change.
Add the --abbrev option to `git describe` to the placeholder interface
in order to provide tools to the user for fine-tuning project defaults
and ensure reproducible archives.
One alternative would be to just always specify --abbrev=40 but this may
be a bit too biased...
Signed-off-by: Eli Schwartz <redacted>
---
Documentation/pretty-formats.txt | 4 ++++
pretty.c | 15 +++++++++++++++
t/t4205-log-pretty-formats.sh | 8 ++++++++
3 files changed, 27 insertions(+)
@@ -222,6 +222,10 @@ The placeholders are: + ** 'tags[=<bool>]': Instead of only considering annotated tags, consider lightweight tags as well.+** 'abbrev=<number>': Instead of using the default number of hexadecimal digits+ (which will vary according to the number of objects in the repository with a+ default of 7) of the abbreviated object name, use <number> digits, or as many+ digits as needed to form a unique object name. ** 'match=<pattern>': Only consider tags matching the given `glob(7)` pattern, excluding the "refs/tags/" prefix. ** 'exclude=<pattern>': Do not consider tags matching the given
From: Johannes Schindelin <hidden> Date: 2021-11-03 23:20:41
Hi Eli,
On Tue, 26 Oct 2021, Eli Schwartz wrote:
On 10/26/21 8:06 AM, Đoàn Trần Công Danh wrote:
quoted
Other than the question pointed out by Eric,
with DEVELOPER=1, -Werror=declaration-after-statement
We'll need this change squashed in:
Thanks for the advice. In v1 of this patchset I attempted to do a
developer build but failed due to preexisting errors:
CC run-command.o
run-command.c: In function ‘async_die_is_recursing’:
run-command.c:1102:9: error: ‘pthread_setspecific’ expecting 1 byte in a
region of size 0 [-Werror=stringop-overread]
1102 | pthread_setspecific(async_die_counter, (void *)1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/openssl/crypto.h:415,
from /usr/include/openssl/comp.h:16,
from /usr/include/openssl/ssl.h:17,
from git-compat-util.h:309,
from cache.h:4,
from run-command.c:1:
/usr/include/pthread.h:1308:12: note: in a call to function
‘pthread_setspecific’ declared with attribute ‘access (none, 2)’
1308 | extern int pthread_setspecific (pthread_key_t __key,
| ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
My system has a custom compiled glibc from git roughly around the 2.34
release (a similar environment could be obtained by using Fedora rawhide
I guess), and this commit looks mighty suspicious:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a1561c3bbe8e72c6e44280d1eb5e529d2da4ecd0
For this reason, I did not bother to try testing v2 under a developer
build, leading to my overlooking this issue. ;)
From: Johannes Schindelin <hidden> Date: 2021-11-04 09:29:12
Hi Eli,
On Thu, 4 Nov 2021, Johannes Schindelin wrote:
On Tue, 26 Oct 2021, Eli Schwartz wrote:
quoted
On 10/26/21 8:06 AM, Đoàn Trần Công Danh wrote:
quoted
Other than the question pointed out by Eric,
with DEVELOPER=1, -Werror=declaration-after-statement
We'll need this change squashed in:
Thanks for the advice. In v1 of this patchset I attempted to do a
developer build but failed due to preexisting errors:
CC run-command.o
run-command.c: In function ‘async_die_is_recursing’:
run-command.c:1102:9: error: ‘pthread_setspecific’ expecting 1 byte in a
region of size 0 [-Werror=stringop-overread]
1102 | pthread_setspecific(async_die_counter, (void *)1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/openssl/crypto.h:415,
from /usr/include/openssl/comp.h:16,
from /usr/include/openssl/ssl.h:17,
from git-compat-util.h:309,
from cache.h:4,
from run-command.c:1:
/usr/include/pthread.h:1308:12: note: in a call to function
‘pthread_setspecific’ declared with attribute ‘access (none, 2)’
1308 | extern int pthread_setspecific (pthread_key_t __key,
| ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
My system has a custom compiled glibc from git roughly around the 2.34
release (a similar environment could be obtained by using Fedora rawhide
I guess), and this commit looks mighty suspicious:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a1561c3bbe8e72c6e44280d1eb5e529d2da4ecd0
For this reason, I did not bother to try testing v2 under a developer
build, leading to my overlooking this issue. ;)
From: Eli Schwartz <hidden> Date: 2021-11-07 12:40:19
On 11/3/21 7:20 PM, Johannes Schindelin wrote:
Hi Eli,
On Tue, 26 Oct 2021, Eli Schwartz wrote:
quoted
My system has a custom compiled glibc from git roughly around the 2.34
release (a similar environment could be obtained by using Fedora rawhide
I guess), and this commit looks mighty suspicious:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=a1561c3bbe8e72c6e44280d1eb5e529d2da4ecd0
For this reason, I did not bother to try testing v2 under a developer
build, leading to my overlooking this issue. ;)
FWIW this was present in the official version of glibc released in
August... the problem is finding an official version of a distro that
ships it. :D
Thanks for the heads up.
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User