File indexing completed on 2024-04-28 16:01:31
0001 /****************************************************************************** 0002 * This file is part of the libqgit2 library 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public 0015 * License along with this library; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0017 */ 0018 0019 #ifndef LIBQGIT2_CHECKOUTOPTIONS_H 0020 #define LIBQGIT2_CHECKOUTOPTIONS_H 0021 0022 #include "git2.h" 0023 #include <QSharedPointer> 0024 #include "libqgit2_export.h" 0025 0026 namespace LibQGit2 0027 { 0028 /** 0029 * Options that specify how a checkout operation is performed. 0030 * 0031 * @ingroup LibQGit2 0032 * @{ 0033 */ 0034 class LIBQGIT2_EXPORT CheckoutOptions 0035 { 0036 public: 0037 /** 0038 * A checkout strategy. 0039 */ 0040 enum Strategy { 0041 None, ///< No actual updates 0042 Safe, ///< Allow safe updates that cannot overwrite uncommitted data 0043 Force ///< Allow all updates to force working directory to look like index 0044 }; 0045 0046 /** 0047 * Options specifying details about how a checkout is performed. 0048 */ 0049 enum Flag { 0050 AllowConflicts = 1u << 0, ///< Allow checkout to make safe updates even if conflicts are found 0051 RemoveUntracked = 1u << 1, ///< Remove untracked files not in index (that are not ignored) 0052 RemoveIgnored = 1u << 2, ///< Remove ignored files not in index 0053 UpdateOnly = 1u << 3, ///< Only update existing files, don't create new ones 0054 DontUpdateIndex = 1u << 4, ///< Normally checkout updates index entries as it goes; this stops that 0055 NoRefresh = 1u << 5, ///< Don't refresh index/config/etc before doing checkout 0056 SkipUnmerged = 1u << 6, ///< Allow checkout to skip unmerged files 0057 UnmergedUseOurs = 1u << 7, ///< For unmerged files, checkout stage 2 from index 0058 UnmergedUseTheirs = 1u << 8, ///< For unmerged files, checkout stage 3 from index 0059 RecreateMissing = 1u << 9 ///< Allow checkout to recreate missing files 0060 }; 0061 Q_DECLARE_FLAGS(Flags, Flag) 0062 0063 /** 0064 * Constructs a new CheckoutOptions. 0065 * @param strategy The checkout strategy to use. 0066 * @param flags Details about the checkout process. 0067 */ 0068 CheckoutOptions(Strategy strategy = None, Flags flags = Flags()); 0069 0070 /** 0071 * Set the target directory where the files will be checked out. 0072 * The default is to use the working directory. 0073 */ 0074 void setTargetDirectory(const QString &dir); 0075 0076 /** 0077 * Sets the paths which are checked out. 0078 * These can be exact path names or wildcard matchers like `*.c`. 0079 * The wildcard syntax is that accepted by the POSIX \c fnmatch function. 0080 * @param paths The paths to checkout. 0081 */ 0082 void setPaths(const QList<QString> &paths); 0083 0084 const git_checkout_options* data() const; 0085 0086 private: 0087 class Private; 0088 QSharedPointer<Private> d_ptr; 0089 Q_DECLARE_PRIVATE() 0090 }; 0091 0092 Q_DECLARE_OPERATORS_FOR_FLAGS(CheckoutOptions::Flags) 0093 0094 /** @} */ 0095 0096 } 0097 0098 #endif // LIBQGIT2_CHECKOUTOPTIONS_H