Commit Graph

3062 Commits

Author SHA1 Message Date
Carlos Martín Nieto
b200a813c0 config: fix Unicode BOM detection
Defining the BOM as a string makes the array include the
NUL-terminator, which means that the memcpy is going to check for that
as well and thus never match for a nonempty file.

Define the array as three chars, which makes the size correct.
2012-09-14 20:46:34 +02:00
Russell Belfer
f4ea176fa8 Remove unnecessary include
I don't think clone.c needs in #include dirent.h and it is not
portable, so let's just get rid of it.
2012-09-14 10:31:40 -07:00
Russell Belfer
38760efb37 Merge pull request #934 from nulltoken/patch-1
Fix MSVC compilation warnings
2012-09-14 02:04:32 -07:00
nulltoken
7505022397 Fix MSVC compilation warnings 2012-09-14 11:47:43 +03:00
Vicent Martí
dfc50de260 Merge pull request #933 from barrbrain/pack-iterate-objects-in-offset-order
pack: iterate objects in offset order
2012-09-13 23:04:16 -07:00
David Michael Barr
60ecdf59d3 pack: iterate objects in offset order
Compute the ordering on demand and persist until the index is freed.
2012-09-14 15:52:41 +10:00
Carlos Martín Nieto
687ec68be4 http: use the new unicode functions
The winhttp branch was based on a version before these existed, so the
build broke on Windows.
2012-09-14 00:51:29 +02:00
Vicent Martí
db066a9655 Merge pull request #901 from carlosmn/winhttp
http: use WinHTTP on Windows
2012-09-13 17:24:08 -07:00
Carlos Martín Nieto
3ce22c7485 http: use WinHTTP on Windows
Wondows has its own HTTP library. Use that one when possible instead of
our own.

As we don't depend on them anymore, remove the http-parser library from
the Windows build, as well as the search for OpenSSL.
2012-09-14 02:13:30 +02:00
Vicent Martí
57ad9f2e79 Merge pull request #931 from scunz/error_text
Fix error text s/buffer too long/buffer too short/
2012-09-13 14:35:41 -07:00
Sascha Cunz
13b554e376 Fix error text s/buffer too long/buffer too short/ 2012-09-13 23:30:31 +02:00
Vicent Martí
d973a5afd4 Merge pull request #929 from arrbee/diff-iter-fixes
Fix problems in diff iterator record chaining
2012-09-13 14:20:43 -07:00
Russell Belfer
12b6af1718 Forgot to reset hunk & line between files
The last change tweaked the way we use the hunk_curr pointer
during iteration, but failed to reset the value back to NULL
when switching files.
2012-09-13 14:15:07 -07:00
Vicent Martí
76bed9b2c2 Merge pull request #930 from nulltoken/fix/tracking-without-fetch-refspec
refspec: No remote tracking ref from a fetchspec-less remote
2012-09-13 13:35:04 -07:00
nulltoken
e16fc07f7e refspec: No remote tracking ref from a fetchspec-less remote 2012-09-13 22:31:29 +02:00
Russell Belfer
49d34c1c0c Fix problems in diff iterator record chaining
There is a bug in building the linked list of line records in the
diff iterator and also an off by one element error in the hunk
counts.  This fixes both of these, adds some test data with more
complex sets of hunk and line diffs to exercise this code better.
2012-09-13 13:17:38 -07:00
Vicent Martí
9be2261eaa Merge pull request #927 from arrbee/hashfile-with-filters
Add git_repository_hashfile to hash with filters
2012-09-13 09:24:12 -07:00
Vicent Martí
45c4697c48 Merge pull request #928 from barrbrain/odb-pack-stat-less
odb_pack: try lookup before refreshing packs
2012-09-13 09:07:06 -07:00
Michael Schubert
13faa77c57 Fix -Wuninitialized warning 2012-09-13 17:57:45 +02:00
David Michael Barr
ab8a0402ae odb_pack: try lookup before refreshing packs
This reduces the rate of syscalls for the common case of sequences of
object reads from the same pack.

Best of 5 timings for libgit2_clar before this patch:
real    0m5.375s
user    0m0.392s
sys     0m3.564s

After applying this patch:
real    0m5.285s
user    0m0.356s
sys     0m3.544s

0.6% improvement in system time.
9.2% improvement in user time.
1.7% improvement in elapsed time.

Confirmed a 0.6% reduction in number of system calls with strace.

Expect greater improvement for graph-traversal with large packs.
2012-09-13 09:31:24 +10:00
Russell Belfer
a13fb55afd Add tests and improve param checks
Fixed some minor `git_repository_hashfile` issues:

- Fixed incorrect doc (saying that repo could be NULL)
- Added checking of object type value to acceptable ones
- Added more tests for various parameter permutations
2012-09-11 17:26:21 -07:00
Russell Belfer
47bfa0be6d Add git_repository_hashfile to hash with filters
The existing `git_odb_hashfile` does not apply text filtering
rules because it doesn't have a repository context to evaluate
the correct rules to apply.  This adds a new hashfile function
that will apply repository-specific filters (based on config,
attributes, and filename) before calculating the hash.
2012-09-11 15:01:09 -07:00
Vicent Martí
21d847d38f Merge pull request #920 from scunz/mergebase_const
git_mergebase: Constness-Fix for consistency
2012-09-11 14:56:13 -07:00
Vicent Marti
412293dcc9 Merge branch 'diff-crlf-filters' into development 2012-09-11 23:38:16 +02:00
Vicent Marti
c859184bb4 Properly handle p_reads 2012-09-11 23:05:24 +02:00
Russell Belfer
1f35e89dbf Fix diff binary file detection
In the process of adding tests for the max file size threshold
(which treats files over a certain size as binary) there seem to
be a number of problems in the new code with detecting binaries.
This should fix those up, as well as add a test for the file
size threshold stuff.

Also, this un-deprecates `GIT_DIFF_LINE_ADD_EOFNL`, since I
finally found a legitimate situation where it would be returned.
2012-09-11 12:03:33 -07:00
Vicent Martí
5a409c44ba Merge pull request #924 from schu/cache-fix-race-cond
cache: fix race condition
2012-09-11 11:04:09 -07:00
Michael Schubert
6ee6861123 cache: fix race condition
Example: a cached node is owned only by the cache (refcount == 1).
Thread A holds the lock and determines that the entry which should get
cached equals the node (git_oid_cmp(&node->oid, &entry->oid) == 0).
It frees the given entry to instead return the cached node to the user
(entry = node). Now, before Thread A happens to increment the refcount
of the node *outside* the cache lock, Thread B tries to store another
entry and hits the slot of the node before, decrements its refcount and
frees it *before* Thread A gets a chance to increment for the user.

	git_cached_obj_incref(entry);

	git_mutex_lock(&cache->lock);
	{
		git_cached_obj *node = cache->nodes[hash & cache->size_mask];

		if (node == NULL) {
			cache->nodes[hash & cache->size_mask] = entry;
		} else if (git_oid_cmp(&node->oid, &entry->oid) == 0) {
			git_cached_obj_decref(entry, cache->free_obj);
			entry = node;
		} else {
			git_cached_obj_decref(node, cache->free_obj);

// Thread B is here

			cache->nodes[hash & cache->size_mask] = entry;
		}
	}
	git_mutex_unlock(&cache->lock);

// Thread A is here

	/* increase the refcount again, because we are
	 * returning it to the user */
	git_cached_obj_incref(entry);
2012-09-11 15:58:13 +02:00
Russell Belfer
2130dee49f Merge pull request #914 from authmillenon/index-fixes
Fix logical error in git_index_set_caps
2012-09-10 23:19:00 -07:00
Russell Belfer
eff14d384c Merge pull request #906 from nulltoken/topic/git_reference_peel
git reference peel
2012-09-10 23:15:54 -07:00
Russell Belfer
c6ac28fdc5 Reorg internal odb read header and object lookup
Often `git_odb_read_header` will "fail" and have to read the
entire object into memory instead of just the header.  When this
happens, the object is loaded and then disposed of immediately,
which makes it difficult to efficiently use the header information
to decide if the object should be loaded (since attempting to do
so will often result in loading the object twice).

This commit takes the existing code and reorganizes it to have
two new functions:

- `git_odb__read_header_or_object` which acts just like the old
  read header function except that it returns the object, too, if
  it was forced to load the whole thing.  It then becomes the
  callers responsibility to free the `git_odb_object`.
- `git_object__from_odb_object` which was extracted from the old
  `git_object_lookup` and creates a subclass of `git_object` from
  an existing `git_odb_object` (separating the ODB lookup from the
  `git_object` creation).  This allows you to use the first header
  reading function efficiently without instantiating the
  `git_odb_object` twice.

There is no net change to the behavior of any of the existing
functions, but this allows internal code to tap into the ODB
lookup and object creation to be more efficient.
2012-09-10 12:24:05 -07:00
Russell Belfer
e597b1890e Move diff max_size to public API
This commit adds a max_size value in the public `git_diff_options`
structure so that the user can automatically flag blobs over a
certain size as binary regardless of other properties.

Also, and perhaps more importantly, this moves binary detection
to be as early as possible in the diff traversal inner loop and
makes sure that we stop loading objects as soon as we decide that
they are binary.
2012-09-10 11:49:12 -07:00
Russell Belfer
b36effa22e Replace git_diff_iterator_num_files with progress
The `git_diff_iterator_num_files` API was problematic, since we
don't actually know the exact number of files to be iterated over
until we load those files into memory.  This replaces it with a
new `git_diff_iterator_progress` API that goes from 0 to 1, and
moves and renamed the old API for the internal places that can
tolerate a max value instead of an exact value.
2012-09-10 09:59:14 -07:00
Sascha Cunz
857323d4db git_mergebase: Constness-Fix for consistency 2012-09-09 15:53:57 +02:00
Russell Belfer
17b06f4d47 Add missing accessor for fetchRecurseSubmodules
When `git_submodule` became an opaque structure, I forgot to add
accessor functions for the fetchRecurseSubmodules config setting.
This fixes that.
2012-09-07 15:49:08 -07:00
Russell Belfer
3a3deea80b Clean up blob diff path
Previously when diffing blobs, the diff code just ran with a NULL
repository object. Of course, that's not necessary and the test
for a NULL repo was confusing. This makes the blob diff run with
the repo that contains the blobs and clarifies the test that it
is possible to be diffing data where the path is unknown.
2012-09-06 15:45:50 -07:00
Russell Belfer
60b9d3fcef Implement filters for status/diff blobs
This adds support to diff and status for running filters (a la crlf)
on blobs in the workdir before computing SHAs and before generating
text diffs.  This ended up being a bit more code change than I had
thought since I had to reorganize some of the diff logic to minimize
peak memory use when filtering blobs in a diff.

This also adds a cap on the maximum size of data that will be loaded
to diff.  I set it at 512Mb which should match core git.  Right now
it is a #define in src/diff.h but it could be moved into the public
API if desired.
2012-09-06 15:34:02 -07:00
Russell Belfer
8f9b6a132b Better header comments 2012-09-06 15:34:02 -07:00
Russell Belfer
f8e2cc9a0a Alternate test for autocrlf with status
I couldn't get the last failing test to actually fail.  This
is a different test suggested by @nulltoken which should fail.
2012-09-06 15:24:03 -07:00
pontusm
52462e1cce Test case to reproduce issue #690.
Staged file status does not handle CRLF correctly. Ensures that the test repo has core.autocrlf=true for the test to fail.
2012-09-06 15:24:03 -07:00
nulltoken
cf4c43abaa object: make git_object_peel() test more readable 2012-09-06 18:40:09 +02:00
nulltoken
746642a6b3 checkout: fix documentation code alignment 2012-09-06 18:40:08 +02:00
nulltoken
35d2e449bd checkout: cleanup misplaced declaration 2012-09-06 18:40:07 +02:00
nulltoken
ced8d1420a errors: deploy GIT_EBAREREPO usage 2012-09-06 18:40:06 +02:00
nulltoken
bb2d305c20 errors: introduce GIT_EBAREREPO 2012-09-06 18:40:06 +02:00
nulltoken
316659489a refs: introduce git_reference_peel()
Fix #530
2012-09-06 18:40:05 +02:00
Michael Schubert
0e9f2fcef6 odb: mark unused variable 2012-09-06 11:35:09 +02:00
Vicent Martí
7a3fc9fb17 Merge pull request #900 from pwkelley/development
Expose a malloc function to 3rd party ODB backends
2012-09-06 01:17:23 -07:00
Vicent Martí
4e2b8b4cdc Merge pull request #912 from schu/netops-ssl-error
netops: be more careful with SSL errors
2012-09-06 01:15:14 -07:00
Vicent Marti
01ae1909c5 diff: Cleanup documentation and printf compat 2012-09-06 10:13:38 +02:00