<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/builtin/patch-id.c, branch v2.40.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.40.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.40.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2022-10-24T22:44:20Z</updated>
<entry>
<title>builtin: patch-id: remove unused diff-tree prefix</title>
<updated>2022-10-24T22:44:20Z</updated>
<author>
<name>Jerry Zhang</name>
<email>Jerry@skydio.com</email>
</author>
<published>2022-10-24T20:07:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0d32ae8d7ffab444a83ce1db11e5341a95d109dd'/>
<id>urn:sha1:0d32ae8d7ffab444a83ce1db11e5341a95d109dd</id>
<content type='text'>
The last git version that had "diff-tree" in the header text
of "git diff-tree" output was v1.3.0 from 2006. The header text
was changed from "diff-tree" to "commit" in 91539833
("Log message printout cleanups").

Given how long ago this change was made, it is highly unlikely that
anyone is still feeding in outputs from that git version.

Remove the handling of the "diff-tree" prefix and document the
source of the other prefixes so that the overall functionality
is more clear.

Signed-off-by: Jerry Zhang &lt;Jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin: patch-id: add --verbatim as a command mode</title>
<updated>2022-10-24T22:44:20Z</updated>
<author>
<name>Jerry Zhang</name>
<email>jerry@skydio.com</email>
</author>
<published>2022-10-24T20:07:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2871f4d447214874e13cf764ab3a170c9d844ca2'/>
<id>urn:sha1:2871f4d447214874e13cf764ab3a170c9d844ca2</id>
<content type='text'>
There are situations where the user might not want the default
setting where patch-id strips all whitespace. They might be working
in a language where white space is syntactically important, or they
might have CI testing that enforces strict whitespace linting. In
these cases, a whitespace change would result in the patch
fundamentally changing, and thus deserving of a different id.

Add a new mode that is exclusive of --stable and --unstable called
--verbatim. It also corresponds to the config
patchid.verbatim = true. In this mode, the stable algorithm is
used and whitespace is not stripped from the patch text.

Users of --unstable mainly care about compatibility with old git
versions, which unstripping the whitespace would break. Thus there
isn't a usecase for the combination of --verbatim and --unstable,
and we don't expose this so as to not add maintainence burden.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
fixes https://github.com/Skydio/revup/issues/2
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>builtin: patch-id: fix patch-id with binary diffs</title>
<updated>2022-10-24T22:44:19Z</updated>
<author>
<name>Jerry Zhang</name>
<email>Jerry@skydio.com</email>
</author>
<published>2022-10-24T20:07:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0df19eb9d905ff9b6115139106d98d8f0a8a9046'/>
<id>urn:sha1:0df19eb9d905ff9b6115139106d98d8f0a8a9046</id>
<content type='text'>
"git patch-id" currently doesn't produce correct output if the
incoming diff has any binary files. Add logic to get_one_patchid
to handle the different possible styles of binary diff. This
attempts to keep resulting patch-ids identical to what would be
produced by the counterpart logic in diff.c, that is it produces
the id by hashing the a and b oids in succession.

In general we handle binary diffs by first caching the object ids from
the "index" line and using those if we then find an indication
that the diff is binary.

The input could contain patches generated with "git diff --binary". This
currently breaks the parse logic and results in multiple patch-ids
output for a single commit. Here we have to skip the contents of the
patch itself since those do not go into the patch id. --binary
implies --full-index so the object ids are always available.

When the diff is generated with --full-index there is no patch content
to skip over.

When a diff is generated without --full-index or --binary, it will
contain abbreviated object ids. This will still result in a sufficiently
unique patch-id when hashed, but does not match internal patch id
output. We'll call this ok for now as we already need specialized
arguments to diff in order to match internal patch id (namely -U3).

Signed-off-by: Jerry Zhang &lt;Jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>patch-id: fix scan_hunk_header on diffs with 1 line of before/after</title>
<updated>2022-02-02T19:24:23Z</updated>
<author>
<name>Jerry Zhang</name>
<email>jerry@skydio.com</email>
</author>
<published>2022-02-02T04:19:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=757e75c81e4332e363b90a0534a657b1bb6546fa'/>
<id>urn:sha1:757e75c81e4332e363b90a0534a657b1bb6546fa</id>
<content type='text'>
Normally diffs will contain a hunk header of the format
"@@ -2,2 +2,15 @@ code". However when there is only 1 line of
change, the unified diff format allows for the second comma
separated value to be omitted in either before or after
line counts.

This can produce hunk headers that look like
"@@ -2 +2,18 @@ code" or "@@ -2,2 +2 @@ code".
As a result, scan_hunk_header mistakenly returns the line
number as line count, which then results in unpredictable
parsing errors with the rest of the patch, including giving
multiple lines of output for a single commit.

Fix by explicitly setting line count to 1 when there is
no comma, and add a test.

apply.c contains this same logic except it is correct. A
worthwhile future project might be to unify these two diff
parsers so they both benefit from fixes.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>patch-id: use oid_to_hex() to print multiple object IDs</title>
<updated>2019-12-09T20:26:40Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2019-12-07T19:16:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4507ecc7710e172ed36421eaa4efe743785ccb4b'/>
<id>urn:sha1:4507ecc7710e172ed36421eaa4efe743785ccb4b</id>
<content type='text'>
flush_current_id() prints the hexadecimal representation of two object
IDs.  When the code was added in f97672225b (Add "git-patch-id" program
to generate patch ID's., 2005-06-23), sha1_to_hex() had only a single
internal static buffer, so the result of one invocation had to be stored
in a local buffer.

Since dcb3450fd8 (sha1_to_hex() usage cleanup, 2006-05-03) it rotates
through four buffers, which allows to print up to four object IDs at the
same time.  1a876a69af6 (patch-id: convert to use struct object_id,
2015-03-13) replaced sha1_to_hex() with oid_to_hex(), which has the same
feature.  Use it to simplify the code.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Acked-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>patch-id: convert to use the_hash_algo</title>
<updated>2019-08-19T22:04:57Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2019-08-18T20:04:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=36261e42ec30477434f3325f279fd91a1d9eb434'/>
<id>urn:sha1:36261e42ec30477434f3325f279fd91a1d9eb434</id>
<content type='text'>
Convert the two separate patch-id implementations to use the_hash_algo
in their implementation.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>format-patch: make --base patch-id output stable</title>
<updated>2019-05-08T10:27:43Z</updated>
<author>
<name>Stephen Boyd</name>
<email>sboyd@kernel.org</email>
</author>
<published>2019-04-26T23:51:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a8f6855f48fd474719e92eecc66c29a28fdc0f46'/>
<id>urn:sha1:a8f6855f48fd474719e92eecc66c29a28fdc0f46</id>
<content type='text'>
We weren't flushing the context each time we processed a hunk in the
patch-id generation code in diff.c, but we were doing that when we
generated "stable" patch-ids with the 'patch-id' tool. Let's port that
similar logic over from patch-id.c into diff.c so we can get the same
hash when we're generating patch-ids for 'format-patch --base=' types of
command invocations.

Cc: Xiaolong Ye &lt;xiaolong.ye@intel.com&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@kernel.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>config: don't include config.h by default</title>
<updated>2017-06-15T19:56:22Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-06-14T18:07:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b2141fc1d20e659810245ec6ca1c143c60e033ec'/>
<id>urn:sha1:b2141fc1d20e659810245ec6ca1c143c60e033ec</id>
<content type='text'>
Stop including config.h by default in cache.h.  Instead only include
config.h in those files which require use of the config system.

Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZ</title>
<updated>2017-03-27T05:08:21Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2017-03-26T16:01:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cd02599c480570484ec0a38a5bf66ac69ee3dd19'/>
<id>urn:sha1:cd02599c480570484ec0a38a5bf66ac69ee3dd19</id>
<content type='text'>
Since we will likely be introducing a new hash function at some point,
and that hash function might be longer than 20 bytes, use the constant
GIT_MAX_RAWSZ, which is designed to be suitable for allocations, instead
of GIT_SHA1_RAWSZ.  This will ease the transition down the line by
distinguishing between places where we need to allocate memory suitable
for the largest hash from those where we need to handle the current
hash.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/patch-id-use-skip-prefix'</title>
<updated>2016-06-03T21:38:03Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-06-03T21:38:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=29e54b019f55f48af3f0d4c62eede86058c16b52'/>
<id>urn:sha1:29e54b019f55f48af3f0d4c62eede86058c16b52</id>
<content type='text'>
Code clean-up.

* rs/patch-id-use-skip-prefix:
  patch-id: use starts_with() and skip_prefix()
</content>
</entry>
</feed>
