diff options
Diffstat (limited to 'bpkg/fetch.hxx')
-rw-r--r-- | bpkg/fetch.hxx | 73 |
1 files changed, 69 insertions, 4 deletions
diff --git a/bpkg/fetch.hxx b/bpkg/fetch.hxx index d57dcf3..daf1ffe 100644 --- a/bpkg/fetch.hxx +++ b/bpkg/fetch.hxx @@ -102,18 +102,29 @@ namespace bpkg const repository_location&, const dir_path&); + + // Verify that the symlinks target paths in the working tree are valid, + // relative, and none of them refer outside the repository directory. + // + void + git_verify_symlinks (const common_options&, const dir_path&); + // Fix up or revert the fixes (including in submodules, recursively) in a // working tree previously checked out by git_checkout() or // git_checkout_submodules(). Return true if any changes have been made to - // the filesystem. + // the filesystem. On error issue diagnostics and return nullopt in the + // ignore errors mode and throw failed otherwise. // // Noop on POSIX. On Windows it may replace git's filesystem-agnostic // symlinks with hardlinks for the file targets and junctions for the // directory targets. Note that it still makes sure the working tree is // being treated by git as "clean" despite the changes. // - bool - git_fixup_worktree (const common_options&, const dir_path&, bool revert); + optional<bool> + git_fixup_worktree (const common_options&, + const dir_path&, + bool revert, + bool ignore_errors = false); // Low-level fetch API (fetch.cxx). // @@ -127,11 +138,65 @@ namespace bpkg // option for details). // process - start_fetch (const common_options& o, + start_fetch (const common_options&, const string& url, const path& out = {}, const string& user_agent = {}, const butl::url& proxy = {}); + + // Similar to the above but can only be used for fetching HTTP(S) URL to a + // file. Additionally return the HTTP status code, if the underlying fetch + // program provides an easy way to retrieve it, and 0 otherwise. + // + pair<process, uint16_t> + start_fetch_http (const common_options&, + const string& url, + const path& out, + const string& user_agent = {}, + const butl::url& proxy = {}); + + // As above but fetches HTTP(S) URL to stdout, which can be read by the + // caller from the specified stream. On HTTP errors (e.g., 404) this stream + // may contain the error description returned by the server and the process + // may exit with 0 code. + // + // Fetch process stderr redirect mode. + // + enum class stderr_mode + { + // Don't redirect stderr. + // + pass, + + // If the underlying fetch program provides an easy way to retrieve the + // HTTP status code, then redirect the fetch process stderr to a pipe, so + // that depending on the returned status code the caller can either drop + // or dump the fetch process diagnostics. Otherwise, may still redirect + // stderr for some implementation-specific reasons (to prevent the + // underlying fetch program from interacting with the user, etc). The + // caller can detect whether stderr is redirected or not by checking + // process::in_efd. + // + redirect, + + // As above but if stderr is redirected, minimize the amount of + // diagnostics printed by the fetch program by only printing errors. That + // allows the caller to read stdout and stderr streams sequentially in the + // blocking mode by assuming that the diagnostics always fits into the + // pipe buffer. If stderr is not redirected, then ignore this mode in + // favor of the more informative diagnostics. + // + redirect_quiet + }; + + pair<process, uint16_t> + start_fetch_http (const common_options&, + const string& url, + ifdstream& out, + fdstream_mode out_mode, + stderr_mode, + const string& user_agent = {}, + const butl::url& proxy = {}); } #endif // BPKG_FETCH_HXX |