git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Cai <johncai86@gmail.com>
To: Erik Cervin Edin <erik@cervined.in>
Cc: git@vger.kernel.org
Subject: Re: bug: git name-rev --stdin --no-undefined on detached head
Date: Thu, 23 Dec 2021 22:09:50 -0800	[thread overview]
Message-ID: <D22DF4C4-C98C-45FB-8D26-57B50A44FA3F@gmail.com> (raw)
In-Reply-To: <DA9B4728-C45D-4CA0-A40D-4A81665AB0E6@gitlab.com>


> 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?

> 
> 
>> 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
> 


  reply	other threads:[~2021-12-24  6:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-22 10:05 bug: git name-rev --stdin --no-undefined on detached head Erik Cervin Edin
2021-12-23 18:39 ` John Cai
2021-12-24  6:09   ` John Cai [this message]
2021-12-24 11:44     ` Erik Cervin Edin
2021-12-24 19:42   ` Junio C Hamano
2021-12-24 20:09     ` John Cai
2021-12-25  0:35     ` Junio C Hamano
2021-12-31 17:16     ` Philip Oakley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D22DF4C4-C98C-45FB-8D26-57B50A44FA3F@gmail.com \
    --to=johncai86@gmail.com \
    --cc=erik@cervined.in \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).