# bug: git mv dir with submodule in dir/sub

1 messages from 2015-03-03 to 2015-03-03. Participants: Jason Woofenden.
Thread: https://gitlist.dev/t/38691

## Jason Woofenden, 2015-03-03 15:52

Subject: bug: git mv dir with submodule in dir/sub
Message-ID: <20150303155207.GM30045@compy.jasonwoof.org>
URL: https://gitlist.dev/e/20150303155207.GM30045%40compy.jasonwoof.org

```
Hi all,

First, many thanks for all your work on git. It has been an
invaluable tool.

I believe I've found a bug. Submodules break when I use ``git mv``
to rename a directory, which contains a submodule as one of its
_sub_directories.

Here's the script I've been using to reproduce:

	#!/bin/bash

	# Settings
	REPO_TO_CLONE="$HOME/www/wfpl.git"

	# run in new directory
	export REPODIR="git-bug-$(date '+%s')"
	mkdir "$REPODIR" || exit $?
	cd "$REPODIR" || exit $?

	git --version

	# make a git repo with a submodule
	git init || exit $?
	mkdir old || exit $?
	git submodule add ~/www/wfpl.git old/wfpl || exit $?

	# run the command that borks the submodule
	git mv old new || exit $?

	# demonstrate that it's borked:
	git status || exit $?
	# for me this command produces:
	#     fatal: Could not chdir to '../../../../old/wfpl': No such file or directory
	#     fatal: 'git status --porcelain' failed in submodule new/wfpl

I run that and get this:

	git version 2.3.1.431.g836cf63
	Initialized empty Git repository in
	/home/jasonwoof/git-bug/git-bug-1425397321/.git/
	Cloning into 'old/wfpl'...
	done.
	fatal: Could not chdir to '../../../../old/wfpl': No such file or
	directory
	fatal: 'git status --porcelain' failed in submodule new/wfpl
	zsh: exit 128   ./script.sh

I got this same error (every time) with git-2.1.4-2.1 from debian
unstable, and from github's master (7f4ba4b6e3ba7), and from
github's pu branch (836cf6345)

All of the above running on debian unstable.

You'll need to change REPO_TO_CLONE of course.

It's probably worth noting that if I use ``git mv`` on the
submodule directly, it works fine. eg if I replace the ``git mv``
line in the above script with:

	mkdir new
	git mv old/wfpl new/wfpl

then it works fine (no error messages).


I am not subscribed to this list, so please remember to reply-all
if I can be of further assistance.

Thanks you!

-- 
Jason

```
