Skip to content

git init: Invalid symlink: Function not implemented #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Radrik5 opened this issue Mar 16, 2016 · 8 comments
Closed
1 task done

git init: Invalid symlink: Function not implemented #698

Radrik5 opened this issue Mar 16, 2016 · 8 comments

Comments

@Radrik5
Copy link

Radrik5 commented Mar 16, 2016

  • I was not able to find an open
    or closed issue
    matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? 32-bit or 64-bit? Include the
    output of git version as well.

git version 2.7.2 64-bit

$ git --version
git version 2.7.2.windows.1
  • Which version of Windows are you running? 32-bit or 64-bit?

Windows 7 64-bit

  • What options did you set as part of the installation? Or did you choose the
    defaults?

Path Option: BashOnly
SSH Option: OpenSSH
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Disabled

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Git doesn't work inside a directory symlink. I see the error in Git CMD but not in Git Bash.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git CMD

The real problem is that I cannot use nigher C:\Program Files\Git\bin\git.exe nor C:\Program Files\Git\cmd\git.exe from a .bat script. Git fails with the same error: Function not implemented.

E:\Projects\test\symlik-test>mkdir targetdir

E:\Projects\test\symlik-test>mklink /D symlink targetdir
symbolic link created for symlink <<===>> targetdir

E:\Projects\test\symlik-test>cd symlink

E:\Projects\test\symlik-test\symlink>git init
fatal: Invalid symlink 'E:/Projects/test/symlik-test/symlink': Function not implemented
  • What did you expect to occur after running these commands?
symlink $ git init
Initialized empty Git repository in E:/Projects/test/symlik-test/targetdir/.git/
  • What actually happened instead?

fatal error: Invalid symlink: Function not implemented

@PhilipOakley
Copy link

Have you noticed the direction of the directory separators....

The final E: message is using the wrong style for a drive path indicating (to me) that the path has been badly formed (if it's in MSYS2 format it would be /e/Projects .. for the e drive.

In general G4W avoids any use of symlinks because of all the compatibility issues across Windows OS versions, and between Windows and Linux expectations.

@Radrik5
Copy link
Author

Radrik5 commented Mar 17, 2016

Have you noticed that it works in Git Bash? It's the same folder (symlink) and the same command.

I need this in a .bat script, so maybe there is a workaround that can run git in environment similar to Git Bash with working symlinks?

@Radrik5
Copy link
Author

Radrik5 commented Mar 17, 2016

G4W actually supports symlinks. See issue #117 and PR #156.

So, here is the workaround:

E:\Projects\test\symlink-test\symlink>set MSYS="winsymlinks:nativestrict"

E:\Projects\test\symlink-test\symlink>git init
Initialized empty Git repository in E:/Projects/test/symlink-test/targetdir/.git/

@PhilipOakley
Copy link

Hi Dmitry,

maybe you could update https://github.com/git-for-windows/git/wiki/Symbolic-Links with the appropriate commands and commentary?

i.e. the symtoms and 'workaround' setting, and where that setting is derived from (real question, as I don't know).

It good to see the issues being bottomed out and documented..

Philip
----- Original Message -----
From: Dmitry Oksenchuk
To: git-for-windows/git
Cc: Philip Oakley
Sent: Thursday, March 17, 2016 12:26 PM
Subject: Re: [git] git init: Invalid symlink: Function not implemented (#698)

G4W actually supports symlinks. See issue #117 and PR #156.

So, here is the workaround:

E:\Projects\test\symlink-test\symlink>set MSYS="winsymlinks:nativestrict"

E:\Projects\test\symlink-test\symlink>git init
Initialized empty Git repository in E:/Projects/test/symlink-test/targetdir/.git/

You are receiving this because you commented.
Reply to this email directly or view it on GitHub

@dscho
Copy link
Member

dscho commented Mar 17, 2016

I would have expected that setting core.symlinks = true would fix it, but it did not without this patch:

diff --git a/builtin/init-db.c b/builtin/init-db.c
index ec4c569..ec9340d 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -194,6 +194,7 @@ static int create_default_files(const char *template_path)
     */
    copy_templates(template_path);

+   git_config_clear();
    git_config(git_default_config, NULL);
    is_bare_repository_cfg = init_is_bare_repository;

@@ -528,6 +529,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
        shared_repository = init_shared_repository;

    /*
+    * We need the settings *before* trying to determine the current
+    * Git directory, e.g. to support core.symlinks properly.
+    */
+   git_config(git_default_config, NULL);
+
+   /*
     * GIT_WORK_TREE makes sense only in conjunction with GIT_DIR
     * without --bare.  Catch the error early.
     */

This patch needs to be cleaned up, a test needs to be added to test it (most likely, the git_config_clear() actually fixes a bug where templates' configs are not heeded) and a proper commit message needs to be crafted.

@dscho
Copy link
Member

dscho commented Mar 18, 2016

In case it was not clear: this diff is all I had time (for the time being) to contribute to the resolution of this ticket.

@Radrik5
Copy link
Author

Radrik5 commented Mar 20, 2016

Thank you @dscho. Unfortunately I also don't have enough time to finish the work.

@dscho
Copy link
Member

dscho commented Mar 21, 2016

@Radrik5 okay.

@dscho dscho closed this as completed Mar 21, 2016
dscho pushed a commit to dscho/git that referenced this issue Oct 28, 2024
…ws#698)

There was a typo in the configuration Scalar registers, which was missed
by author and reviewer 🤦. No big harm done, let's just fix this in time
for the next Git for Windows version.

This is a companion to git-for-windows#5220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants