<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/libgit2.git/src/diff.h, branch ethomson/libssh2_not_libssh</title>
<subtitle>github.com: libgit2/libgit2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/'/>
<entry>
<title>consistent header guards</title>
<updated>2018-02-01T23:56:33+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2018-02-01T23:55:48+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=abb04caa2f74bb4783eb87202a904c0c3517df85'/>
<id>abb04caa2f74bb4783eb87202a904c0c3517df85</id>
<content type='text'>
use consistent names for the #include / #define header guard pattern.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
use consistent names for the #include / #define header guard pattern.
</pre>
</div>
</content>
</entry>
<entry>
<title>diff_generate: avoid excessive stats of .gitattribute files</title>
<updated>2018-01-03T16:28:24+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2018-01-03T16:07:36+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=d8896bda5c43616f3c755242703fce7c2a97ad67'/>
<id>d8896bda5c43616f3c755242703fce7c2a97ad67</id>
<content type='text'>
When generating a diff between two trees, for each file that is to be
diffed we have to determine whether it shall be treated as text or as
binary files. While git has heuristics to determine which kind of diff
to generate, users can also that default behaviour by setting or
unsetting the 'diff' attribute for specific files.

Because of that, we have to query gitattributes in order to determine
how to diff the current files. Instead of hitting the '.gitattributes'
file every time we need to query an attribute, which can get expensive
especially on networked file systems, we try to cache them instead. This
works perfectly fine for every '.gitattributes' file that is found, but
we hit cache invalidation problems when we determine that an attribuse
file is _not_ existing. We do create an entry in the cache for missing
'.gitattributes' files, but as soon as we hit that file again we
invalidate it and stat it again to see if it has now appeared.

In the case of diffing large trees with each other, this behaviour is
very suboptimal. For each pair of files that is to be diffed, we will
repeatedly query every directory component leading towards their
respective location for an attributes file. This leads to thousands or
even hundreds of thousands of wasted syscalls.

The attributes cache already has a mechanism to help in that scenario in
form of the `git_attr_session`. As long as the same attributes session
is still active, we will not try to re-query the gitmodules files at all
but simply retain our currently cached results. To fix our problem, we
can create a session at the top-most level, which is the initialization
of the `git_diff` structure, and use it in order to look up the correct
diff driver. As the `git_diff` structure is used to generate patches for
multiple files at once, this neatly solves our problem by retaining the
session until patches for all files have been generated.

The fix has been tested with linux.git by calling
`git_diff_tree_to_tree` and `git_diff_to_buf` with v4.10^{tree} and
v4.14^{tree}.

                | time    | .gitattributes stats
    without fix | 33.201s | 844614
    with fix    | 30.327s | 4441

While execution only improved by roughly 10%, the stat(3) syscalls for
.gitattributes files decreased by 99.5%. The benchmarks were quite
simple with best-of-three timings on Linux ext4 systems. One can assume
that for network based file systems the performance gain will be a lot
larger due to a much higher latency.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When generating a diff between two trees, for each file that is to be
diffed we have to determine whether it shall be treated as text or as
binary files. While git has heuristics to determine which kind of diff
to generate, users can also that default behaviour by setting or
unsetting the 'diff' attribute for specific files.

Because of that, we have to query gitattributes in order to determine
how to diff the current files. Instead of hitting the '.gitattributes'
file every time we need to query an attribute, which can get expensive
especially on networked file systems, we try to cache them instead. This
works perfectly fine for every '.gitattributes' file that is found, but
we hit cache invalidation problems when we determine that an attribuse
file is _not_ existing. We do create an entry in the cache for missing
'.gitattributes' files, but as soon as we hit that file again we
invalidate it and stat it again to see if it has now appeared.

In the case of diffing large trees with each other, this behaviour is
very suboptimal. For each pair of files that is to be diffed, we will
repeatedly query every directory component leading towards their
respective location for an attributes file. This leads to thousands or
even hundreds of thousands of wasted syscalls.

The attributes cache already has a mechanism to help in that scenario in
form of the `git_attr_session`. As long as the same attributes session
is still active, we will not try to re-query the gitmodules files at all
but simply retain our currently cached results. To fix our problem, we
can create a session at the top-most level, which is the initialization
of the `git_diff` structure, and use it in order to look up the correct
diff driver. As the `git_diff` structure is used to generate patches for
multiple files at once, this neatly solves our problem by retaining the
session until patches for all files have been generated.

The fix has been tested with linux.git by calling
`git_diff_tree_to_tree` and `git_diff_to_buf` with v4.10^{tree} and
v4.14^{tree}.

                | time    | .gitattributes stats
    without fix | 33.201s | 844614
    with fix    | 30.327s | 4441

While execution only improved by roughly 10%, the stat(3) syscalls for
.gitattributes files decreased by 99.5%. The benchmarks were quite
simple with best-of-three timings on Linux ext4 systems. One can assume
that for network based file systems the performance gain will be a lot
larger due to a much higher latency.
</pre>
</div>
</content>
</entry>
<entry>
<title>Make sure to always include "common.h" first</title>
<updated>2017-07-03T08:51:48+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2017-06-30T11:39:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=0c7f49dd4316b332f30b4ea72a657bace41e1245'/>
<id>0c7f49dd4316b332f30b4ea72a657bace41e1245</id>
<content type='text'>
Next to including several files, our "common.h" header also declares
various macros which are then used throughout the project. As such, we
have to make sure to always include this file first in all
implementation files. Otherwise, we might encounter problems or even
silent behavioural differences due to macros or defines not being
defined as they should be. So in fact, our header and implementation
files should make sure to always include "common.h" first.

This commit does so by establishing a common include pattern. Header
files inside of "src" will now always include "common.h" as its first
other file, separated by a newline from all the other includes to make
it stand out as special. There are two cases for the implementation
files. If they do have a matching header file, they will always include
this one first, leading to "common.h" being transitively included as
first file. If they do not have a matching header file, they instead
include "common.h" as first file themselves.

This fixes the outlined problems and will become our standard practice
for header and source files inside of the "src/" from now on.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Next to including several files, our "common.h" header also declares
various macros which are then used throughout the project. As such, we
have to make sure to always include this file first in all
implementation files. Otherwise, we might encounter problems or even
silent behavioural differences due to macros or defines not being
defined as they should be. So in fact, our header and implementation
files should make sure to always include "common.h" first.

This commit does so by establishing a common include pattern. Header
files inside of "src" will now always include "common.h" as its first
other file, separated by a newline from all the other includes to make
it stand out as special. There are two cases for the implementation
files. If they do have a matching header file, they will always include
this one first, leading to "common.h" being transitively included as
first file. If they do not have a matching header file, they instead
include "common.h" as first file themselves.

This fixes the outlined problems and will become our standard practice
for header and source files inside of the "src/" from now on.
</pre>
</div>
</content>
</entry>
<entry>
<title>Teach `git_patch_from_diff` about parsed diffs</title>
<updated>2016-08-24T14:08:57+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@github.com</email>
</author>
<published>2016-08-24T04:38:39+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=b859faa61ce3f1fda5c29ac1e72a3d58fee2ede6'/>
<id>b859faa61ce3f1fda5c29ac1e72a3d58fee2ede6</id>
<content type='text'>
Ensure that `git_patch_from_diff` can return the patch for parsed diffs,
not just generate a patch for a generated diff.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Ensure that `git_patch_from_diff` can return the patch for parsed diffs,
not just generate a patch for a generated diff.
</pre>
</div>
</content>
</entry>
<entry>
<title>introduce `git_diff_from_buffer` to parse diffs</title>
<updated>2016-05-26T18:01:09+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@github.com</email>
</author>
<published>2016-04-25T04:35:48+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=7166bb16659790ae2b398e1e95c752f784f6f1d3'/>
<id>7166bb16659790ae2b398e1e95c752f784f6f1d3</id>
<content type='text'>
Parse diff files into a `git_diff` structure.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Parse diff files into a `git_diff` structure.
</pre>
</div>
</content>
</entry>
<entry>
<title>git_diff_generated: abstract generated diffs</title>
<updated>2016-05-26T18:01:08+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@github.com</email>
</author>
<published>2016-04-19T19:12:18+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=9be638ecf0d64ec98b3fd16f2d983a86d1aca131'/>
<id>9be638ecf0d64ec98b3fd16f2d983a86d1aca131</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>checkout: only consider nsecs when built that way</title>
<updated>2015-11-23T20:49:54+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@microsoft.com</email>
</author>
<published>2015-11-23T20:49:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=25e84f959ae77f21c32849aa98f274b9d8283f2d'/>
<id>25e84f959ae77f21c32849aa98f274b9d8283f2d</id>
<content type='text'>
When examining the working directory and determining whether it's
up-to-date, only consider the nanoseconds in the index entry when
built with `GIT_USE_NSEC`.  This prevents us from believing that
the working directory is always dirty when the index was originally
written with a git client that uinderstands nsecs (like git 2.x).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When examining the working directory and determining whether it's
up-to-date, only consider the nanoseconds in the index entry when
built with `GIT_USE_NSEC`.  This prevents us from believing that
the working directory is always dirty when the index was originally
written with a git client that uinderstands nsecs (like git 2.x).
</pre>
</div>
</content>
</entry>
<entry>
<title>Only write index if updated when passing GIT_DIFF_UPDATE_INDEX</title>
<updated>2015-06-26T06:00:21+00:00</updated>
<author>
<name>Pierre-Olivier Latour</name>
<email>pol@mac.com</email>
</author>
<published>2015-06-06T01:26:49+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=c2e1b0581ada8453447bdeaacca92d972d83b1a8'/>
<id>c2e1b0581ada8453447bdeaacca92d972d83b1a8</id>
<content type='text'>
When diffing the index with the workdir and GIT_DIFF_UPDATE_INDEX has been passed,
the previous implementation was always writing the index to disk even if it wasn't
modified.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When diffing the index with the workdir and GIT_DIFF_UPDATE_INDEX has been passed,
the previous implementation was always writing the index to disk even if it wasn't
modified.
</pre>
</div>
</content>
</entry>
<entry>
<title>stash: save the workdir file when deleted in index</title>
<updated>2015-06-23T23:15:16+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@microsoft.com</email>
</author>
<published>2015-06-23T20:27:33+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=9017711143ed106ec75df8fc007e383b0c90e18e'/>
<id>9017711143ed106ec75df8fc007e383b0c90e18e</id>
<content type='text'>
When stashing the workdir tree, examine the index as well.  Using
a mechanism similar to `git_diff_tree_to_workdir_with_index`
allows us to determine that a file was added in the index and
subsequently modified in the working directory.  Without examining
the index, we would erroneously believe that this file was
untracked and fail to include it in the working directory tree.

Use a slightly modified `git_diff_tree_to_workdir_with_index` in
order to avoid some of the behavior custom to `git diff`.  In
particular, be sure to include the working directory side of a
file when it was deleted in the index.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When stashing the workdir tree, examine the index as well.  Using
a mechanism similar to `git_diff_tree_to_workdir_with_index`
allows us to determine that a file was added in the index and
subsequently modified in the working directory.  Without examining
the index, we would erroneously believe that this file was
untracked and fail to include it in the working directory tree.

Use a slightly modified `git_diff_tree_to_workdir_with_index` in
order to avoid some of the behavior custom to `git diff`.  In
particular, be sure to include the working directory side of a
file when it was deleted in the index.
</pre>
</div>
</content>
</entry>
<entry>
<title>git_diff__merge: allow pluggable diff merges</title>
<updated>2015-06-23T20:48:50+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@microsoft.com</email>
</author>
<published>2015-06-23T14:29:59+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/libgit2.git/commit/?id=5ef43d41b036d4178c6d886c2222db9dd7f32fc1'/>
<id>5ef43d41b036d4178c6d886c2222db9dd7f32fc1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
