git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Đoàn Trần Công Danh" <congdanhqx@gmail.com>
To: "D. Ben Knoble" <ben.knoble@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git check-ignore --verbose fails oddly when invoked via an alias
Date: Mon, 11 May 2020 07:24:05 +0700	[thread overview]
Message-ID: <20200511002405.GA16475@danh.dev> (raw)
In-Reply-To: <CALnO6CBiAy-Jf+q7Qr3rtV9wy3f7ySd0SgK1ckCZvz30ER3i6g@mail.gmail.com>

On 2020-05-10 15:59:08-0400, "D. Ben Knoble" <ben.knoble@gmail.com> wrote:
> I have the following two aliases:
> 
>     ig = check-ignore
>     igv = !git ig --verbose

Your "git igv" is an alias to a shell command.

> $ pwd
> /Users/Knoble/write/junk-drawer/code
> $ g rev-parse --show-toplevel
> /Users/Knoble/write/junk-drawer

You're working on subdirectory of git worktree.

> $ tree -a sml-binary
> sml-binary/

[.snip.]

> $ cat sml-binary/.gitignore
> myprog
> myprog.amd64-darwin
> $ g check-ignore sml-binary/*
> sml-binary/myprog
> sml-binary/myprog.amd64-darwin
> $ g check-ignore --verbose sml-binary/*
> code/sml-binary/.gitignore:1:myprog sml-binary/myprog
> code/sml-binary/.gitignore:2:myprog.amd64-darwin sml-binary/myprog.amd64-darwin
> $ g ig sml-binary/*
> sml-binary/myprog
> sml-binary/myprog.amd64-darwin
> $ g igv sml-binary/*
> $ echo $?
> 1

In git-config(1), we've noted that:

           Note that
           shell commands will be executed from the top-level directory of a
           repository, which may not necessarily be the current directory.
           GIT_PREFIX is set as returned by running git rev-parse
           --show-prefix from the original current directory. See git-rev-
           parse(1).

Which is the parent directory of your "$PWD".

So, two below commands are equivalent:

	$ git igv sml-binary/*
	$ (cd .. && git check-ignore --verbose sml-binary/myprog sml-binary/myprog.amd64-darwin <and other files>)

From Git 2.23.0, Git allows recursive alias expansion:

	igv = ig --verbose

-- 
Danh

      reply	other threads:[~2020-05-11  0:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-10 19:59 git check-ignore --verbose fails oddly when invoked via an alias D. Ben Knoble
2020-05-11  0:24 ` Đoàn Trần Công Danh [this message]

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=20200511002405.GA16475@danh.dev \
    --to=congdanhqx@gmail.com \
    --cc=ben.knoble@gmail.com \
    --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).