Skip to content

doc: apply new format to git-branch man page #1880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

jnavila
Copy link

@jnavila jnavila commented Mar 11, 2025

Working on git-branch's doc uncovered a bug in the completion logic that did not take into account the new formatting of options. Apart from that, the changes are quite standard now.

Changes since V1:

  • rework commit messages
  • De-GNU-ify and simplify script

@jnavila jnavila force-pushed the doc_git_branch branch 5 times, most recently from 0eb4dbf to 5d2afbc Compare March 15, 2025 15:26
Copy link

gitgitgadget bot commented Mar 15, 2025

There are issues in commit 4386d71:
completion: take into account the formatting backticks for options
Lines in the body of the commit messages should be wrapped between 60 and 76 characters.
Indented lines, and lines without whitespace, are exempt

@jnavila
Copy link
Author

jnavila commented Mar 15, 2025

/submit

Copy link

gitgitgadget bot commented Mar 15, 2025

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1880/jnavila/doc_git_branch-v1

To fetch this version to local tag pr-1880/jnavila/doc_git_branch-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1880/jnavila/doc_git_branch-v1

@@ -13,8 +13,8 @@ print_config_list () {
cat <<EOF
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Jean-Noël Avila via GitGitGadget" <[email protected]> writes:

> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <[email protected]>
>
> With the modern formatting of the manpages, the options and commands are now
> backticked in their definition lists. This patch updates the generation of
> the completion list to take into account this new format.
>
> Signed-off-by: Jean-Noël Avila <[email protected]>
> ---
>  generate-configlist.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/generate-configlist.sh b/generate-configlist.sh
> index dffdaada8b5..802178daad4 100755
> --- a/generate-configlist.sh
> +++ b/generate-configlist.sh
> @@ -13,8 +13,8 @@ print_config_list () {
>  	cat <<EOF
>  static const char *config_name_list[] = {
>  EOF
> -	grep -h '^[a-zA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/*config.adoc "$SOURCE_DIR"/Documentation/config/*.adoc |
> -	sed '/deprecated/d; s/::$//; s/,  */\n/g' |
> +	grep -h '^`\?[a-zA-Z].*\..*`\?::$' "$SOURCE_DIR"/Documentation/*config.adoc "$SOURCE_DIR"/Documentation/config/*.adoc |

Using \? in BRE as a short-hand for \{0,1\} (or trying to use any
single regexp magic in BRE by adding a backslash when that magic is
only available in ERE) is a GNUism, isn't it?

We probably should rewrite the thing as ERE, perhaps like

	grep -E -h '^`?[a-zA-Z].*\..*`?::$' ...

Also, if we can avoid piping grep into sed or awk, we should do so,
when it does not lose readability.  Perhaps we can do something like

	sed -E -n -e '/... that pattern .../{
		/deprecated/d;
		s/::$//;
		...
	}' "$SOURCE_DIR"/Documentation/*config.adoc ... |
        sort |
	...

in this case?

> +	sed '/deprecated/d; s/::$//; s/`//g; s/,  */\n/g' |
>  	sort |
>  	sed 's/^.*$/	"&",/'
>  	cat <<EOF

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Jean-Noël AVILA wrote (reply to this):

On Monday, 17 March 2025 21:52:13 CET Junio C Hamano wrote:
> "Jean-Noël Avila via GitGitGadget" <[email protected]> writes:
> > From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <[email protected]>
> > 
> > With the modern formatting of the manpages, the options and commands are 
now
> > backticked in their definition lists. This patch updates the generation of
> > the completion list to take into account this new format.
> > 
> > Signed-off-by: Jean-Noël Avila <[email protected]>
> > ---
> > 
> >  generate-configlist.sh | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/generate-configlist.sh b/generate-configlist.sh
> > index dffdaada8b5..802178daad4 100755
> > --- a/generate-configlist.sh
> > +++ b/generate-configlist.sh
> > @@ -13,8 +13,8 @@ print_config_list () {
> > 
> >  	cat <<EOF
> >  
> >  static const char *config_name_list[] = {
> >  EOF
> > 
> > -	grep -h '^[a-zA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/
*config.adoc
> > "$SOURCE_DIR"/Documentation/config/*.adoc | -	sed '/deprecated/d; s/::$//;
> > s/,  */\n/g' |
> > +	grep -h '^`\?[a-zA-Z].*\..*`\?::$'
> > "$SOURCE_DIR"/Documentation/*config.adoc
> > "$SOURCE_DIR"/Documentation/config/*.adoc |
> Using \? in BRE as a short-hand for \{0,1\} (or trying to use any
> single regexp magic in BRE by adding a backslash when that magic is
> only available in ERE) is a GNUism, isn't it?
> 
> We probably should rewrite the thing as ERE, perhaps like
> 
> 	grep -E -h '^`?[a-zA-Z].*\..*`?::$' ...
> 
> Also, if we can avoid piping grep into sed or awk, we should do so,
> when it does not lose readability.  Perhaps we can do something like
> 
> 	sed -E -n -e '/... that pattern .../{
> 		/deprecated/d;
> 		s/::$//;
> 		...
> 	}' "$SOURCE_DIR"/Documentation/*config.adoc ... |
>         sort |
> 	...
> 
> in this case?

For the GNUism, the tests on MacOS and Windows by gitgitgadget passed. But I 
get your point and will reroll.



Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Junio C Hamano wrote (reply to this):

Jean-Noël AVILA <[email protected]> writes:

> For the GNUism, the tests on MacOS and Windows by gitgitgadget passed. But I 
> get your point and will reroll.

Is there a good test in our test suite that validates the output of
this script?  I had an impression that even if the regexp match by
this grep were a bit off, the only end-user visible effect of such a
breakage is that some entries from config_name_list[] may be missing
when "git help --config-for-completion" is called, but I do not
think of any sensible way to notice that some entries are missing or
extra entries exist in the output.  So unless the regexp is broken
so badly that makes the resulting config-list.h syntactically
incorrect, it is unlikely that our test suite would catch anything,
I suspect.

If I deliberately break the regexp (this is before your patch), it
does not seem to break t0012 (which uses --config-for-completion).

 generate-configlist.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git c/generate-configlist.sh w/generate-configlist.sh
index dffdaada8b..a6eb9739ea 100755
--- c/generate-configlist.sh
+++ w/generate-configlist.sh
@@ -13,7 +13,7 @@ print_config_list () {
 	cat <<EOF
 static const char *config_name_list[] = {
 EOF
-	grep -h '^[a-zA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/*config.adoc "$SOURCE_DIR"/Documentation/config/*.adoc |
+	grep -h '^[a-uA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/*config.adoc "$SOURCE_DIR"/Documentation/config/*.adoc |
 	sed '/deprecated/d; s/::$//; s/,  */\n/g' |
 	sort |
 	sed 's/^.*$/	"&",/'


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Jean-Noël AVILA wrote (reply to this):

On Tuesday, 18 March 2025 05:16:32 CET Junio C Hamano wrote:
> Jean-Noël AVILA <[email protected]> writes:
> > For the GNUism, the tests on MacOS and Windows by gitgitgadget passed. But 
I
> > get your point and will reroll.
> 
> Is there a good test in our test suite that validates the output of
> this script?  I had an impression that even if the regexp match by
> this grep were a bit off, the only end-user visible effect of such a
> breakage is that some entries from config_name_list[] may be missing
> when "git help --config-for-completion" is called, but I do not
> think of any sensible way to notice that some entries are missing or
> extra entries exist in the output.  So unless the regexp is broken
> so badly that makes the resulting config-list.h syntactically
> incorrect, it is unlikely that our test suite would catch anything,
> I suspect.
> 
> If I deliberately break the regexp (this is before your patch), it
> does not seem to break t0012 (which uses --config-for-completion).
> 

I noticed the bug when working with git-branch's doc, because it broke t9902 
which specifically tests completion for 'git config get br' and could no longer 
find the 'branch.'  So the tests have eventually found the regression when the 
formatting went a little more widespread.

As for a way to validate the content of the script, I can only think of 
committing the config-list.h and checking when the contents diverge.

 

@@ -1,41 +1,42 @@
branch.autoSetupMerge::
Tells 'git branch', 'git switch' and 'git checkout' to set up new branches
`branch.autoSetupMerge`::
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Junio C Hamano wrote (reply to this):

"Jean-Noël Avila via GitGitGadget" <[email protected]> writes:

> From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <[email protected]>
>
> - Switch the synopsis to a synopsis block which automatically
>   formats placeholders in italics and keywords in monospace
> - Use _<placeholder>_ instead of <placeholder> in the description
> - Use `backticks` for keywords and more complex option
> descriptions. The new rendering engine applies synopsis rules to
> these spans.

And the one effective reformatting in this patch that is not covered
by the list is that the possible values for some variables, that
were mentioned in the description prose, are now made into
enumerated list.

Nicely done.

Copy link

gitgitgadget bot commented Mar 18, 2025

This patch series was integrated into seen via git@30423c7.

@gitgitgadget gitgitgadget bot added the seen label Mar 18, 2025
jnavila added 2 commits March 18, 2025 05:50
With the modern formatting of the manpages, the options and commands are now
backticked in their definition lists. This patch updates the generation of
the completion list to take into account this new format.

The script `generate-configlist.sh` is updated to get rid of extraneous
commands and fit everything in a single sed script.

Signed-off-by: Jean-Noël Avila <[email protected]>
- Switch the synopsis to a synopsis block which automatically
  formats placeholders in italics and keywords in monospace
- Use _<placeholder>_ instead of <placeholder> in the description
- Use `backticks` for keywords and more complex option
descriptions. The new rendering engine applies synopsis rules to
these spans.

Possible values for some variables, that were mentioned in the description
prose, are now made into enumerated list.

Signed-off-by: Jean-Noël Avila <[email protected]>
Copy link

gitgitgadget bot commented Mar 18, 2025

This branch is now known as ja/doc-branch-markup.

Copy link

gitgitgadget bot commented Mar 18, 2025

This patch series was integrated into seen via git@c22de74.

Copy link

gitgitgadget bot commented Mar 18, 2025

This patch series was integrated into seen via git@643f7a6.

Copy link

gitgitgadget bot commented Mar 18, 2025

There was a status update in the "New Topics" section about the branch ja/doc-branch-markup on the Git mailing list:

Expecting a reroll to lose GNUism.
cf. <2773494.mvXUDI8C0e@cayenne>
source: <[email protected]>

@jnavila
Copy link
Author

jnavila commented Mar 19, 2025

/submit

Copy link

gitgitgadget bot commented Mar 19, 2025

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1880/jnavila/doc_git_branch-v2

To fetch this version to local tag pr-1880/jnavila/doc_git_branch-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1880/jnavila/doc_git_branch-v2

Copy link

gitgitgadget bot commented Mar 21, 2025

This patch series was integrated into seen via git@6b27c88.

Copy link

gitgitgadget bot commented Mar 21, 2025

There was a status update in the "Cooking" section about the branch ja/doc-branch-markup on the Git mailing list:

Doc mark-up updates.

Will merge to 'next'.
source: <[email protected]>

Copy link

gitgitgadget bot commented Mar 24, 2025

This patch series was integrated into seen via git@d8c1d77.

Copy link

gitgitgadget bot commented Mar 24, 2025

This patch series was integrated into next via git@ba6e1c7.

@gitgitgadget gitgitgadget bot added the next label Mar 24, 2025
Copy link

gitgitgadget bot commented Mar 25, 2025

This patch series was integrated into seen via git@e9745c0.

Copy link

gitgitgadget bot commented Mar 26, 2025

There was a status update in the "Cooking" section about the branch ja/doc-branch-markup on the Git mailing list:

Doc mark-up updates.

Will merge to 'master'.
source: <[email protected]>

Copy link

gitgitgadget bot commented Mar 28, 2025

This patch series was integrated into seen via git@0baa915.

Copy link

gitgitgadget bot commented Mar 29, 2025

This patch series was integrated into seen via git@89054f6.

Copy link

gitgitgadget bot commented Apr 7, 2025

There was a status update in the "Cooking" section about the branch ja/doc-branch-markup on the Git mailing list:

Doc mark-up updates.

Will merge to 'master'.
source: <[email protected]>

Copy link

gitgitgadget bot commented Apr 7, 2025

This patch series was integrated into seen via git@6a9e1c3.

Copy link

gitgitgadget bot commented Apr 7, 2025

This patch series was integrated into master via git@6a9e1c3.

Copy link

gitgitgadget bot commented Apr 7, 2025

This patch series was integrated into next via git@6a9e1c3.

@gitgitgadget gitgitgadget bot added the master label Apr 7, 2025
@gitgitgadget gitgitgadget bot closed this Apr 7, 2025
Copy link

gitgitgadget bot commented Apr 7, 2025

Closed via 6a9e1c3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant