Commit Graph

751 Commits

Author SHA1 Message Date
Carlos Martín Nieto
0130d8184e Fix git__strntolower
Obviously, the whole string should be lower-cased and not just the
last char.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-27 11:20:38 +02:00
Carlos Martín Nieto
a68cf94b37 Fix const char ** warning
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-19 16:40:52 +02:00
Carlos Martín Nieto
e69ac2439f config: export git_config_[sg]et_long
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-19 16:38:55 +02:00
Carlos Martín Nieto
a99264bff6 config: allow uppercase number suffixes
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-19 16:34:22 +02:00
Carlos Martín Nieto
53345e1f1f config: add tests for number suffix
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-11 18:01:01 +02:00
Carlos Martín Nieto
52ca4f8a39 Use internal strtol
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-11 17:51:05 +02:00
Carlos Martín Nieto
631752aaf6 Fix number suffix detection
Allow a number not to have a suffix. This broke when adding the
suffixes.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-11 17:50:22 +02:00
Carlos Martín Nieto
55c197cdd3 Merge upstream/development 2011-04-11 17:43:56 +02:00
Vicent Marti
fdd0cc9e89 Fix path normalization tests
They were backtracking too deep into the filesystem on Linux, where the
tests were running directly on `tmp/`.
2011-04-10 15:25:41 -07:00
Vicent Marti
a6359408a5 Use Z_BEST_SPEED for filebuf deflating
This is what Git uses by default for all deflating.
2011-04-10 12:23:55 -07:00
Vicent Marti
fff036ec15 Import 'with' from __future__ in the build script 2011-04-09 17:45:38 -07:00
Vicent Marti
53b7560ba5 Fix time_t conversion on Win32 2011-04-09 16:16:09 -07:00
Vicent Marti
14eb94eefa Fix gmtime issues in Win32 2011-04-09 16:06:17 -07:00
Vicent Marti
8416c9adcc Rename git_signature_new_now
The new name is more cool.
2011-04-09 15:31:12 -07:00
Carlos Martín Nieto
9e9e6ae177 Add API git_signature_new_now
Most tags will have a timestamp of whenever the code is running and
dealing with time and timezones is error-prone. Optimize for this case
by adding a function which causes the signature to be created with a
current timestamp.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-09 15:29:48 -07:00
Carlos Martín Nieto
b5c00c6d41 Fix the signature documentation
The parameters are given by '@param name' and not '@name'.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-09 15:29:28 -07:00
Carlos Martín Nieto
076141a137 Add a few malloc checks
Add checks to see if malloc failed when allocating the tag members and
signature members.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-09 15:27:16 -07:00
nulltoken
4a34b3a9ff Add two new accessors to the repository
git_repository_path() and git_repository_workdir() respectively return the path to the git repository and the working directory. Those paths are absolute and normalized.
2011-04-09 15:25:24 -07:00
Vicent Marti
c6e65acae6 Properly check strtol for errors
We are now using a custom `strtol` implementation to make sure we're not
missing any overflow errors.
2011-04-09 15:22:11 -07:00
Vicent Marti
b918ae40d1 Do not declare variables in the middle of a func 2011-04-08 15:35:25 -07:00
Vicent Marti
41233c40c0 Add new method git_repository_is_empty 2011-04-08 12:42:18 -07:00
Vicent Marti
cef75d7430 Remove unused variables from test files 2011-04-08 12:41:17 -07:00
Vicent Marti
d79f1da65a refs: Fix issue when packing weak tags
Weak tags (e.g. tags that point directly to a normal object instead of a
tag object) were failing to be packed.
2011-04-08 12:14:33 -07:00
Carlos Martín Nieto
6ac247b381 tag: don't check twice if an object exists
Remove the check in git_tag_create_frombuffer as it's done by
tag_create already.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-08 03:36:53 +03:00
Carlos Martín Nieto
7bc66a79fa tag: don't allow tags to non-existent objects
These indicate an inconsistency in the repository which we've created,
so don't allow them.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-08 03:36:53 +03:00
Carlos Martín Nieto
81234673a1 tag: discover the target type if needed
Don't blindly pass the target type to git_tag_type2string as it will
give an empty string on GIT_OBJ_ANY which would cause us to create an
invalid tag object.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-08 03:36:53 +03:00
Jakob Pfender
26f2c897b8 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-08 03:33:50 +03:00
Sam
5924b2822c Added git_commit_tree_oid and git_commit_parent_oid. 2011-04-08 03:33:46 +03:00
Shuhei Tanuma
98ac678085 fix git_treebuilder_insert probrem.
couldn't add new entry when inserting new one with `git_treebuilder_insert`.
2011-04-08 03:30:47 +03:00
Vicent Marti
5868cd02b7 Do not assert error codes on Hiredis backend
We cannot assume that Redis is never going to return an error code; when
Reddit fails, we cannot crash our library, we need to handle the crash
gracefully.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-04-08 03:28:38 +03:00
Dmitry Kovega
8a64bc292c redis backend 2011-04-08 03:27:01 +03:00
Carlos Martín Nieto
b075b9910c Add getting and setting of long int variables
long int is a safer type than int unless the user knows that the
variable is going to be quite small.

The code has been reworked to use strtol instead of the more
complicated sscanf.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-07 17:17:18 +02:00
Carlos Martín Nieto
7a4dfd6028 Simplify error path in config_set
Many error paths freed their local data althought it is freed later on
when the end of the function notices that there was an error. This can
cause double frees and invalid memory access.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-07 17:15:38 +02:00
Carlos Martín Nieto
493384e39c config: make cvar_free behave more like other free functions
Make cvar_free return void instad of the next element, as it was
mostly a hack to make cvar_list_free shorter but it's now using the
list macros.

Also check if the input is NULL and return immediately in that case.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-07 17:15:38 +02:00
Carlos Martín Nieto
6b45cb8a89 config: use and implement list macros
Use list macros instead of manually changing the head and/or tail of
the variable list.
2011-04-07 17:15:30 +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
Vicent Marti
0ad6efa110 Build & write custom trees in memory 2011-04-04 19:25:33 +03: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
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