Commit Graph

66 Commits

Author SHA1 Message Date
Carlos Martín Nieto
f4be8209af config: don't special-case the multivar iterator
Build it on top of the normal iterator instead, which lets use re-use
a lot of code.
2013-08-14 00:45:05 +02:00
Carlos Martín Nieto
54f3a572b4 config: introduce a regex-filtering iterator 2013-08-12 11:40:57 +02:00
Carlos Martín Nieto
5880962d90 config: introduce _iterator_new()
As the name suggests, it iterates over all the entries
2013-08-12 11:40:57 +02:00
Carlos Martín Nieto
1e96c9d534 config: add _next() and _iterator_free()
Make it look like the refs iterator API.
2013-08-08 20:47:06 +02:00
Carlos Martín Nieto
99dfb538ad config: working multivar iterator
Implement the foreach version as a wrapper around the iterator.
2013-08-08 20:38:42 +02:00
Carlos Martín Nieto
eba7399251 config: move next() and free() into the iterator
Like we have in the references iterator, next and free belong in the
iterator itself.
2013-08-08 14:39:32 +02:00
Carlos Martín Nieto
4efa32903a config: get_multivar -> get_multivar_foreach
The plain function will return an iterator, so move this one out of
the way.
2013-08-08 13:57:01 +02:00
Carlos Martín Nieto
4d588d9713 Don't typedef a pointer
Make the iterator structure opaque and make sure it compiles.
2013-08-08 11:40:41 +02:00
Nico von Geyso
a603c19157 replaced foreach() with non callback based iterations in git_config_backend
new functions in struct git_config_backend:
  * iterator_new(...)
  * iterator_free(...)
  * next(...)

The old callback based foreach style can still be used with `git_config_backend_foreach_match`
2013-08-08 11:14:53 +02:00
Andreas Linde
e196716457 Fixed most documentation header bugs
Fixed a few header @param and @return typos with the help of -Wdocumentation in Xcode.

The following warnings have not been fixed:
common.h:213 - Not sure how the documentation format is for '...'
notes.h:102 - Correct @param name but empty text
notes.h:111 - Correct @param name but empty text
pack.h:140 - @return missing text
pack.h:148 - @return missing text
2013-06-24 15:33:41 +02:00
Sven Strickroth
76b893b653 Add high(est) config level for application specific config files
Some tools use an extra level to maintain an application specific config files on top of the normal ones. Revision 16adc9fade broke this.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2013-06-11 23:37:02 +02:00
Russell Belfer
16adc9fade Typedef git_config_level_t and use it everywhere
The GIT_CONFIG_LEVEL constants actually work well as an enum
because they are mutually exclusive, so this adds a typedef to
the enum and uses that everywhere that one of these constants are
expected, instead of the old code that typically used an unsigned
int.
2013-05-24 10:35:58 -07:00
Linquize
0cb16fe924 Unify whitespaces to tabs 2013-05-15 20:26:55 +08:00
Carlos Martín Nieto
5d8318875f config: convenience function to open global/xdg
The rules for which one to open is a bit silly, so let's make it
easier for our users.
2013-05-07 21:42:56 +02:00
Russell Belfer
83041c711c Move git_config_backend to include/git2/sys
Moving backend implementor objects into include/git2/sys so the
APIs can be isolated from the ones that normal libgit2 users
would be likely to use.
2013-04-21 11:50:55 -07:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Kevin Sawicki
7eb222fc7d Correct typos in documentation 2013-01-06 10:39:35 -08:00
Ben Straub
fac43c54a6 Allow compilation as C++ 2012-12-06 19:41:52 -08:00
Ben Straub
bde336ea51 Add version fields and init macros for public input structs. 2012-11-30 12:55:45 -08:00
Ben Straub
54b2a37ac7 Clean up config.h 2012-11-27 13:18:28 -08:00
nulltoken
270160b91a config: Opening a nonexistent file returns ENOTFOUND 2012-11-17 18:30:34 -08:00
nulltoken
d36451c9d4 config: Make git_config_file__ondisk() internal 2012-11-17 12:34:15 -08:00
Carlos Martín Nieto
3ee078c0f7 config: rename get_config_entry -> config_entry
We're already in the git_config namespace, there is no need to repeat
it.
2012-11-13 13:46:17 -08:00
Russell Belfer
744cc03e2b Add git_config_refresh() API to reload config
This adds a new API that allows users to reload the config if the
file has changed on disk.  A new config callback function to
refresh the config was added.

The modified time and file size are used to test if the file needs
to be reloaded (and are now stored in the disk backend object).

In writing tests, just using mtime was a problem / race, so I
wanted to check file size as well.  To support that, I extended
`git_futils_readbuffer_updated` to optionally check file size in
addition to mtime, and I added a new function `git_filebuf_stats`
to fetch the mtime and size for an open filebuf (so that the
config could be easily refreshed after a write).

Lastly, I moved some similar file checking code for attributes
into filebuf.  It is still only being used for attrs, but it
seems potentially reusable, so I thought I'd move it over.
2012-10-30 12:11:23 -07:00
yorah
a1abe66aca Add config level support in the config API
Added `struct git_config_entry`: a git_config_entry contains the key, the value, and the config file level from which a config element was found.
Added `git_config_open_level`: build a single-level focused config object from a multi-level one.

We are now storing `git_config_entry`s in the khash of the config_file
2012-10-23 12:48:38 +02:00
Sven Strickroth
4258d4832b Rename xdr to xdg
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2012-10-02 17:21:07 +02:00
Sven Strickroth
8b4f9b1758 Correctly read xdr compatible %HOME%/.config/git/config config file
This file is not just read if the global config file (%HOME%/.gitconfig)
is not found, however, it is used everytime but with lower priority.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2012-09-24 18:59:00 +02:00
Russell Belfer
85bd174626 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
2012-08-22 16:16:42 -07:00
Russell Belfer
ca1b6e5409 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.
2012-08-22 16:07:19 -07:00
Josh Triplett
b90202bbdd 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.
2012-08-12 03:56:15 -07:00
Russell Belfer
5dca201072 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.
2012-08-03 17:08:01 -07:00
Russell Belfer
b3ff1dab31 Adding git_config_foreach_match() iteration fn
Adding a new config iteration function that let's you iterate
over just the config entries that match a particular regular
expression.  The old foreach becomes a simple use of this with
an empty pattern.

This also fixes an apparent bug in the existing `git_config_foreach`
where returning a non-zero value from the iteration callback was
not correctly aborting the iteration and the returned value was
not being propogated back to the caller of foreach.

Added to tests to cover all these changes.
2012-07-10 23:19:47 -07:00
Vicent Martí
e172cf082e errors: Rename the generic return codes 2012-05-18 01:26:26 +02:00
Vicent Martí
29e948debe global: Change parameter ordering in API
Consistency is good.
2012-05-18 01:25:57 +02:00
Vicent Martí
c5e944820a config: Refactor & add git_config_get_mapped
Sane API for real-world usage.
2012-03-01 00:52:21 +01:00
Carlos Martín Nieto
d9da4ccaa0 Document {get,set}_multivar 2012-02-17 19:50:30 +01:00
Carlos Martín Nieto
3005855f7e Implement setting multivars 2012-02-17 19:50:30 +01:00
Carlos Martín Nieto
5e0dc4af01 Support getting multivars 2012-02-17 19:43:43 +01:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +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
Carlos Martín Nieto
80a665aaca config: really delete variables
Instead of just setting the value to NULL, which gives unwanted
results when asking for that variable after deleting it, delete the
variable from the list and re-write the file.
2011-12-16 02:28:39 +01:00
Vicent Marti
dd3fd68266 msvc: Remove superfluous includes 2011-10-05 13:44:27 -07:00
Carlos Martín Nieto
dc8e3096d6 Include stdint.h in git2/config.h
Otherwise MSVC doesn't know what we're talking about when we say
int32_t or int64_t.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 02:09:35 +02:00
Vicent Marti
fafd471021 config: Proper type declarations for 64 bit ints 2011-09-30 16:08:41 +02:00
Carlos Martín Nieto
4c562347ae Add git_config_find_system
This allows the library to guess where the system configuration file
should be located.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-27 14:39:38 +02:00
nulltoken
ad196c6ae6 config: make git_config_[get|set]_long() able to properly deal with 8 bytes wide values
Should fix issue #419.

Signed-off-by: nulltoken <emeric.fermas@gmail.com>
2011-09-22 18:58:47 +02:00
Vicent Marti
bb742ede3d Cleanup legal data
1. The license header is technically not valid if it doesn't have a
copyright signature.

2. The COPYING file has been updated with the different licenses used in
the project.

3. The full GPLv2 header in each file annoys me.
2011-09-19 01:54:32 +03:00
David Boyce
d911172255 Standardized doxygen @return lines for int functions to say "GIT_SUCCESS or an error code". 2011-09-13 12:30:25 -04:00
Vicent Marti
b08683ffb2 config: Rename del to `delete 2011-07-12 02:38:20 +02:00
Carlos Martín Nieto
2601fcfc1e Add tests for deleting a config var
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-05 02:32:17 +02:00