git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: specifying revision - how to enforce matching a tag/branch-name or revision only

From
Kyle Meyer <kyle@kyleam.com>
Date
Jun 20, 2019, 22:54 UTC
Message-ID
<87sgs3rhpo.fsf@kyleam.com>
In-Reply-To
<8C0042D8869AEA4AA334B49AFBBCEF820243C01B6A@TUT-EX01-PV.KSTG.corp>
Hi,
"Boettger, Heiko" <Heiko.Boettger@karlstorz.com> writes:
Show 11 quoted lines
> 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
Previous: Boettger, HeikoNext: Junio C Hamano
Message 2 of 11 in “specifying revision - how to enforce matching a tag/branch-name or revision only”
  1. Boettger, HeikoJun 20, 2019
  2. Kyle MeyerJun 20, 2019
  3. Junio C HamanoJun 21, 2019
  4. Duy NguyenJun 25, 2019
  5. AW: specifying revision - how to enforce matching a tag/branch-name or revision onlyBoettger, Heiko, Jun 25, 2019
  6. get_oid: new extended SHA-1 syntax to control resolution processNguyễn Thái Ngọc Duy, Jun 26, 2019
  7. Junio C HamanoJun 26, 2019
  8. Duy NguyenJun 27, 2019
  9. Junio C HamanoJun 27, 2019
  10. Jakub NarebskiJun 30, 2019
  11. Duy NguyenJul 1, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.