git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 28, 2009, 20:50 UTC
Message-ID
<7vskfbhdd5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20090828185652.448AD189B7B@perkele>
Peter Krefting <peter@softwolves.pp.se> writes:
Show 37 quoted lines
> +	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".

Previous: Peter Krefting
Message 2 of 2 in “import-tars: Allow per-tar author and commit message.”
  1. import-tars: Allow per-tar author and commit message.Peter Krefting, Aug 26, 2009
  2. Junio C HamanoAug 28, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.