public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Add script to get modified pages for commit msgs
@ 2020-11-15 23:08 Alejandro Colomar
  2020-11-16  0:16 ` [PATCH v2] " Alejandro Colomar
  0 siblings, 1 reply; 6+ messages in thread
From: Alejandro Colomar @ 2020-11-15 23:08 UTC (permalink / raw)
  To: mtk.manpages; +Cc: Alejandro Colomar, linux-man

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.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---

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

diff --git a/scripts/modified_pages.sh b/scripts/modified_pages.sh
new file mode 100755
index 000000000..7fac2d98c
--- /dev/null
+++ b/scripts/modified_pages.sh
@@ -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/^, //"
-- 
2.29.2


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

end of thread, other threads:[~2020-11-16 20:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-15 23:08 [PATCH] Add script to get modified pages for commit msgs Alejandro Colomar
2020-11-16  0:16 ` [PATCH v2] " Alejandro Colomar
2020-11-16  0:46   ` Alejandro Colomar (man-pages)
2020-11-16  8:07   ` Michael Kerrisk (man-pages)
2020-11-16 19:42     ` Alejandro Colomar
2020-11-16 20:27       ` Michael Kerrisk (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox