All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Damien Lespiau <damien.lespiau@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 maintainer-tools] frob-patch-rank: A little	script to batch renaming patch files
Date: Fri, 13 Jun 2014 13:00:23 +0300	[thread overview]
Message-ID: <87ioo5xh6w.fsf@intel.com> (raw)
In-Reply-To: <1402404413-24677-1-git-send-email-damien.lespiau@intel.com>

On Tue, 10 Jun 2014, Damien Lespiau <damien.lespiau@intel.com> wrote:
> The "usage" text should explain it all. I found, in my quilt series
> handling endeavours, that I wanted to be able to shift the prefix
> numbers of a patch series.
>
> v2: Use heredoc for usage string, fix second example, use mv -i (Jani)
>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  frob-patch-rank | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
>  create mode 100755 frob-patch-rank
>
> diff --git a/frob-patch-rank b/frob-patch-rank
> new file mode 100755
> index 0000000..797774e
> --- /dev/null
> +++ b/frob-patch-rank
> @@ -0,0 +1,51 @@
> +#!/bin/sh
> +set -e
> +
> +script=$(basename $0)
> +
> +read -r -d '' usage << EOU || true

./frob-patch-rank: 6: read: Illegal option -d

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Feb 19 14:13 /bin/sh -> dash

how about just 

usage()
{
	cat << EOF
...
EOF
}

Sorry for causing you all this trouble... :(


Jani.



> +Usage: $script start end expr
> +
> +  Frob patches."
> +
> +  This tiny script renames \"git format-patch\" patches by executing 'expr'
> +  on the number that prefix the patch file, but only if the patch file name
> +  starts with a number in ['start','end'].
> +
> +Examples:
> +  $ ls *patch
> +  0008-Super-patch.patch
> +  0009-Mega-patch.patch
> +  $ $script 8 9 -7
> +  $ ls *patch
> +  0001-Super-patch.patch
> +  0002-Mega-patch.patch
> +
> +  $ ls *patch
> +  0117-Super-patch.patch
> +  0118-Mega-patch.patch
> +  $ $script 117 118 +900 -17
> +  $ ls *patch
> +  1000-Super-patch.patch
> +  1001-Mega-patch.patch
> +EOU
> +
> +[ $# -ge 3 ] || {
> +	echo "$usage"
> +	exit 1
> +}
> +
> +start=$1
> +end=$2
> +shift 2
> +op=$*
> +
> +for i in $(seq $start $end); do
> +	prefix=$(printf "%04d" $i)
> +	for f in $(ls $prefix-*.patch); do
> +		base=${f#$prefix-}
> +		((n=$i $op))
> +		new_prefix=$(printf "%04d" $n)
> +		mv -i $prefix-$base $new_prefix-$base
> +	done
> +done
> -- 
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center

  reply	other threads:[~2014-06-13 10:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10 11:45 [PATCH maintainer-tools] frob-patch-rank: A little script to batch renaming patch files Damien Lespiau
2014-06-10 11:57 ` Jani Nikula
2014-06-10 12:46   ` [PATCH v2 " Damien Lespiau
2014-06-13 10:00     ` Jani Nikula [this message]
2014-06-16 23:36       ` [PATCH v3 " Damien Lespiau
2014-06-17 10:09         ` Jani Nikula
2014-06-17 10:23           ` [PATCH v4 " Damien Lespiau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ioo5xh6w.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=damien.lespiau@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.