# bug when combined with etckeeper

4 messages from 2018-10-10 to 2018-10-13. Participants: Naja Melan, Jeff King, Joey Hess.
Thread: https://gitlist.dev/t/49523

## Naja Melan, 2018-10-10 09:33

Subject: bug when combined with etckeeper
Message-ID: <4d7cddf8-34b3-eaa4-dc9e-e190062e6135@autistici.org>
URL: https://gitlist.dev/e/4d7cddf8-34b3-eaa4-dc9e-e190062e6135%40autistici.org

```
I am running:

Linux  4.18.12-arch1-1-ARCH #1 SMP PREEMPT Thu Oct 4 01:01:27 UTC 2018 x86_64 GNU/Linux

git version 2.19.1

etckeeper Version: 1.18.8


I ran into a strange bug. In the following script the commit at the end will fail with: 

> The following paths are ignored by one of your .gitignore files:
> .etckeeper
> Use -f if you really want to add them.

Note that there is no .gitignore file and no `.etckeeper` file in the repository, there is nothing in .git/exclude. There is no `core.excludesFile`, not locally, global, nor system. There are no userwide or systemwide ignore files. In fact there is not a single text file on my system which matches the regex '^\.etckeeper'. 

Also `git check-ignore .etckeeper` returns exit status 1. Thus I conclude that something isn't right. I don't know where the exclude rule comes from...

It works as expected if the `-a` option is not used on `git commit`.

I have not found any hints in the scripts from the etckeeper package that might explain this.

#------------------------------------------------
#! /usr/bin/bash

rm -rf gitignorebug

mkdir gitignorebug

cd gitignorebug

git init

git config --local user.name  "git bug"
git config --local user.email "git@bug.com"

touch file

git add file

git commit -am"add file"
#---------------------------------------------------

Thank you for looking into it.

```

## Jeff King, 2018-10-10 14:33

Subject: Re: bug when combined with etckeeper
Message-ID: <20181010143333.GA3854@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20181010143333.GA3854%40sigill.intra.peff.net
In-Reply-To: <4d7cddf8-34b3-eaa4-dc9e-e190062e6135@autistici.org>

```
On Wed, Oct 10, 2018 at 09:33:00AM +0000, Naja Melan wrote:

> I ran into a strange bug. In the following script the commit at the end will fail with: 
> 
> > The following paths are ignored by one of your .gitignore files:
> > .etckeeper
> > Use -f if you really want to add them.
> 
> Note that there is no .gitignore file and no `.etckeeper` file in the
> repository, there is nothing in .git/exclude.

That's weird. Do you have any git-related environment variables set? Or
anything in your config that might be pointing git to an alternate
repository or working tree?

Try:

  env | grep GIT

and:

  git config --list --show-origin

-Peff

```

## Joey Hess, 2018-10-10 14:34

Subject: Re: bug when combined with etckeeper
Message-ID: <20181010143427.GA2725@kitenet.net>
URL: https://gitlist.dev/e/20181010143427.GA2725%40kitenet.net
In-Reply-To: <4d7cddf8-34b3-eaa4-dc9e-e190062e6135@autistici.org>

```
/etc/.git/hooks/pre-commit is installed by etckeeper and runs
etckeeper pre-commit, which deals with /etc/.etckeeper, including
running "git add .etckeeper". Why that file would match a gitignore
seems much less important than why git would run that hook in an
entirely different git repository.

       core.hooksPath
           By default Git will look for your hooks in the $GIT_DIR/hooks
           directory. Set this to different path, e.g.  /etc/git/hooks, and Git
           will try to find your hooks in that directory, e.g.
           /etc/git/hooks/pre-receive instead of in $GIT_DIR/hooks/pre-receive.

Hmm, the example "/etc/git/hooks" there is very similar to the
"/etc/.git/hooks" used by etckeeper. So my guess is you have
core.hooksPath set globally.

-- 
see shy jo

```

## Naja Melan, 2018-10-13 12:36

Subject: Re: bug when combined with etckeeper
Message-ID: <d9324f66-6eca-32a9-433a-8732998b30a2@autistici.org>
URL: https://gitlist.dev/e/d9324f66-6eca-32a9-433a-8732998b30a2%40autistici.org
In-Reply-To: <20181010143427.GA2725@kitenet.net>

```
Ok,

my bad. I had a global pre-commit hook which had a lingering etckeeper command for another repository.

Not quite sure why it only runs when commit has the '-a' option...

Thanks for pointing to the hooks possibility.

Naja Melan

```
