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: Fixed error when staging in empty repository #82995

Merged
merged 1 commit into from
Nov 29, 2019

Conversation

anirudhrb
Copy link
Contributor

Trying to stage a commit in an empty repository (i.e. no prior commits)
results in a git fatal error. This is because in an empty repo, HEAD
doesn't point to anything causing git ls-tree -l HEAD ... to fail.

To fix this, send treeish as 'HEAD' to getObjectDetails() only if
there is at least one commit in the repo. Else, send an empty string
causing getObjectDetails() to use lsFiles instead of lsTree.

Fixes #82026.

Trying to stage a commit in an empty repository (i.e. no prior commits)
results in a git fatal error. This is because in an empty repo, HEAD
doesn't point to anything causing `git ls-tree -l HEAD ...` to fail.

To fix this, send `treeish` as `'HEAD'` to `getObjectDetails()` only if
there is at least one commit in the repo. Else, send an empty string
causing `getObjectDetails()` to use `lsFiles` instead of `lsTree`.

Fixes microsoft#82026
extensions/git/src/git.ts Show resolved Hide resolved
@joaomoreno joaomoreno added the git GIT issues label Oct 22, 2019
@anirudhrb
Copy link
Contributor Author

@joaomoreno ping!

@joaomoreno
Copy link
Member

@anirudhrb pong!

@joaomoreno
Copy link
Member

Thanks! 🎆

Ended up running getCommit instead of log, found that to be more specific.

@joaomoreno joaomoreno added this to the November 2019 milestone Nov 29, 2019
@joaomoreno joaomoreno merged commit 7b1a6c8 into microsoft:master Nov 29, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
git GIT issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Git: Errors when staging changes in new repository
3 participants