Skip to content

Git: Fixed error when staging in empty repository#82995

Merged
joaomoreno merged 1 commit intomicrosoft:masterfrom
anirudhrb:git_error_82026
Nov 29, 2019
Merged

Git: Fixed error when staging in empty repository#82995
joaomoreno merged 1 commit intomicrosoft:masterfrom
anirudhrb:git_error_82026

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
@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