{"thread":{"id":"2604","subject":"Re: please pull powerpc-merge.git","startedAt":"2005-11-19T18:24:14Z","lastAt":"2005-11-21T14:22:59Z","messageCount":8,"participants":["Linus Torvalds","Junio C Hamano","Fredrik Kuivinen","H. Peter Anvin","Johannes Schindelin","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"12337","messageId":"Pine.LNX.4.64.0511190957320.13959@g5.osdl.org","threadId":"2604","inReplyTo":"20051119140736.GA24901@lst.de","subject":"Re: please pull powerpc-merge.git","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-19T18:24:14Z","receivedAt":"2005-11-19T18:24:14Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\n[ Junio, Fredrik, you're cc'd because the \"merge-one-file\" logic doesn't \n  clean up empty directories after removing a file in merge ]\n\nOn Sat, 19 Nov 2005, Christoph Hellwig wrote:\n> \n> Btw, in current Linus' tree arch/ppc64/ contains various empty\n> directories, anyone care to git rm -r arch/ppc64 (and include/asm-ppc64\n> now) ?\n\nActually, a git tree can never contain an empty subdirectory (well, it \ntechnically _can_, but it really shouldn't - the index only tracks \n_files_, and directories in git are created only as needed to contain \nthose files. An empty directory tree - while technically possible in a \ndata structure sense - would be a bug in git if git ever created one).\n\nSo when you say \"in current Linus' tree\", I suspect that in my tree it \nvery much does not, but in _your_ tree the stale directories still exist \nbecause \"git pull\" just hasn't removed them.\n\nIt's a git bug/misfeature: git does not remove directories when the last \nfile in it has been removed, simply because git doesn't actually really \neven _track_ directories at all. It only tracks files that just happen to \nbe in directories.\n\n[ Side note: this is not strictly true: git _will_ actually remove \n  directories that become empty when you switch between different branches \n  with \"git checkout\". However, even then it will not actually ever remove \n  a directory that contains any non-tracked files, so if you have old \n  object files etc, git will never remove that directory even if all the \n  tracked files got removed. ]\n\nThe reason I say \"bug/misfeature\" and not outright \"bug\" is the fact that \nremoving directories is not something that git can really always do. \nExactly because directories are often used for things that aren't tracked. \nShould it just remove old object files? Hell no. Stuff git doesn't know \nabout (even if they have been marked in \".gitignore\") it definitely \nshouldn't touch.\n\nSo in general, after you've merged somebody elses tree, the final pruning \nof your own old checked-out directories is really up to you.\n\nBut I agree that git should maybe at least _tell_ people about \"there's a \ndirectory there that I'm not tracking\". And it could perhaps remove the \nempty ones outright a bit more aggressively (ie now it effectively does it \nonly for \"git checkout\" and for the _trivial_ cases of merges that happen \nwith \"git pull\", but it doesn't do it if the merge ended up being of the \nmore involved case that needed higher-level - but still automatic - help).\n\nFrederik - I don't do perl, but I think for the recursive merge strategy, \nit's the \"removeFile()\" thing. And for the old git-merge-one-file.sh, it's \nthat \"deleted in both or deleted in one and unchanged in the other\" case.\n\nIn both cases, I think it should do something like\n\n\t.. remove the file itself ..\n\t#\n\t# remove all directories leading up the path if they\n\t# have become non-empty\n\t#\n\tpath=$(dirname $path)\n\twhile [ \"$path\" ] && rmdir \"$path\"; do\n\t\tpath=$(dirname $path)\n\tdone\n\nor similar.\n\nBut as mentioned, quite often, this still won't remove the directories, \nsince it will have various old stale build-files in them. \n\n\t\t\tLinus\n"},{"id":"12359","messageId":"7v4q683qhe.fsf@assigned-by-dhcp.cox.net","threadId":"2604","inReplyTo":"Pine.LNX.4.64.0511190957320.13959@g5.osdl.org","subject":"[PATCH] merge-one-file: remove empty directories","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-20T04:14:37Z","receivedAt":"2005-11-20T04:14:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When the last file in a directory is removed as the result of a\nmerge, try to rmdir the now-empty directory.\n\n[jc: We probably could use \"rmdir -p\", but for now we do that by\nhand for portability.]\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n    Linus Torvalds <torvalds@osdl.org> writes:\n\n    > [ Junio, Fredrik, you're cc'd because the \"merge-one-file\" logic doesn't \n    >   clean up empty directories after removing a file in merge ]\n\n    Here is the one for merge-one-file that is used by 'git pull\n    -s resolve'.  Next patch will be the merge-recursive one.\n\n git-merge-one-file.sh |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\napplies-to: fbe4060a1b8ba894be5767ffc27402f94f356882\n397c76697f898e0341699fba8ef783f3342329c7\ndiff --git a/git-merge-one-file.sh b/git-merge-one-file.sh\nindex b08597d..b285990 100755\n--- a/git-merge-one-file.sh\n+++ b/git-merge-one-file.sh\n@@ -25,7 +25,12 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \t\techo \"Removing $4\"\n \tfi\n \tif test -f \"$4\"; then\n-\t\trm -f -- \"$4\"\n+\t\trm -f -- \"$4\" &&\n+\t\tdn=\"$4\" &&\n+\t\twhile dn=$(expr \"$dn\" : '\\(.*\\)/') && rmdir \"$dn\" 2>/dev/null\n+\t\tdo\n+\t\t\t:;\n+\t\tdone\n \tfi &&\n \t\texec git-update-index --remove -- \"$4\"\n \t;;\n---\n0.99.9.GIT\n"},{"id":"12360","messageId":"7vy83k2bwn.fsf@assigned-by-dhcp.cox.net","threadId":"2604","inReplyTo":"Pine.LNX.4.64.0511190957320.13959@g5.osdl.org","subject":"[PATCH] merge-recursive::removeFile: remove empty directories","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-20T04:14:48Z","receivedAt":"2005-11-20T04:14:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When the last file in a directory is removed as the result of a\nmerge, try to rmdir the now-empty directory.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n And this is the one for 'git pull -s recursive' which is the\n default these days.\n\n git-merge-recursive.py |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\napplies-to: ea62f7003bb2769fa23d5ca371d84cee9d2ec46f\n80e21a9ed809d98788ff6fb705d911bee37d460b\ndiff --git a/git-merge-recursive.py b/git-merge-recursive.py\nindex d7d36aa..37258ad 100755\n--- a/git-merge-recursive.py\n+++ b/git-merge-recursive.py\n@@ -293,6 +293,10 @@ def removeFile(clean, path):\n         except OSError, e:\n             if e.errno != errno.ENOENT and e.errno != errno.EISDIR:\n                 raise\n+        try:\n+            os.removedirs(os.path.dirname(path))\n+        except:\n+            pass\n \n def uniquePath(path, branch):\n     def fileExists(path):\n---\n0.99.9.GIT\n"},{"id":"12370","messageId":"20051120115102.GC4946@c165.ib.student.liu.se","threadId":"2604","inReplyTo":"7vy83k2bwn.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] merge-recursive::removeFile: remove empty directories","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2005-11-20T11:51:02Z","receivedAt":"2005-11-20T11:51:02Z","isPatch":true,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"On Sat, Nov 19, 2005 at 08:14:48PM -0800, Junio C Hamano wrote:\n> When the last file in a directory is removed as the result of a\n> merge, try to rmdir the now-empty directory.\n> \n> Signed-off-by: Junio C Hamano <junkio@cox.net>\n> \n> ---\n> \n>  And this is the one for 'git pull -s recursive' which is the\n>  default these days.\n> \n>  git-merge-recursive.py |    4 ++++\n>  1 files changed, 4 insertions(+), 0 deletions(-)\n> \n> applies-to: ea62f7003bb2769fa23d5ca371d84cee9d2ec46f\n> 80e21a9ed809d98788ff6fb705d911bee37d460b\n> diff --git a/git-merge-recursive.py b/git-merge-recursive.py\n> index d7d36aa..37258ad 100755\n> --- a/git-merge-recursive.py\n> +++ b/git-merge-recursive.py\n> @@ -293,6 +293,10 @@ def removeFile(clean, path):\n>          except OSError, e:\n>              if e.errno != errno.ENOENT and e.errno != errno.EISDIR:\n>                  raise\n> +        try:\n> +            os.removedirs(os.path.dirname(path))\n> +        except:\n> +            pass\n>  \n\nLooks good, but I would prefer to have 'except OSError:' instead of\nthe except without any exception class. A plain 'except:' will catch\nevery kind of exception which includes things such as NameError and\nAttributeError and we really don't want to silently ignore those two.\n\nA plain 'except:' exists in one other place (actually two, but one of\nthem is ok) in git-merge-recursive.py. I will send a patch to remove\nthat one.\n\n- Fredrik\n"},{"id":"12377","messageId":"Pine.LNX.4.64.0511200901450.13959@g5.osdl.org","threadId":"2604","inReplyTo":"7v4q683qhe.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] merge-one-file: remove empty directories","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-20T17:17:38Z","receivedAt":"2005-11-20T17:17:38Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 19 Nov 2005, Junio C Hamano wrote:\n> \n> [jc: We probably could use \"rmdir -p\", but for now we do that by\n> hand for portability.]\n\nSome googling seems to imply that \"-p\" is pretty much globally available.\n\nIt's in POSIX.1, but more importantly, it seems to actually be actively \nused in BSD projects, and I found a man-page with copyright date in -92 \n(SCO of all places) which mentiones AT&T SVID2 - but not the more modern \nstandards.\n\nEven VMS seems to have it (although if git is ever ported to VMS, I'll \njust have to shoot myself. I used VMS in -88, and the scars are _still_ \nfresh).\n\n\t\t\tLinus\n"},{"id":"12380","messageId":"4380BB97.7070407@zytor.com","threadId":"2604","inReplyTo":"Pine.LNX.4.64.0511200901450.13959@g5.osdl.org","subject":"Re: [PATCH] merge-one-file: remove empty directories","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-11-20T18:08:23Z","receivedAt":"2005-11-20T18:08:23Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Linus Torvalds wrote:\n> \n> Even VMS seems to have it (although if git is ever ported to VMS, I'll \n> just have to shoot myself. I used VMS in -88, and the scars are _still_ \n> fresh).\n> \n\nYeah, well, WinNT is basically the successor to VMS.  (I have heard from \nseveral ex-DECers that WNT was done on top of a stolen copy of what was \nsupposed-to-have-been the successor to VMS.)\n\n\t-hpa\n"},{"id":"12404","messageId":"Pine.LNX.4.63.0511210059190.24828@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2604","inReplyTo":"Pine.LNX.4.64.0511200901450.13959@g5.osdl.org","subject":"Re: [PATCH] merge-one-file: remove empty directories","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-11-21T00:00:26Z","receivedAt":"2005-11-21T00:00:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"On Sun, 20 Nov 2005, Linus Torvalds wrote:\n\n> [...] although if git is ever ported to VMS, I'll just have to shoot \n> myself. I used VMS in -88, and the scars are _still_ fresh.\n\nDoes that mean you are opposed to my plans on porting git to C64? Hmm?\n"},{"id":"12435","messageId":"81b0412b0511210622v87ecab6y7dbe703cb4395dad@mail.gmail.com","threadId":"2604","inReplyTo":"4380BB97.7070407@zytor.com","subject":"Re: [PATCH] merge-one-file: remove empty directories","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2005-11-21T14:22:59Z","receivedAt":"2005-11-21T14:22:59Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 11/20/05, H. Peter Anvin <hpa@zytor.com> wrote:\n> Linus Torvalds wrote:\n> >\n> > Even VMS seems to have it (although if git is ever ported to VMS, I'll\n> > just have to shoot myself. I used VMS in -88, and the scars are _still_\n> > fresh).\n> >\n>\n> Yeah, well, WinNT is basically the successor to VMS.  (I have heard from\n> several ex-DECers that WNT was done on top of a stolen copy of what was\n> supposed-to-have-been the successor to VMS.)\n\n...and yes, the users of NT are almost ready to shoot themselves.\n"}]}