{"thread":{"id":"33066","subject":"\"git commit\" fails due to spurious file in index","startedAt":"2013-03-04T18:15:36Z","lastAt":"2013-03-05T15:30:29Z","messageCount":5,"participants":["Robert Irelan","Thomas Rast","Torsten Bögershausen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"210582","messageId":"2D9BD788B02ABA478C57929170AF952B7622B5@EXCH-MBX-3.epic.com","threadId":"33066","inReplyTo":null,"subject":"\"git commit\" fails due to spurious file in index","fromName":"Robert Irelan","fromEmail":"rirelan@epic.com","sentAt":"2013-03-04T18:15:36Z","receivedAt":"2013-03-04T18:15:36Z","isPatch":false,"sender":{"key":"rirelan@epic.com","avatar":null},"body":"Hello all:\n\nThis is my first time posting to this mailing list, but it appears to\nme, through a Google search, that this is where you go to report what\nmight be bugs. I'm not sure if this is a bug or not, but it is\nmysterious to me.\n\nMy git repository has this directory structure (I don't know if the file\nnames are necessary or not; only the leaf directories contain files):\n\n    $ tree -ad -I.git\n    .\n    └── admin_scripts\n        ├── integchk\n        │   ├── 2012\n        │   └── 2014\n        ├── jrnadmin\n        │   ├── 2012\n        │   └── 2014\n        └── logarchiver\n            ├── 2012\n            └── 2014\n\n    10 directories\n\nThe last commit in this repo was a rearrangement of the hierarchy\ncarried out using `git mv`.  Before, the directory structure went\n`admin_scripts/version/script_name` instead of\n`admin_scripts/script_name/version`.\n\nNow I'm attempting to some new files that I've already created into the\nrepository, so that the repo now looks like this (`setup/2012`\ncontains files, while `setup/2014` is empty):\n\n    $ tree -ad -I.git\n    .\n    └── admin_scripts\n        ├── integchk\n        │   ├── 2012\n        │   └── 2014\n        ├── jrnadmin\n        │   ├── 2012\n        │   └── 2014\n        ├── logarchiver\n        │   ├── 2012\n        │   └── 2014\n        └── setup\n            ├── 2012\n            └── 2014\n\n    13 directories\n\nNow, when I run 'git add admin_script/setup' to add the new directory to\nthe repo and then try to commit, I receive the following message:\n\n    $ git commit\n    mv: cannot stat `admin_scripts/setup/2012/setup': No such file or directory\n\nThe error message is correct in that `admin_scripts/setup/2012/setup`\ndoes not exist, either as a file or as a directory. However, I'm not\nattempting to add this path at all. Using grep, I've confirmed that the\nonly place this path appears in any of my files is in `.git/index`.\n\nAlso, I can commit to other places in the repository without triggering\nany error. In addition, I can clone the repository to other locations\nand apply the problematic commit manually. This is how I've worked\naround the problem for now, and I've moved the repository that's\nexhibiting problems to another directory and started work on the cloned\ncopy.\n\nWhy is this spurious path appearing in the index? Is it a bug, or a\nsymptom that my repo has been somehow corrupted? Any help would be\ngreatly appreciated.\n\nRobert Irelan | Server Systems | Epic | (608) 271-9000\n"},{"id":"210587","messageId":"87y5e2op9p.fsf@pctrast.inf.ethz.ch","threadId":"33066","inReplyTo":"2D9BD788B02ABA478C57929170AF952B7622B5@EXCH-MBX-3.epic.com","subject":"Re: \"git commit\" fails due to spurious file in index","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2013-03-04T20:58:58Z","receivedAt":"2013-03-04T20:58:58Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Robert Irelan <rirelan@epic.com> writes:\n\n> Now, when I run 'git add admin_script/setup' to add the new directory to\n> the repo and then try to commit, I receive the following message:\n>\n>     $ git commit\n>     mv: cannot stat `admin_scripts/setup/2012/setup': No such file or directory\n>\n> The error message is correct in that `admin_scripts/setup/2012/setup`\n> does not exist, either as a file or as a directory. However, I'm not\n> attempting to add this path at all. Using grep, I've confirmed that the\n> only place this path appears in any of my files is in `.git/index`.\n\nTo me that sounds like the message comes from a commit hook.  Can you\ncheck if you have anything in .git/hooks/, especially pre-commit?\n\nThere really isn't any other good reason why 'git commit' would call\n'mv' (plain mv, not git!).\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"210620","messageId":"5135CBBB.60102@web.de","threadId":"33066","inReplyTo":"2D9BD788B02ABA478C57929170AF952B7622B5@EXCH-MBX-3.epic.com","subject":"Re: \"git commit\" fails due to spurious file in index","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2013-03-05T10:40:59Z","receivedAt":"2013-03-05T10:40:59Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 04.03.13 19:15, Robert Irelan wrote:\n> Hello all:\n> \n> This is my first time posting to this mailing list, but it appears to\n> me, through a Google search, that this is where you go to report what\n> might be bugs. I'm not sure if this is a bug or not, but it is\n> mysterious to me.\n> \n> My git repository has this directory structure (I don't know if the file\n> names are necessary or not; only the leaf directories contain files):\n> \n>     $ tree -ad -I.git\n>     .\n>     └── admin_scripts\n>         ├── integchk\n>         │   ├── 2012\n>         │   └── 2014\n>         ├── jrnadmin\n>         │   ├── 2012\n>         │   └── 2014\n>         └── logarchiver\n>             ├── 2012\n>             └── 2014\n> \n>     10 directories\n> \n> The last commit in this repo was a rearrangement of the hierarchy\n> carried out using `git mv`.  Before, the directory structure went\n> `admin_scripts/version/script_name` instead of\n> `admin_scripts/script_name/version`.\n> \n> Now I'm attempting to some new files that I've already created into the\n> repository, so that the repo now looks like this (`setup/2012`\n> contains files, while `setup/2014` is empty):\n> \n>     $ tree -ad -I.git\n>     .\n>     └── admin_scripts\n>         ├── integchk\n>         │   ├── 2012\n>         │   └── 2014\n>         ├── jrnadmin\n>         │   ├── 2012\n>         │   └── 2014\n>         ├── logarchiver\n>         │   ├── 2012\n>         │   └── 2014\n>         └── setup\n>             ├── 2012\n>             └── 2014\n> \n>     13 directories\n> \n> Now, when I run 'git add admin_script/setup' to add the new directory to\n> the repo and then try to commit, I receive the following message:\n> \n>     $ git commit\n>     mv: cannot stat `admin_scripts/setup/2012/setup': No such file or directory\n> \n> The error message is correct in that `admin_scripts/setup/2012/setup`\n> does not exist, either as a file or as a directory. However, I'm not\n> attempting to add this path at all. Using grep, I've confirmed that the\n> only place this path appears in any of my files is in `.git/index`.\n> \n> Also, I can commit to other places in the repository without triggering\n> any error. In addition, I can clone the repository to other locations\n> and apply the problematic commit manually. This is how I've worked\n> around the problem for now, and I've moved the repository that's\n> exhibiting problems to another directory and started work on the cloned\n> copy.\n> \n> Why is this spurious path appearing in the index? Is it a bug, or a\n> symptom that my repo has been somehow corrupted? Any help would be\n> greatly appreciated.\n> \n> Robert Irelan | Server Systems | Epic | (608) 271-9000\nYou have come to the right group.\nIt might be difficult to tell (at least for me) if there is a bug or a corruption,\nMay be some tests could help to bring more light into the darkness:\n\nWhat does \"git status\" (in the problematic repo) tell you?\nWhat does \"git fsck\" (in the problematic repo) tell you?\nWhat does \"git ls-files\" (in both repos) tell you?\n\n/Torsten\n"},{"id":"210628","messageId":"2D9BD788B02ABA478C57929170AF952B7637B5@EXCH-MBX-3.epic.com","threadId":"33066","inReplyTo":"87y5e2op9p.fsf@pctrast.inf.ethz.ch","subject":"RE: \"git commit\" fails due to spurious file in index","fromName":"Robert Irelan","fromEmail":"rirelan@epic.com","sentAt":"2013-03-05T15:30:04Z","receivedAt":"2013-03-05T15:30:04Z","isPatch":false,"sender":{"key":"rirelan@epic.com","avatar":null},"body":"Yes, you're correct, it was a bug in my pre-commit hook. Thanks!\n\nFor posterity, the issue is that I had the following line:\n\n    git diff -z --cached --name-only | egrep -z '\\.(pl|pm|t)$' | \\\n            while read -d'' -r f; do ...\n\nIn Bash, when `read` is passed the `-d` option with a zero-length\nstring argument, read will split on null characters (`'\\0'`). However,\nI did not put a space between the `-d` option and the argument, so\nit took the `-` in the next argument `-r` as the delimiter. My commit\nincludes Perl files with `-` characters in the name, which I had not\npreviously committed to this repo, which is why I only ran into the\nproblem now. I fixed it by changing the read command to\n`read -r -d '' f`, which now has the crucial space between -d and\nits argument, making the zero-length string a separate argument.\n\nRobert Irelan | Server Systems | Epic | (608) 271-9000\n\n\n-----Original Message-----\nFrom: Thomas Rast [mailto:trast@student.ethz.ch] \nSent: Monday, March 04, 2013 2:59 PM\nTo: Robert Irelan\nCc: git@vger.kernel.org\nSubject: Re: \"git commit\" fails due to spurious file in index\n\nRobert Irelan <rirelan@epic.com> writes:\n\n> Now, when I run 'git add admin_script/setup' to add the new directory \n> to the repo and then try to commit, I receive the following message:\n>\n>     $ git commit\n>     mv: cannot stat `admin_scripts/setup/2012/setup': No such file or \n> directory\n>\n> The error message is correct in that `admin_scripts/setup/2012/setup` \n> does not exist, either as a file or as a directory. However, I'm not \n> attempting to add this path at all. Using grep, I've confirmed that \n> the only place this path appears in any of my files is in `.git/index`.\n\nTo me that sounds like the message comes from a commit hook.  Can you check if you have anything in .git/hooks/, especially pre-commit?\n\nThere really isn't any other good reason why 'git commit' would call 'mv' (plain mv, not git!).\n\n--\nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"210629","messageId":"2D9BD788B02ABA478C57929170AF952B7637BC@EXCH-MBX-3.epic.com","threadId":"33066","inReplyTo":"5135CBBB.60102@web.de","subject":"RE: \"git commit\" fails due to spurious file in index","fromName":"Robert Irelan","fromEmail":"rirelan@epic.com","sentAt":"2013-03-05T15:30:29Z","receivedAt":"2013-03-05T15:30:29Z","isPatch":false,"sender":{"key":"rirelan@epic.com","avatar":null},"body":"Nope, it was a bug in my pre-commit hook. See the other response to this message.\n\nRobert Irelan | Server Systems | Epic | (608) 271-9000\n\n\n-----Original Message-----\nFrom: Torsten Bögershausen [mailto:tboegi@web.de] \nSent: Tuesday, March 05, 2013 4:41 AM\nTo: Robert Irelan\nCc: git@vger.kernel.org\nSubject: Re: \"git commit\" fails due to spurious file in index\n\nOn 04.03.13 19:15, Robert Irelan wrote:\n> Hello all:\n> \n> This is my first time posting to this mailing list, but it appears to \n> me, through a Google search, that this is where you go to report what \n> might be bugs. I'm not sure if this is a bug or not, but it is \n> mysterious to me.\n> \n> My git repository has this directory structure (I don't know if the \n> file names are necessary or not; only the leaf directories contain files):\n> \n>     $ tree -ad -I.git\n>     .\n>     └── admin_scripts\n>         ├── integchk\n>         │   ├── 2012\n>         │   └── 2014\n>         ├── jrnadmin\n>         │   ├── 2012\n>         │   └── 2014\n>         └── logarchiver\n>             ├── 2012\n>             └── 2014\n> \n>     10 directories\n> \n> The last commit in this repo was a rearrangement of the hierarchy \n> carried out using `git mv`.  Before, the directory structure went \n> `admin_scripts/version/script_name` instead of \n> `admin_scripts/script_name/version`.\n> \n> Now I'm attempting to some new files that I've already created into \n> the repository, so that the repo now looks like this (`setup/2012` \n> contains files, while `setup/2014` is empty):\n> \n>     $ tree -ad -I.git\n>     .\n>     └── admin_scripts\n>         ├── integchk\n>         │   ├── 2012\n>         │   └── 2014\n>         ├── jrnadmin\n>         │   ├── 2012\n>         │   └── 2014\n>         ├── logarchiver\n>         │   ├── 2012\n>         │   └── 2014\n>         └── setup\n>             ├── 2012\n>             └── 2014\n> \n>     13 directories\n> \n> Now, when I run 'git add admin_script/setup' to add the new directory \n> to the repo and then try to commit, I receive the following message:\n> \n>     $ git commit\n>     mv: cannot stat `admin_scripts/setup/2012/setup': No such file or \n> directory\n> \n> The error message is correct in that `admin_scripts/setup/2012/setup` \n> does not exist, either as a file or as a directory. However, I'm not \n> attempting to add this path at all. Using grep, I've confirmed that \n> the only place this path appears in any of my files is in `.git/index`.\n> \n> Also, I can commit to other places in the repository without \n> triggering any error. In addition, I can clone the repository to other \n> locations and apply the problematic commit manually. This is how I've \n> worked around the problem for now, and I've moved the repository \n> that's exhibiting problems to another directory and started work on \n> the cloned copy.\n> \n> Why is this spurious path appearing in the index? Is it a bug, or a \n> symptom that my repo has been somehow corrupted? Any help would be \n> greatly appreciated.\n> \n> Robert Irelan | Server Systems | Epic | (608) 271-9000\nYou have come to the right group.\nIt 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:\n\nWhat does \"git status\" (in the problematic repo) tell you?\nWhat does \"git fsck\" (in the problematic repo) tell you?\nWhat does \"git ls-files\" (in both repos) tell you?\n\n/Torsten\n\n\n\n"}]}