Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git - add support for reftable storage format #224395

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ export interface PullOptions {
}

export class Repository {
private _isUsingRefTable = false;

constructor(
private _git: Git,
Expand Down Expand Up @@ -2330,13 +2331,25 @@ export class Repository {
}

async getHEAD(): Promise<Ref> {
try {
// Attempt to parse the HEAD file
const result = await this.getHEADFS();
return result;
}
catch (err) {
this.logger.warn(`[Git][getHEAD] Failed to parse HEAD file: ${err.message}`);
if (!this._isUsingRefTable) {
try {
// Attempt to parse the HEAD file
const result = await this.getHEADFS();

// Git 2.45 adds support for a new reference storage backend called "reftable", promising
// faster lookups, reads, and writes for repositories with any number of references. For
// backwards compatibility the `.git/HEAD` file contains `ref: refs/heads/.invalid`. More
// details are available at https://git-scm.com/docs/reftable
if (result.name === '.invalid') {
this._isUsingRefTable = true;
this.logger.warn(`[Git][getHEAD] Failed to parse HEAD file: Repository is using reftable format.`);
} else {
return result;
}
}
catch (err) {
this.logger.warn(`[Git][getHEAD] Failed to parse HEAD file: ${err.message}`);
}
}

try {
Expand Down
Loading