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

🐛 sl clone silently fails for some repositories #375

Closed
vegerot opened this issue Dec 31, 2022 · 5 comments
Closed

🐛 sl clone silently fails for some repositories #375

vegerot opened this issue Dec 31, 2022 · 5 comments

Comments

@vegerot
Copy link
Contributor

vegerot commented Dec 31, 2022

image

Background: I am trying to clone https://github.com/cli/cli (in order to build it from source to help debug #350 )

Steps to reproduce:

  1. sl clone git@github.com:cli/cli.git
  2. ls cli

Expected output:

Actual output:

  • nothing 🙈

Other sanity-testing checks:

  • git clone works
  • sl clone another repo works
  • gh repo clone works

versions and configs

  • sl: built from source on 97ec2f9 (sl version reports Sapling 4.4.2)
  • git: 2.39.0
  • gh: 2.21.1
  • os: macOS 13.1 (Ventura)
❯ sl config
alias.commit=commit --verbose
alias.sst=!$HG status && $HG ssl
merge-tools.nvimDiff.args=-d $local $other $base -c 'redraw | echomsg "hg merge conflict, type \":cq\" to abort vimdiff"'
merge-tools.nvimDiff.executable=/usr/local/bin/nvim
merge-tools.nvimDiff.priority=100
ui.editor=nvim
ui.username=Max 👨🏽‍💻 Coplan <mchcopl@gmail.com>
git config --list

credential.helper=osxkeychain
alias.s=!{ git for-each-ref --sort=-committerdate --format='%(refname)' refs/heads/ refs/remotes/$(git remote || printf origin)|sed -e 's-refs/heads/--'| sed -e "s-refs/remotes/$(git remote || printf origin)/--" & printf 'develop
main
master
'; } | uniq | grep -i -m1 --color=never $1 | xargs -I {} sh -c " echo {}; git switch {}"
alias.sf=!git switch $(git for-each-ref --sort=-committerdate --format='%(refname)' refs/heads/ refs/remotes/$(git remote || printf origin)/|sed -e 's-refs/heads/--'| sed -e "s-refs/remotes/$(git remote || printf origin)/--" | uniq | fzf) $@
alias.fr=!git fetch $(git remote | head) && git rebase
alias.frm=!git fetch $(git remote | head) && git rebase $(git remote | head)/main
alias.fru=!git fetch upstream && git rebase upstream/main
alias.cw=commit --fixup=wip
core.pager=${_GIT_CONTRIB:-/usr/local/share/git-core/contrib}/diff-highlight/diff-highlight | $PAGER
color.branch.current=yellow reverse
color.branch.local=yellow
color.branch.remote=green
color.diff.meta=yellow bold
color.diff.frag=magenta bold
color.status.added=green bold
color.status.changed=red bold strike
color.status.untracked=cyan
color.status.branch=yellow bold ul
commit.verbose=true
interactive.difffilter=$_GIT_CONTRIB/diff-highlight/diff-highlight | $PAGER
rebase.instructionformat=(%al) %s
pull.fastforward=true
pull.ff=only
pull.rebase=true
user.email=Max.Coplan@walmart.com
user.name=Max 👨🏽‍💻 Coplan
help.autocorrect=1
url.git@github.com:.insteadof=https://github.com/
❯ gh config list
git_protocol=ssh
editor=
prompt=enabled
pager=
http_unix_socket=
browser=

Please let me know what other info you need 🙂

Happy New Year 🎆 🎊 🎈

@bolinfest
Copy link
Contributor

Hmm, that url.git@github.com:.insteadof=https://github.com/ line in your git config --list seems interesting? I just tried sl clone git@github.com:cli/cli.git with the latest Sapling release on Windows, but it failed with a more straightforward error:

abort: git command failed with exit code 128
  git "--git-dir=C:\Users\bolin\src\cli\.sl/store\git" ls-remote --refs "ssh://git@github.com/cli/cli.git" refs/heads/main refs/heads/master
    Host key verification failed.
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

C:\Users\bolin\src>git --version
git version 2.36.1.windows.1

Though then I tried sl clone https://github.com/cli/cli and I got the same empty repo as you!

Looking at https://github.com/cli/cli, I suspect the issue is that the default branch for that repo appears to be trunk!

Indeed, this seems to work for me:

sl clone https://github.com/cli/cli --updaterev trunk

I suppose that, at least for GitHub repos, we could query what the default branch is via the API?

@strager
Copy link
Contributor

strager commented Dec 31, 2022

I have the same issue with Sapling 0.1.20221118-210929-cfbb68aa and Sapling 0.2.20221222-152408 (installed with Homebrew) on macOS. sl clone git@github.com:cli/cli.git lights up my Yubikey, and after pressing it, the command exits with a zero exit code, and I'm left with a Sapling working copy with no files checked out.

@strager
Copy link
Contributor

strager commented Dec 31, 2022

I suppose that, at least for GitHub repos, we could query what the default branch is via the API?

You can use the following command to query the default branch for any remote Git repo:

git ls-remote --symref git@github.com:cli/cli.git HEAD

@discentem
Copy link
Contributor

discentem commented Jan 5, 2023

I suppose that, at least for GitHub repos, we could query what the default branch is via the API?

Out of my own curiosity, I'm studying the code base to try and figure out where this API might go if added, I'm guessing somewhere in clone() or pull(). Sharing in case its useful for anyone 😃

Or maybe it should be a new command sl clone github [repo] or flag sl clone --github [repo] so we don't have to try and guess if it is a Github repo? 🤔

@discentem
Copy link
Contributor

First attempt to fix, I'm sure it could use improvement! Thanks @strager for pointing out the git command for this!

#386

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

4 participants