Vscode-pull-request-github: Only a single (grafted) commit left in branch after checkout with extension?

Created on 12 Mar 2019  路  4Comments  路  Source: microsoft/vscode-pull-request-github

  • Extension version: 0.5.0
  • VSCode Version: 1.32.1
  • OS: Windows 10 64-bit

Steps to Reproduce:

Unclear. I tried to reproduce the problem with a simplified setup, but to no avail. Here is a list of things I remember:

  • Had accidentally staged all changed/untracked files
  • Unstaged them one by one by clicking the - button on them in source code management sidebar in quick succession (in parallel? it tooks quite a while until it finished in the background)
  • Installed GitHub extension
  • The working copy had branch devel checked out, potentially not up-to-date with remote
  • I wanted to edit something a feature branch call documentation/graph-traversal-build-fix
  • There was already a local branch with that name, but it was behind the remote branch (same name)

    • I had merged origin/devel into documentation/graph-traversal-build-fix on a different machine

    • My local branch was behind but that merge commit

  • Via the GitHub extension, I located the corresponding PR for that branch and clicked the Checkout button
  • When I checked git log the next time in a command prompt, it only gave me this:

    >git log
    commit b7aa332a80c16be8c74c51fb7c2f7cdb8e4e8ff2 (grafted, HEAD -> documentation/graph-traversal-build-fix, origin/documentation/graph-traversal-build-fix)
    Author: Simran ...
    Date:   Fri Mar 8 15:18:44 2019 +0100
    
      Merge remote-tracking branch 'origin/devel' into documentation/graph-traversal-build-fix
    
    

    So the entire history of that branch looks like a single commit and is the merge commit (the one I was behind before the Checkout via the GitHub extension)

  • Shortly after, I noted that it said grafted. In a shallow clone of a repository, it would be expected that you see a truncated history. However, my repo wasn't a shallow clone but a normal working copy with the entire history.
  • The PR on GitHub based on the documentation/graph-traversal-build-fix branch looked alright, so I deleted my local branch and checked out the remote branch - but the history remained a single commit
  • Then I tried to reset --hard, but this didn't change anything either

I cloned the entire repo to a new folder, and there the branch is fine, i.e. the entire history is listed as expected. Does this mean some cache in the original working copy got corrupted?

What does the GitHub extension do exactly if you check out pull requests? Is there any chance for breaking the working copy as described? Is it caused by how the extension uses Git, or does this sound like a bug in Git itself?

If you want to analyze the (possibly) corrupted working copy, download it here: arangodb-grafted.7z (1.1 GB)

bug

Most helpful comment

@Simran-B I had the same problem. Solution was to delete the .git/shallow file.

All 4 comments

@Simran-B I had the same problem. Solution was to delete the .git/shallow file.

There's indeed a shallow file which contains a single line in my case:
b7aa332a80c16be8c74c51fb7c2f7cdb8e4e8ff2 - which is also the commit it shows as entire history on the affected branch. I renamed the file and the full history is back! Thanks @sunsations for this suggestion!

A question remains: what created this shallow file or added this commit to it respectively? Is there any git command to add to this file? As I did nothing out of the ordinary with Git exception using the Github extension of VS Code, I still believe that this was caused by the extension, and I consider that to be a bug.

I got the same problem when I started reviewing a PR through the extension. I have no idea how it got there.

I ran into this again. I believe it's because of the fetch with a depth of 1:

https://github.com/microsoft/vscode-pull-request-github/blob/2285fdc17d20ce325163c23215f5fabc7a923be9/src/github/pullRequestGitHelper.ts#L42

This really interferes with reviewing the log of pull requests. Is it possible to make this configurable?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jonnokc picture Jonnokc  路  3Comments

erihanse picture erihanse  路  4Comments

kieferrm picture kieferrm  路  4Comments

octogonz picture octogonz  路  3Comments

radu-matei picture radu-matei  路  3Comments