Skip to content
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

How to correctly call a git submodule symlinked? #1209

Closed
1 task done
evandrocoan opened this issue Jun 16, 2017 · 1 comment
Closed
1 task done

How to correctly call a git submodule symlinked? #1209

evandrocoan opened this issue Jun 16, 2017 · 1 comment

Comments

@evandrocoan
Copy link

evandrocoan commented Jun 16, 2017

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

Initially opened on:

  1. Why ignore VCS-based packages accordingly to this message? wbond/package_control#1233 Why ignore VCS-based packages accordingly to this message?
  2. How to correctly call a git submodule symlinked?

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.13.0.windows.1
built from commit: eba7af3dbb4c846c6303c5f64102acee696c9ab0
sizeof-long: 4
machine: x86
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.15063]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

$ type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
The system cannot find the path specified.

$ type "C:\Program Files (x86)\Git\etc\install-options.txt"4
The system cannot find the file specified.

$ type "C:\Program Files\Git\etc\install-options.txt"
The system cannot find the path specified.

$ cat /etc/install-options.txt
cat: /etc/install-options.txt: No such file or directory

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

On the Sublime Text Package Control issue:

  1. Why ignore VCS-based packages accordingly to this message?

I find out what causes this error. I had the package All Autocomplete triggering it. Then I gone to the folder Packages/All Autocomplete and noticed it is a git repo synlinked. Then I deleted the .git file which points to gitdir: ../.git/modules/All Autocomplete and recloned the repository, so its files are within the repo. Then the package control stopped throwing the error for the package All Autocomplete and started doing the same error for the next package which also a git submodule and had the .git synlinking to the parent git folder.

It is because the All Autocomplete is a submodule, therefore its gits files are in:

  1. gitdir: ../.git/modules/All Autocomplete

Now you can reproduce it, but you need:

  1. To make your Packages folder a git repository, and add the All Autocomplete as a submodule.
  2. Delete it, and install clone your Package folder repo with git clone --recursive

This will create the All Autocomplete as a git submodule and store its files on the parent git folder at:

  1. gitdir: ../.git/modules/All Autocomplete

I am calling this subprocess on a git submodule symliked:

I did some testing using the python interpreter, and it is a problem with the proc = subprocess.Popen():

>>> import os
>>> import subprocess
>>> startupinfo = subprocess.STARTUPINFO();startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW;
>>> proc = subprocess.Popen( ['C:/Program Files (x86)/Git/bin/git.exe', 'symbolic-ref', '-q', 'HEAD'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=startupinfo, cwd='D:/SublimeText/Data/Packages/amxmodx', env=os.environ )
>>> proc.communicate()
(b'', None)
>>> proc = subprocess.Popen( ['C:/Program Files (x86)/Git/bin/git.exe', 'symbolic-ref', '-q', 'HEAD'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, startupinfo=startupinfo, cwd='D:/SublimeText/Data/Packages/All Autocomplete', env=os.environ )
>>> proc.communicate()
(b'refs/heads/master\n', None)
>>>

On the first command, I do with the package amxmodx which has the .git file symlinking to gitdir: ../.git/modules/amxmodx. And we got the output (b'', None).

On the second command, I do with the package All Autocomplete which has the .git folder inside it, because I just cloned it on as a git submodule. Therefore as its installation was not by git clone --recursive, the .git is
a folder, and is not a symlinked to gitdir: ../.git/modules/, it has the actual git files contents on it.

Hence we got the output (b'refs/heads/master\n', None), which works correctly and make the package control not throw the error.

How to make the call to a symlinked git submodule with subprocess.Popen() to work properly as a call to a git submodule not symlinked to gitdir: ../.git/modules/ which produces the output (b'refs/heads/master\n', None) instead of (b'', None) for a symlinked submodule?


I also tried using os.system:

    >>> cur_dir = os.getcwd()
    >>> os.chdir(r'D:/SublimeText/Data/Packages/All Autocomplete')
    >>> os.getcwd()
    'D:\\SublimeText\\Data\\Packages\\All Autocomplete'
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    refs/heads/master
    0
    >>> os.chdir(r'D:/SublimeText/Data/Packages/amxmodx')
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    1
    >>>

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other
    $ git --version
    git version 2.13.0.windows.1

    $ systeminfo | findstr /B /C:"OS Version"
    OS Version:                10.0.15063 N/A Build 15063

    $ python --version
    Python 3.6.1 :: Anaconda 4.4.0 (32-bit)

    >>> cur_dir = os.getcwd()
    >>> os.chdir(r'D:/SublimeText/Data/Packages/All Autocomplete')
    >>> os.getcwd()
    'D:\\SublimeText\\Data\\Packages\\All Autocomplete'
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    refs/heads/master
    0
    >>> os.chdir(r'D:/SublimeText/Data/Packages/amxmodx')
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    1
    >>>
  • What did you expect to occur after running these commands?
    >>> cur_dir = os.getcwd()
    >>> os.chdir(r'D:/SublimeText/Data/Packages/All Autocomplete')
    >>> os.getcwd()
    'D:\\SublimeText\\Data\\Packages\\All Autocomplete'
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    refs/heads/master
    0
    >>> os.chdir(r'D:/SublimeText/Data/Packages/amxmodx')
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    refs/heads/master
    0
    >>>
  • What actually happened instead?
    >>> cur_dir = os.getcwd()
    >>> os.chdir(r'D:/SublimeText/Data/Packages/All Autocomplete')
    >>> os.getcwd()
    'D:\\SublimeText\\Data\\Packages\\All Autocomplete'
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    refs/heads/master
    0
    >>> os.chdir(r'D:/SublimeText/Data/Packages/amxmodx')
    >>> os.system( r'"C:/Program Files (x86)/Git/bin/git.exe" symbolic-ref -q HEAD' )
    1
    >>>
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

wbond/package_control#1233 Why ignore VCS-based packages accordingly to this message?

@evandrocoan
Copy link
Author

evandrocoan commented Jun 16, 2017

I just figured out the problem. When I do git clone --recursive the submodules are not checkout on their branches, therefore the command git.exe symbolic-ref -q HEAD returns empty.

The solution is just go to each submodule and do git checkout master or the main default branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant