Commit Graph

1882 Commits

Author SHA1 Message Date
Russell Belfer
83bfbdf593 Remove poor git__removechar function
Going back over this, the git__removechar function was not
needed (only invoked once) and is actually mislabeled.  As
implemented, it really only made sense for removing backslash
characters, since two of the "removed" characters in a row
would include the second one -- i.e. it really implements
stripping backslash-escaped strings where a backslash allows
internal whitespace in a word.
2012-01-16 18:00:18 -08:00
Russell Belfer
a51cd8e6f6 Fix handling of relative paths for attrs
Per issue #533, the handling of relative paths in attribute
and ignore files was not right.  Fixed this by pre-joining
the relative path of the attribute/ignore file onto the match
string when a full path match is required.

Unfortunately, fixing this required a bit more code than I
would have liked because I had to juggle things around so that
the fnmatch parser would have sufficient information to prepend
the relative path when it was needed.
2012-01-16 16:58:27 -08:00
Russell Belfer
6e03b12f57 Merge pull request #531 from arrbee/gitignore
Initial implementation of gitignore support

git_status_foreach() and git_status_file() will now be
gitignore aware.
2012-01-16 15:34:35 -08:00
Russell Belfer
cfbc880d8a Patch cleanup for merge
After reviewing the gitignore support with Vicent, we came up
with a list of minor cleanups to prepare for merge, including:

* checking git_repository_config error returns
* renaming git_ignore_is_ignored and moving to status.h
* fixing next_line skipping to include \r skips
* commenting on where ignores are and are not included
2012-01-16 15:16:44 -08:00
Carlos Martín Nieto
d9e5430e5a Windows: store all 64 bits of the size in the stat structure
We force stat to be a stat64 structure, so we can and should put all
64 bits of the size in st_size.
2012-01-16 11:46:49 +01:00
Vicent Martí
1af56d7d7e Fix #534: 64-bit issues in Windows
off_t is always 32 bits in Windows, which is beyond stupid, but we just
don't care anymore because we're using `git_off_t` which is assured to
be 64 bits on all platforms, regardless of compilation mode. Just
ensure that no casts to `off_t` are performed.

Also, the check for `off_t` overflows has been dropped, once again,
because the size of our offsets is always 64 bits on all platforms.

Fixes #534
2012-01-15 15:48:36 -08:00
Carlos Martín Nieto
c1c399cf27 config: handle EOF properly
In the main loop we peek to see what kind of line the next one is. If
there are multiple newlines before the end of the file, the eof marker
won't be set after we read the last line with data and we'll try to
peek again. This peek will return LF (as it pretends that we have a
newline at EOF so other function don't need any special handling).

Fix cfg_getchar so it doesn't try to read past the last character in
the file and config_parse so it considers LF as EOF on peek (as we're
ignoring spaces) and sets the reader's EOF flag to exit the parsing
loop.
2012-01-13 19:33:54 +01:00
Carlos Martín Nieto
2866c01685 examples: use git_repository_odb instead of _database 2012-01-13 18:20:13 +01:00
Russell Belfer
1dbcc9fc4e Fix several memory issues
This contains fixes for several issues discovered by MSVC and
by valgrind, including some bad data access, some memory
leakage (in where certain files were not being successfully
added to the cache), and some code simplification.
2012-01-11 23:21:46 -08:00
Russell Belfer
0cfcff5daa Convert git_path_walk_up to regular function
This gets rid of the crazy macro version of git_path_walk_up
and makes it into a normal function that takes a callback
parameter.  This turned out not to be too messy.
2012-01-11 20:41:55 -08:00
Russell Belfer
15debaf5da Fix bug in dir_for_path
The last checkin accidentally broke dir_for_path by propogating
the dirname return code even when there was no error.
2012-01-11 17:28:25 -08:00
Russell Belfer
6a67a812c2 Allow ignores (and attribs) for nonexistent files
This fixes issue 532 that attributes (and gitignores) could not
be checked for files that don't exist.  It should be possible to
query such things regardless of the existence of the file.
2012-01-11 16:01:48 -08:00
Russell Belfer
fdaa924037 Fix up status tests 2012-01-11 15:25:13 -08:00
Russell Belfer
df743c7d3a Initial implementation of gitignore support
Adds support for .gitignore files to git_status_foreach() and
git_status_file().  This includes refactoring the gitattributes
code to share logic where possible.  The GIT_STATUS_IGNORED flag
will now be passed in for files that are ignored (provided they
are not already in the index or the head of repo).
2012-01-11 14:39:51 -08:00
Russell Belfer
7e443f6960 Restore portability to git_path_prettify.
It turns out that passing NULL for the second parameter of realpath(3)
is not as portable as one might like.  Notably, Mac OS 10.5 and earlier
does not support it.  So this moves us back to a large buffer to get
the realpath info.
2012-01-09 15:46:06 -08:00
Vicent Martí
1d17507496 Merge pull request #528 from arrbee/valgrind-fixes-2
Valgrind fixes in smaller pieces
2012-01-05 17:46:06 -08:00
Carlos Martín Nieto
91d46f8df3 clay tests: free resources
Trees, indices and repos need to be freed
2012-01-06 01:13:08 +01:00
Russell Belfer
fa3cb0dae0 Fix memory leak in git_index_remove.
Missed freeing the entry.
2012-01-05 15:15:43 -08:00
Russell Belfer
2d8405025d Throw first error in chain, not rethrow.
This is the first time this error is throw, so use git__throw instead
of git__rethrow.
2012-01-05 15:03:42 -08:00
Russell Belfer
948431aa01 Remove repo open immediately after init in test
Calling git_repository_open immediately after git_repository_init
results in memory leaks.
2012-01-05 15:00:46 -08:00
Jeff King
671bbdd372 reflog_write: don't access free()'d memory
We get the oid of a reference, free the reference, then
convert the oid to a string. We need to convert the oid
before freeing the memory.
2012-01-05 17:31:13 -05:00
Vicent Martí
f2114d0a35 Merge remote-tracking branch 'nulltoken/topix/path_fromurl' into development
Conflicts:
	tests-clay/clay.h
	tests-clay/clay_main.c
2012-01-04 22:43:11 +01:00
Vicent Martí
b0df89d90b Merge pull request #526 from nulltoken/fix/attr
Fix some "attributes" related issues
2012-01-04 12:34:59 -08:00
nulltoken
f46e622636 Fix Windows specific off-by-one error
The value returned by MultiByteToWideChar includes the NULL termination character.
2012-01-04 21:15:12 +01:00
nulltoken
acb159e191 Fix MSVC compilation warnings 2012-01-04 18:17:55 +01:00
Russell Belfer
7d93f96aa9 Merge pull request #525 from euler0/add-missing-semicolon
Add missing semicolon
2012-01-03 07:28:38 -08:00
Vincent Lee
c6a437eaec Add missing semicolon 2012-01-03 19:44:13 +09:00
Vicent Martí
1d415455d9 clay: Move file_create to the helpers file 2012-01-02 10:06:24 +01:00
Vicent Martí
7a704309ae Merge remote-tracking branch 'drizzd/diff-index-tests' into development
Conflicts:
	tests-clay/clay.h
	tests-clay/clay_main.c
2012-01-02 09:58:39 +01:00
Vicent Martí
9191a6d246 Merge remote-tracking branch 'arrbee/git-attributes' into development
Conflicts:
	tests-clay/clay_main.c
2012-01-02 09:56:48 +01:00
Vicent Martí
9dd4c3e806 config: Rename the delete callback name
`delete` is a reserved keyword in C++.
2011-12-31 05:58:26 +01:00
Russell Belfer
bd370b14fe Improved gitattributes macro implementation
This updates to implementation of gitattribute macros to be much more
similar to core git (albeit not 100%) and to handle expansion of
macros within macros, etc.  It also cleans up the refcounting usage
with macros to be much cleaner.

Also, this adds a new vector function `git_vector_insert_sorted()`
which allows you to maintain a sorted list as you go.  In order to
write that function, this changes the function `git__bsearch()` to
take a somewhat different set of parameters, although the core
functionality is still the same.
2011-12-30 15:00:14 -08:00
Clemens Buchacher
0fb3fba123 add diff-index tests 2011-12-30 20:14:05 +01:00
Clemens Buchacher
1f783edf17 do not use full path in diff-index
Currently, diff_index passes the full relative path from the
repository root to the callback. In case of an addition, it passes
the tree entry instead of the index entry.

This change fixes the path used for addition, and it passes only
the basename of the path. This mimics the current behavior of
git_tree_diff.
2011-12-30 20:14:05 +01:00
Clemens Buchacher
ee3f96d4e0 clay: reset expect_idx in diff_more test
For the diff-index tests, the diff_more test will run multiple
times. Reset the expect_idx counter after each test in order to
allow this.
2011-12-30 20:14:05 +01:00
Clemens Buchacher
e459253815 allow opening index in bare repo
The git.git implementation allows this, and there is no reason not
to.
2011-12-30 20:14:05 +01:00
Clemens Buchacher
599f2849ba add git_index_read_tree 2011-12-30 20:14:05 +01:00
Clemens Buchacher
a26a156349 move entry_is_tree to tree.h 2011-12-30 20:14:01 +01:00
Russell Belfer
c6d2a2c094 Fixed up memory leaks 2011-12-29 21:32:37 -08:00
Clemens Buchacher
e632f68789 cmake: generate tags 2011-12-29 15:40:09 +01:00
Clemens Buchacher
86a459a843 cmake: generate clay main
The clay test suite files clay.h and clay_main.c are generated by
the clay python script. Teach CMake about this dependency and
remove the generated files from the repository.
2011-12-29 15:40:09 +01:00
Russell Belfer
73b51450a3 Add support for macros and cache flush API.
Add support for git attribute macro definitions.  Also, add
support for cache flush API to clear the attribute file content
cache when needed.

Additionally, improved the handling of global and system files,
making common utility functions in fileops and converting config
and attr to both use the common functions.

Adds a bunch more tests and fixed some memory leaks.  Note that
adding macros required me to use refcounted attribute assignment
definitions, which complicated, but probably improved memory usage.
2011-12-29 00:01:10 -08:00
nulltoken
e2580375dc transport: make local transport accept a file Uri containing percent-encoded characters
This makes libgit2 compliant with the following scenario

$ git ls-remote file:///d:/temp/dwm%20tinou
732d790b702db4b8985f5104fc44642654f6a6b6        HEAD
732d790b702db4b8985f5104fc44642654f6a6b6        refs/heads/master
732d790b702db4b8985f5104fc44642654f6a6b6        refs/remotes/origin/HEAD
732d790b702db4b8985f5104fc44642654f6a6b6        refs/remotes/origin/master

$ mv "/d/temp/dwm tinou" /d/temp/dwm+tinou

$ git ls-remote file:///d:/temp/dwm%20tinou
fatal: 'd:/temp/dwm tinou' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

$ git ls-remote file:///d:/temp/dwm+tinou
732d790b702db4b8985f5104fc44642654f6a6b6        HEAD
732d790b702db4b8985f5104fc44642654f6a6b6        refs/heads/master
732d790b702db4b8985f5104fc44642654f6a6b6        refs/remotes/origin/HEAD
732d790b702db4b8985f5104fc44642654f6a6b6        refs/remotes/origin/master
2011-12-28 20:40:08 +01:00
nulltoken
2017a15d6c path: add git_path_fromurl() 2011-12-28 20:35:09 +01:00
nulltoken
459e2dcd7d path: add git__percent_decode() 2011-12-28 20:31:11 +01:00
nulltoken
eb8de7476b util: add git__fromhex() 2011-12-28 20:25:29 +01:00
Vicent Martí
06fcf057b6 Merge pull request #520 from antono/patch-1
Added link to vala bindings
2011-12-27 06:32:11 -08:00
Antono Vasiljev
27f69e4826 Added link to vala bindings 2011-12-27 17:10:12 +03:00
Vicent Martí
9aeef3929c Merge pull request #519 from ingydotnet/development
Add Perl to the list of bindings.
2011-12-26 23:01:06 -08:00
Ingy döt Net
20626db1ac Add Perl to the list of bindings. 2011-12-26 21:58:17 -08:00