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

Re: [PATCHv2 2/4] git-am foreign patch support: autodetect some patch formats

From
Junio C Hamano <gitster@pobox.com>
Date
May 27, 2009, 07:19 UTC
Message-ID
<7vd49vj9mb.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1243298290-5909-3-git-send-email-giuseppe.bilotta@gmail.com>
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> writes:
Show 41 quoted lines
> +	# otherwise, check the first few lines of the first patch to try
> +	# to detect its format
> +	{
> +		read l1
> +		read l2
> +		read l3
> +		case "$l1" in
> +			From\ *)
> +				patch_format=mbox
> +				;;
> +			From:\ *)
> +				patch_format=mbox
> +				;;
> +			'# This series applies on GIT commit'*)
> +				patch_format=stgit-series
> +				;;
> +			"# HG changeset patch")
> +				patch_format=hg
> +				;;
> +			*)
> +				# if the second line is empty and the third is
> +				# a From, Author or Date entry, this is very
> +				# likely an StGIT patch
> +				if test "x$l2" = x
> +				then
> +					case "$l3" in
> +						From:\ *)
> +							patch_format=stgit
> +							;;
> +						Author:\ *)
> +							patch_format=stgit
> +							;;
> +						Date:\ *)
> +							patch_format=stgit
> +							;;
> +						*)
> +							;;
> +					esac
> +				fi
> +				;;
> +		esac
Don't make the case unnecessary too deep nor redundant.
	...
	read l3
	case "$l1" in
	"From "* | "From: "* )
		patch_format=mbox
		;;
	"# This ...")
		...
		;;
	*)
		case "$l2,$l3" in
		,"From: "* | ,"Author: "* | ,"Date: "*)
			patch_format=stgit
			;;
		esac
		;;
	esac
Show 6 quoted lines
> +	} < "$1"
>  }
>  
>  split_patches () {
> -- 
> 1.6.3.1.248.gb44be
Previous: Junio C HamanoNext: Giuseppe Bilotta
Message 10 of 11 in “[PATCHv2 0/4] git-am support for foreign patches”
  1. Giuseppe BilottaMay 26, 2009
  2. 1/4 git-am foreign patch support: introduce patch_formatGiuseppe Bilotta, May 26, 2009
  3. 2/4 git-am foreign patch support: autodetect some patch formatsGiuseppe Bilotta, May 26, 2009
  4. 3/4 git-am foreign patch support: StGIT supportGiuseppe Bilotta, May 26, 2009
  5. 4/4 git-am: refactor 'cleaning up and aborting'Giuseppe Bilotta, May 26, 2009
  6. Junio C HamanoMay 27, 2009
  7. Junio C HamanoMay 27, 2009
  8. Giuseppe BilottaMay 27, 2009
  9. Junio C HamanoMay 27, 2009
  10. Junio C HamanoMay 27, 2009
  11. Giuseppe BilottaMay 27, 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.