forked from qt-creator/qt-creator
Git: Allow commit (or amend) when not on a branch
Git allows that so why can't we? Useful when in the middle of merge/rebase. Change-Id: Id09da3417904ff29e6dd1b4ef383157e9c4920d3 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
6a3f9460d7
commit
d207165f6a
@@ -1519,7 +1519,7 @@ static inline QString trimFileSpecification(QString fileSpec)
|
||||
}
|
||||
|
||||
GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, bool untracked,
|
||||
QString *output, QString *errorMessage, bool *onBranch)
|
||||
QString *output, QString *errorMessage)
|
||||
{
|
||||
// Run 'status'. Note that git returns exitcode 1 if there are no added files.
|
||||
QByteArray outputText;
|
||||
@@ -1537,8 +1537,6 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, bo
|
||||
static const char * NO_BRANCH = "## HEAD (no branch)\n";
|
||||
|
||||
const bool branchKnown = !outputText.startsWith(NO_BRANCH);
|
||||
if (onBranch)
|
||||
*onBranch = branchKnown;
|
||||
// Is it something really fatal?
|
||||
if (!statusRc && !branchKnown) {
|
||||
if (errorMessage) {
|
||||
@@ -1695,15 +1693,10 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
||||
}
|
||||
|
||||
// Run status. Note that it has exitcode 1 if there are no added files.
|
||||
bool onBranch;
|
||||
QString output;
|
||||
const StatusResult status = gitStatus(repoDirectory, true, &output, errorMessage, &onBranch);
|
||||
const StatusResult status = gitStatus(repoDirectory, true, &output, errorMessage);
|
||||
switch (status) {
|
||||
case StatusChanged:
|
||||
if (!onBranch) {
|
||||
*errorMessage = tr("You did not checkout a branch.");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case StatusUnchanged:
|
||||
if (amend)
|
||||
|
@@ -212,7 +212,7 @@ public:
|
||||
StatusResult gitStatus(const QString &workingDirectory,
|
||||
bool untracked = false,
|
||||
QString *output = 0,
|
||||
QString *errorMessage = 0, bool *onBranch = 0);
|
||||
QString *errorMessage = 0);
|
||||
|
||||
void launchGitK(const QString &workingDirectory);
|
||||
void launchRepositoryBrowser(const QString &workingDirectory);
|
||||
|
Reference in New Issue
Block a user