{"action":"created","issue":{"url":"https://api.github.com/repos/github/git-lfs/issues/1100","repository_url":"https://api.github.com/repos/github/git-lfs","labels_url":"https://api.github.com/repos/github/git-lfs/issues/1100/labels{/name}","comments_url":"https://api.github.com/repos/github/git-lfs/issues/1100/comments","events_url":"https://api.github.com/repos/github/git-lfs/issues/1100/events","html_url":"https://github.com/github/git-lfs/issues/1100","id":142369860,"number":1100,"title":"`git lfs push <remote> <ref>` has poor behavior when tag and branch share a name","user":{"login":"epriestley","id":102631,"avatar_url":"https://avatars.githubusercontent.com/u/102631?v=3","gravatar_id":"","url":"https://api.github.com/users/epriestley","html_url":"https://github.com/epriestley","followers_url":"https://api.github.com/users/epriestley/followers","following_url":"https://api.github.com/users/epriestley/following{/other_user}","gists_url":"https://api.github.com/users/epriestley/gists{/gist_id}","starred_url":"https://api.github.com/users/epriestley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/epriestley/subscriptions","organizations_url":"https://api.github.com/users/epriestley/orgs","repos_url":"https://api.github.com/users/epriestley/repos","events_url":"https://api.github.com/users/epriestley/events{/privacy}","received_events_url":"https://api.github.com/users/epriestley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-21T14:40:43Z","updated_at":"2016-03-31T09:54:11Z","closed_at":null,"body":"I don't think users can actually hit this directly, so I'm mostly filing this for completeness.\r\n\r\n#1096,  #1056, and #1079 are related, and deal with a situation where a branch (like `master`) has the same name as a _file_ in the working copy. Users _can_ hit those cases, but #1096 should always resolve them because they are straightforward to disambiguate.\r\n\r\nA more subtle case is when a where a branch has the same name as a _tag_ instead of the same name as a _file_. Setup is roughly:\r\n\r\n  - Check out a branch.\r\n  - Track, add, and commit some LFS stuff.\r\n  - Tag anything with a tag that has the same name as the branch.\r\n  - Run `git lfs push origin <branch>`.\r\n\r\nWhen you run `git push` in a similar scenario, it stops you immediately because the ref name is ambiguous:\r\n\r\n```\r\n$ GIT_TRACE=1 git push origin branch-and-tag\r\n07:32:46.028980 git.c:348               trace: built-in: git 'push' 'origin' 'branch-and-tag'\r\nerror: src refspec branch-and-tag matches more than one.\r\nerror: failed to push some refs to 'git@github.com:epriestley/poems.git'\r\n```\r\n\r\nHowever, when you run `git lfs push origin master`, it runs \"successfully\" but with the wrong behavior:\r\n\r\n```\r\n$ GIT_TRACE=1 git lfs push origin branch-and-tag\r\n07:32:49.058547 git.c:558               trace: exec: 'git-lfs' 'push' 'origin' 'branch-and-tag'\r\n07:32:49.058924 run-command.c:335       trace: run_command: 'git-lfs' 'push' 'origin' 'branch-and-tag'\r\ntrace git-lfs: Upload refs [branch-and-tag] to remote origin\r\ntrace git-lfs: run_command: git rev-list --objects branch-and-tag --not --remotes=origin --\r\ntrace git-lfs: run_command: git cat-file --batch-check\r\ntrace git-lfs: run_command: git cat-file --batch\r\ntrace git-lfs: run_command: 'git' config -l\r\ntrace git-lfs: tq: starting 3 transfer workers\r\ntrace git-lfs: tq: running as individual queue\r\n```\r\n\r\nThis command exits `0`, but should not. Internally, `git rev-list` has failed:\r\n\r\n```\r\n$ git rev-list --objects branch-and-tag --not --remotes=origin --\r\nwarning: refname 'branch-and-tag' is ambiguous.\r\n```\r\n\r\n`git-lfs` fails to detect this, interprets \"no output\" as \"no matching objects\", and concludes it doesn't need to push anything.\r\n\r\nInstead, it should probably detect that `git rev-list` has failed and exit with an error similar to the one `git` exits with."},"comment":{"url":"https://api.github.com/repos/github/git-lfs/issues/comments/203857960","html_url":"https://github.com/github/git-lfs/issues/1100#issuecomment-203857960","issue_url":"https://api.github.com/repos/github/git-lfs/issues/1100","id":203857960,"user":{"login":"sinbad","id":142735,"avatar_url":"https://avatars.githubusercontent.com/u/142735?v=3","gravatar_id":"","url":"https://api.github.com/users/sinbad","html_url":"https://github.com/sinbad","followers_url":"https://api.github.com/users/sinbad/followers","following_url":"https://api.github.com/users/sinbad/following{/other_user}","gists_url":"https://api.github.com/users/sinbad/gists{/gist_id}","starred_url":"https://api.github.com/users/sinbad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sinbad/subscriptions","organizations_url":"https://api.github.com/users/sinbad/orgs","repos_url":"https://api.github.com/users/sinbad/repos","events_url":"https://api.github.com/users/sinbad/events{/privacy}","received_events_url":"https://api.github.com/users/sinbad/received_events","type":"User","site_admin":false},"created_at":"2016-03-31T09:54:11Z","updated_at":"2016-03-31T09:54:11Z","body":"Slept on it and came up with a derived approach which is simpler & more flexible than the above, working on it more & will submit as PR. "}}