Commit Graph

2720 Commits

Author SHA1 Message Date
Vicent Marti
b0b9fd3245 Merge remote-tracking branch 'origin/clone-auth' into development 2012-12-14 02:41:53 +01:00
Jameson Miller
f0a2def5e4 Fix comment so it doesn't go over 100 chars 2012-12-13 18:08:45 -05:00
Jameson Miller
cb2ace69f4 Transport resolution on Win32 should handle absolute local paths 2012-12-13 14:42:40 -05:00
Ben Straub
24393ea6d3 Stop premature remote freeing when cloning 2012-12-13 09:14:56 -08:00
Ben Straub
7c353afd0e Define constant for default fetch spec 2012-12-13 08:47:29 -08:00
Ben Straub
44f36f6e3b Convert clone to use dangling remotes 2012-12-12 19:48:44 -08:00
Edward Thomson
e759b07217 don't walk off the end of the index 2012-12-12 17:54:12 -06:00
Ben Straub
b914e17d82 API to set a dangling remote's repository 2012-12-12 12:23:24 -08:00
Ben Straub
a71c27ccda Allow creation of dangling remotes 2012-12-12 12:15:25 -08:00
Nguyễn Thái Ngọc Duy
08f3d6caf4 tree cache: loosen negative entry count check
While C Git has been writing entry count -1 (ie. never other negative
numbers) as invalid since day 1, it accepts all negative entry counts
as invalid. JGit follows the same rule. libgit2 should also follow, or
the index that works with C Git or JGit may someday be rejected by
libgit2.

Other reimplementations like dulwich and grit have not bothered with
parsing or writing tree cache.
2012-12-12 19:23:05 +07:00
Russell Belfer
91e7d26303 Fix iterator reset and add reset ranges
The `git_iterator_reset` command has not been working in all cases
particularly when there is a start and end range.  This fixes it
and adds tests for it, and also extends it with the ability to
update the start/end range strings when an iterator is reset.
2012-12-10 15:38:41 -08:00
Russell Belfer
9950d27ab6 Clean up iterator APIs
This removes the need to explicitly pass the repo into iterators
where the repo is implied by the other parameters.  This moves
the repo to be owned by the parent struct.  Also, this has some
iterator related updates to the internal diff API to lay the
groundwork for checkout improvements.
2012-12-10 15:38:28 -08:00
Ben Straub
4cbe9a1be1 Add git_cred_acquire_cb payload to winhttp transport 2012-12-10 11:48:20 -08:00
Ben Straub
59bccf33c4 Add a payload param to git_cred_acquire_cb
Fixes #1128.
2012-12-10 11:11:01 -08:00
Vicent Martí
22bcf86c5a Merge pull request #1126 from carlosmn/indexer-buffer
indexer: move the temporary buffers into the indexer object
2012-12-10 06:55:59 -08:00
Scott J. Goldman
7d26c410bf Fix a bunch of leaks, error handling cases 2012-12-09 21:55:51 -08:00
Scott J. Goldman
e51c8b99be Fix mark_parents() to account for bad luck traversals
If commit timestamps are off, we're more likely to hit a traversal
where the first path ends up traversing past the root commit of the tree.
If that happens, it's possible that the loop will complete before the second
path marks some of those final parents. This fix keeps track of the root
nodes that are encountered in the traversal, and verify that they are
properly marked.

In the best case, with accurate timestamps, the traversal will continue
to terminate when all the commits are STALE (parents of a merge-base), as
it did before. In the worst case, where one path makes a complete traversal
past a root commit, we will continue the loop until the root commit itself
is marked.
2012-12-09 21:24:47 -08:00
Scott J. Goldman
9c2a4e8c47 Morph copy of git_merge__bases_many() -> mark_parents()
Integrate mark_parents() with the ahead_behind() code.
2012-12-09 21:01:46 -08:00
Scott J. Goldman
a3a81ae542 Copy git_merge__bases_many() for new ahead-behind code
To be used as a basis for a function which marks nodes with parents
up to the merge base.
2012-12-09 20:43:26 -08:00
Justin Spahr-Summers
1d00960334 orite C89 2012-12-09 02:40:16 -08:00
Justin Spahr-Summers
2bb1c7aa26 Treat git_mutex_lock as successful when threads are disabled 2012-12-09 02:37:33 -08:00
Justin Spahr-Summers
a35b386458 Always check the result of git_mutex_lock 2012-12-09 02:31:39 -08:00
Justin Spahr-Summers
c3320aca76 git__mwindow_mutex needs to be initialized even with pthreads
This could also use PTHREAD_MUTEX_INITIALIZER, but a dynamic initializer seems like a more portable concept, and we won't need another #define on top of git_mutex_init()
2012-12-09 02:22:50 -08:00
Carlos Martín Nieto
6481a68d49 indexer: move the temporary buffers into the indexer object
Storing 4kB or 8kB in the stack is not very gentle. As this part has
to be linear, put the buffer into the indexer object so we allocate it
once in the heap.
2012-12-07 19:24:55 +01:00
Vicent Martí
0249a5032e Merge pull request #1091 from carlosmn/stream-object
Indexer speedup with large objects
2012-12-07 09:40:21 -08:00
Carlos Martín Nieto
f1c75b94a1 tree: relax the filemode parser
There are many different broken filemodes in the wild so we need to
protect against them and give something useful up the chain. Don't
fail when reading a tree from the ODB but normalize the mode as best
we can.

As 664 is no longer a mode that we consider to be valid and gets
normalized to 644, we can stop accepting it in the treebuilder. The
library won't expose it to the user, so any invalid modes are a bug.
2012-12-07 16:59:18 +01:00
Russell Belfer
32770c52a8 Fix diff header comments and missing const
Based on the recent work to wrap diff in objective-git, this
includes a fix for a missing const and a number of clarifications
of the documentation.
2012-12-05 13:56:32 -08:00
Vicent Marti
bf192cdb43 versions: MSVC build fixes 2012-12-05 20:56:27 +01:00
Vicent Marti
43efaabd40 common: Silly vmg. 2012-12-05 20:54:03 +01:00
Vicent Marti
8ff66112d9 common: Silly MSVC 2012-12-05 20:50:19 +01:00
Vicent Martí
e05ca13f1f Merge pull request #1115 from ben/struct-versions
Version info for public structs
2012-12-05 11:47:19 -08:00
Edward Thomson
05fc823fce indentation fix 2012-12-04 16:59:34 -06:00
Edward Thomson
aab8f5af4b hey don't stomp on my memory! 2012-12-04 16:40:09 -06:00
Edward Thomson
b241466133 status should ignore conflicts entries in the index 2012-12-03 14:51:39 -06:00
Ben Straub
ee1c33b146 Don't unconstify when casting 2012-12-03 12:45:15 -08:00
Ben Straub
de70aea6b1 Remove GIT_SIGNATURE_VERSION and friends 2012-12-03 12:41:50 -08:00
Vicent Martí
3368c520dc Merge pull request #1112 from barrbrain/odb-pack-read-header
odb-pack: resurrect pack_backend__read_header
2012-12-03 07:38:58 -08:00
Vicent Marti
7ea3a79f0c Vade retro satana 2012-12-03 16:04:39 +01:00
David Michael Barr
bfb8bcc1df odb-pack: resurrect pack_backend__read_header 2012-12-03 10:39:17 +11:00
David Michael Barr
44f9f54797 pack: add git_packfile_resolve_header
To paraphrase @peff:

You can get both size and type from a packed object reasonably cheaply.
If you have:

* An object that is not a delta; both type and size are available in the
  packfile header.
* An object that is a delta. The packfile type will be OBJ_*_DELTA, and
  you have to resolve back to the base to find the real type. That means
  potentially a lot of packfile index lookups, but each one is
  relatively cheap. For the size, you inflate the first few bytes of the
  delta, whose header will tell you the resulting size of applying the
  delta to the base.

For simplicity, we just decompress the whole delta for now.
2012-12-03 10:39:17 +11:00
nulltoken
cc1466264a revparse: Deploy EINVALIDSPEC usage 2012-12-01 08:34:31 +01:00
nulltoken
bc05f30c47 object: refine git_object_peel() error report 2012-12-01 08:34:29 +01:00
nulltoken
18d6f12040 tag: Deploy EINVALIDSPEC usage 2012-12-01 08:34:28 +01:00
nulltoken
80212ecb1c reflog: Deploy EINVALIDSPEC usage 2012-12-01 08:34:27 +01:00
nulltoken
80d9d1df14 refs: Deploy EINVALIDSPEC usage 2012-12-01 08:34:26 +01:00
nulltoken
83458bb77f refs: Fix error clearing 2012-12-01 08:34:24 +01:00
nulltoken
032ba9e4ad remote: deploy EINVALIDSPEC usage 2012-12-01 08:34:23 +01:00
Ben Straub
0ab3a2ab2c Deploy GIT_INIT_STRUCTURE 2012-11-30 20:34:50 -08:00
David Michael Barr
d1b6ea8ad1 delta-apply: add git__delta_read_header 2012-12-01 14:50:45 +11:00
Ben Straub
c7231c45fe Deploy GITERR_CHECK_VERSION 2012-11-30 16:31:42 -08:00
Ben Straub
4ec197f304 Deploy GIT_SIGNATURE_INIT 2012-11-30 13:12:16 -08:00
Ben Straub
1071176900 Deploy versioned git_transport structure 2012-11-30 13:12:15 -08:00
Ben Straub
79cfa20d60 Deploy GIT_STATUS_OPTIONS_INIT 2012-11-30 13:12:15 -08:00
Ben Straub
b4d136527c Deploy GIT_REPOSITORY_INIT_OPTIONS_INIT 2012-11-30 13:12:15 -08:00
Ben Straub
9267ff586f Deploy GIT_REMOTE_CALLBACKS_INIT 2012-11-30 13:12:15 -08:00
Ben Straub
55f6f21b7d Deploy versioned git_odb_backend structure 2012-11-30 13:12:15 -08:00
Ben Straub
ca901e7b0f Deploy GIT_DIFF_FIND_OPTIONS_INIT 2012-11-30 13:12:15 -08:00
Ben Straub
2f8d30becb Deploy GIT_DIFF_OPTIONS_INIT 2012-11-30 13:12:14 -08:00
Ben Straub
6917762139 Deploy git_config_backend version 2012-11-30 13:12:14 -08:00
Ben Straub
b81aa2f1de Deploy GIT_CHECKOUT_OPTS_INIT 2012-11-30 13:12:14 -08:00
Carlos Martín Nieto
3908c254aa indexer: correctly deal with objects larger than the window size
A mmap-window is not guaranteed to give you the whole object, but the
indexer currently assumes so.

Loop asking for more data until we've successfully CRC'd all of the
packed data.
2012-11-30 19:16:39 +01:00
Carlos Martín Nieto
5a3ad89dbd indexer: make use of streaming also for deltas
Up to now, deltas needed to be enterily in the packfile, and we tried
to decompress then in their entirety over and over again.

Adjust the logic so we read them as they come, just as we do for full
objects. This also allows us to simplify the logic and have less
nested code. The delta resolving phase still needs to decompress the
whole object into memory, as there is not yet any streaming
delta-apply support, but it helps in speeding up the downloading
process and reduces the amount of memory allocations we need to do.
2012-11-30 15:55:23 +01:00
Carlos Martín Nieto
f56f8585c0 indexer: use the packfile streaming API
The new API allows us to read the object bit by bit from the packfile,
instead of needing it all at once in the packfile. This also allows us
to hash the object as it comes in from the network instead of having
to try to read it all and failing repeatedly for larger objects.

This is only the first step, but it already shows huge improvements
when dealing with objects over a few megabytes in size. It reduces the
memory needs in some cases, but delta objects still need to be
completely in memory and the old inefficent method is still used for
that.
2012-11-30 15:55:23 +01:00
Carlos Martín Nieto
46635339e9 pack: introduce a streaming API for raw objects
This allows us to take objects from the packfile as a stream instead
of having to keep it all in memory.
2012-11-30 15:55:23 +01:00
Carlos Martín Nieto
da82043736 graph: plug leak 2012-11-30 15:26:45 +01:00
Carlos Martín Nieto
9ff07c24f5 buf test: make sure we always set the bom variable 2012-11-30 15:17:05 +01:00
Russell Belfer
f684970a10 Merge pull request #1108 from libgit2/ahead-behind-count
Add API to calculate ahead/behind count
2012-11-29 22:53:34 -08:00
Scott J. Goldman
bdf3e6df83 Fix error condition typo 2012-11-29 17:34:41 -08:00
Russell Belfer
d5e44d8498 Fix function name and add real error check
`revwalk.h:commit_lookup()` -> `git_revwalk__commit_lookup()`
and make `git_commit_list_parse()` do real error checking that
the item in the list is an actual commit object.  Also fixed an
apparent typo in a test name.
2012-11-29 17:02:27 -08:00
Vicent Martí
f1e5c506b2 Merge pull request #1110 from libgit2/features/push_rebased
Push! By schu, phkelley, and congyiwu
2012-11-29 12:18:05 -08:00
Philip Kelley
4a6621fdf7 Leverage the min macro from util.h 2012-11-29 08:35:21 -05:00
Philip Kelley
6762fe087b Remove casts of return values of type void * 2012-11-29 08:29:26 -05:00
Philip Kelley
ac22d08f2f Remove git_object_oid2type 2012-11-29 08:22:15 -05:00
Vicent Martí
e2934db2c7 Merge pull request #1090 from arrbee/ignore-invalid-by-default
Ignore invalid entries by default
2012-11-29 02:05:46 -08:00
Vicent Martí
ee06fec507 Merge pull request #1083 from nulltoken/fix/tracking
Fix git_branch_tracking() for branches with empty merge and/or remote config entries
2012-11-29 01:29:50 -08:00
Scott J. Goldman
b994bfe339 graph.c: prune includes 2012-11-28 18:59:13 -08:00
Scott J. Goldman
0984c8768d Rename git_count_ahead_behind -> git_graph_ahead_behind
Moved it into graph.{c,h} which i created for the new "graph"
functions namespace. Also adjusted the function prototype
to use `size_t` and `const git_oid *`.
2012-11-28 18:54:57 -08:00
Scott J. Goldman
c6d03c958f fix coding style: while( -> while ( 2012-11-28 18:54:57 -08:00
Scott J. Goldman
bff53e5405 Add initial implementation of ahead-behind count 2012-11-28 18:54:56 -08:00
nulltoken
37849a8ec3 tracking: fix retrieval of the tracking ref of branch with empty merge and/or remote entry 2012-11-28 20:00:07 +01:00
Russell Belfer
7bf87ab698 Consolidate text buffer functions
There are many scattered functions that look into the contents of
buffers to do various text manipulations (such as escaping or
unescaping data, calculating text stats, guessing if content is
binary, etc).  This groups all those functions together into a
new file and converts the code to use that.

This has two enhancements to existing functionality.  The old
text stats function is significantly rewritten and the BOM
detection code was extended (although largely we can't deal with
anything other than a UTF8 BOM).
2012-11-28 09:58:48 -08:00
Philip Kelley
613d5eb939 Push! By schu, phkelley, and congyiwu, et al 2012-11-28 11:42:37 -05:00
Sascha Cunz
7cdad6c774 Fix uninitialized variable
clang-SVN HEAD kindly provided my the info, that sm_repo maybe
uninitialized when we want to free it (If the expression in line 358 or
359/360 evaluate to true, we jump to "cleanup", where we'd use sm_repo
uninitialized).
2012-11-28 12:43:12 +01:00
Vicent Marti
ae20189170 object: Raise proper code on invalid object type 2012-11-28 11:47:38 +01:00
Vicent Marti
9507a434c6 odb: Add git_odb_add_disk_alternate
Loads a disk alternate by path to the ODB. Mimics the
`GIT_ALTERNATE_OBJECT_DIRECTORIES` shell var.
2012-11-28 10:47:10 +01:00
Russell Belfer
c3fb7d04ed Make git_odb_foreach_cb take const param
This makes the first OID param of the ODB callback a const pointer
and also propogates that change all the way to the backends.
2012-11-27 15:00:49 -08:00
Russell Belfer
2bd5998c9c Remove git_note_data structure 2012-11-27 14:47:39 -08:00
Ben Straub
f4a62c306d Typedef enums. 2012-11-27 14:13:03 -08:00
Ben Straub
1d8ec670be API updates for stash.h 2012-11-27 14:06:56 -08:00
Ben Straub
c9fc4a6ff9 API updates for repository.h 2012-11-27 13:44:49 -08:00
Ben Straub
df705148ec API updates for remote.h
Includes typedef for git_direction, and renames for
GIT_DIR_[FETCH|PUSH] to GIT_DIRECTION_(\1).
2012-11-27 13:19:49 -08:00
Ben Straub
2e76b5fc84 API updates for odb.h 2012-11-27 13:18:30 -08:00
Ben Straub
de5596bfd6 API updates for notes.h/c. 2012-11-27 13:18:30 -08:00
Ben Straub
4ff192d3f2 Move merge functions to merge.c
In so doing, promote commit_list to git_commit_list,
with its own internal API header.
2012-11-27 13:18:29 -08:00
Ben Straub
839c5f574f API updates for indexer.h 2012-11-27 13:18:29 -08:00
Russell Belfer
a8122b5d4a Fix warnings on Win64 build 2012-11-27 13:18:29 -08:00
Russell Belfer
4604a65460 update internal index API to avoid cast 2012-11-27 13:18:29 -08:00
Russell Belfer
d574de0e6e API updates for status.h 2012-11-27 13:18:29 -08:00
Russell Belfer
16248ee2d1 Fix up some missing consts in tree & index
This fixes some missed places where we can apply const-ness to
various public APIs.

There are still some index and tree APIs that cannot take const
pointers because we sort our `git_vectors` lazily and so we can't
reliably bsearch the index and tree content without applying a
`git_vector_sort()` first.

This also fixes some missed places where size_t can be used and
where const can be applied to a couple internal functions.
2012-11-27 13:18:29 -08:00
Ben Straub
f45d51ff8e API updates for index.h 2012-11-27 13:18:28 -08:00
Russell Belfer
d9023dbe0c API updates for tag.h 2012-11-27 13:18:28 -08:00
Russell Belfer
9cd423583f API updates for submodule.h 2012-11-27 13:18:28 -08:00
Russell Belfer
793c438559 Update diff callback param order
This makes the diff functions that take callbacks both take
the payload parameter after the callback function pointers and
pass the payload as the last argument to the callback function
instead of the first.  This should make them consistent with
other callbacks across the API.
2012-11-27 13:18:28 -08:00
Ben Straub
54b2a37ac7 Clean up config.h 2012-11-27 13:18:28 -08:00
Russell Belfer
eecc805029 Update callback fn ptr for git_reference_foreach
As part of API review, use a typedef for the callback fn ptr.
2012-11-27 13:18:28 -08:00
Russell Belfer
e120123e36 API review / update for tree.h 2012-11-27 13:18:28 -08:00
Russell Belfer
824cb2d5e5 Updates to reset.h 2012-11-27 13:18:28 -08:00
Vicent Marti
cfbe4be3fb More external API cleanup
Conflicts:
	src/branch.c
	tests-clar/refs/branches/create.c
2012-11-27 13:18:27 -08:00
Ben Straub
2508cc66eb Rename ref and reflog apis for consistency 2012-11-27 13:17:45 -08:00
Fraser Tweedale
9e9aee6705 fix build on FreeBSD
3f9eb1e introduced support for SSL certificates issued for IP
addresses, making use of in_addr and in_addr6 structs.  On FreeBSD
these are defined in (a file included in) <netinet/in.h>, so include
that file on FreeBSD and get the build working again.
2012-11-26 23:29:34 +10:00
Vicent Martí
8404f2d67f Merge pull request #1101 from csware/prevent_die
pack.c: Set p->mwf.fd to -1 on error
2012-11-26 03:56:25 -08:00
delanne
f2696fa412 Fix invalid read reported by valgrind 2012-11-26 12:12:41 +01:00
Sven Strickroth
fcb48e0680 Set p->mwf.fd to -1 on error
If p->mwf.fd is e.g. -2 then it is closed in packfile_free and an exception might be thrown.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2012-11-24 15:50:51 +01:00
Vicent Martí
c4d8df27bc Merge pull request #1097 from nulltoken/topic/head_tree_error
Make `git_repository_head_tree()` return error codes
2012-11-23 15:19:47 -08:00
Martin Woodward
826bc4a81b Remove use of English expletives
Remove words such as fuck, crap, shit etc.
Remove other potentially offensive words from comments.
Tidy up other geopolicital terms in comments.
2012-11-23 13:31:22 +00:00
nulltoken
5cec896a3b repo: Make git_repository_head_tree() return error codes 2012-11-22 18:51:06 +01:00
Russell Belfer
54be4d57ed Merge pull request #1092 from arrbee/legal-to-not-have-gitconfig
It is okay to not have a .gitconfig file
2012-11-20 15:02:06 -08:00
Russell Belfer
38f7d026dc Need to clear ignored error from config load 2012-11-20 14:50:36 -08:00
Russell Belfer
cc6b4162de It is okay to not have a .gitconfig file
Opening a repo is generating an error if you don't have a
.gitconfig file in your home directory, but that should be
legal.
2012-11-20 10:24:18 -08:00
Eduardo Bart
cf0dadcf6e Minor optimization in win32 do_lstat 2012-11-20 01:19:31 -02:00
Eduardo Bart
2d96fce20b update win32 lstat comment 2012-11-19 23:12:20 -02:00
Russell Belfer
d46b0a04c7 Improve iterator ignoring .git file
The workdir iterator has always tried to ignore .git files, but
it turns out there were some bugs.  This makes it more robust at
ignoring .git files.

This also makes iterators always check ".git" case insensitively
regardless of the properties of the system.  This will make libgit2
skip ".GIT" and the like.  This is different from core git, but on
systems with case insensitive but case preserving file systems,
allowing ".GIT" to be added is problematic.
2012-11-19 16:34:44 -08:00
Russell Belfer
02df42ddbf Set up default internal ignores
This adds "." ".." and ".git" to the internal ignores list by
default - asking about paths with these files will always say
that they are ignored.
2012-11-19 16:33:30 -08:00
Eduardo Bart
52ead7877d Fix win32 lstat 2012-11-19 22:30:20 -02:00
Russell Belfer
cfeef7ce2c Minor optimization to tree entry validity check
This checks for a leading '.' before looking for the invalid
tree entry names.  Even on pretty high levels of optimization,
this seems to make a measurable improvement.

I accidentally used && in the check initially instead of || and
while debugging ended up improving the error reporting of issues
with adding tree entries.  I thought I'd leave those changes, too.
2012-11-19 13:40:08 -08:00
Scott J. Goldman
0d778b1a89 Catch invalid filenames in append_entry()
This prevents the index api from calling write_tree() with a
bogus tree.
2012-11-18 16:52:04 -08:00
Scott J. Goldman
19af78bb36 Prevent creating .., ., and .git with tree builder
As per core git.
2012-11-18 15:15:24 -08:00
Sascha Cunz
4cc7342e95 Indexer: Avoid a possible double-deletion in error case 2012-11-18 09:07:35 +01:00
Michael Schubert
0066955d97 Fix a couple of warnings 2012-11-18 04:27:49 +01:00
nulltoken
b15df1d937 reflog: make entry_byindex() and drop() git compliant
Passing 0 as the index now retrieves the most recent entry instead
of the oldest one.
2012-11-17 18:30:35 -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
nulltoken
6091457e76 repo: ensure is_empty() checks there are no refs 2012-11-17 07:20:08 -08:00
nulltoken
aa8a76eff9 tag: rename git_tag_type to git_tag_target_type 2012-11-17 05:41:20 -08:00
nulltoken
86b9dbc12f Fix MSVC compilation warnings 2012-11-17 05:13:13 -08:00
Vicent Martí
e087973ec7 Merge pull request #1075 from carlosmn/alternates-recurse
odb: recursively load alternates
2012-11-16 10:27:46 -08:00
Carlos Martín Nieto
85e7efa163 odb: recursively load alternates
The maximum depth is 5, like in git
2012-11-16 08:46:02 -08:00
Scott J. Goldman
0cd063fd87 Merge pull request #1071 from arrbee/alternate-fix-strcmp
Win32 fixes for diff/checkout/reset
2012-11-15 23:28:52 -08:00
Michael Schubert
0ec118280c Fix -Wmaybe-uninitialized warning 2012-11-16 02:17:57 +01:00
Vicent Martí
4a0c7f56ab Merge pull request #1074 from edubart/ignore_diff_filemode
Add option to ignore file mode in diffs
2012-11-15 10:31:11 -08:00
Eduardo Bart
c0d5acf69a Add option to ignore file mode in diffs 2012-11-15 14:59:39 -02:00
Russell Belfer
bbe6dbec81 Add explicit git_index ptr to diff and checkout
A number of diff APIs and the `git_checkout_index` API take a
`git_repository` object an operate on the index.  This updates
them to take a `git_index` pointer explicitly and only fall back
on the `git_repository` index if the index input is NULL.  This
makes it easier to operate on a temporary index.
2012-11-14 23:29:48 -08:00
Russell Belfer
bad68c0a99 Add iterator for git_index object
The index iterator could previously only be created from a repo
object, but this allows creating an iterator from a `git_index`
object instead (while keeping, though renaming, the old function).
2012-11-14 22:55:40 -08:00
Russell Belfer
5735bf5e6a Fix diff API to better parameter order
The diff API is not in the parameter order one would expect from
other libgit2 APIs.  This fixes that.
2012-11-14 22:54:31 -08:00
Russell Belfer
cccacac555 Add POSIX compat lstat() variant for win32
The existing p_lstat implementation on win32 is not quite POSIX
compliant when setting errno to ENOTDIR.  This adds an option to
make is be compliant so that code (such as checkout) that cares
to have separate behavior for ENOTDIR can use it portably.

This also contains a couple of other minor cleanups in the
posix_w32.c implementations to avoid unnecessary work.
2012-11-14 22:41:51 -08:00
Russell Belfer
a277345e05 Create internal strcmp variants for function ptrs
Using the builtin strcmp and strcasecmp as function pointers is
problematic on win32.  This adds internal implementations and
divorces us from the platform linkage.
2012-11-14 22:37:13 -08:00
Carlos Martín Nieto
7e9f5e6500 Slightly different valgrind fix
Allocate with calloc rather than conditionally memsetting a specific
part of the struct later on.
2012-11-13 20:06:15 -08:00
Carlos Martín Nieto
6132a54e0b Fix a few valgrind errors 2012-11-13 16:17:37 -08:00
Vicent Martí
513e794ef4 Merge pull request #1068 from carlosmn/config-empty-value
Deal with empty and nonexsitent values in config
2012-11-13 14:59:18 -08:00
Carlos Martín Nieto
0da81d2b39 config: return an emtpy string when there is no value
Returning NULL for the string when we haven't signaled an error
condition is counter-intuitive and causes unnecessary edge
cases. Return an empty string when asking for a string value for a
configuration variable such as '[section] var' to avoid these edge
cases.

If the distinction between no value and an empty value is needed, this
can be retrieved from the entry directly. As a side-effect, this
change stops the int parsing functions from segfaulting on such a
variable.
2012-11-13 14:49:16 -08:00
Vicent Marti
f6c18dda04 http: Unrustle 2012-11-13 14:17:41 -08:00
Vicent Martí
aa1c3b588e Merge pull request #1016 from arrbee/fix-checkout-dir-removal
Update checkout with new strategies & behavior
2012-11-13 14:13:47 -08:00
Carlos Martín Nieto
47db054df0 config: distinguish between a lone variable name and one without rhs
'[section] variable' and '[section] variable =' behave differently
when parsed as booleans, so we need to store that distinction
internally.
2012-11-13 13:53:41 -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
Edward Thomson
2a612fe3c3 filebuf now has a git_hash_ctx instead of a ctx* 2012-11-13 14:57:35 -06:00
Edward Thomson
a8527429dc unload dll / destroy hash ctxs at shutdown 2012-11-13 14:48:10 -06:00
Edward Thomson
7ebefd22e7 move hash library func ptrs to global global 2012-11-13 10:23:05 -06:00
Edward Thomson
603bee0791 Remove git_hash_ctx_new - callers now _ctx_init() 2012-11-13 10:23:05 -06:00
Edward Thomson
d6fb092409 Win32 CryptoAPI and CNG support for SHA1 2012-11-13 10:23:05 -06:00
Ben Straub
e45423dd2c Merge pull request #1065 from nulltoken/fix/memory-leak
Fix memory leaks
2012-11-13 05:45:08 -08:00
Michael Schubert
d51e54f1f4 Remove unused variables 2012-11-13 14:28:44 +01:00
nulltoken
3dee36557e local: fix memory leak 2012-11-13 07:04:30 +01:00
Vicent Marti
19c044a17d Merge remote-tracking branch 'ben/local-transport' into development 2012-11-12 14:23:17 -08:00
Ben Straub
14157652ee Remove unnecessary progress logic
The indexer handles this better than the fetch
logic does.
2012-11-12 07:57:03 -08:00
Ben Straub
0f5520f73a Fix error check 2012-11-12 07:55:09 -08:00
nulltoken
b1a3a70ed1 repository: Refine repository_head() error report 2012-11-12 00:14:51 +01:00
Edward Thomson
b0f6e45d14 create FETCH_HEAD specially instead of as a ref file 2012-11-11 11:56:33 -06:00
Vicent Martí
d18713fb4a Merge pull request #1056 from nulltoken/duplicate-tree-entries
Duplicate tree entries
2012-11-10 20:24:53 -08:00
nulltoken
95d73de15f index: prefer INDEX_OWNER usage 2012-11-10 21:10:49 +01:00
nulltoken
33f95a9b32 index: refine add_from_workdir() error report 2012-11-10 21:01:05 +01:00
nulltoken
69c068c79f index: make git_index_new() work with a NULL path 2012-11-10 20:42:45 +01:00
Russell Belfer
757b406504 Fix warnings and valgrind issues
This fixes some various warnings that showed up in Travis and
a couple uses of uninitialized memory and one memory leak.
2012-11-09 14:01:44 -08:00
Russell Belfer
0f3def715d Fix various cross-platform build issues
This fixes a number of warnings and problems with cross-platform
builds.  Among other things, it's not safe to name a member of a
structure "strcmp" because that may be #defined.
2012-11-09 13:52:07 -08:00
Russell Belfer
a1bf70e4c9 fix regression in diff with submodule oid 2012-11-09 13:52:07 -08:00
Russell Belfer
ad9a921b92 Rework checkout with new strategy options
This is a major reworking of checkout strategy options.  The
checkout code is now sensitive to the contents of the HEAD tree
and the new options allow you to update the working tree so that
it will match the index content only when it previously matched
the contents of the HEAD.  This allows you to, for example, to
distinguish between removing files that are in the HEAD but not
in the index, vs just removing all untracked files.

Because of various corner cases that arise, etc., this required
some additional capabilities in rmdir and other utility functions.

This includes the beginnings of an implementation of code to read
a partial tree into the index based on a pathspec, but that is
not enabled because of the possibility of creating conflicting
index entries.
2012-11-09 13:52:07 -08:00
Russell Belfer
55cbd05b18 Some diff refactorings to help code reuse
There are some diff functions that are useful in a rewritten
checkout and this lays some groundwork for that.  This contains
three main things:

1. Share the function diff uses to calculate the OID for a file
   in the working directory (now named `git_diff__oid_for_file`
2. Add a `git_diff__paired_foreach` function to iterator over
   two diff lists concurrently.  Convert status to use it.
3. Move all the string/prefix/index entry comparisons into
   function pointers inside the `git_diff_list` object so they
   can be switched between case sensitive and insensitive
   versions.  This makes them easier to reuse in various
   functions without replicating logic.  As part of this, move
   a couple of index functions out of diff.c and into index.c.
2012-11-09 13:52:07 -08:00
Russell Belfer
2e3d4b96c0 Move pathspec code in separate files
Diff uses a `git_strarray` of path specs to represent a subset
of all files to be processed.  It is useful to be able to reuse
this filtering in other places outside diff, so I've moved it
into a standalone set of utilities.
2012-11-09 13:52:07 -08:00
Russell Belfer
220d5a6c35 Make iterator ignore eval lazy
This makes it so that the check if a file is ignored will be
deferred until requested on the workdir iterator, instead of
aggressively evaluating the ignore rules for each entry.  This
should improve performance because there will be no need to
check ignore rules for files that are already in the index.
2012-11-09 13:52:07 -08:00
Russell Belfer
32def5af9a Fix checkout behavior when its hands are tied
So, @nulltoken created a failing test case for checkout that
proved to be particularly daunting.  If checkout is given only
a very limited strategy mask (e.g. just GIT_CHECKOUT_CREATE_MISSING)
then it is possible for typechange/rename modifications to leave it
unable to complete the request.  That's okay, but the existing code
did not have enough information not to generate an error (at least
for tree/blob conflicts).

This led me to a significant reorganization of the code to handle
the failing case, but it has three benefits:

1. The test case is handled correctly (I think)
2. The new code should actually be much faster than the old code
   since I decided to make checkout aware of diff list internals.
3. The progress value accuracy is hugely increased since I added
   a fourth pass which calculates exactly what work needs to be
   done before doing anything.
2012-11-09 13:52:06 -08:00
Russell Belfer
331e7de900 Extensions to rmdir and mkdir utilities
* Rework GIT_DIRREMOVAL values to GIT_RMDIR flags, allowing
  combinations of flags
* Add GIT_RMDIR_EMPTY_PARENTS flag to remove parent dirs that
  are left empty after removal
* Add GIT_MKDIR_VERIFY_DIR to give an error if item is a file,
  not a dir (previously an EEXISTS error was ignored, even for
  files) and enable this flag for git_futils_mkpath2file call
* Improve accuracy of error messages from git_futils_mkdir
2012-11-09 13:52:06 -08:00
Vicent Martí
8a328cf442 Merge pull request #1058 from pwkelley/development
Fixes for two segfaults
2012-11-09 13:19:32 -08:00
Philip Kelley
fcd03bebbf Fix a mutex/critical section leak 2012-11-09 15:57:32 -05:00
nulltoken
55f9837f11 config: make git_config_open_level() work with an empty config 2012-11-09 21:49:50 +01:00
Philip Kelley
2f683f0097 Fix uninitialized memory in winhttp subtransport on 64-bit 2012-11-09 15:39:25 -05:00
Philip Kelley
2364735c8f Fix implementation of strndup to not overrun 2012-11-09 15:39:10 -05:00
Ben Straub
90207709a3 Avoid copying duplicate commits 2012-11-09 10:33:16 -08:00
Ben Straub
505da062b8 Implement local transport's fetch 2012-11-09 10:33:05 -08:00
nulltoken
f92bcaea49 index: prevent tree creation from a non merged state
Fix libgit2/libgit2sharp#243
2012-11-09 16:45:47 +01:00
Vicent Martí
0f674411e9 Merge pull request #1052 from delanne/invalid_read
Valgrind reports Invalid Read when the configuration file contains some empty line
2012-11-09 06:16:44 -08:00
nulltoken
7cc1bf0fcb index: Introduce git_index_has_conflicts() 2012-11-08 21:16:48 +01:00
Philip Kelley
9d64128325 Merge pull request #1048 from pwkelley/basic_auth
Basic authentication for http and winhttp
2012-11-08 08:06:23 -08:00
delanne
bcad677ba8 - Update 'tests-clar/resources/config/config11' in order to reproduce the invalidread with the unittest (just added some \n at the end of the file)
- Fix config_file.c
2012-11-08 12:28:21 +01:00
Vicent Martí
8ff2b0c759 Merge pull request #1039 from erikvanzijst/erik/tag_without_message
Correctly parse tags lacking a description
2012-11-07 16:30:55 -08:00
Eduardo Bart
345eef2374 Move inet_pton to posix platform-compatibility layer 2012-11-07 16:15:09 -02:00
Eduardo Bart
d1a69d0fff Fix compilation for mingw32 and cygwin
inet_pton is available only in windows vista or later,
fixed the issue by reimplementing it using WSAStringToAddress
2012-11-06 20:22:11 -02:00
Philip Kelley
11fa847283 Don't store no_check_cert; fetch it on demand 2012-11-06 11:27:23 -05:00
Philip Kelley
2f7538ec00 Fix connection leak in http subtransport 2012-11-06 09:36:04 -05:00
Philip Kelley
091361f569 Basic authentication for http and winhttp 2012-11-06 08:52:03 -05:00
Edward Thomson
09cc0b92dc create callback to handle packs from fetch, move the indexer to odb_pack 2012-11-05 16:00:29 -06:00
Russell Belfer
a5e85d86b7 Merge pull request #1046 from libgit2/empty-remote-url-crash
Bail out of remote loading if the URL would be NULL
2012-11-05 11:06:50 -08:00
Justin Spahr-Summers
c1cd036e40 'geterr' -> 'giterr' 2012-11-05 11:01:00 -08:00
Russell Belfer
065be7a1d9 Merge pull request #1044 from dahlbyk/repo/state
Fix state when HEAD is not detached
2012-11-05 10:44:21 -08:00
Justin Spahr-Summers
f8baece754 Set GITERR_INVALID when encountering a NULL remote URL 2012-11-05 10:42:10 -08:00
Vicent Martí
942a76983b Merge pull request #1034 from carlosmn/packbuilder-foreach
Let the user grab the packfile as it's being written
2012-11-05 06:54:34 -08:00
Justin Spahr-Summers
83885891f5 Bail out if remote->url would be NULL
This fixes a crash from attempting to invoke git__strdup() against NULL.
2012-11-04 22:01:24 -08:00
Keith Dahlby
35d255fda6 repo: fix state when HEAD is not detached 2012-11-04 12:13:42 -06:00
Philip Kelley
1e99ce9ac7 Merge pull request #1042 from pwkelley/progress_cb
Fix bytes_received in fetch tests - we weren't calling the callback
2012-11-02 11:42:45 -07:00
Philip Kelley
438906e160 Fix bytes_received in fetch tests - we weren't calling the callback 2012-11-02 14:34:06 -04:00
Russell Belfer
3ae0aad75a Move error capture to top of giterr_set 2012-11-02 10:42:20 -07:00
Erik van Zijst
6bb9fea13e tags: Fixed the tag parser to correctly treat the message field as optional.
This fix makes libgit2 capable of parsing annotated tag objects that lack
the optional message/description field.
Previously, libgit2 treated this field as mandatory and raised a tag_error on
such tags. However, the message field is optional.

An example of such a tag is refs/tags/v2.6.16.31-rc1 in Linux:

$ git cat-file tag refs/tags/v2.6.16.31-rc1
object afaa018cefb6af63befef1df7d8febaae904434f
type commit
tag v2.6.16.31-rc1
tagger Adrian Bunk <bunk@stusta.de> 1162716505 +0100
$
2012-11-02 10:28:17 -07:00
Vicent Martí
1362a98316 Merge pull request #1014 from arrbee/diff-rename-detection
Initial implementation of diff rename detection
2012-11-02 10:00:28 -07:00
Philip Kelley
473a7a1e70 Merge pull request #1040 from ethomson/index_refactor
Free conflict index entries on removal
2012-11-02 08:43:17 -07:00
Philip Kelley
2c087f81e1 Merge pull request #1041 from pwkelley/transports
Prefer GetLastError() for GITERR_OS on Win32
2012-11-02 08:40:09 -07:00
Philip Kelley
8f624a4726 Prefer GetLastError() for GITERR_OS on Win32 2012-11-02 11:30:55 -04:00
Edward Thomson
050cf8b8a6 freeing index entries would be helpful 2012-11-02 01:01:21 -05:00
Vicent Martí
d13da328e2 Merge pull request #1038 from arrbee/doc-fixes
Improve docs, examples, warnings
2012-11-01 14:18:40 -07:00
Russell Belfer
b90500f03d Improve docs, examples, warnings
This improves docs in some of the public header files, cleans
up and improves some of the example code, and fixes a couple
of pedantic warnings in places.
2012-11-01 14:08:30 -07:00
Vicent Marti
1e808f9cda index: Add git_index_new 2012-11-01 20:28:28 +01:00
Vicent Marti
43eeca04a7 index: Fix tests 2012-11-01 20:24:43 +01:00
Vicent Marti
276ea401b3 index: Add git_index_write_tree 2012-11-01 20:17:10 +01:00
Vicent Marti
8ff0f3250a index: Switch to git_futils_filestamp 2012-11-01 20:17:09 +01:00
Jameson Miller
c902f5a0ff Update of text stats calculation
Do not interpret 0x85 as Next Line (NEL)
char when gathering statistics for a text file.
2012-11-01 12:26:56 -04:00
Vicent Martí
7ae73e94db Merge pull request #1030 from pwkelley/transports
Reorganize transport architecture
2012-11-01 09:15:29 -07:00
Philip Kelley
ff830366ea Http: Set an error for invalid content-type 2012-11-01 12:07:42 -04:00
Philip Kelley
0ccfc63bd6 Improve consistency of WinHTTP request headers 2012-11-01 10:29:30 -04:00
Philip Kelley
41fb1ca0ec Reorganize transport architecture (squashed 3) 2012-11-01 09:02:33 -04:00
Carlos Martín Nieto
b4b935d8ab packbuilder: add accessors for the number of total and written objects 2012-11-01 06:21:49 +01:00
Carlos Martín Nieto
3dfed9cb86 packbuilder: add git_packbuilder_foreach
Let the user get each object as a buffer+size pair so they can handle
the packfile content as they need to.
2012-11-01 06:21:49 +01:00
Vicent Marti
003808b38c Merge branch 'config-refresh' into development 2012-10-31 20:52:16 +01:00
Vicent Marti
c1f61af66b I LIKE THESE NAMES 2012-10-31 20:52:01 +01:00
Russell Belfer
c8b511f3cd Better naming for file timestamp/size checker 2012-10-31 11:26:12 -07:00
Ben Straub
a9db123b09 Checkout: remove duplicate 100% progress report 2012-10-31 10:14:13 -07:00
Ben Straub
c48e87006c Ensure that non-error is not propagated 2012-10-31 10:13:57 -07: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
Vicent Martí
efde422553 Merge pull request #1017 from arrbee/diff-patch-to-str
Add git_diff_patch_to_str API
2012-10-30 12:04:28 -07:00
Vicent Martí
c4a9ded0f9 Merge pull request #1026 from nulltoken/repo/state
repo: enhance git_repository_state() detection
2012-10-30 12:03:22 -07:00
Vicent Martí
6c21358a89 Merge pull request #1029 from ethomson/index_refactor
Index changes
2012-10-30 11:51:58 -07:00
Michael Schubert
6cfbbf7e32 Fix a couple of warnings 2012-10-30 18:50:59 +01:00
Russell Belfer
db106d01f0 Move rename detection into new file
This improves the naming for the rename related functionality
moving it to be called `git_diff_find_similar()` and renaming
all the associated constants, etc. to make more sense.

I also moved the new code (plus the existing `git_diff_merge`)
into a new file `diff_tform.c` where I can put new functions
related to manipulating git diff lists.

This also updates the implementation significantly from the
last revision fixing some ordering issues (where break-rewrite
needs to be handled prior to copy and rename detection) and
improving config option handling.
2012-10-30 09:40:50 -07:00
Edward Thomson
f45ec1a076 index refactoring 2012-10-29 20:04:21 -05:00
Ben Straub
81eecc342b Fetch: don't clobber received count
This memset was being reached after the entire packfile under
WinHttp, so the byte count was being lost for small repos.
2012-10-29 13:34:14 -07:00
Vicent Martí
8a1479a55a Merge pull request #796 from nulltoken/topic/git-stash
Stash
2012-10-29 12:57:04 -07:00
nulltoken
31966d20e3 repo: enhance git_repository_state() detection 2012-10-27 16:45:59 +02:00
Ben Straub
a0ce87c51c Add network transfer callbacks on Windows 2012-10-26 13:43:13 -07:00
nulltoken
e4c64cf2aa stash: add git_stash_drop() 2012-10-26 22:11:15 +02:00
nulltoken
233884131d stash: add git_stash_foreach() 2012-10-26 22:11:09 +02:00
nulltoken
590fb68be0 stash: add git_stash_save() 2012-10-26 22:10:48 +02:00
nulltoken
4ea0a0ca05 refs: add GIT_REFS_STASH_FILE define 2012-10-26 21:02:05 +02:00
nulltoken
b1be9dd0e5 index: introduce git_index_owner() 2012-10-26 21:02:04 +02:00
nulltoken
1f87fa3595 reflog: fix bogus removal of reflog entries 2012-10-26 21:02:01 +02:00