Git: Introduce StashGuard

Offers the user to stash changes (if relevant), stores
the results and pops the stash when it goes out of scope
(unless disabled)

Change-Id: Ibc0d2a5d3e3c953062fb17ecba903ca814524837
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2013-01-24 12:11:01 +02:00
parent c670a66fe1
commit 5551c1e906
8 changed files with 102 additions and 86 deletions

View File

@@ -82,6 +82,27 @@ class GitClient : public QObject
Q_OBJECT
public:
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
Stashed, NotStashed /* User did not want it */ };
class StashGuard
{
public:
StashGuard(const QString &workingDirectory, const QString &keyword);
~StashGuard();
void preventPop();
bool stashingFailed(bool includeNotStashed) const;
StashResult result() const { return stashResult; }
private:
bool pop;
StashResult stashResult;
QString message;
QString workingDir;
GitClient *client;
};
static const char *stashNamePrefix;
explicit GitClient(GitSettings *settings);
@@ -210,9 +231,6 @@ public:
QString readConfigValue(const QString &workingDirectory, const QString &configVar) const;
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
Stashed, NotStashed /* User did not want it */ };
StashResult ensureStash(const QString &workingDirectory, const QString &keyword, QString *message = 0);
StashResult ensureStash(const QString &workingDirectory, const QString &keyword, bool askUser,
QString *message, QString *errorMessage = 0);