{"thread":{"id":"11696","subject":"Files not deleted when merging after a rename","startedAt":"2008-01-21T19:45:07Z","lastAt":"2008-01-24T07:56:38Z","messageCount":8,"participants":["Mark Desnoyer","Alex Riesen","Dmitry Potapov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"66176","messageId":"d997e2110801211145o5fe0a1bbpb1e32dd71b70568e@mail.gmail.com","threadId":"11696","inReplyTo":null,"subject":"Files not deleted when merging after a rename","fromName":"Mark Desnoyer","fromEmail":"mdesnoyer@gmail.com","sentAt":"2008-01-21T19:45:07Z","receivedAt":"2008-01-21T19:45:07Z","isPatch":false,"sender":{"key":"mdesnoyer@gmail.com","avatar":null},"body":"Hi,\n\nI've run across a small problem and I was wondering if I could get\nsome help. I have two users A and B. They are both git-cloned from a\ncommon repository on a different server.\n\nUser A moves a directory:\nfoo/bar/ ==> bar\nusing:\ngit mv foo/bar bar\ngit commit\ngit push\n\nMeanwhile, user B is doing some other changes that are completely\nunrelated and has a few local commits. Now, when user B pulls from the\nrepository (git pull), and returns no errors merging, the directory\n\"bar\" is created, but \"foo/bar\" is not deleted, although, it becomes\nuntracked.\n\nAny ideas why the merge isn't deleting foo/bar? The users are using\ngit version 1.5.2.5 in Ubuntu Hoary. Thanks in advance.\n\n-Mark\n"},{"id":"66202","messageId":"20080121212015.GB5263@steel.home","threadId":"11696","inReplyTo":"d997e2110801211145o5fe0a1bbpb1e32dd71b70568e@mail.gmail.com","subject":"Re: Files not deleted when merging after a rename","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-01-21T21:20:15Z","receivedAt":"2008-01-21T21:20:15Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Mark Desnoyer, Mon, Jan 21, 2008 20:45:07 +0100:\n> Hi,\n> \n> I've run across a small problem and I was wondering if I could get\n> some help. I have two users A and B. They are both git-cloned from a\n> common repository on a different server.\n> \n> User A moves a directory:\n> foo/bar/ ==> bar\n> using:\n> git mv foo/bar bar\n> git commit\n> git push\n> \n> Meanwhile, user B is doing some other changes that are completely\n> unrelated and has a few local commits. Now, when user B pulls from the\n> repository (git pull), and returns no errors merging, the directory\n> \"bar\" is created, but \"foo/bar\" is not deleted, although, it becomes\n> untracked.\n\nDirectories are never tracked. It should have been deleted though.\nDid it have (or still has) some untracked files in it?\n"},{"id":"66210","messageId":"d997e2110801211345x6ee35d48s2038fbd773149110@mail.gmail.com","threadId":"11696","inReplyTo":"20080121212015.GB5263@steel.home","subject":"Re: Files not deleted when merging after a rename","fromName":"Mark Desnoyer","fromEmail":"mdesnoyer@gmail.com","sentAt":"2008-01-21T21:45:40Z","receivedAt":"2008-01-21T21:45:40Z","isPatch":false,"sender":{"key":"mdesnoyer@gmail.com","avatar":null},"body":"Alex,\n\nThe directory did not have any untracked files in it. Looking a little\nmore carefully, I realized that there were subdirectories in foo/bar/.\nAll the files in foo/bar and its subdirectories were deleted\ncorrectly, but the actual directory structure still exists.\n\n-Mark\n\nOn Jan 21, 2008 4:20 PM, Alex Riesen <raa.lkml@gmail.com> wrote:\n> Mark Desnoyer, Mon, Jan 21, 2008 20:45:07 +0100:\n>\n> > Hi,\n> >\n> > I've run across a small problem and I was wondering if I could get\n> > some help. I have two users A and B. They are both git-cloned from a\n> > common repository on a different server.\n> >\n> > User A moves a directory:\n> > foo/bar/ ==> bar\n> > using:\n> > git mv foo/bar bar\n> > git commit\n> > git push\n> >\n> > Meanwhile, user B is doing some other changes that are completely\n> > unrelated and has a few local commits. Now, when user B pulls from the\n> > repository (git pull), and returns no errors merging, the directory\n> > \"bar\" is created, but \"foo/bar\" is not deleted, although, it becomes\n> > untracked.\n>\n> Directories are never tracked. It should have been deleted though.\n> Did it have (or still has) some untracked files in it?\n>\n>\n"},{"id":"66282","messageId":"20080122072825.GA2971@steel.home","threadId":"11696","inReplyTo":"d997e2110801211345x6ee35d48s2038fbd773149110@mail.gmail.com","subject":"Re: Files not deleted when merging after a rename","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-01-22T07:28:25Z","receivedAt":"2008-01-22T07:28:25Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Mark Desnoyer, Mon, Jan 21, 2008 22:45:40 +0100:\n> Alex,\n> \n> The directory did not have any untracked files in it. Looking a little\n> more carefully, I realized that there were subdirectories in foo/bar/.\n\nWere these subdirectories containing exclusively tracked files?\nOr is it Winblows and some process was blocking the deletion?\n"},{"id":"66350","messageId":"d997e2110801221808r22f19ec9qc1c452e13c7698df@mail.gmail.com","threadId":"11696","inReplyTo":"20080122072825.GA2971@steel.home","subject":"Re: Files not deleted when merging after a rename","fromName":"Mark Desnoyer","fromEmail":"mdesnoyer@gmail.com","sentAt":"2008-01-23T02:08:21Z","receivedAt":"2008-01-23T02:08:21Z","isPatch":false,"sender":{"key":"mdesnoyer@gmail.com","avatar":null},"body":"Definitely not Winblows. I try to avoid it even with a 10ft pole. I'm\nrunning Ubuntu 7.10.\n\nCould you define \"exclusively tracked files\"? I'm not sure what you mean here.\n\n-Mark\n\nOn Jan 22, 2008 2:28 AM, Alex Riesen <raa.lkml@gmail.com> wrote:\n> Mark Desnoyer, Mon, Jan 21, 2008 22:45:40 +0100:\n> > Alex,\n> >\n> > The directory did not have any untracked files in it. Looking a little\n> > more carefully, I realized that there were subdirectories in foo/bar/.\n>\n> Were these subdirectories containing exclusively tracked files?\n> Or is it Winblows and some process was blocking the deletion?\n>\n>\n"},{"id":"66377","messageId":"20080123081942.GM14871@dpotapov.dyndns.org","threadId":"11696","inReplyTo":"20080122072825.GA2971@steel.home","subject":"Re: Files not deleted when merging after a rename","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-01-23T08:19:42Z","receivedAt":"2008-01-23T08:19:42Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Tue, Jan 22, 2008 at 08:28:25AM +0100, Alex Riesen wrote:\n> \n> Were these subdirectories containing exclusively tracked files?\n> Or is it Winblows and some process was blocking the deletion?\n\nThe issue is not Windows specific and the problem can be reproduced\nwith different versions of Git including the latest from Git master.\n\nIn fact, user B does not have to made any changes, it is enough that\nmerge was not fast-forward. In contrast with fast-forward merge, which\njust update the references, the recursive merge requires the working\ndirectory to perform the merge. Because directories are not trucked,\nthere is no way to tell at the end whether an empty directory was\ncreated by user before or it became empty as result of merge.\n\nProbably, the problem can be solved by remembering the list of empty\ndirectories before performing a real merge and then, on success, to\nremove all empty directories that are not in that list.\n\nHere is a script that demonstrates the issue.\n\n=== CUT ===\n#!/bin/sh\n\nset -e\nrm -rf shared userA userB\n\nmkdir shared\ncd shared\ngit init\nmkdir -p foo/bar\nfor line in Files not deleted when merging after a rename; do\n\techo $line; done > foo/bar/testfile\ngit add foo/bar/testfile\ngit commit -m 'add foo/bar/testfile'\ncd ..\n\ngit clone file://$PWD/shared/.git userA\ngit clone file://$PWD/shared/.git userB\n\ncd userA\ngit mv foo/bar bar\ngit commit -m 'mv foo/bar bar'\ngit push\ncd ..\n\ncd userB\necho 'more' >> foo/bar/testfile\ngit commit -a -m 'edit foo/bar/testfile'\ngit pull\nfind *\n\n=== CUT ===\n"},{"id":"66454","messageId":"20080124075202.GB3193@steel.home","threadId":"11696","inReplyTo":"d997e2110801221808r22f19ec9qc1c452e13c7698df@mail.gmail.com","subject":"Re: Files not deleted when merging after a rename","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-01-24T07:52:02Z","receivedAt":"2008-01-24T07:52:02Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Mark Desnoyer, Wed, Jan 23, 2008 03:08:21 +0100:\n> Definitely not Winblows. I try to avoid it even with a 10ft pole. I'm\n> running Ubuntu 7.10.\n\nAnything mounted in?\n\n> Could you define \"exclusively tracked files\"? I'm not sure what you mean here.\n\nI asked if the directories contained something else besides the files\nknown to git.\n"},{"id":"66456","messageId":"20080124075638.GC3193@steel.home","threadId":"11696","inReplyTo":"20080123081942.GM14871@dpotapov.dyndns.org","subject":"Re: Files not deleted when merging after a rename","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-01-24T07:56:38Z","receivedAt":"2008-01-24T07:56:38Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Dmitry Potapov, Wed, Jan 23, 2008 09:19:42 +0100:\n> On Tue, Jan 22, 2008 at 08:28:25AM +0100, Alex Riesen wrote:\n> > \n> > Were these subdirectories containing exclusively tracked files?\n> > Or is it Winblows and some process was blocking the deletion?\n> \n> The issue is not Windows specific and the problem can be reproduced\n> with different versions of Git including the latest from Git master.\n> \n> In fact, user B does not have to made any changes, it is enough that\n> merge was not fast-forward. In contrast with fast-forward merge, which\n> just update the references, the recursive merge requires the working\n> directory to perform the merge. Because directories are not trucked,\n> there is no way to tell at the end whether an empty directory was\n> created by user before or it became empty as result of merge.\n\nRight. I extended Cc a bit, to remind of the problem\n\n> Probably, the problem can be solved by remembering the list of empty\n> directories before performing a real merge and then, on success, to\n> remove all empty directories that are not in that list.\n\nProbably. It is all in merge-recursive.c\n"}]}