All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre Habouzit <madcoder@debian.org>
To: Josef Jeff Sipek <jsipek@cs.sunysb.edu>
Cc: git@vger.kernel.org, Pierre Habouzit <madcoder@debian.org>
Subject: [PATCH] More regressions fixes.
Date: Thu, 14 Jun 2007 17:50:54 +0200	[thread overview]
Message-ID: <11818362542177-git-send-email-madcoder@debian.org> (raw)
In-Reply-To: <11818254621527-git-send-email-madcoder@debian.org>

  + use awk again to parse git-cat-file properly
  + fixes .new -> .tmp (always use the same suffix to avoid problems)
  + write in foo.tmp and move it, and not the reverse :)

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 guilt |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/guilt b/guilt
index 58df606..7c78cc7 100755
--- a/guilt
+++ b/guilt
@@ -177,16 +177,22 @@ do_make_header()
 		exit 2
 	fi
 
-	git-cat-file -p "$1" | sed -e \
-		'1,/^$/ {
-			/^author/ {
-				s/^author /From: /
-				s/ [0-9]* [+-]*[0-9][0-9]*$//
-				p
+	git-cat-file -p "$1" | awk '
+		BEGIN{headers=1; firstline=1}
+		/^author / && headers {
+			sub(/^author +/, "");
+			sub(/ [0-9]* [+-]*[0-9][0-9]*$/, "");
+			author=$0
+		}
+		!headers {
+			print
+			if (firstline) {
+				firstline = 0;
+				print "\nFrom: " author;
 			}
-			/^$/p
-			d
-		}'
+		}
+		/^$/ && headers { headers = 0 }
+	'
 }
 
 # usage: do_get_header patchfile
@@ -267,7 +273,7 @@ series_rename_patch()
 {
 	awk -v old="$1" -v new="$2" \
 		'{ if ($0 == old) print new; else print $0 }' \
-		"$series.tmp" > "$series"
+		"$series" > "$series.tmp"
 
 	mv "$series.tmp" "$series"
 }
@@ -284,7 +290,7 @@ applied_rename_patch()
 				print substr($0, 0, 41) new;
 			else
 				print;
-			}' "$applied" > "$applied.new"
+			}' "$applied" > "$applied.tmp"
 
 	mv "$applied.tmp" "$applied"
 }
-- 
1.5.2.1

  parent reply	other threads:[~2007-06-14 15:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-14 12:50 [PATCH guilt] make guilt use standard POSIX shell Pierre Habouzit
2007-06-14 12:50 ` [PATCH] Regression test suite needs bash, that's OK Pierre Habouzit
2007-06-14 12:50 ` [PATCH] guilt(1): Obvious bashisms fixed Pierre Habouzit
2007-06-14 15:15   ` Josef Sipek
2007-06-14 15:18     ` Pierre Habouzit
2007-06-14 12:50 ` [PATCH] guilt(1): simplifications Pierre Habouzit
2007-06-14 14:58   ` Josef Sipek
2007-06-14 15:16     ` Pierre Habouzit
2007-06-14 12:50 ` [PATCH] guilt(1): reimplement push_patch, using a subshell to avoid locals Pierre Habouzit
2007-06-14 12:51 ` [PATCH] Easy commands, without bashisms Pierre Habouzit
2007-06-14 12:51 ` [PATCH] guilt-status(1): Remove bashisms Pierre Habouzit
2007-06-14 12:51 ` [PATCH] Remove last bashisms from remaining commands Pierre Habouzit
2007-06-14 13:07 ` [PATCH guilt] make guilt use standard POSIX shell Pierre Habouzit
2007-06-14 13:20 ` [PATCH] Small regresson when series file is empty Pierre Habouzit
2007-06-14 15:27 ` [PATCH guilt] make guilt use standard POSIX shell Josef Sipek
2007-06-14 15:56   ` Pierre Habouzit
2007-06-14 15:58     ` Pierre Habouzit
2007-06-14 16:39       ` Josef Sipek
2007-06-14 17:16         ` Pierre Habouzit
2007-06-14 15:50 ` Pierre Habouzit [this message]
2007-06-15  8:01 ` Derek Fawcus
2007-06-15 22:31   ` Benjamin Sergeant

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=11818362542177-git-send-email-madcoder@debian.org \
    --to=madcoder@debian.org \
    --cc=git@vger.kernel.org \
    --cc=jsipek@cs.sunysb.edu \
    /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.