summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* config: expand paths with `git_sysdir_expand...`ethomson/expand_tildeEdward Thomson2017-03-231-13/+1
|
* config, attrcache: don't fallback to dirs literally named `~`Edward Thomson2017-03-232-15/+9
| | | | | | | | | | | | The config and attrcache file reading code would attempt to load a file in a home directory by expanding the `~` and looking for the file, using `git_sysdir_find_global_file`. If the file was not found, the error handling would look for the literal path, eg `~/filename.txt`. Use the new `git_config_expand_global_file` instead, which allows us to get the path to the file separately, when the path is prefixed with `~/`, and fail with a not found error without falling back to looking for the literal path.
* Introduce `git_sysdir_expand_global_file`Edward Thomson2017-03-232-0/+23
| | | | | | | Provide a mechanism for callers to expand the full path of a file in the global configuration directory (that is to say, the home directory) even if the file doesn't necessarily exist. This lets callers use their own logic for building paths separate from handling file existence.
* fix error when including a missing config file relative to the home directorySim Domingo2017-03-231-2/+10
|
* Merge branch 'pr/3957'Edward Thomson2017-03-231-0/+20
|\
| * merge: indentation fixupEdward Thomson2017-03-231-1/+1
| |
| * Perf: Don't perform merge operations for trivial merges.Arthur Schreiber2016-10-181-0/+20
| | | | | | | | When one side of a merge is treesame to the ancestor, we can take the other side and skip all the expensive merge operations. This optimization can only be performed when the generation of REUC extension data is skipped.
* | Merge pull request #4163 from pks-t/pks/submodules-with-worktreesEdward Thomson2017-03-224-49/+135
|\ \ | | | | | | Worktree fixes
| * | submodule: resolve URLs relative to main worktreePatrick Steinhardt2017-03-171-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is possible to specify submodule URLs relative to the repository location. E.g. having a submodule with URL "../submodule" will look for the submodule at "repo/../submodule". With the introduction of worktrees, though, we cannot simply resolve the URL relative to the repository location itself. If the repository for which a URL is to be resolved is a working tree, we have to resolve the URL relative to the parent's repository path. Otherwise, the URL would change depending on where the working tree is located. Fix this by special-casing when we have a working tree while getting the URL base.
| * | refdb: create references in commondirPatrick Steinhardt2017-03-171-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | References for a repository are usually created inside of its gitdir. When using worktrees, though, these references are not to be created inside the worktree gitdir, but instead inside the gitdir of its parent repository, which is the commondir. Like this, branches will still be available after the worktree itself has been deleted. The filesystem refdb currently still creates new references inside of the gitdir. Fix this and have it create references in commondir.
| * | worktree: write resolved paths into link filesPatrick Steinhardt2017-03-171-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | The three link files "worktree/.git", ".git/worktrees/<name>/commondir" and ".git/worktrees/<name>/gitdir" should always contain absolute and resolved paths. Adjust the logic creating new worktrees to first use `git_path_prettify_dir` before writing out these files, so that paths are resolved first.
| * | worktree: rename variable in `git_worktree_add`Patrick Steinhardt2017-03-171-13/+13
| | |
| * | worktree: use fully qualified reference name for created HEADPatrick Steinhardt2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a new worktree, we have to set up the initial data structures. Next to others, this also includes the HEAD pseudo-ref. We currently set it to the worktree respectively branch name, which is actually not fully qualified. Use the fully qualified branch name instead.
| * | worktree: parent path should point to the working dirPatrick Steinhardt2017-03-172-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | The working tree's parent path should not point to the parent's gitdir, but to the parent's working directory. Pointing to the gitdir would not make any sense, as the parent's working directory is actually equal to both repository's common directory. Fix the issue.
| * | worktree: implement `git_worktree_open_from_repository`Patrick Steinhardt2017-03-171-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | While we already provide functionality to look up a worktree from a repository, we cannot do so the other way round. That is given a repository, we want to look up its worktree if it actually exists. Getting the worktree of a repository is useful when we want to get certain meta information like the parent's location, getting the locked status, etc.
| * | worktree: split off function opening working directoryPatrick Steinhardt2017-03-171-17/+38
| | | | | | | | | | | | | | | | | | Separate the logic of finding the worktree directory of a repository and actually opening the working tree's directory. This is a preparatory step for opening the worktree structure of a repository itself.
| * | worktree: have `is_worktree_dir` accept a string instead of bufferPatrick Steinhardt2017-03-171-7/+16
| | | | | | | | | | | | | | | This will be used in later commits, where it becomes cumbersome to always pass in a buffer.
* | | Merge pull request #4030 from libgit2/ethomson/fsyncEdward Thomson2017-03-2223-43/+257
|\ \ \ | | | | | | | | fsync all the things
| * | | Honor `core.fsyncObjectFiles`ethomson/fsyncEdward Thomson2017-03-0210-21/+94
| | | |
| * | | win32: don't fsync parent directories on WindowsEdward Thomson2017-02-281-0/+5
| | | | | | | | | | | | | | | | Windows doesn't support it.
| * | | fsync: call it "synchronous" object writingEdward Thomson2017-02-286-11/+11
| | | | | | | | | | | | | | | | | | | | Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` -> `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
| * | | fsync parent directories when fsyncingEdward Thomson2017-02-284-2/+60
| | | | | | | | | | | | | | | | | | | | | | | | When fsync'ing files, fsync the parent directory in the case where we rename a file into place, or create a new file, to ensure that the directory entry is flushed correctly.
| * | | git_futils_writebuffer: default only when flags==0Edward Thomson2017-02-282-12/+12
| | | | | | | | | | | | | | | | | | | | Only use defaults for `git_futils_writebuffer` when flags == 0, lest (1 << 31) be treated as the defaults.
| * | | refdb_fs: optionally fsync packed refsEdward Thomson2017-02-281-2/+5
| | | |
| * | | refdb_fs: optionally fsync loose referencesEdward Thomson2017-02-281-4/+13
| | | |
| * | | git_futils_writebuffer: optionally fsyncEdward Thomson2017-02-282-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a custom `O_FSYNC` bit (if it's not been defined by the operating system`) so that `git_futils_writebuffer` can optionally do an `fsync` when it's done writing. We call `fsync` ourselves, even on systems that define `O_FSYNC` because its definition is no guarantee of its actual support. Mac, for instance, defines it but doesn't support it in an `open(2)` call.
| * | | packbuilder: honor git_object__synchronized_writingEdward Thomson2017-02-281-1/+9
| | | | | | | | | | | | | | | | | | | | Honor `git_object__synchronized_writing` when creating a packfile and corresponding index.
| * | | odb_loose: fsync testsEdward Thomson2017-02-284-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a simple counter that `p_fsync` implements. This is useful for ensuring that `p_fsync` is called when we expect it to be, for example when we have enabled an odb backend to perform `fsync`s when writing objects.
| * | | Add `ENABLE_SYNCHRONIZED_OBJECT_CREATION` optionEdward Thomson2017-02-284-1/+8
| | | | | | | | | | | | | | | | Allow users to enable `SYNCHRONIZED_OBJECT_CREATION` with a setting.
| * | | odb_loose: actually honor the fsync optionEdward Thomson2017-02-281-6/+13
| | | | | | | | | | | | | | | | | | | | We've had an fsync option for a long time, but it was "ignored". Stop ignoring it.
| * | | git_filebuf: optionally fsync when committingEdward Thomson2017-02-282-1/+11
| | | |
* | | | diff_parse: check return value of `git_diff_init_options`Patrick Steinhardt2017-03-211-1/+5
| | | |
* | | | patch_parse: check if advancing over header newline succeedsPatrick Steinhardt2017-03-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While parsing patch header lines, we iterate over each line and check if the line has trailing garbage. What we do not check though is that the line is actually a line ending with a trailing newline. Fix this by checking the return code of `parse_advance_expected_str`.
* | | | odb_pack: initialize `git_rawobj` structurePatrick Steinhardt2017-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `pack_entry_find_prefix` function receives a `git_rawobj` structure as argument. While the function first initializes the structure to a sensible state, Coverity is unable to correctly detect this, resulting in a warning. Fix this warning by initializing the object to all-zeroes before passing it to the function.
* | | | config_file: check if section header buffer runs out of memoryPatrick Steinhardt2017-03-211-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | While parsing section headers, we use a buffer to store the actual section name. We do not check though if the buffer runs out of memory at any stage. Do so.
* | | | blame_git: check return value of object lookupPatrick Steinhardt2017-03-211-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | The function `pass_whole_blame` performs an object lookup but does not check if the lookup actually succeeds. Convert the function to return an error code and check for it in the calling function.
* | | | openssl_stream: fix releasing OpenSSL locksPatrick Steinhardt2017-03-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The OpenSSL library may require multiple locks to work correctly, where it is the caller's responsibility to initialize and release the locks. While we correctly initialized up to `n` locks, as determined by `CRYPTO_num_locks`, we were repeatedly freeing the same mutex in our shutdown procedure. Fix the issue by freeing locks at the correct index.
* | | | Merge pull request #4166 from pks-t/pks/map-free-fixEdward Thomson2017-03-209-15/+9
|\ \ \ \ | | | | | | | | | | Remove `map_free` macros
| * | | | map: remove `*map_free` macrosPatrick Steinhardt2017-03-208-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `map_free` functions were not implemented as functions but instead as macros which also set the map to NULL. While this is most certainly sensible in most cases, we should prefer the more obvious behavior, namingly leaving the map pointer intact. Furthermore, this macro has been refactored incorrectly during the map-refactorings: the two statements are not actually grouped together by a `do { ... } while (0)` block, as it is required for macros to match the behavior of functions more closely. This has led to at least one subtle nesting error in `pack-objects.c`. The following code block ``` if (pb->object_ix) git_oidmap_free(pb->object_ix); ``` would be expanded to ``` if (pb->object_ix) git_oidmap__free(pb->object_ix); pb->object_ix = NULL; ``` which is not what one woudl expect. While it is not a bug here as it would simply become a no-op, the wrong implementation could lead to bugs in other occasions. Fix this by simply removing the macro altogether and replacing it with real function calls. This leaves the burden of setting the pointer to NULL afterwards to the caller, but this is actually expected and behaves like other `free` functions.
| * | | | checkout: fix double-free of checkout_data's mkdir_mapPatrick Steinhardt2017-03-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently call `git_strmap_free` on `checkout_data.mkdir_map` in the `checkout_data_clear` function. The only thing protecting us from a double-free is that the `git_strmap_free` function is in fact not a function, but a macro that also sets the map to NULL. Remove the second call to `git_strmap_free` and explicitly set the map member to NULL.
* | | | | Merge pull request #4169 from csware/absolute-symlinkPatrick Steinhardt2017-03-201-1/+1
|\ \ \ \ \
| * | | | | filebuf: fix resolving absolute symlinksSven Strickroth22017-03-201-1/+1
| | |/ / / | |/| | | | | | | | | | | | | | | | | | The symlink destination is always concatenated to the original path. Fix this by using `git_buf_sets` instead of `git_buf_puts`.
* | | | | Merge pull request #4160 from pks-t/pks/diff-fixesPatrick Steinhardt2017-03-204-82/+49
|\ \ \ \ \ | | | | | | | | | | | | Diff fixes
| * | | | | diff_parse: correctly set options for parsed diffsPatrick Steinhardt2017-03-141-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `diff_parsed_alloc` allocates and initializes a `git_diff_parsed` structure. This structure also contains diff options. While we initialize its flags, we fail to do a real initialization of its values. This bites us when we want to actually use the generated diff as we do not se the option's version field, which is required to operate correctly. Fix the issue by executing `git_diff_init_options` on the embedded struct.
| * | | | | patch_parse: fix parsing minimal trailing diff linePatrick Steinhardt2017-03-141-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a diff, the shortest possible hunk with a modification (that is, no deletion) results from a file with only one line with a single character which is removed. Thus the following hunk @@ -1 +1 @@ -a + is the shortest valid hunk modifying a line. The function parsing the hunk body though assumes that there must always be at least 4 bytes present to make up a valid hunk, which is obviously wrong in this case. The absolute minimum number of bytes required for a modification is actually 2 bytes, that is the "+" and the following newline. Note: if there is no trailing newline, the assumption will not be offended as the diff will have a line "\ No trailing newline" at its end. This patch fixes the issue by lowering the amount of bytes required.
| * | | | | patch_generate: move `git_diff_foreach` to diff.cPatrick Steinhardt2017-03-142-36/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that the `git_diff_foreach` function does not depend on internals of the `git_patch_generated` structure anymore, we can easily move it to the actual diff code.
| * | | | | patch_generate: fix `git_diff_foreach` only working with generated diffsPatrick Steinhardt2017-03-141-23/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current logic of `git_diff_foreach` makes the assumption that all diffs passed in are actually derived from generated diffs. With these assumptions we try to derive the actual diff by inspecting either the working directory files or blobs of a repository. This obviously cannot work for diffs parsed from a file, where we do not necessarily have a repository at hand. Since the introduced split of parsed and generated patches, there are multiple functions which help us to handle patches generically, being indifferent from where they stem from. Use these functions and remove the old logic specific to generated patches. This allows re-using the same code for invoking the callbacks on the deltas.
| * | | | | patch_generate: remove duplicated logicPatrick Steinhardt2017-03-141-29/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under the existing logic, we try to load patch contents differently, depending on whether the patch files stem from the working directory or not. But actually, the executed code paths are completely equal to each other -- so we were always the code despite the condition. Remove the condition altogether and conflate both code paths.
* | | | | | Merge pull request #4162 from pks-t/pks/merge-source-fixesPatrick Steinhardt2017-03-201-5/+5
|\ \ \ \ \ \ | |_|_|/ / / |/| | | | | merge_driver: fix const-correctness for source getters
| * | | | | merge_driver: fix const-correctness for source gettersPatrick Steinhardt2017-03-151-5/+5
| | |_|/ / | |/| | |