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

Re: git check-ignore --verbose fails oddly when invoked via an alias

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
May 11, 2020, 00:24 UTC
Message-ID
<20200511002405.GA16475@danh.dev>
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.]
Show 15 quoted lines
> $ 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
Previous: D. Ben Knoble
Message 2 of 2 in “git check-ignore --verbose fails oddly when invoked via an alias”
  1. D. Ben KnobleMay 10, 2020
  2. Đoàn Trần Công DanhMay 11, 2020

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.