From: Kyle Meyer Date: Thu, 20 Jun 2019 22:54:11 GMT Subject: Re: specifying revision - how to enforce matching a tag/branch-name or revision only Message-ID: <87sgs3rhpo.fsf@kyleam.com> In-Reply-To: <8C0042D8869AEA4AA334B49AFBBCEF820243C01B6A@TUT-EX01-PV.KSTG.corp> Hi, "Boettger, Heiko" writes: > Hi, > > I discovered an interesting problem when using `git checkout` to which > I couldn't find a good solution. We have an automatic system trying to > checkout a branch only when it exists. To do so we check whether `git > rev-parse` finds a commit for given branch name: > > git rev-parse "${BRANCH_NAME}"  || git rev-parse "refs/remotes/${UPSTREAM}/${BRANCH_NAME}" > > Unfortunately somebody used the branch name "add-gcc10" and `git rev-parse` which didn't exist on one repository. However `git rev-parse` > also supports to parse the `git-describe` format which resulted in checkout a commit starting with "cc10". Can't you prepend "refs/heads/" to BRANCH_NAME to disambiguate? -- Kyle