Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
d1ebbcb8
Commit
d1ebbcb8
authored
16 years ago
by
Friedemann Kleint
Browse files
Options
Downloads
Patches
Plain Diff
Fixes: git commit fails due to wrong working directory
Details: Execute git status from repo directory
parent
d8bc36eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/git/gitclient.cpp
+24
-9
24 additions, 9 deletions
src/plugins/git/gitclient.cpp
with
24 additions
and
9 deletions
src/plugins/git/gitclient.cpp
+
24
−
9
View file @
d1ebbcb8
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
#include
<QtCore/QRegExp>
#include
<QtCore/QRegExp>
#include
<QtCore/QTemporaryFile>
#include
<QtCore/QTemporaryFile>
#include
<QtCore/QFuture>
#include
<QtCore/QFuture>
#include
<QtCore/QTime>
#include
<QtGui/QErrorMessage>
#include
<QtGui/QErrorMessage>
...
@@ -76,6 +77,12 @@ inline Core::IEditor* locateEditor(const Core::ICore *core, const char *property
...
@@ -76,6 +77,12 @@ inline Core::IEditor* locateEditor(const Core::ICore *core, const char *property
return
0
;
return
0
;
}
}
static
QString
formatCommand
(
const
QString
&
binary
,
const
QStringList
&
args
)
{
const
QString
timeStamp
=
QTime
::
currentTime
().
toString
(
QLatin1String
(
"HH:mm"
));
return
GitClient
::
tr
(
"%1 Executing: %2 %3
\n
"
).
arg
(
timeStamp
,
binary
,
args
.
join
(
QString
(
QLatin1Char
(
' '
))));
}
GitClient
::
GitClient
(
GitPlugin
*
plugin
,
Core
::
ICore
*
core
)
:
GitClient
::
GitClient
(
GitPlugin
*
plugin
,
Core
::
ICore
*
core
)
:
m_msgWait
(
tr
(
"Waiting for data..."
)),
m_msgWait
(
tr
(
"Waiting for data..."
)),
m_plugin
(
plugin
),
m_plugin
(
plugin
),
...
@@ -331,7 +338,8 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a
...
@@ -331,7 +338,8 @@ void GitClient::executeGit(const QString &workingDirectory, const QStringList &a
{
{
if
(
Git
::
Constants
::
debug
)
if
(
Git
::
Constants
::
debug
)
qDebug
()
<<
"executeGit"
<<
workingDirectory
<<
arguments
<<
editor
;
qDebug
()
<<
"executeGit"
<<
workingDirectory
<<
arguments
<<
editor
;
outputWindow
->
clearContents
();
m_plugin
->
m_outputWindow
->
append
(
formatCommand
(
QLatin1String
(
kGitCommand
),
arguments
));
QProcess
process
;
QProcess
process
;
ProjectExplorer
::
Environment
environment
=
ProjectExplorer
::
Environment
::
systemEnvironment
();
ProjectExplorer
::
Environment
environment
=
ProjectExplorer
::
Environment
::
systemEnvironment
();
...
@@ -363,8 +371,11 @@ bool GitClient::synchronousGit(const QString &workingDirectory
...
@@ -363,8 +371,11 @@ bool GitClient::synchronousGit(const QString &workingDirectory
{
{
if
(
Git
::
Constants
::
debug
)
if
(
Git
::
Constants
::
debug
)
qDebug
()
<<
"synchronousGit"
<<
workingDirectory
<<
arguments
;
qDebug
()
<<
"synchronousGit"
<<
workingDirectory
<<
arguments
;
QProcess
process
;
const
QString
binary
=
QLatin1String
(
kGitCommand
);
m_plugin
->
m_outputWindow
->
append
(
formatCommand
(
binary
,
arguments
));
QProcess
process
;
process
.
setWorkingDirectory
(
workingDirectory
);
process
.
setWorkingDirectory
(
workingDirectory
);
ProjectExplorer
::
Environment
environment
=
ProjectExplorer
::
Environment
::
systemEnvironment
();
ProjectExplorer
::
Environment
environment
=
ProjectExplorer
::
Environment
::
systemEnvironment
();
...
@@ -372,7 +383,7 @@ bool GitClient::synchronousGit(const QString &workingDirectory
...
@@ -372,7 +383,7 @@ bool GitClient::synchronousGit(const QString &workingDirectory
environment
.
set
(
QLatin1String
(
"PATH"
),
m_plugin
->
m_settingsPage
->
path
());
environment
.
set
(
QLatin1String
(
"PATH"
),
m_plugin
->
m_settingsPage
->
path
());
process
.
setEnvironment
(
environment
.
toStringList
());
process
.
setEnvironment
(
environment
.
toStringList
());
process
.
start
(
QLatin1String
(
kGitCommand
)
,
arguments
);
process
.
start
(
binary
,
arguments
);
if
(
!
process
.
waitForFinished
())
{
if
(
!
process
.
waitForFinished
())
{
if
(
errorText
)
if
(
errorText
)
*
errorText
=
"Error: Git timed out"
;
*
errorText
=
"Error: Git timed out"
;
...
@@ -477,6 +488,9 @@ bool GitClient::getCommitData(const QString &workingDirectory,
...
@@ -477,6 +488,9 @@ bool GitClient::getCommitData(const QString &workingDirectory,
CommitData
*
d
,
CommitData
*
d
,
QString
*
errorMessage
)
QString
*
errorMessage
)
{
{
if
(
Git
::
Constants
::
debug
)
qDebug
()
<<
Q_FUNC_INFO
<<
workingDirectory
;
d
->
clear
();
d
->
clear
();
// Find repo
// Find repo
...
@@ -506,9 +520,10 @@ bool GitClient::getCommitData(const QString &workingDirectory,
...
@@ -506,9 +520,10 @@ bool GitClient::getCommitData(const QString &workingDirectory,
QByteArray
outputText
;
QByteArray
outputText
;
QByteArray
errorText
;
QByteArray
errorText
;
QStringList
statusArgs
(
QLatin1String
(
"status"
));
QStringList
statusArgs
(
QLatin1String
(
"status"
));
if
(
untrackedFilesInCommit
)
if
(
untrackedFilesInCommit
)
statusArgs
<<
QLatin1String
(
"-u"
);
statusArgs
<<
QLatin1String
(
"-u"
);
const
bool
statusRc
=
synchronousGit
(
working
Directory
,
statusArgs
,
&
outputText
,
&
errorText
);
const
bool
statusRc
=
synchronousGit
(
repo
Directory
,
statusArgs
,
&
outputText
,
&
errorText
);
if
(
!
statusRc
)
{
if
(
!
statusRc
)
{
// Something fatal
// Something fatal
if
(
!
outputText
.
contains
(
kBranchIndicatorC
))
{
if
(
!
outputText
.
contains
(
kBranchIndicatorC
))
{
...
@@ -565,24 +580,24 @@ bool GitClient::getCommitData(const QString &workingDirectory,
...
@@ -565,24 +580,24 @@ bool GitClient::getCommitData(const QString &workingDirectory,
}
}
// addAndCommit:
// addAndCommit:
bool
GitClient
::
addAndCommit
(
const
QString
&
working
Directory
,
bool
GitClient
::
addAndCommit
(
const
QString
&
repository
Directory
,
const
GitSubmitEditorPanelData
&
data
,
const
GitSubmitEditorPanelData
&
data
,
const
QString
&
messageFile
,
const
QString
&
messageFile
,
const
QStringList
&
checkedFiles
,
const
QStringList
&
checkedFiles
,
const
QStringList
&
origCommitFiles
)
const
QStringList
&
origCommitFiles
)
{
{
if
(
Git
::
Constants
::
debug
)
if
(
Git
::
Constants
::
debug
)
qDebug
()
<<
"GitClient::addAndCommit:"
<<
working
Directory
<<
checkedFiles
<<
origCommitFiles
;
qDebug
()
<<
"GitClient::addAndCommit:"
<<
repository
Directory
<<
checkedFiles
<<
origCommitFiles
;
// Do we need to reset any files that had been added before
// Do we need to reset any files that had been added before
// (did the user uncheck any previously added files)
// (did the user uncheck any previously added files)
const
QSet
<
QString
>
resetFiles
=
origCommitFiles
.
toSet
().
subtract
(
checkedFiles
.
toSet
());
const
QSet
<
QString
>
resetFiles
=
origCommitFiles
.
toSet
().
subtract
(
checkedFiles
.
toSet
());
if
(
!
resetFiles
.
empty
())
if
(
!
resetFiles
.
empty
())
if
(
!
synchronousReset
(
working
Directory
,
resetFiles
.
toList
()))
if
(
!
synchronousReset
(
repository
Directory
,
resetFiles
.
toList
()))
return
false
;
return
false
;
// Re-add all to make sure we have the latest changes
// Re-add all to make sure we have the latest changes
if
(
!
synchronousAdd
(
working
Directory
,
checkedFiles
))
if
(
!
synchronousAdd
(
repository
Directory
,
checkedFiles
))
return
false
;
return
false
;
// Do the final commit
// Do the final commit
...
@@ -593,7 +608,7 @@ bool GitClient::addAndCommit(const QString &workingDirectory,
...
@@ -593,7 +608,7 @@ bool GitClient::addAndCommit(const QString &workingDirectory,
QByteArray
outputText
;
QByteArray
outputText
;
QByteArray
errorText
;
QByteArray
errorText
;
const
bool
rc
=
synchronousGit
(
working
Directory
,
args
,
&
outputText
,
&
errorText
);
const
bool
rc
=
synchronousGit
(
repository
Directory
,
args
,
&
outputText
,
&
errorText
);
const
QString
message
=
rc
?
const
QString
message
=
rc
?
tr
(
"Committed %n file(s)."
,
0
,
checkedFiles
.
size
())
:
tr
(
"Committed %n file(s)."
,
0
,
checkedFiles
.
size
())
:
tr
(
"Unable to commit %n file(s): %1"
,
0
,
checkedFiles
.
size
()).
arg
(
QString
::
fromLocal8Bit
(
errorText
));
tr
(
"Unable to commit %n file(s): %1"
,
0
,
checkedFiles
.
size
()).
arg
(
QString
::
fromLocal8Bit
(
errorText
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment