mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
CanonPath: Add rel_c_str()
Defensively because isRoot() is also defensive.
This commit is contained in:
parent
274d887fee
commit
15f7bdaf27
2 changed files with 8 additions and 2 deletions
|
@ -674,8 +674,7 @@ struct GitExportIgnoreInputAccessor : CachingFilteringInputAccessor {
|
||||||
|
|
||||||
bool gitAttrGet(const CanonPath & path, const char * attrName, const char * & valueOut)
|
bool gitAttrGet(const CanonPath & path, const char * attrName, const char * & valueOut)
|
||||||
{
|
{
|
||||||
std::string pathStr {path.rel()};
|
const char * pathCStr = path.rel_c_str();
|
||||||
const char * pathCStr = pathStr.c_str();
|
|
||||||
|
|
||||||
if (rev) {
|
if (rev) {
|
||||||
git_attr_options opts = GIT_ATTR_OPTIONS_INIT;
|
git_attr_options opts = GIT_ATTR_OPTIONS_INIT;
|
||||||
|
|
|
@ -88,6 +88,13 @@ public:
|
||||||
std::string_view rel() const
|
std::string_view rel() const
|
||||||
{ return ((std::string_view) path).substr(1); }
|
{ return ((std::string_view) path).substr(1); }
|
||||||
|
|
||||||
|
const char * rel_c_str() const
|
||||||
|
{
|
||||||
|
auto cs = path.c_str();
|
||||||
|
assert(cs[0]); // for safety if invariant is broken
|
||||||
|
return &cs[1];
|
||||||
|
}
|
||||||
|
|
||||||
struct Iterator
|
struct Iterator
|
||||||
{
|
{
|
||||||
std::string_view remaining;
|
std::string_view remaining;
|
||||||
|
|
Loading…
Reference in a new issue