This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Keep patch file permissions in mklog
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Yury Gribov <y dot gribov at samsung dot com>, Diego Novillo <dnovillo at google dot com>
- Cc: Geoff Keating <geoffk at geoffk dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 2 Aug 2014 21:23:30 +0200
- Subject: Re: [PATCH] Keep patch file permissions in mklog
- Authentication-results: sourceware.org; auth=none
- References: <5389890F dot 2050501 at mentor dot com> <53DB15C5 dot 6070206 at samsung dot com> <53DB391C dot 7050808 at mentor dot com> <53DB3F2A dot 5070800 at samsung dot com>
On 01-08-14 09:18, Yury Gribov wrote:
On 08/01/2014 10:52 AM, Tom de Vries wrote:
This patch adds a script contrib/mklog-in-patch, which uses mklog to
generate the skeleton log, but generates the log at the start of the
patch as mklog did before (which is how I like to use it).
Yeah, we had some argument about this but kind of agreed that separate log is
preferred.
I can also try to add an --inline option to mklog instead.
I'd prefer this.
This patch implements an --inline option to mklog.
I've used the --inline option to prepend the skeleton log to this patch.
OK for trunk?
Thanks,
- Tom
2014-08-02 Tom de Vries <tom@codesourcery.com>
* mklog: Add --inline option.
diff --git a/contrib/mklog b/contrib/mklog
index 3d17dc5..ba075cf 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -56,19 +56,27 @@ if (-d "$gcc_root/.git") {
# Program starts here. You should not need to edit anything below this
# line.
#-----------------------------------------------------------------------------
-if ($#ARGV != 0) {
+$inline = 0;
+if ($#ARGV == 1 && ("$ARGV[0]" eq "-i" || "$ARGV[0]" eq "--inline")) {
+ $diff = $ARGV[1];
+ $inline = 1;
+ if ($diff eq "-") {
+ die "Reading from - and using -i are not compatible";
+ }
+} elsif ($#ARGV != 0) {
$prog = `basename $0`; chop ($prog);
print <<EOF;
-usage: $prog file.diff
+usage: $prog [ -i | --inline ] file.diff
Generate ChangeLog template for file.diff.
It assumes that patch has been created with -up or -cp.
When file.diff is -, read standard input.
EOF
exit 1;
+} else {
+ $diff = $ARGV[0];
}
-$diff = $ARGV[0];
$dir = `dirname $diff`; chop ($dir);
$basename = `basename $diff`; chop ($basename);
$hdrline = "$date $name <$addr>";
@@ -273,8 +281,32 @@ foreach (@diff_lines) {
# functions.
$cl_entries{$clname} .= $change_msg ? "$change_msg\n" : ":\n";
+if ($inline) {
+ $tmp = `mktemp`;
+ chomp ($tmp);
+ open (FILE1, '>', $tmp) or die "Could not open temp file";
+} else {
+ *FILE1 = STDOUT;
+}
+
+# Print the log
foreach my $clname (keys %cl_entries) {
- print "$clname:\n\n$hdrline\n\n$cl_entries{$clname}\n";
+ print FILE1 "$clname:\n\n$hdrline\n\n$cl_entries{$clname}\n";
+}
+
+
+# Prepend the log to the patch
+if ($inline) {
+ close (FILE1);
+
+ system ("cat $diff >>$tmp") == 0
+ or die "Could not append patch to temp file";
+
+ # We're using cat rather than move, to keep permissions on $diff the same.
+ system ("cat $tmp >$diff") == 0
+ or die "Could not move temp file to patch file";
+
+ unlink ($tmp) == 1 or die "Could not remove temp file";
}
exit 0;
--
1.9.1