src/refs.c


Log

Author Commit Date CI Message
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.
Brodie Rao 2ad45213 2014-01-12T23:31:57 refs: handle NULL pointers passed to git_reference_iterator_free() Signed-off-by: Brodie Rao <brodie@sf.io>
Arthur Schreiber 0b795178 2014-01-02T16:58:13 Allow the log message to be NULL.
Arthur Schreiber e5994eb0 2014-01-02T16:56:09 Add missing `git_reference_symbolic_create_with_log`. It's exported in the headers, but the implementation was missing.
Vicent Marti 4e1f517c 2013-12-18T09:33:45 Merge pull request #1920 from libgit2/cmn/ref-with-log Reference operations with log
Russell Belfer 26c1cb91 2013-12-09T09:44:03 One more rename/cleanup for callback err functions
Russell Belfer f10d7a36 2013-12-06T15:53:26 Further callback error check style fixes Okay, I've decided I like the readability of this style much better so I used it everywhere.
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 dab89f9b 2013-12-04T21:22:57 Further EUSER and error propagation fixes This continues auditing all the places where GIT_EUSER is being returned and making sure to clear any existing error using the new giterr_user_cancel helper. As a result, places that relied on intercepting GIT_EUSER but having the old error preserved also needed to be cleaned up to correctly stash and then retrieve the actual error. Additionally, as I encountered places where error codes were not being propagated correctly, I tried to fix them up. A number of those fixes are included in the this commit as well.
Russell Belfer 96869a4e 2013-12-03T16:45:39 Improve GIT_EUSER handling 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.
Carlos Martín Nieto f2105129 2013-11-23T14:39:53 refs: expose has_log() on the backend 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.
Carlos Martín Nieto 8d5ec910 2013-11-23T14:13:01 refs: expose a way to ensure a ref has a log 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.
Carlos Martín Nieto a57dd3b7 2013-11-13T18:15:20 reflog: integrate into the ref writing 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.
Carlos Martín Nieto 110df893 2013-11-13T13:36:37 refdb: add a `message` parameter for appending to the log This is as yet unused.
Carlos Martín Nieto a6b50808 2013-10-30T17:24:36 refs: adjust to the new reflog API
nulltoken ca84e058 2013-05-14T16:40:09 refs: Introduce git_reference_symbolic_set_target_with_log()
nulltoken 14ab0e10 2013-05-14T16:07:33 refs: Introduce git_reference_set_target_with_log()
nulltoken 56ad3782 2013-05-13T17:44:39 refs: Introduce git_reference_symbolic_create_with_log()
nulltoken bba25f39 2013-05-13T16:21:09 refs: Introduce git_reference_create_with_log()
nulltoken 92f95a17 2013-05-12T14:16:13 refs: Centralize reference creation logic
Vicent Marti 0bfa7323 2013-11-01T17:07:44 iconv: Do not fake an API when iconv is not available
Ben Straub 8f4a8b09 2013-10-28T06:20:28 Merge pull request #1802 from libgit2/cmn/reflog-backend Make reflog part of refdb
Russell Belfer 74353137 2013-10-09T11:57:03 After iconv init reset ref normalize error The iconv init was accidentally clearing the default error state during reference normalization. This resets so that normalization errors will be detected correctly.
Russell Belfer 92dac975 2013-10-08T16:35:57 Make reference lookups apply precomposeunicode Before these changes, looking up a reference would return the same precomposed or decomposed form of the reference name that was used to look it up, so on MacOS which ignores the difference between the two, a single reference could be looked up either way and git_reference_name would return the form of the name that was used to look it up! This change makes lookup always return the precomposed name if core.precomposeunicode is set regardless of which version was used to look it up. The reference iterator was already returning the precomposed form from earlier work. This also updates the CMakeLists.txt rules for enabling iconv usage because the clar tests for this code were actually not being activated properly with the old version. Finally, this moves git_repository_reset_filesystem from include/ git2/repository.h to include/git2/sys/repository.h since it is not really a function that normal library users should have to think about very often.
Carlos Martín Nieto b976f3c2 2013-08-19T13:01:49 reflog: move the reflog implementation into refdb_fs 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.
Vicent Martí dbecec37 2013-08-28T09:38:14 Merge pull request #1805 from libgit2/threading-packed-load Thread safety for the refdb_fs
Nikolai Vladimirov 504850cd 2013-08-25T15:59:50 refs: add git_reference_is_tag
Russell Belfer 24c71f14 2013-08-21T14:10:27 Add internal ref set_name fn instead of realloc The refdb_fs implementation calls realloc directly on a reference object when it wants to rename it. It is not a public object, so this doesn't mess with the immutability of references, but it does assume certain constraints on the reference representation. This commit wraps that assumption in an isolated API to isolate it.
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.
Vicent Martí 947fad4f 2013-06-03T09:28:58 Merge pull request #1624 from libgit2/vmg/full-ref-iterator Breaking RefDB changes
Vicent Martí 9afc5971 2013-05-31T03:09:38 Merge pull request #1559 from carlosmn/ref-shorthand Introduce git_reference_shorthand
Vicent Marti 979f75d8 2013-05-30T17:19:43 Refcounting
Vicent Marti 4e6e2ff2 2013-05-30T03:47:10 ...Aaaand this works
Vicent Marti ec24e542 2013-05-29T22:47:37 What are the chances, really
Vicent Marti 56960b83 2013-05-28T20:47:55 Liike this
Edward Thomson b6cc559a 2013-05-11T02:42:49 Merge pull request #1385 from carlosmn/refs-iter Introduce a refs iterator
Carlos Martín Nieto c58cac12 2013-05-04T18:06:14 Introduce a glob-filtering iterator If the backend doesn't provide support for it, the matching is done in refdb on top of a normal 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.
Carlos Martín Nieto 95727245 2013-05-04T16:03:17 refs: implement _foreach with the iterator
Carlos Martín Nieto 4def7035 2013-03-02T19:31:03 refs: introduce an iterator This allows us to get a list of reference names in a loop instead of callbacks.
Carlos Martín Nieto 4f2eb2b7 2013-05-08T02:28:47 Introduce git_reference_shorthand Generate a shorthand name out of the full refname.
Carlos Martín Nieto 98d633cc 2013-05-07T23:28:21 Expose git_reference_dwim Extract this function out of the rev-parse code to be able to DWIM a reference instead of its target.
Russell Belfer 41e93563 2013-05-01T15:08:12 Error messages for a couple other boundary conditions
Vicent Martí cd2ed9f0 2013-04-30T04:02:52 Merge pull request #1518 from arrbee/export-oid-comparison Remove most inlines from the public API
Russell Belfer b7f167da 2013-04-29T13:52:12 Make git_oid_cmp public and add git_oid__cmp
Carlos Martín Nieto 528a4e24 2013-04-28T14:16:45 Parse shorthand refspecs as valid Relax the ONELEVEL ref naming rules so the refspec parsing code can ask for 'master' to be considered valid.
Russell Belfer 21ca0451 2013-04-21T12:52:17 Move git_reference__alloc to include/git2/sys Create a new include/git2/sys/refs.h and move the reference alloc functions there. Also fix some documentation issues and some minor code cleanups.
Russell Belfer 4dcd8780 2013-04-19T17:17:44 Move refdb_backend to include/git2/sys This moves most of the refdb stuff over to the include/git2/sys directory, with some minor shifts in function organization. While I was making the necessary updates, I also removed the trailing whitespace in a few files that I modified just because I was there and it was bugging me.
Edward Thomson 4e4eab52 2013-04-19T18:19:53 alloc doesn't take a refdb; git_refdb_free nicely in the tests
Vicent Marti fedd0f9e 2013-04-17T23:29:34 refs: Do not union the peel
Vicent Marti 13421eee 2013-04-17T22:32:39 refs: Check alloc is cleaner
Vicent Marti 3be933b1 2013-04-17T17:33:51 refs: Add `git_referene_target_peel`
Vicent Marti 575a54db 2013-04-10T16:55:29 object: Export git_object_dup
Arkadiy Shapkin 10c06114 2013-03-17T04:46:46 Several warnings detected by static code analyzer fixed Implicit type conversion argument of function to size_t type Suspicious sequence of types castings: size_t -> int -> size_t Consider reviewing the expression of the 'A = B == C' kind. The expression is calculated as following: 'A = (B == C)' Unsigned type is never < 0
Russell Belfer 55e0f53d 2013-03-14T15:09:29 Fix various build warnings This fixes various build warnings on Mac and Windows (64-bit).
Edward Thomson d00d5464 2013-03-01T15:37:33 immutable references and a pluggable ref database
Carlos Martín Nieto bb45c57f 2013-03-07T16:38:44 refs: explicitly catch leading slashes It's somewhat common to try to write "/refs/tags/something". There is no easy way to catch it during the main body of the function, as there is no way to distinguish whether it's a leading slash or a double slash somewhere in the middle. Catch this at the beginning so we don't trigger the assert in is_all_caps_and_underscore().
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.
nulltoken c1b5e8c4 2013-02-15T11:35:33 branch: Make git_branch_remote_name() cope with orphaned heads
Russell Belfer 56543a60 2013-02-15T16:02:45 Clear up warnings from cppcheck The cppcheck static analyzer generates warnings for a bunch of places in the libgit2 code base. All the ones fixed in this commit are actually false positives, but I've reorganized the code to hopefully make it easier for static analysis tools to correctly understand the structure. I wouldn't do this if I felt like it was making the code harder to read or worse for humans, but in this case, these fixes don't seem too bad and will hopefully make it easier for better analysis tools to get at any real issues.
nulltoken 2bca5b67 2013-02-07T23:44:18 remote: Introduce git_remote_is_valid_name() Fix libgit2/libgit2sharp#318
nulltoken 4d811c3b 2013-02-07T23:40:10 refs: No component of a refname can end with '.lock'
Carlos Martín Nieto e5ef0f18 2013-01-31T20:23:30 refs: handle ALLOW_ONELEVEL normalization with leading slash A leading slash confuses the name normalization code when the flags include ALLOW_ONELEVEL. Catch this case in particular to avoid triggering an assertion in the uppercase check which expects us not to pass it an empty string. The existing tests don't catch this as they simply use the NORMAL flag. This fixes #1300.
Scott J. Goldman cb35094b 2013-01-22T15:49:51 Allow peeled references without trailing newline at end of file Also ammends one of the tag tests to make sure it's working.
Scott J. Goldman 2a707d0e 2013-01-22T14:08:50 Revert "Handle packed peeled objects without trailing newlines" This reverts commit 28b1cdf3a1bdcd37cf9d550c92b8c19b1782ea6b. //cc #1262 #1267
Scott J. Goldman 28b1cdf3 2013-01-21T14:45:43 Handle packed peeled objects without trailing newlines Fixes #1262
nulltoken bf031581 2013-01-14T14:22:11 branch: Introduce git_branch_tracking_name()
Edward Thomson 359fc2d2 2013-01-08T17:07:25 update copyrights
Scott J. Goldman ef82ff30 2013-01-05T00:46:39 Handle packed refs with no trailing newline I saw a repo in the wild today which had a master branch ref which was packed, but had no trailing newline. Git handled it fine, but libgit2 choked on it. Fix seems simple enough. If we don't see a newline, assume the end of the buffer is the end of the ref line.
Russell Belfer 3865f7f6 2012-12-27T23:23:12 Invalid ref name normalization leaked memory When normalizing a reference name, if there is an error because the name is invalid, then the memory allocated for storing the name could be leaked if the caller was not careful and assumed that the error return code meant that no allocation had occurred. This fixes that by explicitly deallocating the reference name buffer if there is an error in normalizing the name.
Rick Bradley ed4e887d 2012-12-18T16:09:57 Also, whitespace. I was totally flaunting @ben's 3-space tab advice.
Rick Bradley 33f169e2 2012-12-18T16:07:18 Improve comment text This looked wrong to me. I *think* this is more appropriate commentary.
Ben Straub 28abb187 2012-12-14T14:16:10 Stop returning incorrect error message
Ben Straub b524fe1a 2012-12-14T08:35:59 Local Only ignore ENOTFOUNDs when adding corrupted refs
nulltoken 80d9d1df 2012-11-12T15:42:15 refs: Deploy EINVALIDSPEC usage
nulltoken 83458bb7 2012-11-12T14:06:13 refs: Fix error clearing
Russell Belfer d9023dbe 2012-11-20T17:06:54 API updates for tag.h
Russell Belfer eecc8050 2012-11-20T14:03:05 Update callback fn ptr for git_reference_foreach As part of API review, use a typedef for the callback fn ptr.
Ben Straub 2508cc66 2012-11-18T21:38:08 Rename ref and reflog apis for consistency
Russell Belfer 331e7de9 2012-10-24T17:32:50 Extensions to rmdir and mkdir utilities * Rework GIT_DIRREMOVAL values to GIT_RMDIR flags, allowing combinations of flags * Add GIT_RMDIR_EMPTY_PARENTS flag to remove parent dirs that are left empty after removal * Add GIT_MKDIR_VERIFY_DIR to give an error if item is a file, not a dir (previously an EEXISTS error was ignored, even for files) and enable this flag for git_futils_mkpath2file call * Improve accuracy of error messages from git_futils_mkdir
Russell Belfer b90500f0 2012-11-01T14:08:30 Improve docs, examples, warnings This improves docs in some of the public header files, cleans up and improves some of the example code, and fixes a couple of pedantic warnings in places.
Russell Belfer 744cc03e 2012-10-30T12:10:36 Add git_config_refresh() API to reload config This adds a new API that allows users to reload the config if the file has changed on disk. A new config callback function to refresh the config was added. The modified time and file size are used to test if the file needs to be reloaded (and are now stored in the disk backend object). In writing tests, just using mtime was a problem / race, so I wanted to check file size as well. To support that, I extended `git_futils_readbuffer_updated` to optionally check file size in addition to mtime, and I added a new function `git_filebuf_stats` to fetch the mtime and size for an open filebuf (so that the config could be easily refreshed after a write). Lastly, I moved some similar file checking code for attributes into filebuf. It is still only being used for attrs, but it seems potentially reusable, so I thought I'd move it over.
Russell Belfer 4c47a8bc 2012-10-17T14:14:51 Merge pull request #968 from arrbee/diff-support-typechange Support TYPECHANGE records in status and adjust checkout accordingly
Carlos Martín Nieto 7ae5ab56 2012-10-15T16:35:10 Fix leak in the tests Also introduce the slective ref trimming promised but also missed in the previous commit.
Carlos Martín Nieto 47f44b6e 2012-10-15T13:51:25 refs: loosen the OID parsing We used to require loose references to contain only an OID (possibly after trimming the string). This is however not enough for letting us lookup FETCH_HEAD, which can have a lot of content after the initial OID. Change the parsing rules so that a loose refernce must e at least 40 bytes long and the 41st (if it's there) must be accepted by isspace(3). This makes the trim unnecessary, so only do it for symrefs. This fixes #977.
nulltoken 3548fcf5 2012-10-11T14:00:26 refs: propagate EEXISTS upon renaming
Russell Belfer 0d64bef9 2012-10-05T15:56:57 Add complex checkout test and then fix checkout This started as a complex new test for checkout going through the "typechanges" test repository, but that revealed numerous issues with checkout, including: * complete failure with submodules * failure to create blobs with exec bits * problems when replacing a tree with a blob because the tree "example/" sorts after the blob "example" so the delete was being processed after the single file blob was created This fixes most of those problems and includes a number of other minor changes that made it easier to do that, including improving the TYPECHANGE support in diff/status, etc.
nulltoken 4ba23be1 2012-10-06T12:20:13 branch: deploy git_branch_is_head()
nulltoken f3cc7834 2012-09-22T12:51:34 refs: deploy git_repository_set_head() usage
nulltoken 74a24005 2012-09-21T10:28:20 refs: use constants for well-known names
Vicent Martí 8bc5cacc 2012-10-01T13:57:32 Merge pull request #961 from arrbee/win64-cleanups Win64 cleanups
Russell Belfer 7c411fd9 2012-10-01T12:32:55 Fix up more Win64 compile warnings
Carlos Martín Nieto c1281493 2012-09-30T11:37:53 refs: propagate EEXISTS Indicate whether the error comes from the ref already existing or elsewhere. We always perform the check and this lets the user write more concise code.
nulltoken 0adfa20a 2012-09-11T11:42:13 refspec: introduce git_refspec__parse()
nulltoken 77e06d7e 2012-09-17T07:11:32 refs: introduce git_reference_is_valid_name()
nulltoken c030ada7 2012-09-11T12:06:57 refs: make git_reference_normalize_name() accept refspec pattern
nulltoken c2948c77 2012-09-14T21:36:49 refs: prevent locked refs from being enumerated Fix #936
nulltoken 31665948 2012-08-24T21:30:45 refs: introduce git_reference_peel() Fix #530
Russell Belfer f335ecd6 2012-08-30T14:24:16 Diff iterators This refactors the diff output code so that an iterator object can be used to traverse and generate the diffs, instead of just the `foreach()` style with callbacks. The code has been rearranged so that the two styles can still share most functions. This also replaces `GIT_REVWALKOVER` with `GIT_ITEROVER` and uses that as a common error code for marking the end of iteration when using a iterator style of object.
Michael Schubert 0844ed06 2012-08-28T20:15:21 Fix parentheses warning