Commit Graph

1171 Commits

Author SHA1 Message Date
Jakob Pfender
fd279b262d index.c: Correctly check whether index contains extended entries
Although write_index() supports writing extended header versions for
index, this was never done as there was no check for extended index
entries.

Introduce function is_index_extended() that checks whether an index
contains extended entries and check whether an index is extended before
writing it to disk, adjusting its version number if necessary.
2011-04-07 16:58:42 +02:00
Jakob Pfender
a5a546b36c index.h: Correct values for extended flags
As libgit2 separates an index entry's 32-bit flag into two 16-bit values
flags and flags_extended, the values of flags_extended need to be
adjusted.
2011-04-07 16:53:50 +02:00
Carlos Martín Nieto
0d280ea457 config: use snprintf instead of sprintf
Due to the preconditions, there should never be an error, but it pays
to be paranoid.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-06 16:31:06 +02:00
Carlos Martín Nieto
956ad0ed6f config: free the file buffer earlier
There is no need to keep config file in memory until the the
configuration is freed. Free the buffer immediately after the
configuration has been parsed.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-06 15:51:10 +02:00
Carlos Martín Nieto
8bd6c0ab83 Merge remote-tracking branch 'upstream/development' into config 2011-04-06 15:49:29 +02:00
Carlos Martín Nieto
acab3bc474 config: move str(n)tolower to the git__ namespace
Non-static functions in a library should always have a prefix
namespace.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-06 15:31:42 +02:00
Carlos Martín Nieto
aa793424d3 config: coding style fixes 2011-04-06 15:29:01 +02:00
Carlos Martín Nieto
6776fd514b config: really compare the variable name case-insensitively
Make cvar_name_match really compare the last part of the variable
ignoring the case.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-06 15:29:01 +02:00
Jakob Pfender
59f8f24ff8 Merge branch 'development' into index-flags 2011-04-05 10:57:41 +02:00
Vicent Marti
0ad6efa110 Build & write custom trees in memory 2011-04-04 19:25:33 +03:00
Carlos Martín Nieto
511b2370d9 tests: update NAMING file
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 17:24:37 +02:00
Carlos Martín Nieto
8cd767ef52 config: test for a variable on its own
If a variable is on its own, truth should be assumed. Check this is
true in our code.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 17:07:47 +02:00
Carlos Martín Nieto
2470be13f2 config: variable name on its own means true
If a variable name appears on its own in a line, it's assumed the
value is true. Store the variable name as NULL in that case.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 17:06:31 +02:00
Carlos Martín Nieto
0bf8ca8820 config: add tests
These tests are basic, but they should tell us when we've broken
something.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 16:44:23 +02:00
Jakob Pfender
7c7fcdae0e index.h: Add IDXENTRY flags needed for index operations
Add several IDXENTRY flags that need to be checked in
order to properly implement update-index --refresh.
2011-04-04 16:20:09 +02:00
Carlos Martín Nieto
9b7a6a9980 config: check for EOF before newline
If a line ends at EOF there is no need to check for the newline
character and doing so will cause us to read memory beyond the
allocatd memory as we check for the Windows-style new-line, which is
two bytes long.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 16:17:39 +02:00
Carlos Martín Nieto
72946881b5 config: support multiline values
If a variable value has the traditional continuation character (\) as
the last non-space character in the line, then we continue reading the
value on the next line.

Using more than two lines is also supported.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 15:33:26 +02:00
Carlos Martín Nieto
2454ce784f config: don't mix buffer reading methods
Make header and variable parse functions use their own buffers instead
of giving them the line they need to read as a parameter which they
mostly ignore.

This is in preparation for multiline configuration variables.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 15:33:26 +02:00
Carlos Martín Nieto
9f1b54d6d0 config: also free the file buffer on error
On error, the buffer containing the file contents also needs to be
freed.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 15:33:26 +02:00
Carlos Martín Nieto
fe116e261f config: Fix typo and remove debug statement
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-04 15:33:26 +02:00
nulltoken
b153589be2 Make reinitializing a repository return GIT_ENOTIMPLEMENTED instead of GIT_SUCCESS 2011-04-04 13:12:28 +03:00
nulltoken
f3564e1e29 Fix tag reference name in testrepo.git
The git test repository was holding a wrongly named tag reference ("very-simple") pointing at a tag named "e90810b".
This mistake (mine :-/ ) originates back to https://github.com/libgit2/libgit2/commit/9282e92

Whole credit goes to @tclem for having spotted this.
2011-04-04 13:12:23 +03:00
Vicent Marti
d69d0185d1 Add a fake wstream to the ODB
Streaming writes will no longer fail when writing to a backend that
doesn't support streaming writes but supports direct ones.
Now we create a fake stream on memory and then write it as a single
block using the backend `write` callback.
2011-04-04 13:08:54 +03:00
Vicent Marti
29e1789b34 Fix the git_tree_write implementation 2011-04-04 12:14:43 +03:00
Sarath Lakshman
47d8ec56e9 New external API method: git_tree_create
Creates a tree by scanning the index file. The method handles recursive
creation of trees for subdirectories and adds them to the parent tree.
2011-04-03 17:18:56 +05:30
Vicent Marti
3e3e4631a0 Merge branch 'tagging' of https://github.com/nulltoken/libgit2 into development
Conflicts:
	include/git2/tag.h
	src/tag.c
2011-04-02 12:50:25 +03:00
Vicent Marti
720d5472f8 Change parse methods to const buffer
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-04-02 12:42:04 +03:00
Vicent Marti
d8ad64d366 Merge branch 'parse-tag-buffer' of https://github.com/carlosmn/libgit2 into development 2011-04-02 12:28:35 +03:00
Olivier Ramonat
ccfce5f30f Update README after sqlite option change
To build libgit2 with sqlite support, waf configure should be run
with --with-sqlite
2011-04-02 12:23:09 +03:00
Carlos Martín Nieto
f026f2b9ee Merge upstream/development
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:29:13 +02:00
Carlos Martín Nieto
11d0e70578 Add support for subsections
A variable name is stored internally with its section the way it
appeared in the configuration file in order to have the information
about what parts are case-sensitive inline.

Really implement parse_section_header_ext and move the assignment of
variables to config_parse.

The variable name matching is now done in a case-away way by
cvar_name_match and cvar_section_match. Before the user sees it, it's
normalized to the two- or three-dot version.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:21:54 +02:00
Carlos Martín Nieto
6482929b5f move build_varname above parse_section 2011-03-31 15:05:12 +02:00
Carlos Martín Nieto
d7354d70b0 build_varname: lowercase the variable name
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:05:12 +02:00
Carlos Martín Nieto
0bbaf9aaef config_parse: no need to check if current_section is non-null
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:05:12 +02:00
Carlos Martín Nieto
923fe4557f Add strtolower and strntolower functions
As parts of variable names are case-sensitive, we need these functions.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:05:12 +02:00
Carlos Martín Nieto
df22949a35 config_set: really replace the value on overwrite
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:05:12 +02:00
Carlos Martín Nieto
ba84cad380 wscript: Use -O0 on debug
If we want debugging symbols, we most likely want them to point to the
right place. With -O2, gdb or valgrind may give wrong information.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:02:24 +02:00
nulltoken
ac26e2454e Rename git_tag_create_o_f() to git_tag_create_fo() 2011-03-30 23:46:54 +02:00
nulltoken
9e680bcc00 Add git_tag_delete() 2011-03-30 23:26:36 +02:00
nulltoken
a50c145855 Add git_tag_create_o_f() and git_tag_create_f() which overwrite existing tag reference, if any 2011-03-30 23:16:30 +02:00
nulltoken
74e50a2d3e Fix memory leak in tag releated tests 2011-03-30 22:46:52 +02:00
nulltoken
bf4c39f929 Prevent tag_create() from creating a conflicting reference 2011-03-30 22:30:55 +02:00
nulltoken
6d3160148b Add test demonstrating that one can create a tag pointing at a non existent target 2011-03-30 22:26:53 +02:00
nulltoken
8e9a3d4217 Enforce the testing of the correct creation of a tag 2011-03-30 21:46:19 +02:00
nulltoken
673de2cf59 Fix misleading comments 2011-03-30 21:29:10 +02:00
Carlos Martín Nieto
8ecc5ae5cb git_config_set_int: use the right buffer
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 16:50:28 +02:00
Carlos Martín Nieto
e21881d1db git_config: reorder fields according to use
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 15:44:23 +02:00
Carlos Martín Nieto
dadc0158fb config: use a singly-linked list instead of a hash table
Such a list preserves the order the variables were first read in which
will be useful later for merging different data-sets. Furthermore,
reading and writing out the same configuration should not reorganize
the variables, which could happen when iterating through all the items
in a hash table.

A hash table is overkill for this small a data-set anyway.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 15:44:23 +02:00
Carlos Martín Nieto
d28830c255 Store the parsed variables
Store the key-value pair as strings.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 13:43:01 +02:00
Carlos Martín Nieto
934fcf78f2 Initialise the config reader in config_parse
git_config_open shouldn't have to initialise variables that are only
used inside config_parse and its callees.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 13:42:25 +02:00