Commit Graph

62 Commits

Author SHA1 Message Date
Russell Belfer
ce23330fd6 Add new git_signature_default API using config
This adds a new API for creating a signature that uses the
config to look up "user.name" and "user.email".
2013-08-16 15:04:15 -07:00
Vicent Martí
93da7af707 Merge pull request #1642 from arrbee/diff-function-context
Diff code reorg plus function context in diff headers
2013-06-12 14:52:47 -07:00
Carlos Martín Nieto
24ec69998d signature: extend trimming to more whitespace
There are all sorts of misconfiguration in the wild. We already rely
on the signature constructor to trim SP. Extend the logic to use
`isspace` to decide whether a character should be trimmed.
2013-06-11 11:01:45 +02:00
Russell Belfer
114f5a6c41 Reorganize diff and add basic diff driver
This is a significant reorganization of the diff code to break it
into a set of more clearly distinct files and to document the new
organization.  Hopefully this will make the diff code easier to
understand and to extend.

This adds a new `git_diff_driver` object that looks of diff driver
information from the attributes and the config so that things like
function content in diff headers can be provided.  The full driver
spec is not implemented in the commit - this is focused on the
reorganization of the code and putting the driver hooks in place.

This also removes a few #includes from src/repository.h that were
overbroad, but as a result required extra #includes in a variety
of places since including src/repository.h no longer results in
pulling in the whole world.
2013-06-10 10:10:39 -07:00
Scott J. Goldman
dc33b3d7b2 Don't bail on parsing commits with an invalid timezone
git doesn't do that, and it's not something that's usually
actionable to fix. if you have a git repository with one bad
timezone in the history, it's too late to change it most likely.
2013-06-02 02:13:45 -07:00
nulltoken
1fed6b07f0 Fix trailing whitespaces 2013-05-15 22:41:30 +02:00
Vicent Marti
f0ab73720a signature: Lenient when dupping, strict when creating 2013-05-15 17:51:57 +02:00
Nicolas Viennot
9e46f67618 Return error for empty name/email 2013-04-18 00:56:42 -04:00
Vicent Marti
cf80993a50 signature: Small cleanup 2013-02-20 18:46:10 +01:00
Vicent Marti
41051e3fe1 signature: Shut up MSVC, you silly goose 2013-02-20 17:09:51 +01:00
Vicent Marti
c51880eeaf Simplify signature parsing 2013-02-20 17:03:18 +01:00
Russell Belfer
965e4e2d31 Parse commit time as uint64_t to avoid overflow
The commit time is already stored as a git_time_t, but we were
parsing is as a uint32_t.  This just switches the parser to use
uint64_t which will handle dates further in the future (and adds
some tests of those future dates).
2013-01-21 13:19:41 -08:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Ben Straub
de70aea6b1 Remove GIT_SIGNATURE_VERSION and friends 2012-12-03 12:41:50 -08:00
Ben Straub
4ec197f304 Deploy GIT_SIGNATURE_INIT 2012-11-30 13:12:16 -08:00
nulltoken
b97c169ec0 Fix MSVC compilation warnings 2012-09-04 10:01:18 +02:00
Carlos Martín Nieto
d03d309b10 signature: make the OS give us the offset for git_signature_now
There is a better and less fragile way to calculate time offsets. Let
the OS take care of dealing with DST and simply take the the offset
between the local time and UTC that it gives us.
2012-08-28 18:02:12 +02:00
nulltoken
8aedf1d558 signature: prevent angle bracket usage in identity 2012-07-11 20:40:13 +02:00
Ben Straub
9ecf860d48 Rename posix wrappers with 'p_' prefix. 2012-06-06 13:24:25 -07:00
Ben Straub
56a5000d58 Merge branch 'development' into rev-parse
Conflicts:
	src/util.h
	tests-clar/refs/branches/listall.c
2012-06-05 12:52:44 -07:00
Vicent Martí
e172cf082e errors: Rename the generic return codes 2012-05-18 01:26:26 +02:00
Ben Straub
1ce4cc0164 Fix date.c build in msvc.
Ported the win32 implementations of gmtime_r,
localtime_r, and gettimeofday to be part of the 
posix compatibility layer, and fixed
git_signature_now to use them.
2012-05-15 15:41:05 -07:00
Russell Belfer
44ef8b1b30 Fix warnings on 64-bit windows builds
This fixes all the warnings on win64 except those in deps, which
come from the regex code.
2012-04-17 10:47:39 -07:00
Russell Belfer
a4c291ef12 Convert reflog to new errors
Cleaned up some other issues.
2012-03-20 21:57:38 -07:00
Russell Belfer
4aa7de1515 Convert indexer, notes, sha1_lookup, and signature
More files moved to new error handling style.
2012-03-19 17:49:46 -07:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Russell Belfer
97769280ba Use git_buf for path storage instead of stack-based buffers
This converts virtually all of the places that allocate GIT_PATH_MAX
buffers on the stack for manipulating paths to use git_buf objects
instead.  The patch is pretty careful not to touch the public API
for libgit2, so there are a few places that still use GIT_PATH_MAX.

This extends and changes some details of the git_buf implementation
to add a couple of extra functions and to make error handling easier.

This includes serious alterations to all the path.c functions, and
several of the fileops.c ones, too.  Also, there are a number of new
functions that parallel existing ones except that use a git_buf
instead of a stack-based buffer (such as git_config_find_global_r
that exists alongsize git_config_find_global).

This also modifies the win32 version of p_realpath to allocate whatever
buffer size is needed to accommodate the realpath instead of hardcoding
a GIT_PATH_MAX limit, but that change needs to be tested still.
2011-12-07 23:08:15 -08:00
Vicent Marti
3286c408ec global: Properly use git__ memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
2011-10-28 19:02:36 -07:00
Brodie Rao
6f2856f308 signature: don't blow up trying to parse names containing '>'
When trying to find the end of an email, instead of starting at the
beginning of the signature, we start at the end of the name (after the
first '<').

This brings libgit2 more in line with Git's behavior when reading out
existing signatures.

However, note that Git does not allow names like these through the
usual porcelain; instead, it silently strips any '>' characters it
sees.
2011-10-12 16:19:46 -07: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 Martí
71a4c1f16f Merge pull request #384 from kiryl/warnings
Add more -W flags to CFLAGS
2011-09-18 20:07:59 -07: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
Kirill A. Shutemov
d568d5856b CMakefile: add -Wmissing-prototypes and fix warnings
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-08-30 23:55:22 +03:00
schu
63396a3998 signature: adjust API to return error codes
git_signature_new() and git_signature_now() currently don't return error
codes. Change the API to return error codes and not pointers to let the
user handle errors properly.

Signed-off-by: schu <schu-github@schulog.org>
2011-08-03 16:05:32 +02:00
schu
5274c31a89 signature.c: fix off-by-one error
Signed-off-by: schu <schu-github@schulog.org>
2011-08-03 01:17:31 +02:00
nulltoken
7757be33a2 reflog: Fix reflog writer/reader
- Use a space to separate oids and signature
 - Enforce test coverage
 - Make test run in a temporary folder in order not to alter the test repository
2011-07-10 19:17:07 +02:00
Vicent Marti
06c43821b9 Remove unused methods
The direct-writes commit left some (slow) internals methods that
were no longer needed. These have been removed.

Also, the Reflog code was using the old `git_signature__write`, so
it has been rewritten to use a normal buffer and the new `writebuf`
signature writer. It's now slightly simpler and faster.
2011-07-09 02:40:16 +02:00
Vicent Marti
afeecf4f26 odb: Direct writes are back
DIRECT WRITES ARE BACK AND FASTER THAN EVER. The streaming writer to the
ODB was an overkill for the smaller objects like Commit and Tags; most
of the streaming logic was taking too long.

This commit makes Commits, Tags and Trees to be built-up in memory, and
then written to disk in 2 pushes (header + data), instead of streaming
everything.

This is *always* faster, even for big files (since the git_filebuf class
still does streaming writes when the memory cache overflows). This is
also a gazillion lines of code smaller, because we don't have to
precompute the final size of the object before starting the stream (this
was kind of defeating the point of streaming, anyway).

Blobs are still written with full streaming instead of loading them in
memory, since this is still the fastest way.

A new `git_buf` class has been added. It's missing some features, but
it'll get there.
2011-07-09 02:40:16 +02:00
Vicent Marti
d483a911b8 signature: Fix optional header 2011-07-09 02:40:16 +02:00
schu
6727e30028 git_signature__write: make header optionally
Signed-off-by: schu <schu-github@schulog.org>
2011-07-09 02:40:16 +02:00
Vicent Marti
9f86ec52fa signature: Fix warnings
Add extra braces to avoid ambiguous if-else.

Also, free() doesn't need a check.
2011-07-05 02:28:18 +02:00
nulltoken
a01acc47bb signature: straighten the creation of a signature
- Fails on empty name and/or email
 - Trims leading and trailing spaces of name and email
2011-07-05 02:21:26 +02:00
nulltoken
42a1b5e1ad signature: enhance relaxed parsing of bogus signatures
Final fix for issue #278
2011-07-05 02:21:26 +02:00
schu
8b2c913acb git_signature__parse: make parsing less strict
git_signature__parse used to be very strict about what's a well-formed
signature. Since git_signature__parse is used only when reading already
existing signatures, we should not care about if it's a valid signature
too much but rather show what we got.

Reported-by: nulltoken <emeric.fermas@gmail.com>
Signed-off-by: schu <schu-github@schulog.org>
2011-07-05 02:21:25 +02:00
Kirill A. Shutemov
932d1baf29 cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-01 18:02:56 +02:00
Carlos Martín Nieto
5f25149e46 sig: allow empty names
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-28 22:04:27 +02:00
Vicent Marti
e053c911cf commit: Allow spaces inside email addresses
Core Git doesn't care when people use spaces in the email address, even
though this kind of foolery receives the capital punishment in several
states of the USA.

We must obey.
2011-06-28 19:52:41 +02:00
Vicent Marti
fea400f87b signature: Fix compilation 2011-06-01 23:41:30 +02:00
David Glesser
fbfc758022 Fix tag and signature parsing
Before this commit, malformed tag and signature were considered as
valid by the parser. See the test t3800-mktag.sh of git to see example
of malformed tag and signature.
2011-05-31 18:38:59 +02:00
Jakob Pfender
005564967f signature.c: Move to new error handling mechanism 2011-05-23 21:38:37 +03:00