tests/index/filemodes.c


Log

Author Commit Date CI Message
Edward Thomson f0e693b1 2021-09-07T17:53:49 str: introduce `git_str` for internal, `git_buf` is external libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
Edward Thomson cad7a1ba 2020-06-05T08:42:38 clar: include the function name
Edward Thomson 6574cd00 2019-06-08T19:25:36 index: rename `frombuffer` to `from_buffer` The majority of functions are named `from_something` (with an underscore) instead of `fromsomething`. Update the index functions for consistency with the rest of the library.
Edward Thomson 168fe39b 2018-11-28T14:26:57 object_type: use new enumeration names Use the new object_type enumeration names within the codebase.
Edward Thomson 18e71e6d 2018-11-28T13:31:06 index: use new enum and structure names Use the new-style index names throughout our own codebase.
Patrick Steinhardt ecf4f33a 2018-02-08T11:14:48 Convert usage of `git_buf_free` to new `git_buf_dispose`
Patrick Steinhardt cabe16df 2018-02-19T10:18:59 tests: index::filemodes: fix use of uninitialized memory The new index entry structure was not being initialized to all-zeroes. As that structure is used to add a new entry to the current index, and the hashing algorithm of the index making use of the uninitialized flags to calculate the state, we might miscompute the hash of the entry and add it at the wrong position. Later lookups would then fail. Initialize the structure with `memset` to fix the test breaking on some platforms.
Edward Thomson 5f774dbf 2018-02-11T10:14:13 git_index_add_frombuffer: only accept files/links Ensure that the buffer given to `git_index_add_frombuffer` represents a regular blob, an executable blob, or a link. Explicitly reject commit entries (submodules) - it makes little sense to allow users to add a submodule from a string; there's no possible path to success.
Edward Thomson 4afe536b 2016-02-28T16:02:49 tests: use legitimate object ids Use legitimate (existing) object IDs in tests so that we have the ability to turn on strict object validation when running tests.
Carlos Martín Nieto c232d6c3 2015-08-14T21:06:51 index: add tests around case switching We were missing tests for switching the case-sensitivity of an index in-memory and then looking up entries in it.
John Fultz d3282680 2015-04-20T23:41:04 Fix index-adding functions to know when to trust filemodes. The idea...sometimes, a filemode is user-specified via an explicit git_index_entry. In this case, believe the user, always. Sometimes, it is instead built up by statting the file system. In those cases, go with the existing logic we have to determine whether the file system supports all filemodes and symlinks, and make the best guess. On file systems which have full filemode and symlink support, this commit should make no difference. On others (most notably Windows), this will fix problems things like: * git_index_add and git_index_add_frombuffer() should be believed. * As a consequence, git_checkout_tree should make the filemodes in the index match the ones in the tree. * And diffs with GIT_DIFF_UPDATE_INDEX don't write the wrong filemodes. * And merges, and probably other downstream stuff now fixed, too. This makes my previous changes to checkout.c unnecessary, so they are now reverted. Also, added a test for index_entry permissions from git_index_add and git_index_add_frombuffer, both of which failed before these changes.
Carlos Martín Nieto 69a1a691 2014-06-03T16:18:08 Plug a leak in the tests
Carlos Martín Nieto 052a2ffd 2014-05-22T16:01:02 index: check for valid filemodes on add
Ben Straub 17820381 2013-11-14T14:05:52 Rename tests-clar to tests