git/list[1] front-page[2] threads[3] people[4] search[5] about
 

bug: git mv dir with submodule in dir/sub

From
JWJason Woofenden <jason@jasonwoof.com>
Date
Mar 3, 2015, 15:52 UTC
Message-ID
<20150303155207.GM30045@compy.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
Message 1 of 1 in “bug: git mv dir with submodule in dir/sub”
  1. Jason WoofendenMar 3, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.