@matheusbsbs / matheus-bagliano / commits / 88b5a74883
Fork 0

format-patch: fix two-argument special case, and make it easier to pick single commits

Luben Tuikov noticed that sometimes being able to say 'git-format-patch <commit>' to format the change a single commit introduces relative to its parent is handy. This patch does not support that directly, but it makes sense to interpret a single argument "rev" to mean "rev^1..rev". With this, the backward compatibility syntaxes still apply: - "format-patch master" means "format-patch master..HEAD" - "format-patch origin master" means "format-patch origin..master" - "format-patch origin.." means "format-patch origin..HEAD" But "format-patch a b c d e" formats the changes these five commits introduce relative to their respective parents. Earlier it rejected these arguments not in "one..two" form. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 21, 2005 at 12:17 UTC 88b5a74883f146eac4b15b30e74bbdeb5ab5a63a
1 file changed +3 -2
git-format-patch.sh
+3 -2
@@ -99,7 +99,7 @@ filelist=$tmp-files
99 # Also, "rev1.." should mean "rev1..HEAD"; git-diff users are
100 # familiar with that syntax.
101
102 -case "$#,$1" in
102 +case "$#,$1$2" in
103 1,?*..?*)
104 # single "rev1..rev2"
105 ;;
@@ -131,7 +131,8 @@ do
131 rev2=`expr "$revpair" : '.*\.\.\(.*\)'`
132 ;;
133 *)
134 - usage
134 + rev1="$revpair^"
135 + rev2="$revpair"
136 ;;
137 esac
138 git-rev-parse --verify "$rev1^0" >/dev/null 2>&1 ||