<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/patch-ids.c, branch v2.14.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.14.3</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.14.3'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2017-06-30T20:11:54Z</updated>
<entry>
<title>patch-ids.c: use hashmap correctly</title>
<updated>2017-06-30T20:11:54Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2017-06-30T19:14:06Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=3da492f8088413c9db2da6c489e117d4808859e9'/>
<id>urn:sha1:3da492f8088413c9db2da6c489e117d4808859e9</id>
<content type='text'>
As alluded to in the previous patch, the code in patch-ids.c is
using the hashmaps API wrong.

Luckily we do not have a bug, as all hashmap functionality that we use
here (hashmap_get) passes through the keydata.  If hashmap_get_next were
to be used, a bug would occur as that passes NULL for the key_data.

So instead use the hashmap API correctly and provide the caller required
data in the compare function via the first argument that always gets
passed and was setup via the hashmap_init function.

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hashmap.h: compare function has access to a data field</title>
<updated>2017-06-30T19:49:28Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2017-06-30T19:14:05Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=7663cdc86c860d5b5293a1dd4b0fb6c4e006d08e'/>
<id>urn:sha1:7663cdc86c860d5b5293a1dd4b0fb6c4e006d08e</id>
<content type='text'>
When using the hashmap a common need is to have access to caller provided
data in the compare function. A couple of times we abuse the keydata field
to pass in the data needed. This happens for example in patch-ids.c.

This patch changes the function signature of the compare function
to have one more void pointer available. The pointer given for each
invocation of the compare function must be defined in the init function
of the hashmap and is just passed through.

Documentation of this new feature is deferred to a later patch.
This is a rather mechanical conversion, just adding the new pass-through
parameter.  However while at it improve the naming of the fields of all
compare functions used by hashmaps by ensuring unused parameters are
prefixed with 'unused_' and naming the parameters what they are (instead
of 'unused' make it 'unused_keydata').

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-tree: convert diff_tree_sha1 to struct object_id</title>
<updated>2017-06-05T02:23:58Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-05-30T17:31:03Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=66f414f885aa6f44ae9e764bdd3e3cd7bd80c5a3'/>
<id>urn:sha1:66f414f885aa6f44ae9e764bdd3e3cd7bd80c5a3</id>
<content type='text'>
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>tree-diff: convert diff_root_tree_sha1 to struct object_id</title>
<updated>2017-06-02T00:36:30Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-05-30T17:30:57Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=7b8dea0c7570a2028f204498c82c8ca7ec6950e3'/>
<id>urn:sha1:7b8dea0c7570a2028f204498c82c8ca7ec6950e3</id>
<content type='text'>
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>diff: convert diff_flush_patch_id to struct object_id</title>
<updated>2017-06-02T00:36:07Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-05-30T17:30:54Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=bd25f288767aa26f42ac02d2d36695c8df9134dd'/>
<id>urn:sha1:bd25f288767aa26f42ac02d2d36695c8df9134dd</id>
<content type='text'>
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>patch-ids: convert to struct object_id</title>
<updated>2017-06-02T00:36:07Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2017-05-30T17:30:53Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=34f3c0ebfbe3c8075587e5b06d0fd280ea57f053'/>
<id>urn:sha1:34f3c0ebfbe3c8075587e5b06d0fd280ea57f053</id>
<content type='text'>
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>add_commit_patch_id(): avoid allocating memory unnecessarily</title>
<updated>2017-05-08T03:18:19Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2017-05-04T13:55:38Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=5748693b9123f55363211d18e8074db5e1b8384e'/>
<id>urn:sha1:5748693b9123f55363211d18e8074db5e1b8384e</id>
<content type='text'>
It would appear that we allocate (and forget to release) memory if the
patch ID is not even defined.

Reported by the Coverity tool.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&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://www.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>patch-ids: refuse to compute patch-id for merge commit</title>
<updated>2016-09-12T20:45:01Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-09-12T17:56:41Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=7c8104079239bb52380e32a11a686665fc16d040'/>
<id>urn:sha1:7c8104079239bb52380e32a11a686665fc16d040</id>
<content type='text'>
The patch-id code which powers "log --cherry-pick" doesn't
look at whether each commit is a merge or not. It just feeds
the commit's first parent to the diff, and ignores any
additional parents.

In theory, this might be useful if you wanted to find
equivalence between, say, a merge commit and a squash-merge
that does the same thing.  But it also promotes a false
equivalence between distinct merges. For example, every
"merge -s ours" would look identical to an empty commit
(which is true in a sense, but presumably there was a value
in merging in the discarded history). Since patch-ids are
meant for throwing away duplicates, we should err on the
side of _not_ matching such merges.

Moreover, we may spend a lot of extra time computing these
merge diffs. In the case that inspired this patch, a "git
format-patch --cherry-pick" dropped from over 3 minutes to
less than 3 seconds.

This seems pretty drastic, but is easily explained. The
command was invoked by a "git rebase" of an older topic
branch; there had been tens of thousands of commits on the
upstream branch in the meantime. In addition, this project
used a topic-branch workflow with occasional "back-merges"
from "master" to each topic (to resolve conflicts on the
topics rather than in the merge commits). So there were not
only extra merges, but the diffs for these back-merges were
generally quite large (because they represented _everything_
that had been merged to master since the topic branched).

This patch treats a merge fed to commit_patch_id() or
add_commit_patch_id() as an error, and a lookup for such a
merge via has_commit_patch_id() will always return NULL.
An earlier version of the patch tried to distinguish between
"error" and "patch id for merges not defined", but that
becomes unnecessarily complicated. The only callers are:

  1. revision traversals which want to do --cherry-pick;
     they call add_commit_patch_id(), but do not care if it
     fails. They only want to add what we can, look it up
     later with has_commit_patch_id(), and err on the side
     of not-matching.

  2. format-patch --base, which calls commit_patch_id().
     This _does_ notice errors, but should never feed a
     merge in the first place (and if it were to do so
     accidentally, then this patch is a strict improvement;
     we notice the bug rather than generating a bogus
     patch-id).

So in both cases, this does the right thing.

Helped-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>patch-ids: turn off rename detection</title>
<updated>2016-09-09T21:13:53Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-09-09T20:34:34Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=5a29cbc6e9c5f7d28228f4f389a122ca074a9c08'/>
<id>urn:sha1:5a29cbc6e9c5f7d28228f4f389a122ca074a9c08</id>
<content type='text'>
The patch-id code may be running inside another porcelain
like "git log" or "git format-patch", and therefore may have
set diff_detect_rename_default, either via the diff-ui
config, or by default since 5404c11 (diff: activate
diff.renames by default, 2016-02-25). This is the case even
if a command is run with `--no-renames`, as that is applied
only to the diff-options used by the command itself.

Rename detection doesn't help the patch-id results. It
_may_ actually hurt, as minor differences in the files that
would be overlooked by patch-id's canonicalization might
result in different renames (though I'd doubt that it ever
comes up in practice).

But mostly it is just a waste of CPU to compute these
renames.

Note that this does have one user-visible impact: the
prerequisite patches listed by "format-patch --base". There
may be some confusion between different versions of git as
older ones will enable renames, but newer ones will not.
However, this was already a problem, as people with
different settings for the "diff.renames" config would get
different results. After this patch, everyone should get the
same results, regardless of their config.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
