summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* reset: perform the checkout before moving HEAD or the indexcmn/reset-dir-fileCarlos Martín Nieto2015-12-091-6/+6
| | | | | | This keeps the state of the workdir the same as one from HEAD, removing a source of possible confusion when calculating the work that is to be done.
* Merge pull request #3539 from libgit2/typedef-submodule-cbCarlos Martín Nieto2015-12-081-1/+1
|\ | | | | Use a typedef for the submodule_foreach callback.
| * Use a typedef for the submodule_foreach callback.joshaber2015-12-081-1/+1
| | | | | | | | | | | | This fits with the style for the rest of the project, but more importantly, makes life easier for bindings authors who auto-generate code.
* | tree: mark a tree as already sortedcmn/tree-is-sortedCarlos Martín Nieto2015-12-061-1/+2
|/ | | | | The trees are sorted on-disk, so we don't have to go over them again. This cuts almost a fifth of time spent parsing trees.
* Merge pull request #3530 from libgit2/cmn/parse-modeEdward Thomson2015-12-031-5/+21
|\ | | | | tree: use a specialised mode parse function
| * tree: use a specialised mode parse functioncmn/parse-modeCarlos Martín Nieto2015-12-021-5/+21
| | | | | | | | | | Instead of going out to strtol, which is made to parse generic numbers, copy a parse function from git which is specialised for file modes.
* | index: canonicalize inserted paths safelyEdward Thomson2015-12-031-1/+1
|/ | | | | | | | | | | | | | | | | | When adding to the index, we look to see if a portion of the given path matches a portion of a path in the index. If so, we will use the existing path information. For example, when adding `foo/bar.c`, if there is an index entry to `FOO/other` and the filesystem is case insensitive, then we will put `bar.c` into the existing tree instead of creating a new one with a different case. Use `strncmp` to do that instead of `memcmp`. When we `bsearch` into the index, we locate the position where the new entry would go. The index entry at that position does not necessarily have a relation to the entry we're adding, so we cannot make assumptions and use `memcmp`. Instead, compare them as strings. When canonicalizing paths, we look for the first index entry that matches a given substring.
* tree: mark cloned tree entries as un-pooledPatrick Steinhardt2015-12-011-0/+2
| | | | | | | | | | | | When duplicating a `struct git_tree_entry` with `git_tree_entry_dup` the resulting structure is not allocated inside a memory pool. As we do a 1:1 copy of the original struct, though, we also copy the `pooled` field, which is set to `true` for pooled entries. This results in a huge memory leak as we never free tree entries that were duplicated from a pooled tree entry. Fix this by marking the newly duplicated entry as un-pooled.
* Merge pull request #3508 from libgit2/cmn/tree-parse-speedEdward Thomson2015-11-302-17/+55
|\ | | | | Improvements to tree parsing speed
| * tree: ensure the entry filename fits in 16 bitscmn/tree-parse-speedCarlos Martín Nieto2015-11-301-16/+26
| | | | | | | | | | | | Return an error in case the length is too big. Also take this opportunity to have a single allocating function for the size and overflow logic.
| * tree: make path len uint16_t and avoid holesCarlos Martín Nieto2015-11-282-2/+2
| | | | | | | | | | | | This reduces the size of the struct from 32 to 26 bytes, and leaves a single padding byte at the end of the struct (which comes from the zero-length array).
| * tree: calculate the filename length onceCarlos Martín Nieto2015-11-281-5/+8
| | | | | | | | | | We already know the size due to the `memchr()` so use that information instead of calling `strlen()` on it.
| * tree: pool the entry memory allocationsCarlos Martín Nieto2015-11-282-6/+33
| | | | | | | | | | | | | | These are rather small allocations, so we end up spending a non-trivial amount of time asking the OS for memory. Since these entries are tied to the lifetime of their tree, we can give the tree a pool so we speed up the allocations.
| * tree: avoid advancing over the filename multiple timesCarlos Martín Nieto2015-11-281-4/+2
| | | | | | | | | | | | | | We've already looked at the filename with `memchr()` and then used `strlen()` to allocate the entry. We already know how much we have to advance to get to the object id, so add the filename length instead of looking at each byte again.
* | object: remove unused constant OBJECT_BASE_SIZEPatrick Steinhardt2015-11-301-2/+0
| |
* | Merge pull request #3513 from ethomson/merge_recursiveCarlos Martín Nieto2015-11-304-125/+402
|\ \ | |/ |/| Recursive Merge
| * recursive merge: add a recursion limitEdward Thomson2015-11-251-3/+10
| |
| * merge: handle conflicts in recursive base buildingEdward Thomson2015-11-251-19/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building a recursive merge base, allow conflicts to occur. Use the file (with conflict markers) as the common ancestor. The user has already seen and dealt with this conflict by virtue of having a criss-cross merge. If they resolved this conflict identically in both branches, then there will be no conflict in the result. This is the best case scenario. If they did not resolve the conflict identically in the two branches, then we will generate a new conflict. If the user is simply using standard conflict output then the results will be fairly sensible. But if the user is using a mergetool or using diff3 output, then the common ancestor will be a conflict file (itself with diff3 output, haha!). This is quite terrible, but it matches git's behavior.
| * merge: use annotated commits for recursionEdward Thomson2015-11-253-68/+122
| | | | | | | | | | | | | | Use annotated commits to act as our virtual bases, instead of regular commits, to avoid polluting the odb with virtual base commits and trees. Instead, build an annotated commit with an index and pointers to the commits that it was merged from.
| * merge: merge annotated commits instead of regular commitsEdward Thomson2015-11-253-166/+159
| |
| * merge: octopus merge common ancestors when >2Edward Thomson2015-11-253-119/+189
| | | | | | | | | | | | When there are more than two common ancestors, continue merging the virtual base with the additional common ancestors, effectively octopus merging a new virtual base.
| * merge: compute octopus merge basesEdward Thomson2015-11-251-89/+100
| |
| * merge: build virtual base of multiple merge basesEdward Thomson2015-11-251-10/+123
| | | | | | | | | | When the commits to merge have multiple common ancestors, build a "virtual" base tree by merging the common ancestors.
| * merge: rename `git_merge_tree_flags_t` -> `git_merge_flags_t`Edward Thomson2015-11-252-8/+8
| |
* | checkout: only consider nsecs when built that wayEdward Thomson2015-11-235-66/+46
| | | | | | | | | | | | | | | | When examining the working directory and determining whether it's up-to-date, only consider the nanoseconds in the index entry when built with `GIT_USE_NSEC`. This prevents us from believing that the working directory is always dirty when the index was originally written with a git client that uinderstands nsecs (like git 2.x).
* | Merge pull request #3515 from jacquesg/unsigned-signedEdward Thomson2015-11-211-1/+1
|\ \ | |/ |/| Fix <0 unsigned comparison (stat.st_size should be an off_t)
| * Make stat.st_size a __int64 not a uint64_tJacques Germishuys2015-11-211-1/+1
| |
* | Merge pull request #3514 from jacquesg/stat-fixesEdward Thomson2015-11-201-8/+6
|\ \ | | | | | | Stat fixes
| * | Detect stat's structureJacques Germishuys2015-11-201-8/+6
| |/
* | repository: distinguish sequencer cherry-pick and revertcmn/repository-state-sequencerCarlos Martín Nieto2015-11-202-3/+15
|/ | | | These are not quite like their plain counterparts and require special handling.
* Merge pull request #3511 from ethomson/racy_fixes_2Carlos Martín Nieto2015-11-171-43/+94
|\ | | | | Racy fixes for writing new indexes
| * racy: make git_index_read_index handle racinessEdward Thomson2015-11-161-30/+48
| | | | | | | | | | | | | | | | | | | | | | Ensure that `git_index_read_index` clears the uptodate bit on files that it modifies. Further, do not propagate the cache from an on-disk index into another on-disk index. Although this should not be done, as `git_index_read_index` is used to bring an in-memory index into another index (that may or may not be on-disk), ensure that we do not accidentally bring in these bits when misused.
| * index: clear uptodate bit on saveEdward Thomson2015-11-161-1/+16
| | | | | | | | | | | | The uptodate bit should have a lifecycle of a single read->write on the index. Once the index is written, the files within it should be scanned for racy timestamps against the new index timestamp.
| * index: don't detect raciness in uptodate entriesEdward Thomson2015-11-161-2/+7
| | | | | | | | | | | | | | | | | | | | | | Keep track of entries that we believe are up-to-date, because we added the index entries since the index was loaded. This prevents us from unnecessarily examining files that we wrote during the cleanup of racy entries (when we smudge racily clean files that have a timestamp newer than or equal to the index's timestamp when we read it). Without keeping track of this, we would examine every file that we just checked out for raciness, since all their timestamps would be newer than the index's timestamp.
| * racy-git: do a single index->workdir diffEdward Thomson2015-11-161-10/+23
| | | | | | | | | | | | When examining paths that are racily clean, do a single index->workdir diff over the entirety of the racily clean files, instead of a diff per file.
* | settings: allow users to set PROGRAMDATAEdward Thomson2015-11-161-3/+12
|/ | | | | | Allow users to set the `git_libgit2_opts` search path for the `GIT_CONFIG_LEVEL_PROGRAMDATA`. Convert `GIT_CONFIG_LEVEL_PROGRAMDATA` to `GIT_SYSDIR_PROGRAMDATA` for setting the configuration.
* pool: Never return unaligned buffersvmg/pool-alignVicent Marti2015-11-131-8/+16
|
* Merge pull request #3170 from CmdrMoozy/nsec_fixCarlos Martín Nieto2015-11-1210-34/+136
|\ | | | | git_index_entry__init_from_stat: set nsec fields in entry stats
| * diff: refactor complex timestamp check into its own functionAxel Rasmussen2015-10-011-5/+27
| |
| * index: don't populate nsec values if GIT_USE_NSEC is offAxel Rasmussen2015-10-011-0/+3
| |
| * Merge branch 'master' into nsec_fix_nextAxel Rasmussen2015-10-0116-56/+226
| |\
| * | apple: work around non-POSIX struct stat on OS X.Axel Rasmussen2015-09-181-6/+17
| | |
| * | diff/index: respect USE_NSEC for racily clean file detectionAxel Rasmussen2015-09-184-13/+30
| | |
| * | win32: define our own POSIX struct stat, and support USE_NSECAxel Rasmussen2015-09-185-17/+57
| | |
| * | cmake: Only provide USE_NSEC if struct stat members are avilable.Axel Rasmussen2015-09-181-2/+1
| | | | | | | | | | | | | | | | | | This allows us to remove OS checks from source code, instead relying on CMake to detect whether or not `struct stat` has the nanoseconds members we rely on.
| * | settings: expose GIT_USE_NSEC flag in git_libgit2_featuresAxel Rasmussen2015-09-181-0/+3
| | |
| * | cmake: add USE_NSEC, and only check nanosec m/ctime if enabledAxel Rasmussen2015-09-182-2/+9
| | |
* | | Merge pull request #3499 from ethomson/ref_dir_errmsgsCarlos Martín Nieto2015-11-122-5/+21
|\ \ \ | | | | | | | | Improve error messages when dirs prevent ref/reflog creation
| * | | reflog: error when a directory is at reflog pathEdward Thomson2015-11-121-4/+11
| | | | | | | | | | | | | | | | | | | | When a non-empty directory exists and prevents the creation of a reflog, provide a more informative error message.
| * | | refs: complain when a directory exists at refEdward Thomson2015-11-121-1/+4
| | | | | | | | | | | | | | | | | | | | When a (non-empty) directory exists at the reference target location, complain with a more actionable error message.