Skip to content

Git: Fixed error when staging in empty repository - #82995

Merged
João Moreno (joaomoreno) merged 1 commit into
microsoft:masterfrom
anirudhrb:git_error_82026
Nov 29, 2019
Merged

João Moreno (joaomoreno) merged 1 commit into
microsoft:masterfrom
anirudhrb:git_error_82026

Conversation

@anirudhrb

Copy link
Copy Markdown
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
Comment thread extensions/git/src/git.ts Resolved
@joaomoreno João Moreno (joaomoreno) added the git GIT issues label Oct 22, 2019
@anirudhrb

Copy link
Copy Markdown
Contributor Author

João Moreno (@joaomoreno) ping!

@joaomoreno

Copy link
Copy Markdown
Contributor

Anirudh Rayabharam (@anirudhrb) pong!

@joaomoreno

Copy link
Copy Markdown
Contributor

Thanks! 🎆

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

@joaomoreno
João Moreno (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