summaryrefslogtreecommitdiff
path: root/src/index.c
Commit message (Collapse)AuthorAgeFilesLines
* index: overwrite the path when inserting conflictsntk/case_index_conflictsCarlos Martín Nieto2015-11-121-1/+1
| | | | | | | | | When we insert a conflict in a case-insensitive index, accept the new entry's path as the correct case instead of leaving the path we already had. This puts `git_index_conflict_add()` on the same level as `git_index_add()` in this respect.
* index: correctly report which conflict stage has a wrong filemodeCarlos Martín Nieto2015-11-121-1/+1
| | | | | When we're at offset 'i', we're dealing with the 'i+1' stage, since conflicts start at 1.
* index: read_index must update hashesEdward Thomson2015-10-301-9/+29
|
* pool: Simplify implementationVicent Marti2015-10-281-1/+1
|
* reuc: Be smarter when inserting new REUC entriesVicent Marti2015-10-271-19/+16
| | | | | | | | | | Inserting new REUC entries can quickly become pathological given that each insert unsorts the REUC vector, and both subsequent lookups *and* insertions will require sorting it again before being successful. To avoid this, we're switching to `git_vector_insert_sorted`: this keeps the REUC vector constantly sorted and lets us use the `on_dup` callback to skip an extra binary search on each insertion.
* index: Remove unneeded constsVicent Marti2015-10-211-3/+3
|
* index: also try conflict mode when insertingEdward Thomson2015-09-301-15/+62
| | | | | | | | | | When we do not trust the on-disk mode, we use the mode of an existing index entry. This allows us to preserve executable bits on platforms that do not honor them on the filesystem. If there is no stage 0 index entry, also look at conflicts to attempt to answer this question: prefer the data from the 'ours' side, then the 'theirs' side before falling back to the common ancestor.
* Merge pull request #3353 from ethomson/wrongcase_addCarlos Martín Nieto2015-09-081-22/+114
|\ | | | | index: canonicalize directory case when adding
| * git_index_add: allow case changing renamesEdward Thomson2015-09-081-15/+26
| | | | | | | | | | | | | | | | | | | | | | On case insensitive platforms, allow `git_index_add` to provide a new path for an existing index entry. Previously, we would maintain the case in an index entry without the ability to change it (except by removing an entry and re-adding it.) Higher-level functions (like `git_index_add_bypath` and `git_index_add_frombuffers`) continue to keep the old path for easier usage.
| * index: canonicalize directory case when addingEdward Thomson2015-09-081-7/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On case insensitive systems, when given a user-provided path in the higher-level index addition functions (eg `git_index_add_bypath` / `git_index_add_frombuffer`), examine the index to try to match the given path to an existing directory. Various mechanisms can cause the on-disk representation of a folder to not match the representation in HEAD or the index - for example, a case changing rename of some file `a/file.txt` to `A/file.txt` will update the paths in the index, but not rename the folder on disk. If a user subsequently adds `a/other.txt`, then this should be stored in the index as `A/other.txt`.
* | Merge pull request #3381 from leoyanggit/index_directory_iteratorEdward Thomson2015-09-081-0/+24
|\ \ | |/ |/| New feature: add the ablility to iterate through a directory in index
| * New API: git_index_find_prefixLeo Yang2015-09-041-0/+24
| | | | | | | | Find the first index entry matching a prefix.
* | Merge pull request #3366 from libgit2/cmn/index-hashmapEdward Thomson2015-09-061-17/+99
|\ \ | |/ |/| Use a hashmap for path-based lookups in the index
| * index: put the icase insert choice in macroscmn/index-hashmapCarlos Martín Nieto2015-09-041-25/+30
| | | | | | | | | | This should let us see more clearly what we're doing and avoid the ugly 'if' we need every time we want to interact with the map.
| * index: keep a hash table as well as a vector of entriesCarlos Martín Nieto2015-08-141-17/+94
| | | | | | | | | | The hash table allows quick lookup of specific paths, while we use the vector for enumeration.
* | racy-git: TODO to use improved diffingEdward Thomson2015-08-281-0/+1
| |
* | iterator: use an options struct instead of argsEdward Thomson2015-08-281-4/+5
|/
* errors: tighten up git_error_state OOMs a bit moreEdward Thomson2015-08-031-3/+3
| | | | | When an error state is an OOM, make sure that we treat is specially and do not try to free it.
* index: stage an unregistered submodule as wellcmn/add-unreg-submoduleCarlos Martín Nieto2015-08-011-5/+58
| | | | | | We previously added logic to `_add_bypath()` to update a submodule. Go further and stage the submodule even if it's not registered to behave like git.
* index: allow add_bypath to update submodulescmn/index-add-submoduleCarlos Martín Nieto2015-07-121-2/+22
| | | | | Similarly to how git itself does it, allow the index update operation to stage a change in a submodule's HEAD.
* index: check racily clean entries more thoroughlyCarlos Martín Nieto2015-06-221-2/+41
| | | | | | When an entry has a racy timestamp, we need to check whether the file itself has changed since we put its entry in the index. Only then do we smudge the size field to force a check the next time around.
* index: make relative comparison use the checksum as wellcmn/index-checksumCarlos Martín Nieto2015-06-201-4/+2
| | | | | | This is used by the submodule in order to figure out if the index has changed since it last read it. Using a timestamp is racy, so let's make it use the checksum, just like we now do for reloading the index itself.
* index: use the checksum to check whether it's been modifiedCarlos Martín Nieto2015-06-191-5/+42
| | | | | | | | | | | | | We currently use a timetamp to check whether an index file has been modified since we last read it, but this is racy. If two updates happen in the same second and we read after the first one, we won't detect the second one. Instead read the SHA-1 checksum of the file, which are its last 20 bytes which gives us a sure-fire way to detect whether the file has changed since we last read it. As we're now keeping track of it, expose an accessor to this data.
* index: zero the size of racily-clean entriesCarlos Martín Nieto2015-06-161-0/+18
| | | | | | | | | | | | | | | | If a file entry has the same timestamp as the index itself, it is considered racily-clean, as it may have been modified after the index was written, but during the same second. We take extra steps to check the contents, but this is just one part of avoiding races. For files which do have changes but have not been updated in the index, updating the on-disk index means updating its timestamp, which means we would no longer recognise these entries as racy and we would trust the timestamp to tell us whether they have changed. In order to work around this, git zeroes out the file-size field in entries with the same timestamp as the index in order to force the next diff to check the contents. Do so in libgit2 as well.
* diff: introduce binary diff callbacksEdward Thomson2015-06-121-1/+1
| | | | | | | Introduce a new binary diff callback to provide the actual binary delta contents to callers. Create this data from the diff contents (instead of directly from the ODB) to support binary diffs including the workdir, not just things coming out of the ODB.
* index_add_all: remove conflicts when no wd fileEdward Thomson2015-05-281-1/+2
| | | | | | | If there exists a conflict in the index, but no file in the working directory, this implies that the user wants to accept the resolution by removing the file. Thus, remove the conflict entry from the index, instead of trying to add a (nonexistent) file.
* introduce `git_index_entry_is_conflict`Edward Thomson2015-05-281-1/+6
| | | | | | | | | It's not always obvious the mapping between stage level and conflict-ness. More importantly, this can lead otherwise sane people to write constructs like `if (!git_index_entry_stage(entry))`, which (while technically correct) is unreadable. Provide a nice method to help avoid such messy thinking.
* index: validate mode of new conflictsEdward Thomson2015-05-281-0/+9
|
* index: remove error message in non-error removeEdward Thomson2015-05-281-0/+3
| | | | | If `git_index_remove_bypath` does no work, and returns an OK error code, it should not set an error message.
* conflicts: when adding conflicts, remove stagedEdward Thomson2015-05-281-1/+16
| | | | | | When adding a conflict for some path, remove the staged entry. Otherwise, an illegal index (with both stage 0 and high-stage entries) would result.
* git_index_add_all: don't recurse ignored dirsEdward Thomson2015-05-201-2/+1
| | | | | No need to get reports about individual ignored files, having a single ignored directory delta is enough.
* index_add_all: include untracked files in new subdirsEdward Thomson2015-05-201-1/+4
|
* index: include TYPECHANGE in the diffCarlos Martín Nieto2015-05-141-1/+2
| | | | Without this option, we would not be able to catch exec bit changes.
* index: make add_all to act on a diffCarlos Martín Nieto2015-05-141-80/+28
| | | | | | | Instead of going through each entry we have and re-adding, which may not even be correct for certain crlf options and has bad performance, use the function which performs a diff against the worktree and try to add and remove files from that list.
* index: refactor diff-based update_all to match other appliesCarlos Martín Nieto2015-05-141-80/+87
| | | | | Refactor so we look like the code we're replacing, which should also allow us to more easily inplement add-all.
* index: use a diff to perform update_allCarlos Martín Nieto2015-05-141-2/+79
| | | | | | | | | We currently iterate over all the entries and re-add them to the index. While this provides correctness, it is wasteful as we try to re-insert files which have not changed. Instead, take a diff between the index and the worktree and only re-add those which we already know have changed.
* index: introduce git_index_read_indexEdward Thomson2015-05-111-0/+98
|
* Fix index-adding functions to know when to trust filemodes.John Fultz2015-04-211-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | The idea...sometimes, a filemode is user-specified via an explicit git_index_entry. In this case, believe the user, always. Sometimes, it is instead built up by statting the file system. In those cases, go with the existing logic we have to determine whether the file system supports all filemodes and symlinks, and make the best guess. On file systems which have full filemode and symlink support, this commit should make no difference. On others (most notably Windows), this will fix problems things like: * git_index_add and git_index_add_frombuffer() should be believed. * As a consequence, git_checkout_tree should make the filemodes in the index match the ones in the tree. * And diffs with GIT_DIFF_UPDATE_INDEX don't write the wrong filemodes. * And merges, and probably other downstream stuff now fixed, too. This makes my previous changes to checkout.c unnecessary, so they are now reverted. Also, added a test for index_entry permissions from git_index_add and git_index_add_frombuffer, both of which failed before these changes.
* Entry argument passed to git_index_add_frombuffer() should be constPierre-Olivier Latour2015-04-031-1/+1
|
* Add API to add a memory buffer to an indexDamien PROFETA2015-02-251-8/+52
| | | | | | git_index_add_frombuffer enables now to store a memory buffer in the odb and to store an entry in the index directly if the index is attached to a repository.
* Merge pull request #2831 from ethomson/merge_lockCarlos Martín Nieto2015-02-151-29/+93
|\ | | | | merge: lock index during the merge (not just checkout)
| * indexwriter: an indexwriter for repo operationsEdward Thomson2015-02-141-0/+32
| | | | | | | | | | Provide git_indexwriter_init_for_operation for the common locking pattern in merge, rebase, revert and cherry-pick.
| * git_indexwriter: lock then write the indexEdward Thomson2015-02-141-29/+61
| | | | | | | | | | | | Introduce `git_indexwriter`, to allow us to lock the index while performing additional operations, then complete the write (or abort, unlocking the index).
* | Make our overflow check look more like gcc/clang'sEdward Thomson2015-02-131-8/+9
| | | | | | | | | | | | | | | | | | Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
* | overflow checking: don't make callers set oomEdward Thomson2015-02-121-3/+1
| | | | | | | | | | | | Have the ALLOC_OVERFLOW testing macros also simply set_oom in the case where a computation would overflow, so that callers don't need to.
* | allocations: test for overflow of requested sizeEdward Thomson2015-02-121-4/+14
|/ | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Ensure git_index_entry is not NULL before trying to free itJacques Germishuys2015-01-251-0/+3
|
* index: reuc and name entrycounts should be size_tEdward Thomson2014-12-221-4/+4
| | | | | | For the REUC and NAME entries, we use size_t internally, and we take size_t for the get_byindex() functions, but the entrycount() functions strangely cast to an unsigned int instead.
* checkout: disallow bad paths on win32Edward Thomson2014-12-161-88/+31
| | | | | | | | | | | | | | | Disallow: 1. paths with trailing dot 2. paths with trailing space 3. paths with trailing colon 4. paths that are 8.3 short names of .git folders ("GIT~1") 5. paths that are reserved path names (COM1, LPT1, etc). 6. paths with reserved DOS characters (colons, asterisks, etc) These paths would (without \\?\ syntax) be elided to other paths - for example, ".git." would be written as ".git". As a result, writing these paths literally (using \\?\ syntax) makes them hard to operate with from the shell, Windows Explorer or other tools. Disallow these.
* index: Check for valid paths before creating an index entryVicent Marti2014-12-161-15/+95
|