tests/refs/reflog/reflog.c


Log

Author Commit Date CI Message
Patrick Steinhardt 7968e90f 2019-10-18T12:33:07 refdb_fs: properly parse corrupted reflogs In previous versions, libgit2 could be coerced into writing reflog messages with embedded newlines into the reflog by using `git_stash_save` with a message containing newlines. While the root cause is fixed now, it was noticed that upstream git is in fact able to read such corrupted reflog messages just fine. Make the reflog parser more lenient in order to just skip over malformatted reflog lines to bring us in line with git. This requires us to change an existing test that verified that we do indeed _fail_ to parse such logs.
Patrick Steinhardt d8233feb 2019-10-18T09:24:14 reflog: allow adding entries with newlines in their message Currently, the reflog disallows any entries that have a message with newlines, as that would effectively break the reflog format, which may contain a single line per entry, only. Upstream git behaves a bit differently, though, especially when considering stashes: instead of rejecting any reflog entry with newlines, git will simply replace newlines with spaces. E.g. executing 'git stash push -m "foo\nbar"' will create a reflog entry with "foo bar" as entry message. This commit adjusts our own logic to stop rejecting commit messages with newlines. Previously, this logic was part of `git_reflog_append`, only. There is a second place though where we add reflog entries, which is the serialization code in the filesystem refdb. As it didn't contain any sanity checks whatsoever, the refdb would have been perfectly happy to write malformatted reflog entries to the disk. This is being fixed with the same logic as for the reflog itself.
Patrick Steinhardt e54343a4 2019-06-29T09:17:32 fileops: rename to "futils.h" to match function signatures Our file utils functions all have a "futils" prefix, e.g. `git_futils_touch`. One would thus naturally guess that their definitions and implementation would live in files "futils.h" and "futils.c", respectively, but in fact they live in "fileops.h". Rename the files to match expectations.
Edward Thomson f673e232 2018-12-27T13:47:34 git_error: use new names in internal APIs and usage Move to the `git_error` name in the internal API for error-related functions.
Etienne Samson e226ad8f 2018-11-17T17:55:10 refs: add support for core.logAllRefUpdates=always Since we were not expecting this config entry to contain a string, we would fail as soon as its (cached) value would be accessed. Hence, provide some constants for the 4 states we use, and account for "always" when we decide to reflog changes.
Patrick Steinhardt 9994cd3f 2018-06-25T11:56:52 treewide: remove use of C++ style comments C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
Patrick Steinhardt ecf4f33a 2018-02-08T11:14:48 Convert usage of `git_buf_free` to new `git_buf_dispose`
Etienne Samson 53672128 2017-07-21T17:35:30 tests: gather the reflog entry content tests
Richard Ipsum 397cf1a1 2017-02-28T22:22:02 Add test for inclusion of (merge) in reflog This test ensures that the string '(merge)' is included in the reflog when a merge commit is made.
Edward Thomson 8f0d5cde 2016-12-29T12:55:49 tests: update error message checking
Edward Thomson 0a700ee3 2015-11-03T17:34:54 reflog: error when a directory is at reflog path When a non-empty directory exists and prevents the creation of a reflog, provide a more informative error message.
Edward Thomson 2d556f31 2015-11-03T14:48:31 reflog: test reflog is deleted when ref is deleted
Stjepan Rajko 335c9e2f 2015-10-26T15:33:00 Prevent segfault when parsing a reflog with oid parse error Using calloc instead of malloc because the parse error will lead to an immediate free of committer (and its properties, which can segfault on free if undefined - test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_returns_error segfaulted before the fix). #3458
Carlos Martín Nieto 659cf202 2015-01-07T12:23:05 Remove the signature from ref-modifying functions 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.
Carlos Martín Nieto 83504371 2014-03-19T22:27:23 reflog: follow core.logallrefupdates On bare by default, or when core.logallrefupdates is false, we must not write the reflog.
Carlos Martín Nieto 1afe1400 2014-03-18T22:16:58 refdb: don't update when there's no need 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.
Carlos Martín Nieto 4b7e1b9e 2014-01-15T13:19:48 refs: append to the HEAD reflog when updating the current branch 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.
Ben Straub ccf6ce5c 2014-01-28T11:30:36 Ensure renaming a reference updates the reflog
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.
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 6f13a305 2013-11-17T23:26:49 reflog: write to the reflog following git's rules 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.
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 13c9e44a 2013-11-14T19:41:09 reflog: remove git_reflog_append_to() This was a convenience method for the refs front-end to do the reflog writing. This is now done in the backend and it has no more reason for being.
Ben Straub 17820381 2013-11-14T14:05:52 Rename tests-clar to tests