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

anirudhrb commented Oct 21, 2019

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 #82026
extensions/git/src/git.ts Show resolved Hide resolved
@Fleta
Fleta approved these changes Oct 22, 2019
@joaomoreno joaomoreno added the git label Oct 22, 2019
@anirudhrb

This comment has been minimized.

Copy link
Contributor Author

anirudhrb commented Oct 29, 2019

@joaomoreno ping!

@joaomoreno

This comment has been minimized.

Copy link
Member

joaomoreno commented Oct 29, 2019

@anirudhrb pong!

@joaomoreno

This comment has been minimized.

Copy link
Member

joaomoreno commented Nov 29, 2019

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
2 checks passed
2 checks passed
VS Code #20191021.46 succeeded
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.