summaryrefslogtreecommitdiff
path: root/src/path.c
Commit message (Collapse)AuthorAgeFilesLines
* path: fix "comparison always true" warningEtienne Samson2018-09-251-1/+1
|
* path validation: `char` is not signed by default.signed_charEdward Thomson2018-09-121-1/+1
| | | | | | | | | | | | | | | | | | | ARM treats its `char` type as `unsigned type` by default; as a result, testing a `char` value as being `< 0` is always false. This is a warning on ARM, which is promoted to an error given our use of `-Werror`. Per ISO 9899:199, section "6.2.5 Types": > The three types char, signed char, and unsigned char are collectively > called the character types. The implementation shall define char to > have the same range, representation, and behavior as either signed > char or unsigned char. > ... > Irrespective of the choice made, char is a separate type from the other > two and is not compatible with either.
* Merge pull request #4436 from pks-t/pks/packfile-stream-freeEdward Thomson2018-06-111-8/+8
|\ | | | | pack: rename `git_packfile_stream_free`
| * Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-8/+8
| |
* | path: unify `git_path_is_*` APIsPatrick Steinhardt2018-06-011-58/+34
|/ | | | | | | | | | | | | | | | Right now, there's quite a lot of different function calls to determine whether a path component matches a specific name after normalization from the filesystem. We have a function for each of {gitattributes, gitmodules, gitignore} multiplicated with {generic, NTFS, HFS} checks. In the long time, this is unmaintainable in case there are e.g. new filesystems with specific semantics, blowing up the number of functions we need to implement. Replace all functions with a simple `git_path_is_gitfile` function, which accepts an enum pointing out the filename that is to be checked against as well as the filesystem normalizations to check for. This greatly simplifies implementation at the expense of the caller having to invoke a somewhat longer function call.
* path: check for a symlinked .gitmodules in fs-agnostic codeCarlos Martín Nieto2018-05-231-8/+32
| | | | | We still compare case-insensitively to protect more thoroughly as we don't know what specifics we'll see on the system and it's the behaviour from git.
* path: reject .gitmodules as a symlinkCarlos Martín Nieto2018-05-231-8/+16
| | | | | | | | Any part of the library which asks the question can pass in the mode to have it checked against `.gitmodules` being a symlink. This is particularly relevant for adding entries to the index from the worktree and for checking out files.
* path: accept the name length as a parameterCarlos Martín Nieto2018-05-221-27/+25
| | | | | We may take in names from the middle of a string so we want the caller to let us know how long the path component is that we should be checking.
* path: expose dotgit detection functions per filesystemCarlos Martín Nieto2018-05-221-3/+42
| | | | | These will be used by the checkout code to detect them for the particular filesystem they're on.
* path: add functions to detect .gitconfig and .gitattributesCarlos Martín Nieto2018-05-181-0/+10
|
* path: add a function to detect an .gitmodules fileCarlos Martín Nieto2018-05-181-0/+13
| | | | | | | | Given a path component it knows what to pass to the filesystem-specific functions so we're protected even from trees which try to use the 8.3 naming rules to get around us matching on the filename exactly. The logic and test strings come from the equivalent git change.
* path: provide a generic function for checking dogit files on NTFSCarlos Martín Nieto2018-05-181-0/+53
| | | | | It checks against the 8.3 shortname variants, including the one which includes the checksum as part of its name.
* path: provide a generic dogit checking function for HFSCarlos Martín Nieto2018-05-181-6/+19
| | | | This lets us check for other kinds of reserved files.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* path: only set dotgit flags when configs were readPatrick Steinhardt2017-06-081-4/+5
|
* path: short-circuit `git_path_apply_relative` on errorPatrick Steinhardt2017-04-041-2/+2
| | | | | | | Short-circuit the call to `git_path_resolve_relative` in case `git_buf_joinpath` returns an error. While this does not fix any immediate errors, the resulting code is easier to read and handles potential new error conditions raised by `git_buf_joinpath`.
* path: handle error returned by `git_buf_joinpath`Patrick Steinhardt2017-04-041-1/+2
| | | | | | | | In the `_check_dir_contents` function, we first allocate memory for joining the directory and subdirectory together and afterwards use `git_buf_joinpath`. While this function in fact should not fail as memory is already allocated, err on the safe side and check for returned errors.
* path: ensure dirname on Win32 prefix always has a trailing '/'Patrick Steinhardt2017-02-081-7/+15
| | | | | | | | | | When calling `git_path_dirname_r` on a Win32 prefix, e.g. a drive or network share prefix, we always want to return the trailing '/'. This does not work currently when passing in a path like 'C:', where the '/' would not be appended correctly. Fix this by appending a '/' if we try to normalize a Win32 prefix and there is no trailing '/'.
* path: get correct dirname for Windows rootPatrick Steinhardt2017-02-081-0/+3
| | | | | | | | | | | | Getting the dirname of a filesystem root should return the filesystem root itself. E.g. the dirname of "/" is always "/". On Windows, we emulate this behavior and as such, we should return e.g. "C:/" if calling dirname on "C:/". But we currently fail to do so and instead return ".", as we do not check if we actually have a Windows prefix before stripping off the last directory component. Fix this by calling out to `win32_prefix_length` immediately after stripping trailing slashes, returning early if we have a prefix.
* path: extract `win32_path_prefix` functionPatrick Steinhardt2017-02-081-23/+33
| | | | | | Extract code which determines if a path is at a Windows system's root. This incluses drive prefixes (e.g. "C:\") as well as network computer names (e.g. "//computername/").
* giterr_set: consistent error messagesEdward Thomson2016-12-291-15/+15
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* path: remove unused local variablePatrick Steinhardt2016-12-121-1/+0
|
* refdb: bubble up locked files on the read sideCarlos Martín Nieto2016-11-141-0/+4
| | | | | | On Windows we can find locked files even when reading a reference or the packed-refs file. Bubble up the error in this case as well to allow callers on Windows to retry more intelligently.
* path: pass string instead of git_buf to giterr_setPatrick Steinhardt2016-11-141-1/+1
|
* Patch parsing from patch filesEdward Thomson2016-05-261-0/+19
|
* Introduce `git_path_common_dirlen`Edward Thomson2016-03-241-0/+14
|
* path: use GITERR_CHECK_ALLOC_BUF to verify passed in bufferPatrick Steinhardt2016-02-231-2/+1
|
* index: allow read of index w/ illegal entriesEdward Thomson2016-02-171-1/+6
| | | | | | | | | Allow `git_index_read` to handle reading existing indexes with illegal entries. Allow the low-level `git_index_add` to add properly formed `git_index_entry`s even if they contain paths that would be illegal for the current filesystem (eg, `AUX`). Continue to disallow `git_index_add_bypath` from adding entries that are illegal universally illegal (eg, `.git`, `foo/../bar`).
* Fix a couple function signaturesThomas Edvalson2015-12-141-1/+1
|
* core::mkdir tests: ensure we don't stomp symlinks in mkdirEdward Thomson2015-09-171-0/+11
| | | | | In `mkdir` and `mkdir_r`, ensure that we don't try to remove symlinks that are in our way.
* diriter: don't double '/' on posixEdward Thomson2015-09-131-1/+5
| | | | | | The canonical directory path of the root directory of a volume on POSIX already ends in a slash (eg, `/`). This is true only at the root. Do not add a slash to paths in this case.
* diriter: don't double '/' on WindowsEdward Thomson2015-09-131-1/+5
| | | | | | The canonical directory path of the root directory of a volume on windows already ends in a slash (eg, `c:/`). This is true only at the volume root. Do not add a slash to paths in this case.
* Fix duplicate basenames to support older VSJohn Haley2015-08-051-1/+1
| | | | | | | With Visual Studio versions 2008 and older they ignore the full path to files and only check the basename of the file to find a collision. Additionally, having duplicate basenames can break other build tools like GYP. This fixes https://github.com/libgit2/libgit2/issues/3356
* Merge pull request #3307 from libgit2/cmn/submodule-backslashEdward Thomson2015-07-241-0/+16
|\ | | | | Normalize submodule urls before looking at them
| * submodule, path: extract slash conversioncmn/submodule-backslashCarlos Martín Nieto2015-07-131-0/+16
| | | | | | | | Extract the backslash-to-slash conversion into a helper function.
* | Make libgit2 work on Windows Vista againSven Strickroth2015-07-221-3/+8
|/ | | | | | (fixes issue #3316) Signed-off-by: Sven Strickroth <email@cs-ware.de>
* buffer: don't allow growing borrowed buffersCarlos Martín Nieto2015-06-241-2/+2
| | | | | | | | | | When we don't own a buffer (asize=0) we currently allow the usage of grow to copy the memory into a buffer we do own. This muddles the meaning of grow, and lets us be a bit cavalier with ownership semantics. Don't allow this any more. Usage of grow should be restricted to buffers which we know own their own memory. If unsure, we must not attempt to modify it.
* Fixed Xcode 6.1 build warningsPierre-Olivier Latour2015-06-171-1/+1
|
* Fixed Xcode 6.1 build warningsPierre-Olivier Latour2015-06-151-2/+2
|
* path: remove unnecessary readdir_r usagecmn/readdirCarlos Martín Nieto2015-06-151-4/+3
| | | | | | Arguably all uses of readdir_r are unnecessary, but in this case especially so, as the directory handle only exists within this function, so we don't race with anybody.
* Fix memory leak on windows in diriter.Jeff Hostetler2015-06-121-0/+2
|
* Merge pull request #3165 from ethomson/downcaseCarlos Martín Nieto2015-06-081-1/+1
|\ | | | | Downcase
| * git__tolower: a tolower() that isn't dumbEdward Thomson2015-05-291-1/+1
| | | | | | | | | | | | | | | | Some brain damaged tolower() implementations appear to want to take the locale into account, and this may require taking some insanely aggressive lock on the locale and slowing down what should be the most trivial of trivial calls for people who just want to downcase ASCII.
* | path: error out if the callback returns an errorcmn/foreach-cancel-looseCarlos Martín Nieto2015-06-061-2/+4
|/ | | | | | | When the callback returns an error, we should stop immediately. This broke when trying to make sure we pass specific errors up the chain. This broke cancelling out of the loose backend's foreach.
* path: don't let direach overwrite the callback's error messageCarlos Martín Nieto2015-05-151-1/+3
| | | | | | | | | | This function deals with functions doing IO which means the amount of errors that can happen is quit large. It does not help if it always ovewrites the underlying error message with a less understandable version of "something went wrong". Instead, only use this generic message if there was no error set by the callback.
* diriter: actually use iconv on macEdward Thomson2015-05-011-2/+3
|
* git_buf_put_w: introduce utf16->utf8 conversionEdward Thomson2015-05-011-23/+4
|
* git_path_diriter: use FindFirstFile in win32Edward Thomson2015-05-011-2/+186
| | | | | | | Using FindFirstFile and FindNextFile in win32 allows us to use the directory information that is returned, instead of us having to get the file attributes all over again, which is a distinct cost savings on win32.
* git_path_diriter: next shouldn't take path ptrEdward Thomson2015-05-011-12/+15
| | | | | | | | The _next method shouldn't take a path pointer (and a path_len pointer) as 100% of current users use the full path and ignore the filename. Plus let's add some docs and a unit test.
* git_path_dirload_with_stat: moved to fs_iteratorEdward Thomson2015-05-011-127/+0
|