src/repository.c


Log

Author Commit Date CI Message
Carlos Martín Nieto ee550477 2014-01-26T16:11:18 config: use git_buf for returning paths Again, we already did this internally, so simply remove the conversions.
Carlos Martín Nieto 7a3bd1e7 2014-01-26T15:35:17 repository: move to use a git_buf for outputting strings Since we now export that type, we can avoid making the user guess a size.
Russell Belfer 6b415f62 2014-01-17T13:46:44 Convert gitdir paths to posix on Windows Apparently, a .git file with "gitdir: path" link on Windows is allowed to use backslashes in the path. Who knew?
Carlos Martín Nieto 0b28217b 2014-01-15T12:51:31 refs: remove the _with_log differentiation Any well-behaved program should write a descriptive message to the reflog whenever it updates a reference. Let's make this more prominent by removing the version without the reflog parameters.
Russell Belfer 25e0b157 2013-12-06T15:07:57 Remove converting user error to GIT_EUSER This changes the behavior of callbacks so that the callback error code is not converted into GIT_EUSER and instead we propagate the return value through to the caller. Instead of using the giterr_capture and giterr_restore functions, we now rely on all functions to pass back the return value from a callback. To avoid having a return value with no error message, the user can call the public giterr_set_str or some such function to set an error message. There is a new helper 'giterr_set_callback' that functions can invoke after making a callback which ensures that some error message was set in case the callback did not set one. In places where the sign of the callback return value is meaningful (e.g. positive to skip, negative to abort), only the negative values are returned back to the caller, obviously, since the other values allow for continuing the loop. The hardest parts of this were in the checkout code where positive return values were overloaded as meaningful values for checkout. I fixed this by adding an output parameter to many of the internal checkout functions and removing the overload. This added some code, but it is probably a better implementation. There is some funkiness in the network code where user provided callbacks could be returning a positive or a negative value and we want to rely on that to cancel the loop. There are still a couple places where an user error might get turned into GIT_EUSER there, I think, though none exercised by the tests.
Russell Belfer 9f77b3f6 2013-11-25T14:21:34 Add config read fns with controlled error behavior This adds `git_config__lookup_entry` which will look up a key in a config and return either the entry or NULL if the key was not present. Optionally, it can either suppress all errors or can return them (although not finding the key is not an error for this function). Unlike other accessors, this does not normalize the config key string, so it must only be used when the key is known to be in normalized form (i.e. all lower-case before the first dot and after the last dot, with no invalid characters). This also adds three high-level helper functions to look up config values with no errors and a fallback value. The three functions are for string, bool, and int values, and will resort to the fallback value for any error that arises. They are: * `git_config__get_string_force` * `git_config__get_bool_force` * `git_config__get_int_force` None of them normalize the config `key` either, so they can only be used for internal cases where the key is known to be in normal format.
Edward Thomson bab0b9f2 2013-11-22T18:02:12 clean up state metadata more consistently
Victor Garcia 40b99d05 2013-11-08T12:14:31 splitting funcionality in two methods to avoid ambiguity with NULL
Victor Garcia 0fe522d1 2013-11-07T14:16:20 allowing create remote with custom fetch spec
Edward Thomson 1d3a8aeb 2013-11-04T18:28:57 move mode_t to filebuf_open instead of _commit
Russell Belfer 867f7c9b 2013-10-08T16:59:59 Rename new fn to git_repository_reinit_filesystem
Russell Belfer 14997dc5 2013-10-08T12:45:43 More filemode cleanups for FAT on MacOS This cleans up some additional issues. The main change is that on a filesystem that doesn't support mode bits, libgit2 will now create new blobs with GIT_FILEMODE_BLOB always instead of being at the mercy to the filesystem driver to report executable or not. This means that if "core.filemode" lies and claims that filemode is not supported, then we will ignore the executable bit from the filesystem. Previously we would have allowed it. This adds an option to the new git_repository_reset_filesystem to recurse through submodules if desired. There may be other types of APIs that would like a "recurse submodules" option, but this one is particularly useful. This also has a number of cleanups, etc., for related things including trying to give better error messages when problems come up from the filesystem. For example, the FAT filesystem driver on MacOS appears to return errno EINVAL if you attempt to write a filename with invalid UTF-8 in it. We try to capture that with a better error message now.
Russell Belfer 5173ea92 2013-10-04T16:32:16 Add git_repository_reset_filesystem and fix tests When a repository is transferred from one file system to another, many of the config settings that represent the properties of the file system may be wrong. This adds a new public API that will refresh the config settings of the repository to account for the change of file system. This doesn't do a full "reinitialize" and operates on a existing git_repository object refreshing the config when done. This commit then makes use of the new API in clar as each test repository is set up. This commit also has a number of other clar test fixes where we were making assumptions about the type of filesystem, either based on outdated config data or based on the OS instead of the FS.
Russell Belfer 840fb4fc 2013-10-03T14:42:37 Update repo init with fewer platform assumptions The repo init code was assuming Windows == no filemode, and Mac or Windows == no case sensitivity. Those assumptions are not consistently true depending on the mounted file system. This is a first step to removing those assumptions. It focuses on the repo init code and the tests of that code. There are still many other tests that are broken when those assumptions don't hold true, but this clears up one area of the code. Also, this moves the core.precomposeunicode logic to be closer to the current logic in core Git where it will be set to true on any filesystem where composed unicode is decomposed when read back.
Russell Belfer af302aca 2013-10-02T14:13:11 Clean up annoying warnings The indexer code was generating warnings on Windows 64-bit. I looked closely at the logic and was able to simplify it a bit. Also this fixes some other Windows and Linux warnings.
Russell Belfer 6b7991e2 2013-09-30T16:13:53 Add check if we need to precompose unicode on Mac This adds initialization of core.precomposeunicode to repo init on Mac. This is necessary because when a Mac accesses a repo on a VFAT or SAMBA file system, it will return directory entries in decomposed unicode even if the filesystem entry is precomposed. This also removes caching of a number of repo properties from the repo init pipeline because these are properties of the specific filesystem on which the repo is created, not of the system as a whole.
Russell Belfer 1ca3e49f 2013-09-23T13:34:01 Clean up newly introduced warnings The attempt to "clean up warnings" seems to have introduced some new warnings on compliant compilers. This fixes those in a way that I suspect will also be okay for the non-compliant compilers. Also this fixes what appears to be an extra semicolon in the repo initialization template dir handling (and as part of that fix, handles the case where an error occurs correctly).
Linquize 417472e3 2013-09-20T09:02:58 Check error value from git_futils_find_template_dir
Linquize 0cd1c3bb 2013-09-18T23:06:10 Make init.templatedir work
Vicent Martí 3d4f1698 2013-09-17T10:21:22 Merge pull request #1858 from linquize/win32-template-dir Configurable template dir for Win32
Russell Belfer 4b11f25a 2013-09-11T16:38:33 Add ident filter This adds the ident filter (that knows how to replace $Id$) and tweaks the filter APIs and code so that git_filter_source objects actually have the updated OID of the object being filtered when it is a known value.
Russell Belfer 85d54812 2013-08-28T16:44:04 Create public filter object and use it This creates include/sys/filter.h with a basic definition of a git_filter and then converts the internal code to use it. There are related internal objects (git_filter_list) that we will want to publish at some point, but this is a first step.
Linquize a025907e 2013-09-17T23:55:11 Can load default template directory
Carlos Martín Nieto 605da51a 2013-09-17T09:50:30 No such thing as an orphan branch Unfortunately git-core uses the term "unborn branch" and "orphan branch" interchangeably. However, "orphan" is only really there for the checkout command, which has the `--orphan` option so it doesn't actually create the branch. Branches never have parents, so the distinction of a branch with no parents is odd to begin with. Crucially, the error messages deal with unborn branches, so let's use that.
Russell Belfer 42181836 2013-08-29T10:27:01 Treat detached HEAD as non-empty repo This simplifies the git_repository_is_empty a bit so that a detached HEAD is just taken to mean the repo is not empty, since a newly initialized repo will not have a detached HEAD.
Vicent Martí 8b2f230c 2013-08-29T13:27:37 repository: Make the is_empty check more explicit
Justin Spahr-Summers 4ab6a759 2013-08-28T22:51:44 Fix incorrect precedence within git_repository_is_empty() Reverts part of 9146f1e57ec4f2b6fa293c78d54f1383464ff5be.
Rémi Duraffort 9146f1e5 2013-07-15T15:59:18 repository: clarify assignment and test order
Russell Belfer 3fe046cf 2013-06-29T13:13:38 Add BARE option to git_repository_open_ext This adds a BARE option to git_repository_open_ext which allows a fast open path that still knows how to read gitlinks and to search for the actual .git directory from a subdirectory. `git_repository_open_bare` is still simpler and faster, but having a gitlink aware fast open is very useful for submodules where we want to quickly be able to peek at the HEAD and index data without doing any other meaningful repo operations.
Vicent Marti 6de9b2ee 2013-06-12T21:10:33 util: It's called `memzero`
Vicent Marti eb58e2d0 2013-06-12T21:05:48 Merge remote-tracking branch 'arrbee/minor-paranoia' into development
Russell Belfer 3eadfecd 2013-06-10T15:24:20 start implementing diff driver registry
Russell Belfer 114f5a6c 2013-06-10T10:10:39 Reorganize diff and add basic diff driver This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
Russell Belfer 3e9e6cda 2013-06-07T09:54:33 Add safe memset and use it This adds a `git__memset` routine that will not be optimized away and updates the places where I memset() right before a free() call to use it.
Russell Belfer f658dc43 2013-05-31T14:09:58 Zero memory for major objects before freeing By zeroing out the memory when we free larger objects (i.e. those that serve as collections of other data, such as repos, odb, refdb), I'm hoping that it will be easier for libgit2 bindings to find errors in their object management code.
Vicent Marti ec24e542 2013-05-29T22:47:37 What are the chances, really
Ben Straub 6f0b8142 2013-05-23T17:28:52 Stop leaking memory
Ben Straub 93d8f77f 2013-05-23T15:11:53 Improve test failure output
Linquize 0cb16fe9 2013-05-15T20:26:55 Unify whitespaces to tabs
Edward Thomson b6cc559a 2013-05-11T02:42:49 Merge pull request #1385 from carlosmn/refs-iter Introduce a refs iterator
Carlos Martín Nieto 2b562c3a 2013-05-04T16:32:58 refs: remove the OID/SYMBOLIC filtering Nobody should ever be using anything other than ALL at this level, so remove the option altogether. As part of this, git_reference_foreach_glob is now implemented in the frontend using an iterator. Backends will later regain the ability of doing the glob filtering in the backend.
Russell Belfer 3d1c9f61 2013-05-09T06:45:06 Fix git_repository_message docs This clarifies the docs for git_repository_message and also adds to the tests to explicitly check NUL termination of data when the output buffer is smaller than the message size. There is a minor behavior change so that a non-NULL output buffer will always be NUL terminated (at length zero) if an error occurs.
Carlos Martín Nieto a4b75dcf 2013-05-06T21:51:25 repo: unconditionally create a global config backend When a repository is initialised, we need to probe to see if there is a global config to load. If this is not the case, the user isn't able to write to the global config without creating the backend and adding it themselves, which is inconvenient and overly complex. Unconditionally create and add a backend for the global config file regardless of whether it exists as a convenience for users. To enable this, we allow creating backends to files that do not exist yet, changing the semantics somewhat, and making some tests invalid.
Russell Belfer 1a9e406c 2013-05-01T15:47:37 minor missing error message
Vicent Marti bade5194 2013-04-30T21:02:13 lol namespaces
Vicent Marti 879458e7 2013-04-24T15:52:33 repo: Add `git_repository__cleanup`
Russell Belfer e976b56d 2013-04-15T14:27:53 Add git__compare_and_swap and use it This removes the lock from the repository object and changes the internals to use the new atomic git__compare_and_swap to update the _odb, _config, _index, and _refdb variables in a threadsafe manner.
Russell Belfer 53607868 2013-04-15T00:09:03 Further threading fixes This builds on the earlier thread safety work to make it so that setting the odb, index, refdb, or config for a repository is done in a threadsafe manner with minimized locking time. This is done by adding a lock to the repository object and using it to guard the assignment of the above listed pointers. The lock is only held to assign the pointer value. This also contains some minor fixes to the other work with pack files to reduce the time that locks are being held to and fix an apparently memory leak.
Vicent Marti 5df18424 2013-04-01T19:38:23 lol this worked first try wtf
Russell Belfer 1384b688 2013-04-19T13:00:12 Move some low-level repo fns to include/git2/sys
John Wiegley 7cc3c920 2013-01-29T07:48:36 Added git_repository_new function
Vicent Marti a442ed68 2013-04-17T04:46:37 repository: Add `git_repository_open_bare`
Edward Thomson d00d5464 2013-03-01T15:37:33 immutable references and a pluggable ref database
Vicent Martí b72f5d40 2013-03-05T15:35:28 Merge pull request #1369 from arrbee/repo-init-template-hooks More tests (and fixes) for initializing repo from template
Russell Belfer 18f08264 2013-02-27T13:44:15 Make mode handling during init more like git When creating files, instead of actually using GIT_FILEMODE_BLOB and the other various constants that happen to correspond to mode values, apparently I should be just using 0666 and 0777, and relying on the umask to clear bits and make the value sane. This fixes the rules for copying a template directory and fixes the checks to match that new behavior. (Further changes to the checkout logic to follow separately.)
Russell Belfer 0d1b094b 2013-02-26T13:15:06 Fix portability issues on Windows The new tests were not taking core.filemode into account when testing file modes after repo initialization. Fixed that and some other Windows warnings that have crept in.
Russell Belfer 3c42e4ef 2013-02-26T11:43:14 Fix initialization of repo directories When PR #1359 removed the hooks from the test resources/template directory, it made me realize that the tests for git_repository_init_ext using templates must be pretty shabby because we could not have been testing if the hooks were getting created correctly. So, this started with me recreating a couple of hooks, including a sample and symlink, and adding tests that they got created correctly in the various circumstances, including with the SHARED modes, etc. Unfortunately this uncovered some issues with how directories and symlinks were copied and chmod'ed. Also, there was a FIXME in the code related to the chmod behavior as well. Going back over the directory creation logic for setting up a repository, I found it was a little difficult to read and could result in creating and/or chmod'ing directories that the user almost certainly didn't intend. So that let to this work which makes repo initialization much more careful (and hopefully easier to follow). It required a couple of extensions / changes to core fileops utilities, but I also think those are for the better, at least for git_futils_cp_r in terms of being careful about what actions it takes.
Sascha Cunz 25e7c9b7 2013-02-26T18:21:03 Increment reference counter in git_repository_set_config This fixes #1365
Sebastian Bauer 85f40312 2013-01-13T11:30:05 Do not use GIT_CPDIR_CHMOD flag when copying the template. This is an intermin solution. While this essentially disables the --shared flag feature, previously external templates did not work at all. This change fixes the previously corrected, and since then failing, repo_init__extended_with_template() test. The problem is now documented in the source code comments.
Sebastian Bauer b7b1acfd 2013-01-12T20:02:00 Clear local error variable after invoking giterr_clear().
Edward Thomson 359fc2d2 2013-01-08T17:07:25 update copyrights
Ben Straub 87bc689f 2012-12-20T15:50:33 git_remote_create calls git_remote_save
Ben Straub 29f27599 2012-12-20T10:51:09 Rename remote creation APIs git_remote_add -> git_remote_create git_remote_new -> git_remote_create_inmemory
Ben Straub c7231c45 2012-11-30T16:31:42 Deploy GITERR_CHECK_VERSION
Ben Straub b4d13652 2012-11-29T20:06:23 Deploy GIT_REPOSITORY_INIT_OPTIONS_INIT
Ben Straub c9fc4a6f 2012-11-27T13:44:49 API updates for repository.h
Ben Straub 54b2a37a 2012-11-20T16:02:25 Clean up config.h
Ben Straub 2508cc66 2012-11-18T21:38:08 Rename ref and reflog apis for consistency
nulltoken 5cec896a 2012-11-22T18:51:06 repo: Make git_repository_head_tree() return error codes
Russell Belfer 38f7d026 2012-11-20T14:50:36 Need to clear ignored error from config load
Russell Belfer cc6b4162 2012-11-20T10:24:18 It is okay to not have a .gitconfig file Opening a repo is generating an error if you don't have a .gitconfig file in your home directory, but that should be legal.
Michael Schubert 0066955d 2012-11-18T04:27:49 Fix a couple of warnings
nulltoken 270160b9 2012-11-17T13:39:24 config: Opening a nonexistent file returns ENOTFOUND
nulltoken 6091457e 2012-11-17T07:19:14 repo: ensure is_empty() checks there are no refs
nulltoken b1a3a70e 2012-11-12T00:14:51 repository: Refine repository_head() error report
Keith Dahlby 35d255fd 2012-11-04T12:13:42 repo: fix state when HEAD is not detached
nulltoken 31966d20 2012-10-27T09:30:03 repo: enhance git_repository_state() detection
Edward Thomson 632d8b23 2012-10-23T15:42:09 reset changes for merge
yorah a1abe66a 2012-09-10T12:11:02 Add config level support in the config API Added `struct git_config_entry`: a git_config_entry contains the key, the value, and the config file level from which a config element was found. Added `git_config_open_level`: build a single-level focused config object from a multi-level one. We are now storing `git_config_entry`s in the khash of the config_file
nulltoken 8b05bea8 2012-10-19T17:07:39 errors: deploy GIT_EORPHANEDHEAD usage
Carlos Martín Nieto a8918418 2012-10-16T17:58:19 config: also free the XDG buffer
Vicent Martí 52748f7b 2012-10-16T08:36:55 Merge pull request #952 from csware/config-locations Config location fixes
nulltoken 096d9e94 2012-10-07T21:00:46 remote: use constants for well-known names
nulltoken 74a24005 2012-09-21T10:28:20 refs: use constants for well-known names
Sven Strickroth 4258d483 2012-10-02T17:21:07 Rename xdr to xdg Signed-off-by: Sven Strickroth <email@cs-ware.de>
Sven Strickroth 407cf4e4 2012-09-24T23:22:07 Fixed typo: xdr config needs to have a lower priority than the global one Signed-off-by: Sven Strickroth <email@cs-ware.de>
Sven Strickroth 8b4f9b17 2012-09-24T18:59:00 Correctly read xdr compatible %HOME%/.config/git/config config file This file is not just read if the global config file (%HOME%/.gitconfig) is not found, however, it is used everytime but with lower priority. Signed-off-by: Sven Strickroth <email@cs-ware.de>
Sven Strickroth b1127a30 2012-09-20T22:32:19 git_repository_hashfile: Only close file handle if we have a valid one Otherwise this throws an exception on MFC based systems. Signed-off-by: Sven Strickroth <email@cs-ware.de>
nulltoken 44af67a8 2012-09-15T22:07:45 repository: introduce git_repository_set_head()
nulltoken 4ebe38bd 2012-09-15T22:07:09 repository: introduce git_repository_set_head_detached()
nulltoken 3f4c3072 2012-09-15T22:03:31 repository: introduce git_repository_detach_head()
nulltoken 75050223 2012-09-14T11:47:43 Fix MSVC compilation warnings
Sascha Cunz 13b554e3 2012-09-13T23:30:31 Fix error text s/buffer too long/buffer too short/
Russell Belfer a13fb55a 2012-09-11T17:26:21 Add tests and improve param checks Fixed some minor `git_repository_hashfile` issues: - Fixed incorrect doc (saying that repo could be NULL) - Added checking of object type value to acceptable ones - Added more tests for various parameter permutations
Russell Belfer 47bfa0be 2012-09-07T13:27:49 Add git_repository_hashfile to hash with filters The existing `git_odb_hashfile` does not apply text filtering rules because it doesn't have a repository context to evaluate the correct rules to apply. This adds a new hashfile function that will apply repository-specific filters (based on config, attributes, and filename) before calculating the hash.
nulltoken 89cd5708 2012-08-29T14:20:53 repository: make initialization cope with missing core.worktree
Russell Belfer 5f4a61ae 2012-08-09T19:43:25 Working implementation of git_submodule_status This is a big redesign of the git_submodule_status API and the implementation of the redesigned API. It also fixes a number of bugs that I found in other parts of the submodule API while writing the tests for the status part. This also fixes a couple of bugs in the iterators that had not been noticed before - one with iterating when there is a gitlink (i.e. separate-work-dir) and one where I was treating anything even vaguely submodule-like as a submodule, more aggressively than core git does.
Russell Belfer 2eb4edf5 2012-08-24T10:48:48 Fix errors on Win32 with new repo init
Russell Belfer e9ca852e 2012-08-23T09:20:17 Fix warnings and merge issues on Win64
Russell Belfer 85bd1746 2012-08-22T16:03:35 Some cleanup suggested during review This cleans up a number of items suggested during code review with @vmg, including: * renaming "outside repo" config API to `git_config_open_default` * killing the `git_config_open_global` API * removing the `git_` prefix from the static functions in fileops * removing some unnecessary functionality from the "cp" command