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

Re: Files not deleted when merging after a rename

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Jan 23, 2008, 08:19 UTC
Message-ID
<20080123081942.GM14871@dpotapov.dyndns.org>
In-Reply-To
<20080122072825.GA2971@steel.home>
On Tue, Jan 22, 2008 at 08:28:25AM +0100, Alex Riesen wrote:
> 
> Were these subdirectories containing exclusively tracked files?
> Or is it Winblows and some process was blocking the deletion?

The issue is not Windows specific and the problem can be reproduced with different versions of Git including the latest from Git master.

In fact, user B does not have to made any changes, it is enough that merge was not fast-forward. In contrast with fast-forward merge, which just update the references, the recursive merge requires the working directory to perform the merge. Because directories are not trucked, there is no way to tell at the end whether an empty directory was created by user before or it became empty as result of merge.

Probably, the problem can be solved by remembering the list of empty directories before performing a real merge and then, on success, to remove all empty directories that are not in that list.

Here is a script that demonstrates the issue.

=== CUT === #!/bin/sh

set -e rm -rf shared userA userB

mkdir shared
cd shared
git init
mkdir -p foo/bar
for line in Files not deleted when merging after a rename; do
	echo $line; done > foo/bar/testfile
git add foo/bar/testfile
git commit -m 'add foo/bar/testfile'
cd ..

git clone file://$PWD/shared/.git userA git clone file://$PWD/shared/.git userB

cd userA git mv foo/bar bar git commit -m 'mv foo/bar bar' git push cd ..

cd userB echo 'more' >> foo/bar/testfile git commit -a -m 'edit foo/bar/testfile' git pull find *

=== CUT ===
Previous: Alex RiesenNext: Alex Riesen
Message 7 of 8 in “Files not deleted when merging after a rename”
  1. Mark DesnoyerJan 21, 2008
  2. Alex RiesenJan 21, 2008
  3. Mark DesnoyerJan 21, 2008
  4. Alex RiesenJan 22, 2008
  5. Mark DesnoyerJan 23, 2008
  6. Alex RiesenJan 24, 2008
  7. Dmitry PotapovJan 23, 2008
  8. Alex RiesenJan 24, 2008

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.