Skip to content

Commit d55c7a4

Browse files
mojavelinuxisomorphic-git-bot
authored andcommitted
fix: handle no-refs response from git-upload-pack for git > 2.41.0 (#1862)
1 parent 9559a73 commit d55c7a4

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

js/isomorphic-git/index.cjs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6954,14 +6954,17 @@ async function parseRefsAdResponse(stream, { service }) {
69546954

69556955
const [firstRef, capabilitiesLine] = splitAndAssert(lineTwo, '\x00', '\\x00');
69566956
capabilitiesLine.split(' ').map(x => capabilities.add(x));
6957-
const [ref, name] = splitAndAssert(firstRef, ' ', ' ');
6958-
refs.set(name, ref);
6959-
while (true) {
6960-
const line = await read();
6961-
if (line === true) break
6962-
if (line !== null) {
6963-
const [ref, name] = splitAndAssert(line.toString('utf8'), ' ', ' ');
6964-
refs.set(name, ref);
6957+
// see no-refs in https://git-scm.com/docs/pack-protocol#_reference_discovery (since git 2.41.0)
6958+
if (firstRef !== '0000000000000000000000000000000000000000 capabilities^{}') {
6959+
const [ref, name] = splitAndAssert(firstRef, ' ', ' ');
6960+
refs.set(name, ref);
6961+
while (true) {
6962+
const line = await read();
6963+
if (line === true) break
6964+
if (line !== null) {
6965+
const [ref, name] = splitAndAssert(line.toString('utf8'), ' ', ' ');
6966+
refs.set(name, ref);
6967+
}
69656968
}
69666969
}
69676970
// Symrefs are thrown into the "capabilities" unfortunately.

js/isomorphic-git/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6948,14 +6948,17 @@ async function parseRefsAdResponse(stream, { service }) {
69486948

69496949
const [firstRef, capabilitiesLine] = splitAndAssert(lineTwo, '\x00', '\\x00');
69506950
capabilitiesLine.split(' ').map(x => capabilities.add(x));
6951-
const [ref, name] = splitAndAssert(firstRef, ' ', ' ');
6952-
refs.set(name, ref);
6953-
while (true) {
6954-
const line = await read();
6955-
if (line === true) break
6956-
if (line !== null) {
6957-
const [ref, name] = splitAndAssert(line.toString('utf8'), ' ', ' ');
6958-
refs.set(name, ref);
6951+
// see no-refs in https://git-scm.com/docs/pack-protocol#_reference_discovery (since git 2.41.0)
6952+
if (firstRef !== '0000000000000000000000000000000000000000 capabilities^{}') {
6953+
const [ref, name] = splitAndAssert(firstRef, ' ', ' ');
6954+
refs.set(name, ref);
6955+
while (true) {
6956+
const line = await read();
6957+
if (line === true) break
6958+
if (line !== null) {
6959+
const [ref, name] = splitAndAssert(line.toString('utf8'), ' ', ' ');
6960+
refs.set(name, ref);
6961+
}
69596962
}
69606963
}
69616964
// Symrefs are thrown into the "capabilities" unfortunately.

js/isomorphic-git/index.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/index.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/isomorphic-git/size_report.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)