<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/libgit2.git/tests/index/collision.c, branch ethomson/https_proxy</title>
<subtitle>github.com: libgit2/libgit2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/'/>
<entry>
<title>object_type: use new enumeration names</title>
<updated>2018-12-01T11:54:57+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2018-11-28T14:26:57+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=168fe39bea3368972a8b1a33d5908e73bc790c18'/>
<id>168fe39bea3368972a8b1a33d5908e73bc790c18</id>
<content type='text'>
Use the new object_type enumeration names within the codebase.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use the new object_type enumeration names within the codebase.
</pre>
</div>
</content>
</entry>
<entry>
<title>index: use new enum and structure names</title>
<updated>2018-12-01T10:46:44+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2018-11-28T13:31:06+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=18e71e6d597abe6c7feb666429c921bd19dc0ba8'/>
<id>18e71e6d597abe6c7feb666429c921bd19dc0ba8</id>
<content type='text'>
Use the new-style index names throughout our own codebase.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use the new-style index names throughout our own codebase.
</pre>
</div>
</content>
</entry>
<entry>
<title>index: fix adding index entries with conflicting files</title>
<updated>2018-10-19T10:28:28+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2018-09-21T13:18:03+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=8b6e28958c99b4f9effbbedb84ae779b3b1b9d98'/>
<id>8b6e28958c99b4f9effbbedb84ae779b3b1b9d98</id>
<content type='text'>
When adding an index entry "a/b/c" while an index entry "a/b" already
exists, git will happily remove "a/b/c" and only add the new index
entry:

    $ git init test
    Initialized empty Git repository in /tmp/test.repo/test/.git/
    $ touch x
    $ git add x
    $ rm x
    $ mkdir x
    $ touch x/y
    $ git add x/y
    $ git status
    A x/y

The other way round, adding an index entry "a/b" with an entry "a/b/c"
already existing is equivalent, where git will remove "a/b/c" and add
"a/b".

In contrast, libgit2 will currently fail to add these properly and
instead complain about the entry appearing as both a file and a
directory. This is a programming error, though: our current code already
tries to detect and, in the case of `git_index_add`, to automatically
replace such index entries. Funnily enough, we already remove the
conflicting index entries, but instead of adding the new entry we then
bail out afterwards. This leaves callers with the worst of both worlds:
we both remove the old entry but fail to add the new one.

The root cause is weird semantics of the `has_file_name` and
`has_dir_name` functions. While these functions only sound like they are
responsible for detecting such conflicts, they will also already remove
them in case where its `ok_to_replace` parameter is set. But even if we
tell it to replace such entries, it will return an error code.

Fix the error by returning success in case where the entries have been
replaced. Fix an already existing test which tested for wrong behaviour.
Note that the test didn't notice that the resulting tree had no entries.
Thus it is fine to change existing behaviour here, as the previous
result could've let to silently loosing data. Also add a new test that
verifies behaviour in the reverse conflicting case.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When adding an index entry "a/b/c" while an index entry "a/b" already
exists, git will happily remove "a/b/c" and only add the new index
entry:

    $ git init test
    Initialized empty Git repository in /tmp/test.repo/test/.git/
    $ touch x
    $ git add x
    $ rm x
    $ mkdir x
    $ touch x/y
    $ git add x/y
    $ git status
    A x/y

The other way round, adding an index entry "a/b" with an entry "a/b/c"
already existing is equivalent, where git will remove "a/b/c" and add
"a/b".

In contrast, libgit2 will currently fail to add these properly and
instead complain about the entry appearing as both a file and a
directory. This is a programming error, though: our current code already
tries to detect and, in the case of `git_index_add`, to automatically
replace such index entries. Funnily enough, we already remove the
conflicting index entries, but instead of adding the new entry we then
bail out afterwards. This leaves callers with the worst of both worlds:
we both remove the old entry but fail to add the new one.

The root cause is weird semantics of the `has_file_name` and
`has_dir_name` functions. While these functions only sound like they are
responsible for detecting such conflicts, they will also already remove
them in case where its `ok_to_replace` parameter is set. But even if we
tell it to replace such entries, it will return an error code.

Fix the error by returning success in case where the entries have been
replaced. Fix an already existing test which tested for wrong behaviour.
Note that the test didn't notice that the resulting tree had no entries.
Thus it is fine to change existing behaviour here, as the previous
result could've let to silently loosing data. Also add a new test that
verifies behaviour in the reverse conflicting case.
</pre>
</div>
</content>
</entry>
<entry>
<title>tests: index: do not re-allocate index</title>
<updated>2016-08-29T11:29:01+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2016-08-29T11:09:58+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=86e88534d6ad2982d7519084e4323e93829a571c'/>
<id>86e88534d6ad2982d7519084e4323e93829a571c</id>
<content type='text'>
Plug a memory leak caused by re-allocating a `git_index`
structure which has already been allocated by the test suite's
initializer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Plug a memory leak caused by re-allocating a `git_index`
structure which has already been allocated by the test suite's
initializer.
</pre>
</div>
</content>
</entry>
<entry>
<title>odb: actually insert the empty blob in tests</title>
<updated>2016-08-06T00:34:19+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@github.com</email>
</author>
<published>2016-08-06T00:34:19+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=9bc8c80ffa3d20e958406a104c521e2aae0f1255'/>
<id>9bc8c80ffa3d20e958406a104c521e2aae0f1255</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>conflict tests: use GIT_IDXENTRY_STAGE_SET</title>
<updated>2015-05-28T13:44:22+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@microsoft.com</email>
</author>
<published>2015-05-19T15:17:07+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=2f1080ea04ad1235efcd4b213dbe3a1b847644f7'/>
<id>2f1080ea04ad1235efcd4b213dbe3a1b847644f7</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>More index collision tests</title>
<updated>2014-01-29T21:15:53+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@microsoft.com</email>
</author>
<published>2014-01-29T20:53:01+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=bae8bea051806682fef48137e32f0305e94398b8'/>
<id>bae8bea051806682fef48137e32f0305e94398b8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add test for blob/tree name collisions in index</title>
<updated>2014-01-29T21:15:50+00:00</updated>
<author>
<name>Russell Belfer</name>
<email>rb@github.com</email>
</author>
<published>2014-01-29T00:22:37+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/libgit2.git/commit/?id=95fbedcd8eaaff2747196e20abd959596baf7e98'/>
<id>95fbedcd8eaaff2747196e20abd959596baf7e98</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
