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

Re: bug: git name-rev --stdin --no-undefined on detached head

From
John Cai <johncai86@gmail.com>
Date
Dec 24, 2021, 06:09 UTC
Message-ID
<D22DF4C4-C98C-45FB-8D26-57B50A44FA3F@gmail.com>
In-Reply-To
<DA9B4728-C45D-4CA0-A40D-4A81665AB0E6@gitlab.com>
Show 7 quoted lines
> On Dec 23, 2021, at 10:39 AM, John Cai <jcai@gitlab.com> wrote:
> 
> It seems like this bug can be generalized to “git name-rev --stdin” does not work with --no-undefined nor --name-only
> 
> The --name-only case seems clear to me that we should fix it. It’s misleading to return the sha instead of “undefined” for a rev without a symbolic name, as a sha could be a symbolic name.
> 
> I think we can also make the argument that --no-undefined should also die in --stdin mode when given a rev without any symbolic names.
While I think this would make name-rev more consistent, I’d be interested in hearing what others think about changing the behavior of this command. This would have the potential of breaking scripts that rely on the current behavior. Since I’m a bit new, I’m wondering how we generally handle these cases?
Show 38 quoted lines
> 
> 
>> On Dec 22, 2021, at 2:05 AM, Erik Cervin Edin <erik@cervined.in> wrote:
>> 
>> Hey all!
>> 
>> I ran into a situation that I think may be a bug
>> using git name-rev for detached heads.
>> 
>> Steps to reproduce:
>> Create a detached head
>> git checkout --detached
>> git commit --allow-empty -m foo
>> 
>> Expected results:
>> My understanding is that
>> git name-rev $(git rev-list -1 HEAD)
>> git rev-list -1 HEAD | git name-rev --stdin
>> should yield the same result.
>> 
>> As well as combining with other flags
>> like --name-only / --no-undefined
>> 
>> Actual results:
>> Where this fails as expected
>> git name-rev --no-undefined $(git rev-list HEAD)
>> this just prints the SHA wo failing
>> git rev-list -1 HEAD |  git name-rev --stdin --no-undefined
>> 
>> "name-only" is also affected
>> git rev-list -1 HEAD |  git name-rev --stdin --name-only
>> returns the SHA and not the name
>> 
>> Tested on
>> git version 2.34.1.windows.1
>> -- 
>> Erik Cervin-Edin
> 
Previous: John CaiNext: Erik Cervin Edin
Message 3 of 8 in “bug: git name-rev --stdin --no-undefined on detached head”
  1. Erik Cervin EdinDec 22, 2021
  2. John CaiDec 23, 2021
  3. John CaiDec 24, 2021
  4. Erik Cervin EdinDec 24, 2021
  5. Junio C HamanoDec 24, 2021
  6. John CaiDec 24, 2021
  7. Junio C HamanoDec 25, 2021
  8. Philip OakleyDec 31, 2021

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.