All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Jean Delvare <jdelvare@suse.de>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Andreas Grünbacher" <andreas.gruenbacher@gmail.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
	"Oleg Nesterov" <oleg@redhat.com>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	quilt-dev@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Paul McKenney" <paulmck@linux.vnet.ibm.com>,
	"Ingo Molnar" <mingo@kernel.org>
Subject: Re: [Quilt-dev] Quilt vs gmail
Date: Wed, 13 Jun 2018 15:35:08 +0200	[thread overview]
Message-ID: <20180613133508.GA3291@kroah.com> (raw)
In-Reply-To: <20180613150025.62cf94ca@endymion>

[-- Attachment #1: Type: text/plain, Size: 1711 bytes --]

On Wed, Jun 13, 2018 at 03:00:25PM +0200, Jean Delvare wrote:
> On Tue, 12 Jun 2018 12:23:26 -0700, Linus Torvalds wrote:
> > On Tue, Jun 12, 2018 at 11:52 AM Andreas Grünbacher
> > <andreas.gruenbacher@gmail.com> wrote:
> > >
> > > Quilt uses those Content-Disposition headers to preserve the patch
> > > filenames;  
> > 
> > That' what I was assuming, but does anybody really care?
> 
> Long ago (probably a decade by now, literally) I wrote a shell script
> named "rename-patch" for Greg KH which suggests a file name for a patch
> received by e-mail. The script first looks for a "filename" attribute
> in the Content-Disposition header, and only if not found, falls back to
> a heuristic which attempts to generate a good-looking file name based
> on the e-mail's subject.
> 
> The script used to be published on my kernel.org personal web space,
> but went away when kernel.org got hacked, and I never bothered
> publishing my few scripts again, sorry about that.
> 
> I'm still using that script myself, to name patches generated with "git
> show --pretty=email", however there is no Content-Disposition header
> there, so the subject heuristic is always used. I don't know if Greg is
> still using rename-patch in combination with quilt. Greg?

Yes I am, I also use it for other things, it's quite useful to me.  It's
attached below if anyone else wants it.

But I don't really use the Content-Disposition portion of the logic in
that script much, if any, anymore as I handle most of my normal kernel
work using git.  I only use quilt these days for local work before using
git, and for all of my stable kernel work.

So if that logic goes away in quilt, I'm not going to miss it :)

thanks,

greg k-h

[-- Attachment #2: rename-patch --]
[-- Type: text/plain, Size: 2076 bytes --]

#!/bin/bash

# Rename patch files according to the Content-Disposition header line
# if they do have one, or Subject if they don't.
#
# Copyright (C) 2005, 2006, 2008  Jean Delvare <khali@linux-fr.org>
#
# 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; either version 2
# of the License, or (at your option) any later version.
# 
# 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/copyleft/gpl.html
#
# The latest official version of this script can be found at:
# ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/scripts/rename-patch

# Avoid nasty locale effects
export LC_ALL=C

findname()
{
	local file="$1" pattern;

	# Try Content-Disposition first
	pattern='^Content-Disposition:[[:space:]]*inline[[:space:]]*;[[:space:]]*filename[[:space:]]*=';
	if grep -q $pattern "$file"
	then
		sed -ne "/$pattern/{s/$pattern[[:space:]]*//p;q}" "$file"
		return
	fi

	# Fallback to Subject
	pattern='^Subject:';
	if grep -q $pattern "$file"
	then
		sed -ne "/$pattern/{
			s/$pattern[[:space:]]*//;
			s/\[[^]]*\]//g;
			s/[^a-z0-9._-]/-/ig;
			s/--*/-/g;
			s/^-//;
			s/^re-//i;
			s/[.-]*$/.patch/;
			p;q}" "$file" | \
		tr A-Z a-z
		return
	fi
}

if [ $# -eq 0 ]
then
	echo "Usage: rename-patch file [file...]" >&2
	exit 1
fi

for file in "$@"
do
	name=$(findname "$file")
	if echo "$file" | grep -q '/'
	then
		path=$(echo "$file" | sed -e 's/\/[^/]*$/\//')
	else
		path=''
	fi

	if [ -z "$name" ]
	then
		echo "No name found for $file" >&2
		continue
	fi

	if [ "$path$name" == "$file" ]
	then
		# It's already OK
		continue
	fi

	if [ -e "$path$name" ]
	then
		echo "Can't rename $file to $path$name which already exists" >&2
		continue
	fi

	mv -f "$file" "$path$name"
#	echo "$file renamed to $path$name"
	echo "$path$name"
done

  reply	other threads:[~2018-06-13 13:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12  8:34 [PATCH 0/3] sched/swait: Convert to full exclusive mode Peter Zijlstra
2018-06-12  8:34 ` [PATCH 1/3] sched/swait: Remove __prepare_to_swait Peter Zijlstra
2018-06-20  9:39   ` [tip:sched/core] " tip-bot for Peter Zijlstra
2018-06-12  8:34 ` [PATCH 2/3] sched/swait: Switch to full exclusive mode Peter Zijlstra
2018-06-20  9:40   ` [tip:sched/core] " tip-bot for Peter Zijlstra
2018-06-12  8:34 ` [PATCH 3/3] sched/swait: Rename to exclusive Peter Zijlstra
2018-06-20  9:40   ` [tip:sched/core] " tip-bot for Peter Zijlstra
2018-06-12 16:47 ` [PATCH 0/3] sched/swait: Convert to full exclusive mode Linus Torvalds
2018-06-12 17:14   ` Quilt vs gmail (Was: [PATCH 0/3] sched/swait: Convert to full exclusive mode) Peter Zijlstra
2018-06-13 12:32     ` Jean Delvare
2018-06-13 13:27       ` Andreas Grünbacher
2018-06-13 13:48         ` Linus Torvalds
2018-06-13 14:40         ` Jean Delvare
2018-06-12 18:52   ` [PATCH 0/3] sched/swait: Convert to full exclusive mode Andreas Grünbacher
     [not found]     ` <CA+55aFx81igOjFZcvO03mvDFd3=pxsq2QuNrWrPW+4pvJy780A@mail.gmail.com>
2018-06-12 19:43       ` Thomas Gleixner
2018-06-12 21:54         ` Sebastian Andrzej Siewior
2018-06-12 22:03           ` Linus Torvalds
2018-06-12 22:55             ` Randy Dunlap
2018-06-13 13:00       ` [Quilt-dev] Quilt vs gmail Jean Delvare
2018-06-13 13:35         ` Greg KH [this message]
2018-06-14  1:27 ` [PATCH 0/3] sched/swait: Convert to full exclusive mode Paul E. McKenney
2018-06-19 14:49   ` Paul E. McKenney

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=20180613133508.GA3291@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=andreas.gruenbacher@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=jdelvare@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=quilt-dev@nongnu.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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.