summaryrefslogtreecommitdiff
path: root/src/submodule.c
Commit message (Collapse)AuthorAgeFilesLines
* index: make relative comparison use the checksum as wellcmn/index-checksumCarlos Martín Nieto2015-06-201-3/+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.
* Remove the callbacks struct from the remoteCarlos Martín Nieto2015-05-131-1/+1
| | | | | | | | | | | | | | Having the setting be different from calling its actions was not a great idea and made for the sake of the wrong convenience. Instead of that, accept either fetch options, push options or the callbacks when dealing with the remote. The fetch options are currently only the callbacks, but more options will be moved from setters and getters on the remote to the options. This does mean passing the same struct along the different functions but the typical use-case will only call git_remote_fetch() or git_remote_push() and so won't notice much difference.
* Implement git_submodule_set_branch.Patrick Steinhardt2015-04-121-2/+26
|
* Fix git_submodule_sync writing URL to wrong key.Patrick Steinhardt2015-03-121-2/+2
| | | | | | | | Currently git_submodule_sync writes the submodule's URL to the key 'branch.<REMOTE_NAME>.remote' while the reference implementation of `git submodule sync` writes to 'remote.<REMOTE_NAME>.url', which is the intended behavior according to git-submodule(1).
* repository: remove log message override for switching the active branchCarlos Martín Nieto2015-03-031-2/+2
| | | | | | We want to use the "checkout: moving from ..." message in order to let git know when a change of branch has happened. Make the convenience functions for this goal write this message.
* Remove the signature from ref-modifying functionsCarlos Martín Nieto2015-03-031-3/+2
| | | | | | | | | | The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
* Remove extra semicolon outside of a functionStefan Widgren2015-02-151-1/+1
| | | | | Without this change, compiling with gcc and pedantic generates warning: ISO C does not allow extra ‘;’ outside of a function.
* Add extern function to initialize submodule update options.David Calavera2015-01-071-0/+7
|
* submodule: declare vars at top of func blockEdward Thomson2015-01-061-1/+4
|
* Introduce a convenience function for submodule updatejamill/submodule_updateJameson Miller2014-12-221-10/+197
| | | | | | | | | This introduces the functionality of submodule update in 'git_submodule_do_update'. The existing 'git_submodule_update' function is renamed to 'git_submodule_update_strategy'. The 'git_submodule_update' function now refers to functionality similar to `git submodule update`, while `git_submodule_update_strategy` is used to get the configured value of submodule.<name>.update.
* submodule init should resolve relative url pathsJameson Miller2014-12-221-10/+24
| | | | | Submodule init should handle relative paths in .gitmodules files and resolve these urls when updating the git config file.
* remote: rename _load() to _lookup()cmn/remote-lookupCarlos Martín Nieto2014-11-081-2/+2
| | | | This brings it in line with the rest of the lookup functions.
* Introduce option to use relative paths for repository work directoryjamill/relative_gitlinkJameson Miller2014-09-021-33/+73
| | | | | | | Teach git_repository_init_ext to use relative paths for the gitlink to the work directory. This is used when creating a sub repository where the sub repository resides in the parent repository's .git directory.
* Be more careful with user-supplied buffersrb/fix-2333Russell Belfer2014-05-081-1/+3
| | | | | | | | | | | This adds in missing calls to `git_buf_sanitize` and fixes a number of places where `git_buf` APIs could inadvertently write NUL terminator bytes into invalid buffers. This also changes the behavior of `git_buf_sanitize` to NUL terminate a buffer if it can and of `git_buf_shorten` to do nothing if it can. Adds tests of filtering code with zeroed (i.e. unsanitized) buffer which was previously triggering a segfault.
* Attribute file cache refactorRussell Belfer2014-04-171-2/+0
| | | | | | | This is a big refactoring of the attribute file cache to be a bit simpler which in turn makes it easier to enforce a lock around any updates to the cache so that it can be used in a threaded env. Tons of changes to the attributes and ignores code.
* Add diff threading tests and attr file cache locksRussell Belfer2014-04-171-2/+1
| | | | | | This adds a basic test of doing simultaneous diffs on multiple threads and adds basic locking for the attr file cache because that was the immediate problem that arose from these tests.
* Test (and fix) the git_submodule_sync changesRussell Belfer2014-04-031-3/+12
| | | | | I wrote this stuff a while ago and forgot to write tests. Wanted to do so now to wrap up the PR and immediately found problems.
* Minor code cleanupRussell Belfer2014-04-031-78/+47
|
* git_submodule_resolve_url supports relative urlsJan Melcher2014-04-031-53/+83
| | | | | | | | | | | The base for the relative urls is determined as follows, with descending priority: - remote url of HEAD's remote tracking branch - remote "origin" - workdir This follows git.git behaviour
* Fix submodule accounting for name and path changesRussell Belfer2014-04-011-10/+40
| | | | | | | | Wrote tests that try adding, removing, and updating the name of submodules which showed a number of problems with how we account for changes when incrementally updating the submodule info. Most of these issues didn't exist before because reloading would always blow away the old submodule data.
* Minor submodule cache locking improvementsRussell Belfer2014-04-011-14/+44
| | | | | | | | | This improvement the management of the lock around submodule cache updates slightly, using the lock to make sure that foreach can safely make a snapshot of all existing submodules and making sure that git_submodule_add_setup also grabs a lock before inserting the new submodule. Cache initialization / refresh should already have been holding the lock correctly as it adds submodules.
* Reinstate efficient submodule reloadingRussell Belfer2014-04-011-123/+111
| | | | | This makes it so that git_submodule_reload_all will actually only reload changed items unless the `force` flag is used.
* Use enums instead of bools for submodule optionsRussell Belfer2014-04-011-20/+37
| | | | | | | When forcing cache flushes or reload, etc., it is easier to keep track of intent using enums instead of plain bools. Also, this fixes a bug where the cache was not being properly refreshes by a git_submodule_reload_all.
* Make submodule refresh a bit smarterRussell Belfer2014-04-011-57/+96
| | | | | | This makes submodule cache refresh actually look at the timestamps from the data sources for submodules and reload as needed if they have changed since the last refresh.
* Make a real submodule cache objectRussell Belfer2014-04-011-134/+211
| | | | | | | This takes the old submodule cache which was just a git_strmap and makes a real git_submodule_cache object that can contain other things like a lock and timestamp-ish data to control refreshing of submodule info.
* Submodule sync refactoringRussell Belfer2014-04-011-47/+41
| | | | | | Turns out there was already a helper to do what I wanted to do, so I just made it so that I could use it for sync and switched to that instead.
* Fix git_submodule_sync and add new config helperRussell Belfer2014-04-011-62/+76
| | | | | | | | | | | | This fixes `git_submodule_sync` to correctly update the remote URL of the default branch of the submodule along with the URL in the parent repository config (i.e. match core Git's behavior). Also move some useful helper logic from the submodule code into a shared config API `git_config__update_entry` that can either set or delete an entry with constraints like not overwriting or not creating a new entry. I used that helper to update a couple other places in the code.
* Add efficient git_buf join3 APIRussell Belfer2014-04-011-4/+5
| | | | | | | There are a few places where we need to join three strings to assemble a path. This adds a simple join3 function to avoid the comparatively expensive join_n (which calls strlen on each string twice).
* Add faster git_submodule__is_submodule checkRussell Belfer2014-03-311-0/+15
|
* Fix memory leak of submodule branch nameRussell Belfer2014-03-271-0/+1
|
* Fix use-after-free in submodule reloadRussell Belfer2014-03-271-3/+6
| | | | | | If the first call to release a no-longer-existent submodule freed the object, the check if a second is needed would dereference the data that was just freed.
* Fix error when submodule path and name differRussell Belfer2014-03-261-2/+5
| | | | | | | | When a submodule was inserted with a different path and name, the return value from khash greater than zero was allowed to propagate back out to the caller when it should really be zeroed. This led to a possible crash when reloading submodules if that was the first time that submodule data was loaded.
* Fix segfault if gitmodules is invalidRussell Belfer2014-03-261-2/+3
| | | | | | The reload_all call could end up dereferencing a NULL pointer if there was an error while attempting to load the submodules config data (i.e. invalid content in the gitmodules file). This fixes it.
* Fix submodule leaks and invalid referencesRussell Belfer2014-03-251-24/+89
| | | | | | | This cleans up some places I missed that could hold onto submodule references and cleans up the way in which the repository cache is both reloaded and released so that existing submodule references aren't destroyed inappropriately.
* Make submodules externally refcountedRussell Belfer2014-03-251-33/+73
| | | | | | | | `git_submodule` objects were already refcounted internally in case the submodule name was different from the path at which it was stored. This makes that refcounting externally used as well, so `git_submodule_lookup` and `git_submodule_add_setup` return an object that requires a `git_submodule_free` when done.
* MSVC is sillyCarlos Martín Nieto2014-03-101-2/+2
|
* Add git_submodule_resolve_url()Jan Melcher2014-03-101-10/+20
|
* Make submodule fetchRecurse match other optionsRussell Belfer2014-01-301-1/+6
| | | | | | This removes the fetchRecurse compiler warnings and makes the behavior match the other submodule options (i.e. the in-memory setting can be reset to the on-disk value).
* index: rename an entry's id to 'id'Carlos Martín Nieto2014-01-251-6/+6
| | | | This was not converted when we converted the rest, so do it now.
* Merge pull request #2022 from KTXSoftware/developmentRussell Belfer2014-01-031-0/+20
|\ | | | | submodule branch option + little VS2013 fix
| * Read the submodule branch option from Git 1.8.2.Robert Konrad2014-01-021-0/+20
| |
* | Fix warnings with submodule changesRussell Belfer2014-01-021-3/+3
|/
* Default value for fetchRecurseSubmodules should be yesLinquize2013-12-311-0/+1
|
* Accept 'submodule.*.fetchRecurseSubmodules' config 'on-demand' valueLinquize2013-12-311-11/+38
|
* Fix up some valgrind leaks and warningsRussell Belfer2013-12-111-1/+1
|
* One more rename/cleanup for callback err functionsRussell Belfer2013-12-111-1/+1
|
* Some callback error check style cleanupsRussell Belfer2013-12-111-1/+3
| | | | I find this easier to read...
* Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-39/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Improve GIT_EUSER handlingRussell Belfer2013-12-111-54/+68
| | | | | | | | | | | This adds giterr_user_cancel to return GIT_EUSER and clear any error message that is sitting around. As a result of using that in places, we need to be more thorough with capturing errors that happen inside a callback when used internally. To help with that, this also adds giterr_capture and giterr_restore so that when we internally use a foreach-type function that clears errors and converts them to GIT_EUSER, it is easier to restore not just the return value, but the actual error message text.
* Add config read fns with controlled error behaviorRussell Belfer2013-12-111-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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.