[PATCH] More regressions fixes.

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

 



  + 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@xxxxxxxxxx>
---
 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux