Skip to content

Commit

Permalink
Improve error reporting in fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
creationix committed Aug 5, 2014
1 parent 4bd600b commit edd0da7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions net/git-fetch-pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,25 @@ function fetchPack(transport, onError) {
Object.defineProperty(refs, "caps", {value: caps});
Object.defineProperty(refs, "shallows", {value:[]});
var index = line.indexOf("\0");
line.substring(index + 1).split(" ").forEach(function (cap) {
var i = cap.indexOf("=");
if (i >= 0) {
caps[cap.substring(0, i)] = cap.substring(i + 1);
}
else {
caps[cap] = true;
}
});
line = line.substring(0, index);
if (index >= 0) {
line.substring(index + 1).split(" ").forEach(function (cap) {
var i = cap.indexOf("=");
if (i >= 0) {
caps[cap.substring(0, i)] = cap.substring(i + 1);
}
else {
caps[cap] = true;
}
});
line = line.substring(0, index);
}
}
var match = line.match(/(^[0-9a-f]{40}) (.*)$/);
if (!match) {
throw new Error("Invalid line: " + line);
if (typeof line === "string" && /^ERR/i.test(line)) {
throw new Error(line);
}
throw new Error("Invalid line: " + JSON.stringify(line));
}
refs[match[2]] = match[1];
socket.take(onRef);
Expand Down

0 comments on commit edd0da7

Please sign in to comment.