summaryrefslogtreecommitdiff
path: root/src/refdb_fs.c
Commit message (Collapse)AuthorAgeFilesLines
* refdb: delete a ref's reflog upon deletioncmn/reflog-del-backendCarlos Martín Nieto2015-07-121-0/+7
| | | | | | Removing a reflog upon ref deletion is something which only some backends might wish to do. Backends which are database-backed may wish to archive a reflog, log-based ones may not need to do anything.
* refdb: use the same id for old and new when renaming a referencecmn/rename-reflogCarlos Martín Nieto2015-03-081-1/+1
| | | | | | | | | When we rename a reference, we want the old and new ids to be the same one (as we did not change it). The normal code path looks up the old id from the current value of the brtanch, but by the time we look it up, it does not exist anymore and thus we write a zero id. Pass the old id explicitly instead.
* 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.
* Fix branch creation when branch name matches namespace of previously deleted ↵Jeff Hostetler2015-02-031-0/+9
| | | | branch
* reference_create: validate loose namesEdward Thomson2014-12-161-1/+1
| | | | Validate loose reference names on Win32.
* checkout: disallow bad paths on win32Edward Thomson2014-12-161-0/+10
| | | | | | | | | | | | | | | Disallow: 1. paths with trailing dot 2. paths with trailing space 3. paths with trailing colon 4. paths that are 8.3 short names of .git folders ("GIT~1") 5. paths that are reserved path names (COM1, LPT1, etc). 6. paths with reserved DOS characters (colons, asterisks, etc) These paths would (without \\?\ syntax) be elided to other paths - for example, ".git." would be written as ".git". As a result, writing these paths literally (using \\?\ syntax) makes them hard to operate with from the shell, Windows Explorer or other tools. Disallow these.
* Introduce reference transactionsCarlos Martín Nieto2014-09-301-18/+100
| | | | | | | | | A transaction allows you to lock multiple references and set up changes for them before applying the changes all at once (or as close as the backend supports). This can be used for replication purposes, or for making sure some operations run when the reference is locked and thus cannot be changed.
* refs: copy the packed refs on iterationcmn/ref-iter-concurrentCarlos Martín Nieto2014-06-021-8/+16
| | | | | This lets us work without worrying about what's happening but work on a snapshot.
* Increase use of config snapshotsrb/coverity-fixesRussell Belfer2014-05-131-10/+6
| | | | And decrease extra reload checks of config data.
* refdb: fix typo and wordingCarlos Martín Nieto2014-04-261-1/+1
|
* Add efficient git_buf join3 APIRussell Belfer2014-04-011-1/+1
| | | | | | | 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).
* reflog: remove some dead codeCarlos Martín Nieto2014-03-201-3/+0
|
* reflog: follow core.logallrefupdatesCarlos Martín Nieto2014-03-201-10/+31
| | | | | On bare by default, or when core.logallrefupdates is false, we must not write the reflog.
* reflog: handle symref chainsCarlos Martín Nieto2014-03-191-3/+33
| | | | | Given HEAD -> master -> foo, when updating foo's reflog we should also update HEAD's, as it's considered the current branch.
* reflog: handle the birth of a branchCarlos Martín Nieto2014-03-191-18/+24
| | | | | | The reflog append function was overzealous in its checking. When passed an old and new ids, it should not do any checking, but just serialize the data to a reflog entry.
* reflog: simplify the append logicCarlos Martín Nieto2014-03-191-22/+7
| | | | Remove some duplicated logic.
* refdb: don't update when there's no needCarlos Martín Nieto2014-03-191-0/+17
| | | | | If the caller wants to update a ref to point to the same target as it currently has, we should return early and avoid writing to the reflog.
* reflog: more comprehensive HEAD testsCarlos Martín Nieto2014-03-181-4/+4
| | | | | | | | | The existing ones lack checking zeroed ids when switching back from an unborn branch as well as what happens when detaching. The reflog appending function mistakenly wrote zeros when dealing with a detached HEAD. This explicitly checks for those situations and fixes them.
* refs: append to the HEAD reflog when updating the current branchCarlos Martín Nieto2014-03-171-21/+84
| | | | | | | | When we update the current branch, we must also append to HEAD's reflog to keep them in sync. This is a bit of a hack, but as git.git says, it covers 100% of default cases.
* Plug a few leaks in the testsCarlos Martín Nieto2014-03-071-1/+4
|
* refdb: catch a directory disappearingCarlos Martín Nieto2014-03-051-2/+10
| | | | | | | | If a directory disappears between the time we look up the entries of its parent and the time when we go to look at it, we should ignore the error and move forward. This fixes #2046.
* refs: conditional wording fixupsCarlos Martín Nieto2014-02-101-3/+2
| | | | | This addresses arrbee's concerns about wording in the conditional reference udpate functions.
* refs: catch cases where the ref type has changedCarlos Martín Nieto2014-02-051-3/+15
| | | | | If the type of the on-disk reference has changed, the old value comparison should fail.
* refs: placeholder conditional deleteCarlos Martín Nieto2014-02-051-22/+44
| | | | We don't actually pass the old value yet.
* refs: factor out old value comparisonCarlos Martín Nieto2014-02-051-14/+26
| | | | We will reuse this later for deletion.
* refdb: add conditional symbolic updatesCarlos Martín Nieto2014-02-051-17/+18
| | | | | Add a parameter to the backend to allow checking for the old symbolic target.
* refs: fix leak on successful updateCarlos Martín Nieto2014-02-051-7/+7
| | | | Free the old ref even on success.
* refs: return GIT_EMODIFIED if the ref target movedCarlos Martín Nieto2014-02-051-2/+4
| | | | | In case we loose the race to update the reference, return GIT_EMODIFIED to let the user distinguish it from other types of errors.
* refs: conditional ref updatesCarlos Martín Nieto2014-02-051-7/+34
| | | | Allow updating references if the old value matches the given one.
* Check for errors when dereferencing symbolic refsBen Straub2014-02-011-2/+6
|
* Reflog: correct "new" id for reattaching HEADBen Straub2014-02-011-1/+3
|
* Enhance clarityBen Straub2014-01-301-2/+4
|
* Ensure updating HEAD updates reflogBen Straub2014-01-301-3/+4
|
* Merge pull request #1920 from libgit2/cmn/ref-with-logVicent Marti2013-12-181-25/+192
|\ | | | | Reference operations with log
| * refs: expose has_log() on the backendCarlos Martín Nieto2013-12-091-0/+12
| | | | | | | | | | | | The frontend used to look at the file directly, but that's obviously not the right thing to do. Expose it on the backend and use that function instead.
| * refs: expose a way to ensure a ref has a logCarlos Martín Nieto2013-12-091-1/+20
| | | | | | | | | | | | Sometimes (e.g. stash) we want to make sure that a log will be written, even if it's not in one of the standard locations. Let's make that easier.
| * reflog: write to the reflog following git's rulesCarlos Martín Nieto2013-12-091-3/+33
| | | | | | | | | | | | git-core only writes to the reflogs of HEAD, refs/heads/ and, refs/notes/ or if there is already a reflog in place. Adjust our code to follow these semantics.
| * reflog: integrate into the ref writingCarlos Martín Nieto2013-11-231-8/+96
| | | | | | | | | | | | | | | | | | | | | | | | Whenever a reference is created or updated, we need to write to the reflog regardless of whether the user gave us a message, so we shouldn't leave that to the ref frontend, but integrate it into the backend. This also eliminates the race between ref update and writing to the reflog, as we protect the reflog with the ref lock. As an additional benefit, this reflog append on the backend happens by appending to the file instead of parsing and rewriting it.
| * refdb: add a `message` parameter for appending to the logCarlos Martín Nieto2013-11-231-14/+32
| | | | | | | | This is as yet unused.
* | Remove converting user error to GIT_EUSERRussell Belfer2013-12-111-19/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+20
|/ | | | | | | | | | | 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.
* move mode_t to filebuf_open instead of _commitEdward Thomson2013-11-041-7/+7
|
* Merge pull request #1802 from libgit2/cmn/reflog-backendBen Straub2013-10-281-0/+345
|\ | | | | Make reflog part of refdb
| * reflog: bring _append and _drop back to the frontendCarlos Martín Nieto2013-10-021-103/+0
| | | | | | | | These functions act purely on the reflog data structure.
| * reflog: move the reflog implementation into refdb_fsCarlos Martín Nieto2013-10-021-0/+448
| | | | | | | | | | | | | | | | | | | | References and their logs are logically coupled, let's make it so in the code by moving the fs-based reflog implementation to live next to the fs-based refs one. As part of the change, make the function take names rather than references, as only the names are relevant when looking up and handling reflogs.
* | Initial iconv hookup for precomposed unicodeRussell Belfer2013-10-031-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This hooks up git_path_direach and git_path_dirload so that they will take a flag indicating if directory entry names should be tested and converted from decomposed unicode to precomposed form. This code will only come into play on the Apple platform and even then, only when certain types of filesystems are used. This involved adding a flag to these functions which involved changing a lot of places in the code. This was an opportunity to do a bit of code cleanup here and there, for example, getting rid of the git_futils_cleanupdir_r function in favor of a simple flag to git_futils_rmdir_r to not remove the top level entry. That ended up adding depth tracking during rmdir_r which led to a safety check for infinite directory recursion. Yay. This hasn't actually been tested on the Mac filesystems where the issue occurs. I still need to get test environment for that.
* | Put hooks in place for precompose in dirload fnRussell Belfer2013-10-031-2/+8
|/ | | | | | This doesn't actual do string precompose but it puts the hooks in place into the iterators and the git_path_dirload function so that the actual precompose work is ready to go.
* 'del' instead of 'delete' for the poor C++ usersEdward Thomson2013-09-241-1/+1
|
* path: Make direach() return EUSER on callback errornulltoken2013-09-101-1/+1
|
* Convert sortedcache to use rwlockRussell Belfer2013-08-221-72/+59
| | | | | This is the first use we have of pthread_rwlock_t in libgit2. Hopefully it won't cause any serious portability problems.