Re: [PATCH v2] Add script to get modified pages for commit msgs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/16/20 1:16 AM, Alejandro Colomar wrote:
> 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.
> 
> Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>

Hi Alex,

Can you resend with a copyright notice in the file.

Thanks,

Michael

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


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



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux