¿Cómo hacer que git-svn se encargue de los directorios vacíos con elegancia?

I am very happily using git-svn, though I noticed that git has a different approach when it comes to empty directories as SVN. I need a way to get around the following particular situation:

I have in my project's SVN repository several empty directories that belong in there and should not be touched. Due to some refactoring, I had to delete another directory that used to have files in it. git svn dcommit deletes the files, but leaves the directory. It strikes me that git's ignorance of empty directories is resulting in inconsistency in my SVN repo.

I would like to have that particular directory removed from my SVN repository. Can git-svn do that? And if not, how should I be doing that? (And - eventually - how can I do that while committing other files with them as well in the same changeset?)

preguntado el 08 de noviembre de 11 a las 14:11

2 Respuestas

Use rmdir argument or config parameter:

--rmdir

Only used with the dcommit, set-tree and commit-diff commands.

Remove directories from the SVN tree if there are no files left behind. SVN can version empty directories, and they are not removed by default if there are no files left in them. git cannot version empty directories. Enabling this flag will make the commit to SVN act like git.

config key: svn.rmdir

respondido 09 nov., 11:13

Habilitar esta bandera hará que el compromiso con SVN actúe como git. Which is exactly not what I want; I want SVN to be distinctive about whether or not empty directories are in the tree. I just want to remove one empty directory (of many existing) in particular on the SVN side, not all of them. - El Pellmeister

If you switch on the parameter, it would not delete existing empty directories. But next time you delete last file from a directory, dcommit will delete the directory from svn too, in one commit. If you want change something with empty directories in svn which was committed already, you should use SVN directly, the rmdir afecta solo dcommit. - puede

Ah, thanks! I tested it with a local repo, and it does exactly what you describe. For some reason I didn't learn that from the manual you quoted. (I read the first sentence as "All empty dirs will be removed"). Thanks a lot! - El Pellmeister

Can this be configured as the default when using git-svn? - Sam Hendley

@SamHendley "config key: svn.rmdir" - so, just git config --global svn.rmdir true. - puede

You will have to delete it on the SVN side:

svn delete -m "deleting empty dir" http://path/to/deleted/dir

respondido 08 nov., 11:21

+1, though I am not very happy with that for two reasons: 1. I need to type the repo path specifically every time I want to do something like this, and 2. It takes a separate commit to get it done. Is this the only option there is? - El Pellmeister

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.