git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: demerphq <demerphq@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: should git rev-parse -q --verify on a range produce output?
Date: Sun, 8 Jan 2023 11:45:13 +0100	[thread overview]
Message-ID: <CANgJU+UeZJP=tBx7ALd8_X=b25RkAdQ1NkQpueSL-p+kpCO17Q@mail.gmail.com> (raw)
In-Reply-To: <xmqqmt6tzrcx.fsf@gitster.g>

On Sun, 8 Jan 2023 at 03:34, Junio C Hamano <gitster@pobox.com> wrote:
>
> demerphq <demerphq@gmail.com> writes:
>
> > I was curious if it is a bug that `rev-parse -q --verify` produces
> > output for a commit range, and only reveals it is supposed to be used
> > with a single commit as an error message?
>
> I know that the original scenario that the combination of "--verify"
> and "--quiet" was invented for was "I have a string that ought to
> resolve to a single object name, but the object may be missing", and
>
>         if git cat-file -e "$name" 2>/dev/null
>         then
>                 rawname=$(git rev-parse --verify "$name")
>                 true
>         else
>                 false
>         fi &&
>         ... do something that uses $rawname here ...
>
> is a mouthful.  It becomes easier to use if we can say
>
>         rawname=$(git rev-parse -q --verify "$name") &&
>         ... do something that uses $rawname here ...
>
> I do not think the behaviour in usecase outside that was carefully
> designed to the details.

Is this something you think should be fixed? I would give it a go if
there was some direction on what it should do in this case. Just error
early and produce no output?

BTW, the weird behavior of it is documented here:
https://github.com/Perl/perl5/pull/20657

We have some tooling which we use to generate lists of contributors
for each release from the git commits, and we test this code each
build on specific known commit ranges. We noticed this because some of
our tests run in shallow clones and we were using rev-parse to disable
the test if the clone didnt have the right commit range. But it was
failing sometimes when it didnt have the complete range and we were
"doing it wrong" by not checking the error code and just checking to
see if it output anything.

cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

  reply	other threads:[~2023-01-08 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-07 23:03 should git rev-parse -q --verify on a range produce output? demerphq
2023-01-08  2:34 ` Junio C Hamano
2023-01-08 10:45   ` demerphq [this message]
2023-01-09  3:51     ` Junio C Hamano
2023-01-09  9:04       ` demerphq

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='CANgJU+UeZJP=tBx7ALd8_X=b25RkAdQ1NkQpueSL-p+kpCO17Q@mail.gmail.com' \
    --to=demerphq@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).