navid/veins / 96f30f16c4319a85e8ccc3c97bc84950cf53e5f9cf7db59977076b5c1f3796cf / xveins/src/worktree/pathspec.h

pathspec.h

← xveins/src/worktree · 707 bytes · raw · download

#pragma once

#include "core/common.h"

#include <optional>
#include <string>

namespace vn {

// Current directory relative to the repository root, or nullopt when the
// process is outside the repository.
std::optional<std::string> cwd_relative(const fs::path& root);

// Normalize one command-line operand into a repository-relative path. Relative
// operands are resolved against `cwd_rel`; absolute operands must live inside
// `root`. Glob metacharacters are preserved.
std::optional<std::string> pathspec_normalize(const fs::path& root, std::string_view cwd_rel,
                                              std::string_view arg);

bool pathspec_has_glob(std::string_view value);

} // namespace vn