Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jgit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Faculty of Technology
Software Engineering
tools
cms
jgit
Commits
79bb1594
Commit
79bb1594
authored
15 years ago
by
Shawn Pearce
Committed by
Code Review
15 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Check for remote server exec failures and report"
parents
baaa78f1
08a77c04
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
+40
-16
40 additions, 16 deletions
....jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
with
40 additions
and
16 deletions
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
+
40
−
16
View file @
79bb1594
/*
* Copyright (C) 2008-200
9
, Google Inc.
* Copyright (C) 2008-20
1
0, Google Inc.
* Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
...
...
@@ -127,6 +127,23 @@ private static void sq(final StringBuilder cmd, final String val) {
cmd
.
append
(
QuotedString
.
BOURNE
.
quote
(
val
));
}
private
String
commandFor
(
final
String
exe
)
{
String
path
=
uri
.
getPath
();
if
(
uri
.
getScheme
()
!=
null
&&
uri
.
getPath
().
startsWith
(
"/~"
))
path
=
(
uri
.
getPath
().
substring
(
1
));
final
StringBuilder
cmd
=
new
StringBuilder
();
final
int
gitspace
=
exe
.
indexOf
(
"git "
);
if
(
gitspace
>=
0
)
{
sqMinimal
(
cmd
,
exe
.
substring
(
0
,
gitspace
+
3
));
cmd
.
append
(
' '
);
sqMinimal
(
cmd
,
exe
.
substring
(
gitspace
+
4
));
}
else
sqMinimal
(
cmd
,
exe
);
cmd
.
append
(
' '
);
sqAlways
(
cmd
,
path
);
return
cmd
.
toString
();
}
ChannelExec
exec
(
final
String
exe
)
throws
TransportException
{
initSession
();
...
...
@@ -134,21 +151,7 @@ ChannelExec exec(final String exe) throws TransportException {
final
int
tms
=
getTimeout
()
>
0
?
getTimeout
()
*
1000
:
0
;
try
{
final
ChannelExec
channel
=
(
ChannelExec
)
sock
.
openChannel
(
"exec"
);
String
path
=
uri
.
getPath
();
if
(
uri
.
getScheme
()
!=
null
&&
uri
.
getPath
().
startsWith
(
"/~"
))
path
=
(
uri
.
getPath
().
substring
(
1
));
final
StringBuilder
cmd
=
new
StringBuilder
();
final
int
gitspace
=
exe
.
indexOf
(
"git "
);
if
(
gitspace
>=
0
)
{
sqMinimal
(
cmd
,
exe
.
substring
(
0
,
gitspace
+
3
));
cmd
.
append
(
' '
);
sqMinimal
(
cmd
,
exe
.
substring
(
gitspace
+
4
));
}
else
sqMinimal
(
cmd
,
exe
);
cmd
.
append
(
' '
);
sqAlways
(
cmd
,
path
);
channel
.
setCommand
(
cmd
.
toString
());
channel
.
setCommand
(
commandFor
(
exe
));
errStream
=
createErrorStream
();
channel
.
setErrStream
(
errStream
,
true
);
channel
.
connect
(
tms
);
...
...
@@ -158,6 +161,17 @@ ChannelExec exec(final String exe) throws TransportException {
}
}
void
checkExecFailure
(
int
status
,
String
exe
)
throws
TransportException
{
if
(
status
==
127
)
{
String
why
=
errStream
.
toString
();
IOException
cause
=
null
;
if
(
why
!=
null
&&
why
.
length
()
>
0
)
cause
=
new
IOException
(
why
);
throw
new
TransportException
(
uri
,
"cannot execute: "
+
commandFor
(
exe
),
cause
);
}
}
/**
* @return the error stream for the channel, the stream is used to detect
* specific error reasons for exceptions.
...
...
@@ -305,6 +319,8 @@ public void run() {
class
SshFetchConnection
extends
BasePackFetchConnection
{
private
ChannelExec
channel
;
private
int
exitStatus
;
SshFetchConnection
()
throws
TransportException
{
super
(
TransportGitSsh
.
this
);
try
{
...
...
@@ -327,6 +343,8 @@ class SshFetchConnection extends BasePackFetchConnection {
try
{
readAdvertisedRefs
();
}
catch
(
NoRemoteRepositoryException
notFound
)
{
close
();
checkExecFailure
(
exitStatus
,
getOptionUploadPack
());
throw
cleanNotFound
(
notFound
);
}
}
...
...
@@ -337,6 +355,7 @@ public void close() {
if
(
channel
!=
null
)
{
try
{
exitStatus
=
channel
.
getExitStatus
();
if
(
channel
.
isConnected
())
channel
.
disconnect
();
}
finally
{
...
...
@@ -349,6 +368,8 @@ public void close() {
class
SshPushConnection
extends
BasePackPushConnection
{
private
ChannelExec
channel
;
private
int
exitStatus
;
SshPushConnection
()
throws
TransportException
{
super
(
TransportGitSsh
.
this
);
try
{
...
...
@@ -371,6 +392,8 @@ class SshPushConnection extends BasePackPushConnection {
try
{
readAdvertisedRefs
();
}
catch
(
NoRemoteRepositoryException
notFound
)
{
close
();
checkExecFailure
(
exitStatus
,
getOptionReceivePack
());
throw
cleanNotFound
(
notFound
);
}
}
...
...
@@ -381,6 +404,7 @@ public void close() {
if
(
channel
!=
null
)
{
try
{
exitStatus
=
channel
.
getExitStatus
();
if
(
channel
.
isConnected
())
channel
.
disconnect
();
}
finally
{
...
...
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