Title: git_worktree_add fails on master branch with already checked out · Issue #4977 · libgit2/libgit2 · GitHub
Open Graph Title: git_worktree_add fails on master branch with already checked out · Issue #4977 · libgit2/libgit2
X Title: git_worktree_add fails on master branch with already checked out · Issue #4977 · libgit2/libgit2
Description: Other branches work all OK just seems to be the master that fails. Note that the repo is bare just in case that has any effect. Reproduction steps git clone --bare url git_reference_lookup(ref, Handle, 'refs/heads/master') git_worktree_a...
Open Graph Description: Other branches work all OK just seems to be the master that fails. Note that the repo is bare just in case that has any effect. Reproduction steps git clone --bare url git_reference_lookup(ref, Han...
X Description: Other branches work all OK just seems to be the master that fails. Note that the repo is bare just in case that has any effect. Reproduction steps git clone --bare url git_reference_lookup(ref, Han...
Opengraph URL: https://github.com/libgit2/libgit2/issues/4977
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"git_worktree_add fails on master branch with already checked out","articleBody":"Other branches work all OK just seems to be the master that fails. Note that the repo is bare just in case that has any effect.\r\n \r\n### Reproduction steps\r\n```\r\ngit clone --bare url\r\n```\r\n```\r\n git_reference_lookup(ref, Handle, 'refs/heads/master')\r\n git_worktree_add_init_options(@opts, GIT_WORKTREE_ADD_OPTIONS_VERSION);\r\n opts.ref := ref;\r\n r := git_worktree_add(wt, Handle, 'worktreename', '/some/path', @opts)\r\n```\r\n### Expected behavior\r\nr = 0 (Success)\r\n\r\n### Actual behavior\r\nr = -4 (Fail)\r\nError message = \"reference is already checked out\"\r\n\r\n### Version of libgit2 (release number or SHA1)\r\n0.28\r\n\r\n### Operating system(s) tested\r\nWindows\r\n\r\n### Additional Information\r\nAfter the failure partial work tree structure is left behind which maybe should have been cleaned up or maybe the validity checks should happen before any structure gets created - which may or may not be possible. \r\n\r\nAnyway if I clear out the invalid worktree structure that was left behind and run\r\n```\r\ngit worktree add --checkout /some/path master\r\n```\r\nit works just fine so we know that the master was not checked out anywhere else\r\n\r\n","author":{"url":"https://github.com/mjnz","@type":"Person","name":"mjnz"},"datePublished":"2019-02-13T00:32:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/4977/libgit2/issues/4977"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:17315f90-61d6-4584-85b3-a54cb64ec7d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D25C:20DA71:989373D:CF16F64:6A5ED6FF |
| html-safe-nonce | 25ec6eccfdbdbb34193104f6d9e0bf393f53a2c8180cd8d46b793db11e1cece7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjVDOjIwREE3MTo5ODkzNzNEOkNGMTZGNjQ6NkE1RUQ2RkYiLCJ2aXNpdG9yX2lkIjoiNzM4Mzc5NzIxNjAxOTY2NjY4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1f570b36760482313bf44ceee1b66891507b086e31fb0167a14e69ba7b805b13 |
| hovercard-subject-tag | issue:409566895 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/libgit2/libgit2/4977/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3cfe3ff37362e616a69aa38bc3d11b2def9fd9d0514239c62106d4a97c0c25a5/libgit2/libgit2/issues/4977 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3cfe3ff37362e616a69aa38bc3d11b2def9fd9d0514239c62106d4a97c0c25a5/libgit2/libgit2/issues/4977 |
| og:image:alt | Other branches work all OK just seems to be the master that fails. Note that the repo is bare just in case that has any effect. Reproduction steps git clone --bare url git_reference_lookup(ref, Han... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mjnz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 82d0004a35927bdb00c652a57f456c55aa0eda4ade1bc7956d7510fdea6e454b |
| turbo-cache-control | no-preview |
| go-import | github.com/libgit2/libgit2 git https://github.com/libgit2/libgit2.git |
| octolytics-dimension-user_id | 394745 |
| octolytics-dimension-user_login | libgit2 |
| octolytics-dimension-repository_id | 901662 |
| octolytics-dimension-repository_nwo | libgit2/libgit2 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 901662 |
| octolytics-dimension-repository_network_root_nwo | libgit2/libgit2 |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d2d913dd727d2d7ac189fb4d05b10bc34ecd03ee |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width