fatal: Unable to create '.../repo1/sub/.git/index.lock.lock': No such file or directory

596 views
Skip to first unread message

szak...@gmail.com

unread,
Dec 9, 2013, 5:58:49 AM12/9/13
to msy...@googlegroups.com
Hello msysGit,

I'm trying to create a pre-commit hook which does a merge in a submodule when there is a merge commit in the parent repository but I get the error mentioned in the title. Indeed that file doesn't exist since it's a submodule and .git is a file instead of a directory and it's also strange that it looks for index.lock.lock instead of index.lock. The same merge works fine from the console. The error should be reproducible by running https://gist.github.com/lbf1/7869711 . For me it prints https://gist.github.com/lbf1/7869702 with both 1.7.11.msysgit.1 and
1.8.4.msysgit.0 . I'm posting this here since someone with 1.8.4.2 (not msysGit) did not get the error.
Any idea what the problem might be ?

Thanks !
Istvan

Heiko Voigt

unread,
Dec 9, 2013, 6:25:31 PM12/9/13
to szak...@gmail.com, msy...@googlegroups.com
On Mon, Dec 09, 2013 at 02:58:49AM -0800, szak...@gmail.com wrote:
> Hello msysGit,
>
> I'm trying to create a pre-commit hook which does a merge in a submodule
> when there is a merge commit in the parent repository but I get the error
> mentioned in the title. Indeed that file doesn't exist since it's a
> submodule and .git is a file instead of a directory and it's also strange
> that it looks for index.lock.lock instead of index.lock. The same merge
> works fine from the console. The error should be reproducible by running
> https://gist.github.com/lbf1/7869711 . For me it prints
> https://gist.github.com/lbf1/7869702 with both 1.7.11.msysgit.1 and1.8.4.msysgit.0 . I'm posting this here since someone with 1.8.4.2 (not
> msysGit) did not get the error.
> Any idea what the problem might be ?

That .git is a file that is like a link that points to the real .git
directory. Since on systems like windows there are no real links git had
to implement its own format.

When a hook is run it sets up some environment variables that seem to
disturb what you want to achieve. Git should actually resolve those .git
files but it seems that in your case it does not do that correctly.

I have attached your pre-commit hook with a small change that seems to
circumvent that problem by resetting the variables in question. I left
the set in there for demonstration purposes.

Hope that helps.

Cheers Heiko


----8<-------
#!/bin/sh

#only for merge commits
if [ -e .git/MERGE_HEAD ]; then
echo pre-commit
#git submodule update --merge

merge_head=`cat .git/MERGE_HEAD`
merge_sub=`git rev-parse $merge_head:sub`

(cd sub
export GIT_TRACE=1
set
unset GIT_DIR
unset GIT_INDEX_FILE
git merge $merge_sub
)
ret=$?
if [ "$ret" != "0" ]; then
echo submodule merge failed
exit $ret
fi

git add sub
fi

szak...@gmail.com

unread,
Dec 11, 2013, 9:03:20 AM12/11/13
to msy...@googlegroups.com, szak...@gmail.com
Thank you !! :)

It works fine now.

Best regards,
Istvan
Reply all
Reply to author
Forward
0 new messages