Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v4] import-tars: Allow per-tar author and commit message.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:47:20

Peter Krefting [off-list ref] writes:
+	my $commit_msg = "Imported from $tar_file.";
+	my $this_committer_name = $committer_name;
+	my $this_committer_email = $committer_email;
+	my $this_author_name = $author_name;
+	my $this_author_email = $author_email;
+	if ($metaext ne '')
+	{
+		# Optionally read a commit message from <filename.tar>.msg
+		# Add a line on the form "Committer: name <e-mail>" to override
+		# the committer and "Author: name <e-mail>" to override the
+		# author for this tar ball.
+		if (open MSG, '<', "${tar_file}.${metaext}")
+		{
+			my $header_done = 0;
+			$commit_msg = '';
+			while (<MSG>)
+			{
+				if (!$header_done && /^Committer:\s+([^<>]*)\s+<(.*)>\s*$/i)
+				{
+					$this_committer_name = $1;
+					$this_committer_email = $2;
+				}
+				elsif (!$header_done && /^Author:\s+([^<>]*)\s+<(.*)>\s*$/i)
+				{
+					$this_author_name = $1;
+					$this_author_email = $2;
+				}
+				else
+				{
+					$commit_msg .= $_;
+					$header_done = 1;
+				}
+			}
+			close MSG;
+		}
+	}
+
I think people would expect that if they put a blank line after the header
part, it would be stripped away, because a format that has a list of
colon-separated key-value pairs, followed by a blank line, and then
followed by the body of the message is so familiar.

While you are at it, can you also fix the style?  Existing code in
import-tars.perl looks like this:

		if ($typeflag == 2) { # symbolic link
			print FI "data ", length($linkname), "\n", $linkname;
			$mode = 0120000;
		} else {
			print FI "data $size\n";
			while ($size > 0 && read(I, $_, 512) == 512) {
				print FI substr($_, 0, $size);
				$size -= 512;
			}
		}

i.e. opening brace comes at the end of the line of "if" and "else";
closing brace comes on the same line immediately before "else".
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help