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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-05-10 15:59:08-0400, "D. Ben Knoble" <ben.knoble@xxxxxxxxx> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux