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

Re: [RFC] git-format-patch options

From
Junio C Hamano <junkio@cox.net>
Date
Nov 21, 2005, 19:27 UTC
Message-ID
<7vhda5ssxb.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20051121162540.4722.qmail@web31812.mail.mud.yahoo.com>
Luben Tuikov <ltuikov@yahoo.com> writes:
Show 7 quoted lines
> I was wondering about the value of
>
>   git-format-patch <commit-ish>
>
> to output/prepare a diff patch between the indicated commit
> and its parent.  As opposed to the current behaviour giving
> all changes between the indicated commit and HEAD.

Yes, that would be "git-format-patch $commit^1 $commit", but it might deserve better shortcuts.

Later Andreas quoted the backward compatibility constraints:
Show 10 quoted lines
> # Backward compatible argument parsing hack.
> #
> # Historically, we supported:
> # 1. "rev1"     is equivalent to "rev1..HEAD"
> # 2. "rev1..rev2"
> # 3. "rev1" "rev2   is equivalent to "rev1..rev2"
> #
> # We want to take a sequence of "rev1..rev2" in general.
> # Also, "rev1.." should mean "rev1..HEAD"; git-diff users are
> # familiar with that syntax.

The case statement that follows that comment is not quite right, BTW. "format-patch foo bar..baz" should mean sequence of "foo" and then "bar..baz", but it incorrectly translates to a malformed "foo..bar..baz".

Modulo that bug, what the current code does is to special case one or two arguments case and rewrite them in that case statement, and then iterate over the resulting "$@". We barf if each 'revpair' is not in rev1..rev2 format.

But it might make sense to (still keeping the above three backward compatibility syntax exceptions) interpret "rev" to mean "rev^1..rev", like this:

---
diff --git a/git-format-patch.sh b/git-format-patch.sh
index 7ee5d32..351790c 100755
--- a/git-format-patch.sh
+++ b/git-format-patch.sh
@@ -99,7 +99,7 @@ filelist=$tmp-files
 # Also, "rev1.." should mean "rev1..HEAD"; git-diff users are
 # familiar with that syntax.
 
-case "$#,$1" in
+case "$#,$1$2" in
 1,?*..?*)
 	# single "rev1..rev2"
 	;;
@@ -131,7 +131,8 @@ do
 		rev2=`expr "$revpair" : '.*\.\.\(.*\)'`
 		;;
 	*)
-		usage
+		rev1="$revpair^"
+		rev2="$revpair"
 		;;
 	esac
 	git-rev-parse --verify "$rev1^0" >/dev/null 2>&1 ||
Previous: Luben TuikovNext: Luben Tuikov
Message 8 of 9 in “[RFC] git-format-patch options”
  1. Luben TuikovNov 21, 2005
  2. Andreas EricssonNov 21, 2005
  3. Luben TuikovNov 21, 2005
  4. Andreas EricssonNov 21, 2005
  5. Luben TuikovNov 21, 2005
  6. Ryan AndersonNov 21, 2005
  7. Luben TuikovNov 22, 2005
  8. Junio C HamanoNov 21, 2005
  9. Luben TuikovNov 22, 2005

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.