Dinaiz
Dinaiz

Reputation: 2233

git and libgit : unable to create file (No such file or directory)

I'm creating a git repository and a commit using libgit2 (in C++). It works fine, however, a checkout destroys all the local files.

However they seem to be still present in the repo . That's what I get when I try to look in the repository.

Welcome to Git (version 1.8.3-preview20130601)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

x@x-PC /C/Users/x/Desktop/poiu (master)
$ git log
commit a63cd37ef7d7228053b875e396531d367e2ea745
Author: Unregistered User <[email protected]>
Date:   Fri Oct 25 13:27:21 2013 +0200

    Project Save

x@x-PC /C/Users/x/Desktop/poiu (master)
$ git checkout a63cd37ef7d7228053b875e396531d367e2ea745
D       "db\\32\\879a83081b8d0b4ef41a37b9e28138"
D       "db\\41\\930644af1f4ab6d288bf3d50829558"
D       "db\\48\\3172d42be6ccb80e57071d5aabb584"
D       "db\\80\\0b152a41ba2ef0bc1c55c96add4d33"
D       "db\\c1\\3b1ce3276ed14d7ff7c6ace9b63cf3"
D       "db\\fa\\50e29fe380a8117140463106ae67b1"
Note: checking out 'a63cd37ef7d7228053b875e396531d367e2ea745'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at a63cd37... Project Save

x@x-PC /C/Users/x/Desktop/poiu ((a63cd37...))
$ git checkout -f a63cd37ef7d7228053b875e396531d367e2ea745
error: unable to create file db\32\879a83081b8d0b4ef41a37b9e28138 (No such file or directory)
error: unable to create file db\41\930644af1f4ab6d288bf3d50829558 (No such file or directory)
error: unable to create file db\48\3172d42be6ccb80e57071d5aabb584 (No such file or directory)
error: unable to create file db\80\0b152a41ba2ef0bc1c55c96add4d33 (No such file or directory)
error: unable to create file db\c1\3b1ce3276ed14d7ff7c6ace9b63cf3 (No such file or directory)
error: unable to create file db\fa\50e29fe380a8117140463106ae67b1 (No such file or directory)
HEAD is now at a63cd37... Project Save

x@x-PC /C/Users/x/Desktop/poiu ((a63cd37...))
$

Now, what's "weird"is that if I create the db\xx directories manually before hand, the checkout -f works.

Even weirder, the whole thing works as-is under MacOSx but not Windows ...

Any idea of what's going on here ?

Upvotes: 4

Views: 1932

Answers (2)

jthill
jthill

Reputation: 60275

$ git checkout a63cd37ef7d7228053b875e396531d367e2ea745
D       "db\\32\\879a83081b8d0b4ef41a37b9e28138"

See the quotes? git will use C string literal conventions to display filenames with unusual characters in them. Your repo records a file with that C string as its name -- backslashes included.

:, \, and / aren't invalid everywhere,

$ touch "db\\32\\879a83081b8d0b4ef41a37b9e28138"
$ ls
db\32\879a83081b8d0b4ef41a37b9e28138
$ git add .
$ git ls-files
"db\\32\\879a83081b8d0b4ef41a37b9e28138"
$ 

but they're not portable.

Roughly speaking, Windows filesystems reserve \ and :, Mac, :, Unix, /. There may still be systems that reserve ;.

Upvotes: 3

Bodo
Bodo

Reputation: 172

Can you check if you are in MacOSx and in Windows in a detached Head state?

Another idea would be the filesystem differences, maybe you can find something related to this?

Upvotes: 1

Related Questions