@@ -3,7 +3,7 @@ git-patch-id(1)
33
44NAME
55----
6- git-patch-id - Compute unique ID for a patch
6+ git-patch-id - Compute unique IDs for patches
77
88SYNOPSIS
99--------
@@ -12,7 +12,7 @@ git patch-id [--stable | --unstable | --verbatim]
1212
1313DESCRIPTION
1414-----------
15- Read a patch from the standard input and compute the patch ID for it .
15+ Read patches from standard input and compute the patch IDs .
1616
1717A "patch ID" is nothing but a sum of SHA-1 of the file diffs associated with a
1818patch, with line numbers ignored. As such, it's "reasonably stable", but at
@@ -25,7 +25,8 @@ When dealing with `git diff-tree --patch` output, it takes advantage of
2525the fact that the patch is prefixed with the object name of the
2626commit, and outputs two 40-byte hexadecimal strings. The first
2727string is the patch ID, and the second string is the commit ID.
28- This can be used to make a mapping from patch ID to commit ID.
28+ This can be used to make a mapping from patch ID to commit ID for a
29+ set or range of commits.
2930
3031OPTIONS
3132-------
@@ -67,6 +68,50 @@ This is the default if `patchid.stable` is set to `true`.
6768+
6869This is the default.
6970
71+ EXAMPLES
72+ --------
73+
74+ linkgit:git-cherry[1] shows what commits from a branch have patch ID
75+ equivalent commits in some upstream branch. But it only tells you
76+ whether such a commit exists or not. What if you wanted to know the
77+ relevant commits in the upstream? We can use this command to make a
78+ mapping between your branch and the upstream branch:
79+
80+ ----
81+ #!/bin/sh
82+
83+ upstream="$1"
84+ branch="$2"
85+ test -z "$branch" && branch=HEAD
86+ limit="$3"
87+ if test -n "$limit"
88+ then
89+ tail_opts="$limit".."$upstream"
90+ else
91+ since=$(git log --format=%aI "$upstream".."$branch" | tail -1)
92+ tail_opts=--since="$since"' '"$upstream"
93+ fi
94+ for_branch=$(mktemp)
95+ for_upstream=$(mktemp)
96+
97+ git rev-list --no-merges "$upstream".."$branch" |
98+ git diff-tree --patch --stdin |
99+ git patch-id --stable | sort >"$for_branch"
100+ git rev-list --no-merges $tail_opts |
101+ git diff-tree --patch --stdin |
102+ git patch-id --stable | sort >"$for_upstream"
103+ join -a1 "$for_branch" "$for_upstream" | cut -d' ' -f2,3
104+ rm "$for_branch"
105+ rm "$for_upstream"
106+ ----
107+
108+ Now the first column shows the commit from your branch and the second
109+ column shows the patch ID equivalent commit, if it exists.
110+
111+ SEE ALSO
112+ --------
113+ linkgit:git-cherry[1]
114+
70115GIT
71116---
72117Part of the linkgit:git[1] suite
0 commit comments