Line data Source code
1 : /*! 2 : * \file esys/repo/git/cloneoptions.h 3 : * \brief Options for GitBase::clone (fetch shape; tip name is separate ``rev``) 4 : * 5 : * \cond 6 : * __legal_b__ 7 : * 8 : * Copyright (c) 2026 Michel Gillet 9 : * Distributed under the MIT License. 10 : * (See accompanying file LICENSE.txt or 11 : * copy at https://opensource.org/licenses/MIT) 12 : * 13 : * __legal_e__ 14 : * \endcond 15 : * 16 : */ 17 : 18 : #pragma once 19 : 20 : #include "esys/repo/esysrepo_defs.h" 21 : 22 : //<swig_inc/> 23 : 24 : namespace esys::repo::git 25 : { 26 : 27 : /*! \class CloneOptions esys/repo/git/cloneoptions.h "esys/repo/git/cloneoptions.h" 28 : * \brief How to fetch / check out during clone (``rev`` stays a separate clone argument) 29 : * 30 : * Default-constructed options match the **legacy** path: clone the remote default tip 31 : * only (``rev`` ignored). Low-level ``GitBase::clone(url, path, rev)`` without an 32 : * explicit ``CloneOptions`` uses that default. 33 : * 34 : * ``SyncRepos`` applies the **product** default tip-at-clone 35 : * (``checkout_rev`` + ``single_branch``) per ADR-0030, with automatic legacy when 36 : * the revision is a raw commit SHA or tip clone fails. Override globally with 37 : * ``ESYSREPO_CLONE_CHECKOUT_REV=tip|default``. 38 : */ 39 210 : struct ESYSREPO_API CloneOptions 40 : { 41 : //! Check out the tip named by ``rev`` during clone (``git clone --branch``). 42 : /*! 43 : * When false, backends ignore ``rev`` and clone the remote default tip; 44 : * callers that need another tip fetch/checkout afterward (legacy SyncRepo path). 45 : * When true, ``rev`` must be a **branch or tag name** (not a raw commit SHA). 46 : * SyncRepos skips tip-at-clone for full 40-char hex SHAs (ADR-0030). 47 : */ 48 : bool checkout_rev = false; 49 : 50 : //! Fetch only the tip named by ``rev`` (git ``--single-branch``). 51 : /*! 52 : * Only meaningful when ``checkout_rev`` is true and ``rev`` is non-empty. 53 : * When ``rev`` is empty, backends may still limit to the remote default tip 54 : * (gitcmdline) or ignore this flag (libgit2). Prefer a non-empty ``rev``. 55 : */ 56 : bool single_branch = false; 57 : }; 58 : 59 : } // namespace esys::repo::git