Skip to contentSkip to conversation

Add script to get modified pages for commit msgs

PATCH Superseded Alejandro Colomar 2 participants 6 messages Nov 15, 2020 – Nov 16, 2020 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add script to get modified pages for commit msgs

The script can be used in this way:

git commit -sm "$(./scripts/modified_pages.sh): Short commit msg"

And then maybe --ammend and add a longer message.

This is especially useful for changes to many pages at once, usually when running a script to apply global changes.

---

Hi Michael,

I put into a script the commands I used for a previous patch's commit msg.

Cheers,

Alex

 scripts/modified_pages.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100755 scripts/modified_pages.sh
scripts/modified_pages.sh new file +26 -0
new file mode 100755
index 000000000..7fac2d98c
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+## Usage:
+## git commit -m "$(./scripts/modified_pages.sh): Short message here"
+##
+## How it works:
+## 1) Read git status.
+## 2) Staged changes are always printed before "Changes not staged for commit".
+##    Cut from that point to not include files not staged for commit.
+## 3) grep lines containing "modified:"
+##    (each of those is a changed file)
+## 4) Keep only the basenames of the files,
+##    and separate them using a comma.
+## 5) Remove the newline characters.
+## 6) Remove the comma before the first file
+##
+## The result is a list of all files with changes staged for commit,
+## separated by ", ".
+
+
+git status							\
+|sed "/Changes not staged for commit:/q"			\
+|grep "modified:"						\
+|sed "s%\tmodified:  %,%; s%man[1-9]/%%"			\
+|tr -d '\n'							\
+|sed "s/^, //"
Signature · 1 line
2.29.2
#1 lore raw

PATCH v2 1/1 Add script to get modified pages for commit msgs

The script can be used this way:

git commit -sm "$(./scripts/modified_pages.sh): Short commit msg"

And then maybe --ammend and add a longer message.

This is especially useful for changes to many pages at once, usually when running a script to apply some global changes.

---

Now it will also include new files and deleted files.

 scripts/modified_pages.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 scripts/modified_pages.sh
scripts/modified_pages.sh new file +27 -0
new file mode 100755
index 000000000..c6bc064a4
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+## Usage:
+## git commit -m "$(./scripts/modified_pages.sh): Short message here"
+##
+## How it works:
+## 1) Read git status.
+## 2) Staged changes are always before "Changes not staged for commit".
+##    Cut from that point to not include pages not staged for commit.
+## 3) Keep only lines containing "modified:" or "deleted:" or "new file:"
+##    (each of those is a changed file)
+## 4) Keep only the path, replacing git text by ", ".
+## 5) Keep only the basenames of the files in 'man?/'.
+## 6) Remove any newline characters.
+## 7) Remove the comma before the first file
+##
+## The result is a list of all files with changes staged for commit,
+## separated by ", ".
+
+
+git status							\
+|sed "/Changes not staged for commit:/q"			\
+|grep -E "^\s*(modified|deleted|new file):"			\
+|sed "s/^.*:\s*/, /"						\
+|sed "s%man[1-9]/%%"						\
+|tr -d '\n'							\
+|sed "s/^, //"
Signature · 1 line
2.29.2
#2 lore raw
Quoted 5 lines · Alejandro Colomar

The script can be used this way:

git commit -sm "$(./scripts/modified_pages.sh): Short commit msg"

And then maybe --ammend and add a longer message.

s/ammend/amend/ please :)

Thanks,

Alex

#3 lore raw
In reply to Alejandro Colomar
Quoted 10 lines · Alejandro Colomar

The script can be used this way:

git commit -sm "$(./scripts/modified_pages.sh): Short commit msg"

And then maybe --ammend and add a longer message.

This is especially useful for changes to many pages at once, usually when running a script to apply some global changes.

Hi Alex,

Can you resend with a copyright notice in the file.

Thanks,

Michael

Quoted 42 lines

---

Now it will also include new files and deleted files.

 scripts/modified_pages.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 scripts/modified_pages.sh
scripts/modified_pages.sh new file +27 -0
new file mode 100755
index 000000000..c6bc064a4
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+## Usage:
+## git commit -m "$(./scripts/modified_pages.sh): Short message here"
+##
+## How it works:
+## 1) Read git status.
+## 2) Staged changes are always before "Changes not staged for commit".
+##    Cut from that point to not include pages not staged for commit.
+## 3) Keep only lines containing "modified:" or "deleted:" or "new file:"
+##    (each of those is a changed file)
+## 4) Keep only the path, replacing git text by ", ".
+## 5) Keep only the basenames of the files in 'man?/'.
+## 6) Remove any newline characters.
+## 7) Remove the comma before the first file
+##
+## The result is a list of all files with changes staged for commit,
+## separated by ", ".
+
+
+git status							\
+|sed "/Changes not staged for commit:/q"			\
+|grep -E "^\s*(modified|deleted|new file):"			\
+|sed "s/^.*:\s*/, /"						\
+|sed "s%man[1-9]/%%"						\
+|tr -d '\n'							\
+|sed "s/^, //"
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#4 lore raw

PATCH v2 1/1 Add script to get modified pages for commit msgs

The script can be used this way:

git commit -sm "$(./scripts/modified_pages.sh): Short commit msg"

And then maybe --amend and add a longer message.

This is especially useful for changes to many pages at once, usually when running a script to apply some global changes.

---
 scripts/modified_pages.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100755 scripts/modified_pages.sh
scripts/modified_pages.sh new file +34 -0
new file mode 100755
index 000000000..f6c4a6cea
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+## SPDX-License-Identifier: GPL-2.0-only
+########################################################################
+##
+## (C) Copyright 2020, Alejandro Colomar
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; version 2.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details
+## (http://www.gnu.org/licenses/gpl-2.0.html).
+##
+########################################################################
+##
+## The output of this script is a
+## list of all files with changes staged for commit
+## (basename only if the files are within "man?/"),
+## separated by ", ".
+## Usage:
+## git commit -m "$(./scripts/modified_pages.sh): Short message here"
+##
+
+
+git status							\
+|sed "/Changes not staged for commit:/q"			\
+|grep -E "^\s*(modified|deleted|new file):"			\
+|sed "s/^.*:\s*/, /"						\
+|sed "s%man[1-9]/%%"						\
+|tr -d '\n'							\
+|sed "s/^, //"
Signature · 1 line
2.29.2
#5 lore raw

Hi ALex,

Quoted 45 lines · Alejandro Colomar

The script can be used this way:

git commit -sm "$(./scripts/modified_pages.sh): Short commit msg"

And then maybe --amend and add a longer message.

This is especially useful for changes to many pages at once, usually when running a script to apply some global changes.

---
 scripts/modified_pages.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100755 scripts/modified_pages.sh
scripts/modified_pages.sh new file +24 -0
new file mode 100755
index 000000000..f6c4a6cea
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+## SPDX-License-Identifier: GPL-2.0-only
+########################################################################
+##
+## (C) Copyright 2020, Alejandro Colomar
+## This program is free software; you can redistribute it and/or
+## modify it under the terms of the GNU General Public License
+## as published by the Free Software Foundation; version 2.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details
+## (http://www.gnu.org/licenses/gpl-2.0.html).
+##
+########################################################################
+##
+## The output of this script is a
+## list of all files with changes staged for commit
+## (basename only if the files are within "man?/"),
+## separated by ", ".
+## Usage:
+## git commit -m "$(./scripts/modified_pages.sh): Short message here"

scripts/modified_pages.sh line 34

Quoted 10 lines
scripts/modified_pages.sh new file +10 -0
+##
+
+
+git status							\
+|sed "/Changes not staged for commit:/q"			\
+|grep -E "^\s*(modified|deleted|new file):"			\
+|sed "s/^.*:\s*/, /"						\
+|sed "s%man[1-9]/%%"						\
+|tr -d '\n'							\
+|sed "s/^, //"

Thanks. Patch applied!

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/