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

Rugged::Repository.init_at does not create a branch #952

Open
mslinn opened this issue Mar 10, 2023 · 0 comments
Open

Rugged::Repository.init_at does not create a branch #952

mslinn opened this issue Mar 10, 2023 · 0 comments

Comments

@mslinn
Copy link
Contributor

mslinn commented Mar 10, 2023

The git-init docs say:

This command creates an empty Git repository - basically a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files. An initial branch without any commits will be created (see the --initial-branch option below for its name).

However, Rugged::Repository.init_at does not create any branches:

require 'rugged'
require 'tmpdir'

Dir.mktmpdir do |temp_dir| # This directory will be deleted on exit
  Dir.chdir(temp_dir)
  puts "Working in #{temp_dir}"

  repo = Rugged::Repository.init_at temp_dir
  `git branch -l` # no output and no error
  repo.checkout 'master' # Throws Rugged::ReferenceError: revspec 'master' not found
end

Is this a bug?

Also, attempting to create a branch after calling init_at fails:

repo = Rugged::Repository.init_at temp_dir
repo.create_branch 'master' # Throws Rugged::ReferenceError: revspec 'HEAD' not found

However, attempting to create the branch using the command line after calling init_at works:

Rugged::Repository.init_at temp_dir
`git checkout -b master` # works just fine
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