5

I'm writing a fast-export/fast-import for Plastic SCM but I'm having issues dealing with directories and files containing spaces in their names.

For instance, a git fast-export of something like:

git mv "new directory" "second directory"

ends up being exported as:

D new directory/hello.c
M 100644 :1 second directory/hello.c

Instead of a "move" (R) operation. Same happens with a file with spaces in the name.

Is there a way to handle it correctly?
Does it mean that Git can't handle renames on paths with spaces?

Edited with a real example below:

I've something like this on a commit:

  R src/samples/sampledata src/samples/samplebase
* R src/samples/samplebase/Test.Workflow.xml src/samples/samplebase/new/Test.Workflow.xml

and it fails importing saying

fatal: Path src/samples/samplebase/Test.Workflow.xml not in branch

So, I understand it doesn't support a move of a directory and then a move of a file inside it... It is a little bit weird, isn't it?

pablo
  • 6,392
  • 4
  • 42
  • 62

1 Answers1

2

git fast-import does mention in the "Handling rename" section:

When importing a renamed file or directory, simply delete the old name(s) and modify the new name(s) during the corresponding commit. Git performs rename detection after-the-fact, rather than explicitly during a commit.

So your example seems to follow that logic.

Don't forget Git doesn't version directories, only blob (i.e. file content with an associated path).


To add to your edited question:

  • a move of a directory means, if imported in Git, that the source (directory) will have to be deleted after all the files have been processed (i.e. imported, renamed or not)
  • a move of a file, when imported in Git, is a classic git mv.

In 2011, The OP has posted a question on the old gmane list.
And the issue is currently (2017) discussed in Git for Windows (git-for-windows/git issue 908).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This is confusing because the "rename" operation is also supported: filerename Renames an existing file or subdirectory to a different location within the branch. The existing file or directory must exist. If the destination exists it will be replaced by the source directory. 'R' SP SP LF – pablo Jan 21 '11 at 10:47
  • @pablo: I have edited my answer to address your scenario. You don't move a directory when importing in Git. You simply removes it after processing all the files. – VonC Jan 21 '11 at 12:19
  • @vonc: ok, so, it basically means you can't use "move" doing a git-import?? That's not what the documentation says, but I'm trying right now and it doesn't work doing moves, unfortunately. The problem is that it seems to be pretty random: a directory is renamed from uppercase to lowercase, then 1000 commits later one file fails, while others were successfully modified and imported between these two commits. It seems "move" is supported on git fast-import so other SCMs correctly dealing with moves can export easily, but (unless I have something wrong down here), it doesn't really work. – pablo Jan 21 '11 at 13:22
  • @pablo: the idea is you don't move or rename directories, only files. And then you delete the directories moved. Regarding the case issue, Git doesn't change anything on its own, that could be an OS-related issue. – VonC Jan 21 '11 at 13:30
  • @vonc: no, no, I'm not making myself clear I'm afraid. No, it's not about Git changing anything, it is just that it is supposed to handle "move operations" but it doesn't. Just that. – pablo Jan 21 '11 at 14:14
  • @vonc: I posted my question to the git list too http://article.gmane.org/gmane.comp.version-control.git/165372, but no luck so far... My feeling is that the git fast-import can't correctly deal with moves, but I'm not sure. – pablo Jan 23 '11 at 15:05
  • @pablo: you should include a link to my answer in this page, asking them if said answer is at all relevant to your case. – VonC Jan 23 '11 at 15:38
  • @vonc: you mean the git mailing list?? If so, maybe is better if you answer my email adding the extra info. – pablo Jan 24 '11 at 15:41
  • The gmane list has now closed (except nntp access I think) The git list can be accesssed via public-inbox which includes a search capability based on the old gmane ID. https://public-inbox.org/git/?q=gmane%3A165372 (%3A = ':'). The issue came up recently on GfW issue https://github.com/git-for-windows/git/issues/908, and for a case sensitive filename change the core.ignorecase must be properly set. – Philip Oakley Aug 28 '17 at 15:27
  • @PhilipOakley Thank you. I have included those links in the answer for more visibility. – VonC Aug 28 '17 at 15:42