Russell Belfer [Fri, 24 Aug 2012 19:19:22 +0000 (12:19 -0700)]
Fix valgrind warnings and spurious error messages
Just clean up valgrind warnings about uninitialized memory
and also clear out errno in some cases where it results in
a false error message being generated at a later point.
Russell Belfer [Fri, 10 Aug 2012 02:43:25 +0000 (19:43 -0700)]
Working implementation of git_submodule_status
This is a big redesign of the git_submodule_status API and the
implementation of the redesigned API. It also fixes a number of
bugs that I found in other parts of the submodule API while
writing the tests for the status part.
This also fixes a couple of bugs in the iterators that had not
been noticed before - one with iterating when there is a gitlink
(i.e. separate-work-dir) and one where I was treating anything
even vaguely submodule-like as a submodule, more aggressively
than core git does.
Russell Belfer [Fri, 3 Aug 2012 21:28:07 +0000 (14:28 -0700)]
Fix valgrind issues and leaks
This fixes up a number of problems flagged by valgrind and also
cleans up the internal `git_submodule` allocation handling
overall with a simpler model.
Russell Belfer [Wed, 22 Aug 2012 23:03:35 +0000 (16:03 -0700)]
Some cleanup suggested during review
This cleans up a number of items suggested during code review
with @vmg, including:
* renaming "outside repo" config API to `git_config_open_default`
* killing the `git_config_open_global` API
* removing the `git_` prefix from the static functions in fileops
* removing some unnecessary functionality from the "cp" command
Russell Belfer [Wed, 1 Aug 2012 21:49:47 +0000 (14:49 -0700)]
Don't reference stack vars in cleanup callback
If you use the clar cleanup callback function, you can't pass a
reference pointer to a stack allocated variable because when the
cleanup function runs, the stack won't exist anymore.
Russell Belfer [Wed, 1 Aug 2012 00:02:54 +0000 (17:02 -0700)]
Add template dir and set gid to repo init
This extends git_repository_init_ext further with support for
initializing the repository from an external template directory
and with support for the "create shared" type flags that make a
set GID repository directory.
This also adds tests for much of the new functionality to the
existing `repo/init.c` test suite.
Also, this adds a bunch of new utility functions including a
very general purpose `git_futils_mkdir` (with the ability to
make paths and to chmod the paths post-creation) and a file
tree copying function `git_futils_cp_r`. Also, this includes
some new path functions that were useful to keep the code
simple.
Russell Belfer [Thu, 26 Jul 2012 23:07:01 +0000 (16:07 -0700)]
Add git_repository_init_ext for power initters
The extended version of repository init adds support for many
of the things that you can do with `git init` and sets up
structures that will make it easier to extend further in the
future.
Russell Belfer [Wed, 22 Aug 2012 20:57:57 +0000 (13:57 -0700)]
Minor bug fixes in diff code
In looking at PR #878, I found a few small bugs in the diff code,
mostly related to work that can be avoided when processing tree-
to-tree diffs that was always being carried out. This commit has
some small fixes in it.
Up to now, the idea was that the user would do all the operations for
one repository in the same thread. Thus we could have the
memory-mapped window information thread-local and avoid any locking.
This is not practical in a few environments, such as Apple's GCD which
allocates threads arbitrarily or the .NET CLR, where the OS-level
thread can change at any moment.
Make the control structure global and protect it with a mutex so we
don't depend on the thread currently executing the code.
Russell Belfer [Tue, 14 Aug 2012 17:50:58 +0000 (10:50 -0700)]
Make git_message_prettify return bytes written
If you want to be absolutely safe with git_message_prettify, you
can now pass a NULL pointer for the buffer and get back the number
of bytes that would be copied into the buffer.
This means that an error is a non-negative return code and a
success will be greater than zero from this function.
Josh Triplett [Sun, 12 Aug 2012 10:56:15 +0000 (03:56 -0700)]
Fix incorrect array size in example for git_config_get_mapped
In the documentation for git_config_get_mapped, the sample mapping
array uses [3] but has 4 entries. Fix by dropping the size entirely and
letting the compiler figure it out.
Josh Triplett [Sun, 12 Aug 2012 01:14:07 +0000 (18:14 -0700)]
Export git_attr_value
Commit 0c9eacf3d2c83256736a5bb2a240e73afd13d55f introduced the function
git_attr_value and switched the GIT_ATTR_* macros to use it, but
attempting to use that function leads to a linker error (undefined
reference to `git_attr_value'). Export git_attr_value so programs can
actually call it.
Russell Belfer [Mon, 6 Aug 2012 18:06:05 +0000 (11:06 -0700)]
Fix iterator check and return value
There is a little cleanup necessary from PR #843. Since the
new callbacks return `GIT_EUSER` we have to be a little careful
about return values when they are used internally to the library.
Also, callbacks should be checked for non-zero return values,
not just less than zero.
Russell Belfer [Sat, 4 Aug 2012 00:08:01 +0000 (17:08 -0700)]
Update iterators for consistency across library
This updates all the `foreach()` type functions across the library
that take callbacks from the user to have a consistent behavior.
The rules are:
* A callback terminates the loop by returning any non-zero value
* Once the callback returns non-zero, it will not be called again
(i.e. the loop stops all iteration regardless of state)
* If the callback returns non-zero, the parent fn returns GIT_EUSER
* Although the parent returns GIT_EUSER, no error will be set in
the library and `giterr_last()` will return NULL if called.
This commit makes those changes across the library and adds tests
for most of the iteration APIs to make sure that they follow the
above rules.