src/config_file.c


Log

Author Commit Date CI Message
Carlos Martín Nieto 8e8b6b01 2012-04-04T13:13:43 Clean up valgrind warnings
Russell Belfer bfc9ca59 2012-03-28T16:45:36 Added submodule API and use in status When processing status for a newly checked out repo, it is possible that there will be submodules that have not yet been initialized. The only way to distinguish these from untracked directories is to have some knowledge of submodules. This commit adds a new submodule API which, given a name or path, can determine if it appears to be a submodule and can give information about the submodule.
Vicent Martí dda708e7 2012-03-09T19:55:50 error-handling: On-disk config file backend Includes: - Proper error reporting when encountering syntax errors in a config file (file, line number, column). - Rewritten `config_write`, now with 99% less goto-spaghetti - Error state in `git_filebuf`: filebuf write functions no longer need to be checked for error returns. If any of the writes performed on a buffer fail, the last call to `git_filebuf_commit` or `git_filebuf_hash` will fail accordingly and set the appropiate error message. Baller!
Russell Belfer 854eccbb 2012-02-29T12:04:59 Clean up GIT_UNUSED macros on all platforms It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5 did not fix the GIT_USUSED behavior on all platforms. This commit walks through and really cleans things up more thoroughly, getting rid of the unnecessary stuff. To remove the use of some GIT_UNUSED, I ended up adding a couple of new iterators for hashtables that allow you to iterator just over keys or just over values. In making this change, I found a bug in the clar tests (where we were doing *count++ but meant to do (*count)++ to increment the value). I fixed that but then found the test failing because it was not really using an empty repo. So, I took some of the code that I wrote for iterator testing and moved it to clar_helpers.c, then made use of that to make it easier to open fixtures on a per test basis even within a single test file.
Vicent Martí 13224ea4 2012-02-27T04:28:31 buffer: Unify `git_fbuffer` and `git_buf` This makes so much sense that I can't believe it hasn't been done before. Kill the old `git_fbuffer` and read files straight into `git_buf` objects. Also: In order to fully support 4GB files in 32-bit systems, the `git_buf` implementation has been changed from using `ssize_t` for storage and storing negative values on allocation failure, to using `size_t` and changing the buffer pointer to a magical pointer on allocation failure. Hopefully this won't break anything.
Carlos Martín Nieto 0a43d7cb 2012-02-25T18:52:28 config: correctly deal with setting a multivar with regex where there are no matches We used to erroneously consider "^$" as a special case for appending a value to a multivar. This was a misunderstanding and we should always append a value if there are no existing values that match. While we're in the area, replace all the variables in-memory in one swoop and then replace them on disk so as to avoid matching a value we've just introduced.
Carlos Martín Nieto 3005855f 2012-02-05T00:29:26 Implement setting multivars
Carlos Martín Nieto 5e0dc4af 2012-02-04T23:18:30 Support getting multivars
Carlos Martín Nieto 0774d94d 2012-02-01T17:21:28 Store multivars in the multimap
Carlos Martín Nieto fefd4551 2012-01-23T04:26:49 First round of config multimap changes Move the configuration to use a multimap instead of a list. This commit doesn't provide any functional changes but changes the support structures.
schu 5e0de328 2012-02-13T17:10:24 Update Copyright header Signed-off-by: schu <schu-github@schulog.org>
schu 15f52ae1 2011-12-19T15:59:13 config_file: fix clang sizeof-pointer-memaccess
Carlos Martín Nieto a9fe8ae0 2012-01-23T22:14:04 config: don't use 'section "subsection"' internal form on config_set This had been left over from a time when I believed what the git documentation had to say about case-sensitivity. The rest of the code doesn't recognize this form and we hadn't noticed because most tests don't try to get a recently-set variable but free and reload the configuration, causing the right format to be used.
Carlos Martín Nieto c1c399cf 2012-01-13T19:33:54 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.
Vicent Martí 9dd4c3e8 2011-12-31T05:56:39 config: Rename the `delete` callback name `delete` is a reserved keyword in C++.
schu e95849c1 2011-12-16T11:39:21 config_file: honor error Return an error if we can't write an updated version of the config file after config_delete. Along with that, fix an uninitialized warning. Signed-off-by: schu <schu-github@schulog.org>
Carlos Martín Nieto 80a665aa 2011-12-16T02:28:39 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.
Carlos Martín Nieto 7b2b4adf 2011-12-16T01:39:28 Revert "config: Return ENOTFOUND when a variable was deleted" This would make us think that config variables like [core] something is missing.
Vicent Marti 2ea14da6 2011-12-15T18:14:41 config: Return ENOTFOUND when a variable was deleted
Vicent Marti 9462c471 2011-11-25T08:16:26 repository: Change ownership semantics The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
Carlos Martín Nieto 4e90a0a4 2011-11-26T01:54:12 config: allow to open and write to a new file
Russell Belfer b762e576 2011-11-17T15:10:27 filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanups Update all stack allocations of git_filebuf to use GIT_FILEBUF_INIT and make git_filebuf_open and git_filebuf_cleanup safe to be called multiple times on the same buffer. Signed-off-by: Vicent Marti <tanoku@gmail.com>
Vicent Martí 89fb8f02 2011-10-28T19:04:23 Merge pull request #456 from brodie/perm-fixes Create objects, indexes, and directories with the right file permissions
Vicent Marti 3286c408 2011-10-28T14:51:13 global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
Oleg Andreev 9f861826 2011-10-27T16:45:44 Fixed crash in config parser when empty value is encountered. Example: key1 = value1 key2 = In this config the value will be a bad pointer which config object will attempt to free() causing a crash.
Brodie Rao 01ad7b3a 2011-09-06T15:48:45 *: correct and codify various file permissions The following files now have 0444 permissions: - loose objects - pack indexes - pack files - packs downloaded by fetch - packs downloaded by the HTTP transport And the following files now have 0666 permissions: - config files - repository indexes - reflogs - refs This brings libgit2 more in line with Git. Note that git_filebuf_commit() and git_filebuf_commit_at() have both gained a new mode parameter. The latter change fixes an important issue where filebufs created with GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3) usage). Now we chmod() the file before renaming it into place. Tests have been added to confirm that new commit, tag, and tree objects are created with the right permissions. I don't have access to Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
Carlos Martín Nieto cd19ca95 2011-10-01T20:16:13 Squelch a couple of warnings Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Carlos Martín Nieto 9ac581bf 2011-10-01T19:56:04 config: behave like git with [section.subsection] The documentation is a bit misleading. The subsection name is always case-sensitive, but with a [section.subsection] header, the subsection is transformed to lowercase when the configuration is parsed. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Vicent Martí 71a4c1f1 2011-09-18T20:07:59 Merge pull request #384 from kiryl/warnings Add more -W flags to CFLAGS
Vicent Martí b6ed727a 2011-09-18T19:52:40 Merge pull request #392 from sschuberth/development Fix a bug and GCC warning introduced in 932669b
Vicent Marti 87d9869f 2011-09-19T03:34:49 Tabify everything There were quite a few places were spaces were being used instead of tabs. Try to catch them all. This should hopefully not break anything. Except for `git blame`. Oh well.
Vicent Marti bb742ede 2011-09-19T01:54:32 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.
Sebastian Schuberth 79a34396 2011-09-09T09:32:39 Fix a bug and GCC warning introduced in 932669b For unsigned types, the comparison >= 0 is always true, so avoid it by using a post-decrement and integrating the initial assigment into the loop body. No change in behavior is intended.
Sebastian Schuberth 45e93ef3 2011-09-08T14:22:29 Fix minor indentation issues (spaces to tabs)
Sebastian Schuberth 26e74c6a 2011-09-08T14:21:17 Fix some random size_t vs. int conversion warnings
Kirill A. Shutemov d568d585 2011-08-30T23:55:22 CMakefile: add -Wmissing-prototypes and fix warnings Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 932669b8 2011-08-25T14:22:57 Drop STRLEN() macros There is no need in STRLEN macros. Compilers can do this trivial optimization on its own. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Vicent Marti 84dd3820 2011-08-18T02:13:51 posix: Properly handle `snprintf` in all platforms
schu 5a0659fe 2011-08-17T14:05:41 config_file.c: fix memory leaks Signed-off-by: schu <schu-github@schulog.org>
Carlos Martín Nieto f58c53ce 2011-06-28T16:24:51 Correctly detect truncated input in header parsing If the section header is the last line in the file, parse_section_header would incorrectly decide that the input had been truncated. Fix this by checking whether the actual input line is correctly formatted. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 6d4b6097 2011-06-28T15:20:42 Add git_config_del to delete a variable Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Marti f79026b4 2011-07-04T11:43:34 fileops: Cleanup Cleaned up the structure of the whole OS-abstraction layer. fileops.c now contains a set of utility methods for file management used by the library. These are abstractions on top of the original POSIX calls. There's a new file called `posix.c` that contains emulations/reimplementations of all the POSIX calls the library uses. These are prefixed with `p_`. There's a specific posix file for each platform (win32 and unix). All the path-related methods have been moved from `utils.c` to `path.c` and have their own prefix.
Vicent Marti cfef5fb7 2011-06-29T15:09:21 config: `foreach` now returns variable values too
Carlos Martín Nieto b76934de 2011-06-16T16:55:11 Remove double-space Noticed by txdv Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Marti c716b187 2011-06-17T19:47:58 config: Fix unitialized variable warning
Carlos Martín Nieto b2e361cc 2011-06-16T20:22:05 Plug two leaks in config writing Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 711b1096 2011-06-14T13:08:30 Indent config variables with tags Confg variables are indended using tags and not four spaces as was being done by the code. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 8bb198e6 2011-05-17T16:39:09 config: implement config writing After each variable gets set, we store it in our list (not completely in the right position, but the close enough). Then we write out the new config file in the same way that git.git does it (keep the rest of the file intact and insert or replace the variable in its line). Overwriting variables and adding new ones is supported (even on new sections), though deleting isn't yet. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 3b3577c7 2011-06-07T23:32:14 config: store new variables with the internal representation of the section The section name should be stored in its case-sensitive variant when we are adding a new variable. Use the internalize_section function to do just that. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 5ab50417 2011-06-07T22:49:13 Remove an unfortunate optimisation from cvar_match_section The (rather late) early-exit code, which provides a negligible optimisation causes cvar_match_section to return false negatives when it's called with a section name instead of a full variable name. Remove this optimisation. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto c7e6e958 2011-05-31T17:44:55 Don't try to parse an empty config file Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 5892277c 2011-05-31T15:16:25 Config parse header ext: don't allow text after closing quote Nothing is allowed betwen the closing quotation mark and the ] so return an error if there is. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 7288d8b6 2011-05-31T15:11:49 Parse section header ext: don't leak on error Also free the subsection if we find too many quotes Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto 7bc9e2aa 2011-05-31T15:06:22 Guard against double-freeing the current section If parse_section_header{,_ext} return an error, current_section doesn't get allocated. Set it to NULL after freeing so we don't try to free it again. This fixes part 2-2 of Issue #210. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto a5f43b95 2011-05-31T13:48:44 Config file open: don't free memory that doesn't belong to us On error, it would free the configuration object even though it didn't own that memory, which would cause a double-free. This fixes the first part of Issue #210 Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto f2abee47 2011-05-29T01:24:09 cfg_readline: really ignore empty lines Simplify cfg_readline and at the same time fix it so that it does really ignore empty lines. This fixes point 2-1 of Issue #210 Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
nulltoken 3a1c4310 2011-05-24T18:55:35 Fix compilation warnings in MSVC This allows to successfully build libgit2 with waf on Windows.
Jakob Pfender ec9edd56 2011-05-19T15:46:36 config_file.c: Move to new error handling mechanism
Vicent Marti b0b527e0 2011-05-20T03:20:12 config: Cleanup & renaming of the external API "git_config_backend" have been renamed to "git_config_file", which implements a generic interface to access a configuration file -- be it either on disk, from a DB or whatever mumbojumbo. I think this makes more sense.
Vicent Martí 274f2c21 2011-05-19T14:18:57 Merge pull request #193 from carlosmn/config A couple of config improvements
Sebastian Schuberth 8133afef 2011-05-19T09:26:01 Fix a few minor typos in comments and error messages Regarding "initialize" vs. "initialise", www.dict.cc says the first is American English whereas the latter in British English. For consistency, we should stick to American English.
Sebastian Schuberth 765fdf4a 2011-05-18T17:19:38 Use "__inline" instead of "inline" with MSVC MSVC supports "inline" only in C++ code, not in C code.
Carlos Martín Nieto 6421c49a 2011-05-17T18:55:52 Fix variable name normalization When I changed it over to use different strings for the variable and the name, cvar_name_normalize was left behind. Fix this and rename to cvar_normalize_name to reflect the incompatible change. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Vicent Marti 128d3731 2011-05-17T15:05:41 config_file: Fix compilation
Carlos Martín Nieto 29dca088 2011-05-17T13:38:19 Move config to the new error methods Take this opportunity to fix an instance of returning GIT_EOBJCORRUPTED when malloc failed. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto c0335005 2011-05-06T12:42:47 Move config to a backend structure Configuration options can come from different sources. Currently, there is only support for reading them from a flat file, but it might make sense to read it from a database at some point. Move the parsing code into src/config_file.c and create an include file include/git2/config_backend.h to allow for other backends to be developed. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>