* "git commit" fails due to spurious file in index
@ 2013-03-04 18:15 Robert Irelan
2013-03-04 20:58 ` Thomas Rast
2013-03-05 10:40 ` Torsten Bögershausen
0 siblings, 2 replies; 5+ messages in thread
From: Robert Irelan @ 2013-03-04 18:15 UTC (permalink / raw)
To: git@vger.kernel.org
Hello all:
This is my first time posting to this mailing list, but it appears to
me, through a Google search, that this is where you go to report what
might be bugs. I'm not sure if this is a bug or not, but it is
mysterious to me.
My git repository has this directory structure (I don't know if the file
names are necessary or not; only the leaf directories contain files):
$ tree -ad -I.git
.
└── admin_scripts
├── integchk
│ ├── 2012
│ └── 2014
├── jrnadmin
│ ├── 2012
│ └── 2014
└── logarchiver
├── 2012
└── 2014
10 directories
The last commit in this repo was a rearrangement of the hierarchy
carried out using `git mv`. Before, the directory structure went
`admin_scripts/version/script_name` instead of
`admin_scripts/script_name/version`.
Now I'm attempting to some new files that I've already created into the
repository, so that the repo now looks like this (`setup/2012`
contains files, while `setup/2014` is empty):
$ tree -ad -I.git
.
└── admin_scripts
├── integchk
│ ├── 2012
│ └── 2014
├── jrnadmin
│ ├── 2012
│ └── 2014
├── logarchiver
│ ├── 2012
│ └── 2014
└── setup
├── 2012
└── 2014
13 directories
Now, when I run 'git add admin_script/setup' to add the new directory to
the repo and then try to commit, I receive the following message:
$ git commit
mv: cannot stat `admin_scripts/setup/2012/setup': No such file or directory
The error message is correct in that `admin_scripts/setup/2012/setup`
does not exist, either as a file or as a directory. However, I'm not
attempting to add this path at all. Using grep, I've confirmed that the
only place this path appears in any of my files is in `.git/index`.
Also, I can commit to other places in the repository without triggering
any error. In addition, I can clone the repository to other locations
and apply the problematic commit manually. This is how I've worked
around the problem for now, and I've moved the repository that's
exhibiting problems to another directory and started work on the cloned
copy.
Why is this spurious path appearing in the index? Is it a bug, or a
symptom that my repo has been somehow corrupted? Any help would be
greatly appreciated.
Robert Irelan | Server Systems | Epic | (608) 271-9000
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "git commit" fails due to spurious file in index
2013-03-04 18:15 "git commit" fails due to spurious file in index Robert Irelan
@ 2013-03-04 20:58 ` Thomas Rast
2013-03-05 15:30 ` Robert Irelan
2013-03-05 10:40 ` Torsten Bögershausen
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Rast @ 2013-03-04 20:58 UTC (permalink / raw)
To: Robert Irelan; +Cc: git@vger.kernel.org
Robert Irelan <rirelan@epic.com> writes:
> Now, when I run 'git add admin_script/setup' to add the new directory to
> the repo and then try to commit, I receive the following message:
>
> $ git commit
> mv: cannot stat `admin_scripts/setup/2012/setup': No such file or directory
>
> The error message is correct in that `admin_scripts/setup/2012/setup`
> does not exist, either as a file or as a directory. However, I'm not
> attempting to add this path at all. Using grep, I've confirmed that the
> only place this path appears in any of my files is in `.git/index`.
To me that sounds like the message comes from a commit hook. Can you
check if you have anything in .git/hooks/, especially pre-commit?
There really isn't any other good reason why 'git commit' would call
'mv' (plain mv, not git!).
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "git commit" fails due to spurious file in index
2013-03-04 18:15 "git commit" fails due to spurious file in index Robert Irelan
2013-03-04 20:58 ` Thomas Rast
@ 2013-03-05 10:40 ` Torsten Bögershausen
2013-03-05 15:30 ` Robert Irelan
1 sibling, 1 reply; 5+ messages in thread
From: Torsten Bögershausen @ 2013-03-05 10:40 UTC (permalink / raw)
To: Robert Irelan; +Cc: git@vger.kernel.org
On 04.03.13 19:15, Robert Irelan wrote:
> Hello all:
>
> This is my first time posting to this mailing list, but it appears to
> me, through a Google search, that this is where you go to report what
> might be bugs. I'm not sure if this is a bug or not, but it is
> mysterious to me.
>
> My git repository has this directory structure (I don't know if the file
> names are necessary or not; only the leaf directories contain files):
>
> $ tree -ad -I.git
> .
> └── admin_scripts
> ├── integchk
> │ ├── 2012
> │ └── 2014
> ├── jrnadmin
> │ ├── 2012
> │ └── 2014
> └── logarchiver
> ├── 2012
> └── 2014
>
> 10 directories
>
> The last commit in this repo was a rearrangement of the hierarchy
> carried out using `git mv`. Before, the directory structure went
> `admin_scripts/version/script_name` instead of
> `admin_scripts/script_name/version`.
>
> Now I'm attempting to some new files that I've already created into the
> repository, so that the repo now looks like this (`setup/2012`
> contains files, while `setup/2014` is empty):
>
> $ tree -ad -I.git
> .
> └── admin_scripts
> ├── integchk
> │ ├── 2012
> │ └── 2014
> ├── jrnadmin
> │ ├── 2012
> │ └── 2014
> ├── logarchiver
> │ ├── 2012
> │ └── 2014
> └── setup
> ├── 2012
> └── 2014
>
> 13 directories
>
> Now, when I run 'git add admin_script/setup' to add the new directory to
> the repo and then try to commit, I receive the following message:
>
> $ git commit
> mv: cannot stat `admin_scripts/setup/2012/setup': No such file or directory
>
> The error message is correct in that `admin_scripts/setup/2012/setup`
> does not exist, either as a file or as a directory. However, I'm not
> attempting to add this path at all. Using grep, I've confirmed that the
> only place this path appears in any of my files is in `.git/index`.
>
> Also, I can commit to other places in the repository without triggering
> any error. In addition, I can clone the repository to other locations
> and apply the problematic commit manually. This is how I've worked
> around the problem for now, and I've moved the repository that's
> exhibiting problems to another directory and started work on the cloned
> copy.
>
> Why is this spurious path appearing in the index? Is it a bug, or a
> symptom that my repo has been somehow corrupted? Any help would be
> greatly appreciated.
>
> Robert Irelan | Server Systems | Epic | (608) 271-9000
You have come to the right group.
It might be difficult to tell (at least for me) if there is a bug or a corruption,
May be some tests could help to bring more light into the darkness:
What does "git status" (in the problematic repo) tell you?
What does "git fsck" (in the problematic repo) tell you?
What does "git ls-files" (in both repos) tell you?
/Torsten
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: "git commit" fails due to spurious file in index
2013-03-04 20:58 ` Thomas Rast
@ 2013-03-05 15:30 ` Robert Irelan
0 siblings, 0 replies; 5+ messages in thread
From: Robert Irelan @ 2013-03-05 15:30 UTC (permalink / raw)
To: Thomas Rast; +Cc: git@vger.kernel.org
Yes, you're correct, it was a bug in my pre-commit hook. Thanks!
For posterity, the issue is that I had the following line:
git diff -z --cached --name-only | egrep -z '\.(pl|pm|t)$' | \
while read -d'' -r f; do ...
In Bash, when `read` is passed the `-d` option with a zero-length
string argument, read will split on null characters (`'\0'`). However,
I did not put a space between the `-d` option and the argument, so
it took the `-` in the next argument `-r` as the delimiter. My commit
includes Perl files with `-` characters in the name, which I had not
previously committed to this repo, which is why I only ran into the
problem now. I fixed it by changing the read command to
`read -r -d '' f`, which now has the crucial space between -d and
its argument, making the zero-length string a separate argument.
Robert Irelan | Server Systems | Epic | (608) 271-9000
-----Original Message-----
From: Thomas Rast [mailto:trast@student.ethz.ch]
Sent: Monday, March 04, 2013 2:59 PM
To: Robert Irelan
Cc: git@vger.kernel.org
Subject: Re: "git commit" fails due to spurious file in index
Robert Irelan <rirelan@epic.com> writes:
> Now, when I run 'git add admin_script/setup' to add the new directory
> to the repo and then try to commit, I receive the following message:
>
> $ git commit
> mv: cannot stat `admin_scripts/setup/2012/setup': No such file or
> directory
>
> The error message is correct in that `admin_scripts/setup/2012/setup`
> does not exist, either as a file or as a directory. However, I'm not
> attempting to add this path at all. Using grep, I've confirmed that
> the only place this path appears in any of my files is in `.git/index`.
To me that sounds like the message comes from a commit hook. Can you check if you have anything in .git/hooks/, especially pre-commit?
There really isn't any other good reason why 'git commit' would call 'mv' (plain mv, not git!).
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: "git commit" fails due to spurious file in index
2013-03-05 10:40 ` Torsten Bögershausen
@ 2013-03-05 15:30 ` Robert Irelan
0 siblings, 0 replies; 5+ messages in thread
From: Robert Irelan @ 2013-03-05 15:30 UTC (permalink / raw)
To: Torsten Bögershausen; +Cc: git@vger.kernel.org
Nope, it was a bug in my pre-commit hook. See the other response to this message.
Robert Irelan | Server Systems | Epic | (608) 271-9000
-----Original Message-----
From: Torsten Bögershausen [mailto:tboegi@web.de]
Sent: Tuesday, March 05, 2013 4:41 AM
To: Robert Irelan
Cc: git@vger.kernel.org
Subject: Re: "git commit" fails due to spurious file in index
On 04.03.13 19:15, Robert Irelan wrote:
> Hello all:
>
> This is my first time posting to this mailing list, but it appears to
> me, through a Google search, that this is where you go to report what
> might be bugs. I'm not sure if this is a bug or not, but it is
> mysterious to me.
>
> My git repository has this directory structure (I don't know if the
> file names are necessary or not; only the leaf directories contain files):
>
> $ tree -ad -I.git
> .
> └── admin_scripts
> ├── integchk
> │ ├── 2012
> │ └── 2014
> ├── jrnadmin
> │ ├── 2012
> │ └── 2014
> └── logarchiver
> ├── 2012
> └── 2014
>
> 10 directories
>
> The last commit in this repo was a rearrangement of the hierarchy
> carried out using `git mv`. Before, the directory structure went
> `admin_scripts/version/script_name` instead of
> `admin_scripts/script_name/version`.
>
> Now I'm attempting to some new files that I've already created into
> the repository, so that the repo now looks like this (`setup/2012`
> contains files, while `setup/2014` is empty):
>
> $ tree -ad -I.git
> .
> └── admin_scripts
> ├── integchk
> │ ├── 2012
> │ └── 2014
> ├── jrnadmin
> │ ├── 2012
> │ └── 2014
> ├── logarchiver
> │ ├── 2012
> │ └── 2014
> └── setup
> ├── 2012
> └── 2014
>
> 13 directories
>
> Now, when I run 'git add admin_script/setup' to add the new directory
> to the repo and then try to commit, I receive the following message:
>
> $ git commit
> mv: cannot stat `admin_scripts/setup/2012/setup': No such file or
> directory
>
> The error message is correct in that `admin_scripts/setup/2012/setup`
> does not exist, either as a file or as a directory. However, I'm not
> attempting to add this path at all. Using grep, I've confirmed that
> the only place this path appears in any of my files is in `.git/index`.
>
> Also, I can commit to other places in the repository without
> triggering any error. In addition, I can clone the repository to other
> locations and apply the problematic commit manually. This is how I've
> worked around the problem for now, and I've moved the repository
> that's exhibiting problems to another directory and started work on
> the cloned copy.
>
> Why is this spurious path appearing in the index? Is it a bug, or a
> symptom that my repo has been somehow corrupted? Any help would be
> greatly appreciated.
>
> Robert Irelan | Server Systems | Epic | (608) 271-9000
You have come to the right group.
It might be difficult to tell (at least for me) if there is a bug or a corruption, May be some tests could help to bring more light into the darkness:
What does "git status" (in the problematic repo) tell you?
What does "git fsck" (in the problematic repo) tell you?
What does "git ls-files" (in both repos) tell you?
/Torsten
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-05 15:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-04 18:15 "git commit" fails due to spurious file in index Robert Irelan
2013-03-04 20:58 ` Thomas Rast
2013-03-05 15:30 ` Robert Irelan
2013-03-05 10:40 ` Torsten Bögershausen
2013-03-05 15:30 ` Robert Irelan
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).