git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Toru Okugawa <castor.4bit@gmail.com>
Cc: Eric Sunshine <sunshine@sunshineco.com>,  git@vger.kernel.org
Subject: Re: Re* Unexpected behavior with the rev-parse operation
Date: Tue, 30 Apr 2024 11:46:44 -0700	[thread overview]
Message-ID: <xmqqedamzo17.fsf@gitster.g> (raw)
In-Reply-To: <CANHPH19FCWUAMZLFZEY+_+zv0KUkuVGNQS26WmEPjnPtjrK8KQ@mail.gmail.com> (Toru Okugawa's message of "Tue, 30 Apr 2024 23:26:04 +0900")

Toru Okugawa <castor.4bit@gmail.com> writes:

> However, if determining the presence of a Git repository by checking
> for errors is the appropriate approach, I'm interested in
> understanding the intended use of the `--is-inside-work-tree` option.
> I had thought it was meant to suppress errors in exceptional cases.

    $ rm -fr mine
    $ git init mine ;# notice the lack of --bare
    $ cd mine
    $ git commit --allow-empty -m 'initial'
    $ git rev-parse --is-inside-work-tree; echo $?
    true
    0
    $ cd .git
    $ git rev-parse --is-inside-work-tree; echo $?
    false
    0
    $ cd ../..
    $ git --bare init mine.bare ;# this time bare
    $ cd mine.bare
    false
    0

When you write a script that you might want to use as a part of a
hook, for example, you may end up running it inside .git/ and it may
be necessary (depending on what the script does and how it is
written) to tell where you are in the working tree (or if you are in
the working tree in the first place).



  reply	other threads:[~2024-04-30 18:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 13:58 Unexpected behavior with the rev-parse operation Toru Okugawa
2024-04-28 18:08 ` Eric Sunshine
2024-04-28 23:07   ` Re* " Junio C Hamano
2024-04-30 14:26     ` Toru Okugawa
2024-04-30 18:46       ` Junio C Hamano [this message]
2024-05-01  4:55         ` Toru Okugawa

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=xmqqedamzo17.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=castor.4bit@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.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).