Skip to content

commits off detached HEAD should not be linkable #1478

Open

Description

@shiftkey

Description

We need to be better at handling detached HEAD and getting people back to a happy place, but this is some low-hanging fruit around ensuring we detect unpublished commits correctly and not linking off to GitHub (because they aren't there).

Version

GitHub Desktop version: 0.5.1

OS version: macOS Sierra 10.12.4

Steps to Reproduce

  1. Create a new repository locally with some initialized results (so you have a commit created)
  2. Create another commit, so you have two of them
  3. Publish the repository to GitHub
  4. Launch Repository -> Open in Terminal to open the repository in a shell
  5. Move the repository back to the first commit: git checkout HEAD~1
  6. Create a new file touch FOO.md
  7. Switch back to the application and commit this change
  8. Switch to the History tab, and select the first commit

Expected behaviour: commit should not be linkable

Actual behaviour: it's totally linkable

screen shot 2017-05-16 at 11 25 27 am

Reproduces how often: 100%

Additional Information

This isn't urgent, but implementing it might help us understand more about how to work better with repositories in a detached HEAD state.

Activity

  1. added
    bug
    and removed on Jun 29, 2017
  2. shiftkey commented on Jul 26, 2017

    @shiftkey
    MemberAuthor

    While the commit view has changed a bit, the new View on GitHub button should not be visible for an unpublished commit like this:

    Repro steps:

    • using a GitHub repository
    • open command line and git checkout HEAD~1
    • `git commit --allow-empty -m "i am an empty commit"
    • switch back to the app
  3. shiftkey commented on Feb 14, 2018

    @shiftkey
    MemberAuthor

    This came up in a chat with @iAmWillShepherd and I got to thinking about it again and realised we have a way out of this.

    If your repository is up to date, you can run this command to see if a SHA exists on a given remote:

    $ git for-each-ref --contains={sha} refs/remotes/{remote}
    

    If this exists in any of the refs in the remote, this will emit one or more rows of text. If not, the stdout will be empty. This can be rather expensive if a repository has a lot of refs, so I would be careful with it's usage (defer it until you're displaying the commit details?).

  4. added
    priority-3
    on Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions