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

Re: [PATCH] Handle "git show" output correctly.

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Sep 12, 2012, 15:40 UTC
Message-ID
<vpqpq5rz1ua.fsf@bauges.imag.fr>
In-Reply-To
<1347463571-16831-1-git-send-email-pjones@redhat.com>
> Subject: Re: [PATCH] Handle "git show" output correctly.
No final period please.

This does not say which part of git is made to handle "git show". What about

[PATCH] am: handle "git show" output correctly
Peter Jones <pjones@redhat.com> writes:

This lacks a proper commit message, i.e. an answer to the "why is this change good?" question.

> Signed-off-by: Peter Jones <pjones@redhat.com>
> ---
>  git-am.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
Documentation?
Show 21 quoted lines
> --- a/git-am.sh
> +++ b/git-am.sh
> @@ -216,6 +216,21 @@ check_patch_format () {
>  		read l2
>  		read l3
>  		case "$l1" in
> +                "commit "*)
> +                        case "$l2" in
> +                        "Author: "*)
> +                                case "$l3" in
> +                                "Date: "*)
> +                                        patch_format=gitshow
> +                                        ;;
> +                                *)
> +                                        ;;
> +                                esac
> +                                ;;
> +                        *)
> +                                ;;
> +                        esac
> +                        ;;

Your code is indented with space, Git indents with tabs. Please fix this in your next version.

Show 9 quoted lines
>  			patch_format=mbox
>  			;;
> @@ -321,6 +336,37 @@ split_patches () {
>  		this=
>  		msgnum=
>  		;;
> +        gitshow)
> +		this=0
> +		for stgit in "$@"

Probably a cut-and-paste from the stgit version, but your variable naming doesn't make sense here.

> +		do
> +			this=`expr "$this" + 1`
> +			msgnum=`printf "%0${prec}d" $this`
> +			# Perl version of The first nonemptyline after an
Wrong cut-and-paste again, the sentense doesn't parse.
Show 17 quoted lines
> +                        # empty line is the subject, and the body starts with
> +                        # the next nonempty line.
> +			perl -ne 'BEGIN { $subject = 0 }
> +				if ($subject > 1) { print ; }
> +				elsif (/^\s+$/) { next ; }
> +				elsif (/^Author:/) { s/Author/From/ ; print ;}
> +				elsif (/^(From|Date)/) { print ; }
> +                                elsif (/^commit/) { next ; }
> +				elsif ($subject) {
> +					$subject = 2 ;
> +					print "\n" ;
> +                                        s/^    // ;
> +					print ;
> +				} else {
> +					print "Subject: ", $_ ;
> +					$subject = 1;
> +				}
How does this react to multi-line subject, e.g

This should be the subject line.

And this is the body.
?

git format-patch will merge the lines in a single Subject: header, and your version seems to take only the first line.

A test showing this would be welcome.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Peter JonesNext: Peter Jones
Message 10 of 21 in “Handle "git show" output correctly.”
  1. Handle "git show" output correctly.Peter Jones, Sep 12, 2012
  2. Handle "git show" output correctly.Peter Jones, Sep 12, 2012
  3. Matthieu MoySep 12, 2012
  4. [git-am] Handle "git show" output correctlyPeter Jones, Sep 12, 2012
  5. Matthieu MoySep 12, 2012
  6. Junio C HamanoSep 12, 2012
  7. Peter JonesSep 12, 2012
  8. Junio C HamanoSep 12, 2012
  9. Handle "git show" output correctly.Peter Jones, Sep 12, 2012
  10. Matthieu MoySep 12, 2012
  11. Peter JonesSep 12, 2012
  12. git-am: Handle "git show" output correctlyPeter Jones, Sep 12, 2012
  13. Junio C HamanoSep 12, 2012
  14. Peter JonesSep 12, 2012
  15. git-am: Handle "git show" output correctlyPeter Jones, Sep 12, 2012
  16. Junio C HamanoSep 12, 2012
  17. Dan JohnsonSep 12, 2012
  18. Junio C HamanoSep 12, 2012
  19. Dan JohnsonSep 12, 2012
  20. Junio C HamanoSep 12, 2012
  21. Andreas EricssonSep 12, 2012

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.