src/index.c


Log

Author Commit Date CI Message
Edward Thomson e759b072 2012-12-12T17:54:12 don't walk off the end of the index
Russell Belfer 9950d27a 2012-12-06T13:26:58 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.
Russell Belfer a8122b5d 2012-11-21T15:39:03 Fix warnings on Win64 build
Russell Belfer 4604a654 2012-11-21T11:57:06 update internal index API to avoid cast
Russell Belfer 16248ee2 2012-11-21T11:03:07 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.
Ben Straub f45d51ff 2012-11-20T19:57:46 API updates for index.h
Russell Belfer e120123e 2012-11-20T14:01:46 API review / update for tree.h
Vicent Marti cfbe4be3 2012-11-17T19:54:47 More external API cleanup Conflicts: src/branch.c tests-clar/refs/branches/create.c
Russell Belfer bad68c0a 2012-11-13T14:02:59 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).
Carlos Martín Nieto 6132a54e 2012-11-13T16:13:10 Fix a few valgrind errors
Vicent Martí aa1c3b58 2012-11-13T14:13:47 Merge pull request #1016 from arrbee/fix-checkout-dir-removal Update checkout with new strategies & behavior
Vicent Martí d18713fb 2012-11-10T20:24:53 Merge pull request #1056 from nulltoken/duplicate-tree-entries Duplicate tree entries
nulltoken 95d73de1 2012-11-10T21:10:49 index: prefer INDEX_OWNER usage
nulltoken 33f95a9b 2012-11-10T21:01:05 index: refine add_from_workdir() error report
nulltoken 69c068c7 2012-11-10T20:42:45 index: make git_index_new() work with a NULL path
Russell Belfer 757b4065 2012-11-09T14:01:44 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.
Russell Belfer ad9a921b 2012-11-08T17:05:07 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.
Russell Belfer 55cbd05b 2012-11-08T16:56:34 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.
nulltoken 7cc1bf0f 2012-11-08T21:08:59 index: Introduce git_index_has_conflicts()
Edward Thomson 050cf8b8 2012-11-02T01:01:21 freeing index entries would be helpful
Vicent Marti 1e808f9c 2012-11-01T20:28:28 index: Add `git_index_new`
Vicent Marti 43eeca04 2012-11-01T20:24:43 index: Fix tests
Vicent Marti 276ea401 2012-11-01T20:15:53 index: Add git_index_write_tree
Vicent Marti 8ff0f325 2012-10-31T22:26:57 index: Switch to git_futils_filestamp
Russell Belfer 744cc03e 2012-10-30T12:10:36 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.
Edward Thomson f45ec1a0 2012-10-29T20:04:21 index refactoring
nulltoken b1be9dd0 2012-10-03T12:09:17 index: introduce git_index_owner()
Ben Straub 7d222e13 2012-10-24T13:29:14 Network progress: rename things git_indexer_stats and friends -> git_transfer_progress* Also made git_transfer_progress members more sanely named.
nulltoken 0ae81fc4 2012-10-17T15:30:22 index: remove read_tree() progress indicator git_index_read_tree() was exposing a parameter to provide the user with a progress indicator. Unfortunately, due to the recursive nature of the tree walk, the maximum number of items to process was unknown. Thus, the indicator was only counting processed entries, without providing any information how the number of remaining items.
Philip Kelley ec40b7f9 2012-09-17T15:42:41 Support for core.ignorecase
authmillenon 0e2dd29b 2012-09-04T12:07:51 Fix logical error in git_index_set_caps
Vicent Martí f98c32f3 2012-08-19T01:26:06 Merge pull request #778 from ben/clone Clone
Vicent Marti c07d9c95 2012-08-09T15:33:04 oid: Explicitly include `oid.h` for the inlined CMP
Ben Straub 4bf51156 2012-07-30T14:52:46 Enable stats on git_index_read_tree. Replace with the contents of git_index_read_tree_with_stats() and improve documentation comments.
Ben Straub f1587b97 2012-07-30T14:37:40 Checkout: use git_index_read_tree_with_stats. New variant of git_index_read_tree that fills in the 'total' field of a git_indexer_stats struct as it's walking the tree.
nulltoken b8457baa 2012-07-24T07:57:58 portability: Improve x86/amd64 compatibility
Vicent Marti 0e2fcca8 2012-06-29T02:21:12 tree: Bring back `entry_bypath` Smaller, simpler, faster.
Russell Belfer da825c92 2012-06-19T14:27:02 Make index add/append support core.filemode flag This fixes git_index_add and git_index_append to behave more like core git, preserving old filemode data in the index when adding and/or appending with core.filemode = false. This also has placeholder support for core.symlinks and core.ignorecase, but those flags are not implemented (well, symlinks has partial support for preserving mode information in the same way that git does, but it isn't tested).
Vicent Martí 904b67e6 2012-05-18T01:48:50 errors: Rename error codes
Vicent Martí e172cf08 2012-05-18T01:21:06 errors: Rename the generic return codes
Vicent Martí 9d0011fd 2012-05-16T19:23:47 tree: Naming conventions
Russell Belfer 41a82592 2012-05-15T14:17:39 Ranged iterators and rewritten git_status_file The goal of this work is to rewrite git_status_file to use the same underlying code as git_status_foreach. This is done in 3 phases: 1. Extend iterators to allow ranged iteration with start and end prefixes for the range of file names to be covered. 2. Improve diff so that when there is a pathspec and there is a common non-wildcard prefix of the pathspec, it will use ranged iterators to minimize excess iteration. 3. Rewrite git_status_file to call git_status_foreach_ext with a pathspec that covers just the one file being checked. Since ranged iterators underlie the status & diff implementation, this is actually fairly efficient. The workdir iterator does end up loading the contents of all the directories down to the single file, which should ideally be avoided, but it is pretty good.
Russell Belfer 7c7ff7d1 2012-03-19T16:10:11 Migrate index, oid, and utils to new errors This includes a few cleanups that came up while converting these files. This commit introduces a could new git error classes, including the catchall class: GITERR_INVALID which I'm using as the class for invalid and out of range values which are detected at too low a level of library to use a higher level classification. For example, an overflow error in parsing an integer or a bad letter in parsing an OID string would generate an error in this class.
Russell Belfer deafee7b 2012-03-14T17:36:15 Continue error conversion This converts blob.c, fileops.c, and all of the win32 files. Also, various minor cleanups throughout the code. Plus, in testing the win32 build, I cleaned up a bunch (although not all) of the warnings with the 64-bit build.
Russell Belfer ae9e29fd 2012-03-06T16:14:31 Migrating diff to new error handling Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
Vicent Martí 1a481123 2012-02-17T00:13:34 error-handling: References Yes, this is error handling solely for `refs.c`, but some of the abstractions leak all ofer the code base.
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.
schu 5e0de328 2012-02-13T17:10:24 Update Copyright header Signed-off-by: schu <schu-github@schulog.org>
Russell Belfer 1744fafe 2012-01-17T15:49:47 Move path related functions from fileops to path This takes all of the functions that look up simple data about paths (such as `git_futils_isdir`) and moves them over to path.h (becoming `git_path_isdir`). This leaves fileops.h just with functions that actually manipulate the filesystem or look at the file contents in some way. As part of this, the dir.h header which is really just for win32 support was moved into win32 (with some minor changes).
Russell Belfer fa3cb0da 2012-01-05T15:15:43 Fix memory leak in git_index_remove. Missed freeing the entry.
Clemens Buchacher 599f2849 2011-12-26T18:37:31 add git_index_read_tree
Russell Belfer 86e356ee 2011-12-18T12:08:50 Restore missing lstat in index_entry_init In an effort to remove duplicate code, I accidentally left the stat structure uninitialized in this function. This patch restores that data gathering.
Russell Belfer 97769280 2011-11-30T11:27:15 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.
Carlos Martín Nieto 89886d0b 2011-11-28T21:08:29 Plug a bunch of leaks
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.
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.
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".
Vicent Marti 356f11fe 2011-09-29T16:28:00 index: Silence type-punned warning
Carlos Martín Nieto b419fe2d 2011-08-02T14:38:49 Invalidate the path when removing from the index Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto e23ede0d 2011-07-26T15:22:15 index: invalidate added paths When a file is updated in the index, it's path needs to be invalidated in the tree cache as the hash is no longer correct. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Carlos Martín Nieto b4171320 2011-07-26T11:34:54 Move the tree cache functions to their own file Rename git_index_tree to git_tree_cache. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
nulltoken ad196c6a 2011-09-21T23:17:39 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>
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.
Vicent Marti c035ede2 2011-08-31T03:45:34 Fix compilation in MinGW
Vicent Martí cb1c7563 2011-07-28T05:32:47 Merge pull request #335 from carlosmn/read-updated Don't stat so much when reading references
Kirill A. Shutemov f939d39b 2011-07-18T04:16:42 index: rework index_insert() Now index_insert() takes copy of index entry, not coping it by itself. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov b2dd6815 2011-07-18T04:01:27 index: introduce index_entry_free() Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 51917d9c 2011-07-18T03:53:24 index: extract index_entry_dup() from index_insert() Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 7d9cc9f8 2011-07-15T17:46:55 index: fix cast warnings /home/kas/git/public/libgit2/src/index.c: In function ‘git_index_clear’: /home/kas/git/public/libgit2/src/index.c:228:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/index.c:235:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/index.c: In function ‘index_insert’: /home/kas/git/public/libgit2/src/index.c:392:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/index.c:399:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/index.c: In function ‘read_unmerged’: /home/kas/git/public/libgit2/src/index.c:681:35: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/index.c: In function ‘read_entry’: /home/kas/git/public/libgit2/src/index.c:716:33: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 76159921 2011-07-18T04:27:56 index: rework index entry initialization routine index_init_entry() renamed to index_entry_init(). Now it allocates entry on its own. git_index_add() and git_index_append() reworked accordingly. This commit fixes warning: /home/kas/git/public/libgit2/src/index.c: In function ‘index_init_entry’: /home/kas/git/public/libgit2/src/index.c:452:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default] Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Carlos Martín Nieto 7db40d45 2011-07-23T13:57:06 index: use git_futils_readbuffer_updated This helps readability a bit as well. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Kirill A. Shutemov 26b1b157 2011-07-18T02:05:23 index: fix memory leak We need really free vectors on index freeing, not only clear. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Vicent Marti 3dd26d1e 2011-07-13T02:15:31 index: Yes, we have to truncate
Kirill A. Shutemov b16692fa 2011-07-12T20:29:12 index: fix potential overflow mode field of git_index_entry_unmerged is array of unsigned ints. It's unsafe to cast pointer to an element of the array to long int *. It may cause overflow in git_strtol32(). Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov ae9f771c 2011-07-12T19:53:51 index: drop useless type casting Type casting usually points to some trick or bug. It's better not hide it between useless type castings. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov e1fca014 2011-07-12T19:33:30 vector: mark internal functions as static Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 046dfea3 2011-07-12T19:01:09 vector: avoid double asserting index_initialize() calls assert() for arguments on its own. No need to call it twice. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov fad6607a 2011-07-12T18:56:40 index: drop sort_index() Remove dummy wrapper around git_vector_sort(). Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 07d34877 2011-07-12T18:37:27 index: do not sort index before git_vector_bsearch2() git_vector_bsearch2() calls git_vector_sort(). No need to call it directly. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 212b379a 2011-07-12T18:30:34 index: do not free vectors twice in git_index_free() git_index_clear() frees index->entries and index->unmerged. No need to free it once again. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Vicent Marti f0ab9fda 2011-07-08T18:22:44 index: Return `GIT_ENOTFOUND` when an entry cannot be opened
Vicent Marti da5b1e1c 2011-07-07T17:56:10 index: Fix memory leak on OOM
Vicent Marti de18f276 2011-07-07T01:46:20 vector: Timsort all of the things Drop the GLibc implementation of Merge Sort and replace it with Timsort. The algorithm has been tuned to work on arrays of pointers (void **), so there's no longer a need to abstract the byte-width of each element in the array. All the comparison callbacks now take pointers-to-elements, not pointers-to-pointers, so there's now one less level of dereferencing. E.g. int index_cmp(const void *a, const void *b) { - const git_index_entry *entry_a = *(const git_index_entry **)(a); + const git_index_entry *entry_a = (const git_index_entry *)(a); The result is up to a 40% speed-up when sorting vectors. Memory usage remains lineal. A new `bsearch` implementation has been added, whose callback also supplies pointer-to-elements, to uniform the Vector API again.
Kirill A. Shutemov 8cc16e29 2011-06-30T23:22:42 index: speedup git_index_append()/git_index_append2() git_index_find() in index_insert() is useless if replace is not requested (append). Do not call it in this case. It speedup git_index_append() *dramatically* on large indexes. $ cat index_test.c int main(int argc, char **argv) { git_index *index; git_repository *repo; git_odb *odb; struct git_index_entry entry; git_oid tree_oid; char tree_hex[41]; int i; git_repository_init(&repo, "/tmp/myrepo", 0); odb = git_repository_database(repo); git_repository_index(&index, repo); memset(&entry, 0, sizeof(entry)); git_odb_write(&entry.oid, odb, "", 0, GIT_OBJ_BLOB); entry.path = "test.file"; for (i = 0; i < 50000; i++) git_index_append2(index, &entry); git_tree_create_fromindex(&tree_oid, index); git_oid_fmt(tree_hex, &tree_oid); tree_hex[40] = '\0'; printf("tree: %s\n", tree_hex); git_index_free(index); git_repository_free(repo); return 0; } Before: $ time ./index_test tree: 43f73659c43b651588cc81459d9e25b08721b95d ./index_test 151.19s user 0.05s system 99% cpu 2:31.78 total After: $ time ./index_test tree: 43f73659c43b651588cc81459d9e25b08721b95d ./index_test 0.05s user 0.00s system 94% cpu 0.059 total About 2573 times speedup on this test :) Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Kirill A. Shutemov 245adf4f 2011-07-02T01:08:42 index: introduce git_index_uniq() function It removes all entries with equal path except last added. On large indexes git_index_append() + git_index_uniq() before writing is *much* faster, than git_index_add(). Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
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.
Kirill A. Shutemov 932d1baf 2011-06-30T19:52:34 cleanup: remove trailing spaces Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Vicent Marti fa48608e 2011-06-16T02:36:21 oid: Rename methods Yeah. Finally. Fuck the old names, this ain't POSIX and they don't make any sense at all.
Sebastian Schuberth c1802641 2011-06-10T13:56:24 Prefer to use file mode defines instead of raw numbers
Vicent Marti ae496955 2011-06-08T17:03:41 windows: Fix Symlink issues Handle Symlinks if they can be handled in Win32. This is not even compiled. Needs review. The lstat implementation is modified from core Git. The readlink implementation is modified from PHP.
Jakob Pfender fdd1e04c 2011-06-07T14:10:06 fileops: Allow differentiation between deep and shallow exists() When calling gitfo_exists() on a symbolic link, sometimes we need to simply check whether the link exists and sometimes we need to check whether the file pointed to by the symlink exists. Introduce a new function gitfo_shallow_exists that only checks if the link exists and revert gitfo_exists to the original functionality of checking whether the file pointed to by the link exists.
Jakob Pfender b74c867a 2011-06-07T11:11:09 blob: Stat path inside git_blob_create_fromfile 00582bc introduced a change that required the caller of git_blob_create_fromfile() to pass a struct stat with the stat information for the file. Several developers pointed out that this would make life hard for the bindings developers as struct stat isn't widely supported by other languages. Make git_blob_create_fromfile() stat the path itself, eliminating the need for the file to be stat'ed by the caller. This makes index_init_entry() more costly as the file will be stat'ed twice but makes life easier for everyone else.
Jakob Pfender c1a2a14e 2011-05-25T16:16:41 index: Correctly write entry mode The entry mode flags for an entry created from a path name were not correctly written if the entry was a symlink. The st_mode of a statted symlink is 0120777, however git requires the mode to read 0120000, because it does not care about permissions of symlinks. Introduce index_create_mode() that correctly writes the mode flags in the form expected by git.
Jakob Pfender 1869b31e 2011-05-25T16:11:57 index/fileops: Correctly process symbolic links gitfo_exists() used to error out if the given file was a symbolic link, due to access() returning an error code. This is not expected behaviour, as gitfo_exists() should only check whether the file itself exists, not its link target if it is a symbolic link. Fix this by calling gitfo_lstat() instead, which is just a wrapper for lstat(). Also fix the same error in index_init_entry().
Jakob Pfender 4d7905c5 2011-05-25T16:04:29 blob: Require stat information for git_blob_create_fromfile() In order to be able to write symlinks with git_blob_create_fromfile(), we need to check whether the file to be written is a symbolic link or not. Since the calling function of git_blob_create_fromfile() is likely to have stated the file before calling, we make it pass the stat. The reason for this is that writing symbolic link blobs is significantly different from writing ordinary files - we do not want to open the link destination but instead want to write the link itself, regardless of whether it exists or not. Previously, index_init_entry() used to error out if the file to be added was a symlink that pointed to a nonexistent file. Fix this behaviour to add the file regardless of whether it exists. This mimics git.git's behaviour.
Romain Geissler f11e0797 2011-06-05T21:19:03 Index: API uniformisation: Use unsigned int for all index number. Feature Added: Search an unmerged entry by path (git_index_get_unmerged renamed to git_index_get_unmerged_bypath) or by index (git_index_get_unmerged_byindex).
Vicent Marti 3a42e0a3 2011-06-03T21:38:55 index: Add `git_index_entry_stage` method As suggested by Romain-Geissler