Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix the branch API to work with libgit2 upstream

  • Loading branch information...
commit 5aac0b11935a470064227e17d583076de602f554 1 parent 9a9f605
@vmg vmg authored
View
2  ext/rugged/rugged.c
@@ -263,7 +263,6 @@ void Init_rugged()
rb_define_module_function(rb_mRugged, "prettify_message", rb_git_prettify_message, 2);
Init_rugged_object();
- Init_rugged_branch();
Init_rugged_commit();
Init_rugged_tree();
Init_rugged_tag();
@@ -273,6 +272,7 @@ void Init_rugged()
Init_rugged_repo();
Init_rugged_revwalk();
Init_rugged_reference();
+ Init_rugged_branch();
Init_rugged_config();
Init_rugged_remote();
View
8 ext/rugged/rugged.h
@@ -67,6 +67,7 @@ VALUE rugged_signature_new(const git_signature *sig, const char *encoding_name);
VALUE rugged_index_new(VALUE klass, VALUE owner, git_index *index);
VALUE rugged_object_new(VALUE owner, git_object *object);
VALUE rugged_config_new(VALUE klass, VALUE owner, git_config *cfg);
+VALUE rugged_ref_new(VALUE klass, VALUE owner, git_reference *ref);
VALUE rugged_otype_new(git_otype t);
git_otype rugged_otype_get(VALUE rb_type);
@@ -119,4 +120,11 @@ static inline VALUE rugged_create_oid(const git_oid *oid)
return rugged_str_new(out, 40, NULL);
}
+#define RUGGED_UNPACK_REFERENCE(_rb_obj, _rugged_obj) {\
+ if (DATA_PTR(_rb_obj) == NULL)\
+ rb_raise(rb_eRuntimeError,\
+ "This Git Reference has been deleted and no longer exists on the repository");\
+ Data_Get_Struct(_rb_obj, git_reference, _rugged_obj);\
+}
+
#endif
View
178 ext/rugged/rugged_branch.c
@@ -1,7 +1,7 @@
/*
* The MIT License
*
- * Copyright (c) 2011 GitHub, Inc
+ * Copyright (c) 2012 GitHub, Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,11 +27,34 @@
extern VALUE rb_mRugged;
extern VALUE rb_cRuggedRepo;
extern VALUE rb_cRuggedObject;
+extern VALUE rb_cRuggedReference;
VALUE rb_cRuggedBranch;
+static inline VALUE rugged_branch_new(VALUE owner, git_reference *ref)
+{
+ return rugged_ref_new(rb_cRuggedBranch, owner, ref);
+}
+
+static int parse_branch_type(VALUE rb_filter)
+{
+ ID id_filter;
+
+ Check_Type(rb_filter, T_SYMBOL);
+ id_filter = SYM2ID(rb_filter);
+
+ if (id_filter == rb_intern("local")) {
+ return GIT_BRANCH_LOCAL;
+ } else if (id_filter == rb_intern("remote")) {
+ return GIT_BRANCH_REMOTE;
+ } else {
+ rb_raise(rb_eTypeError,
+ "Invalid branch filter. Expected `:remote`, `:local` or `nil`");
+ }
+}
+
static VALUE rb_git_branch_create(int argc, VALUE *argv, VALUE self)
{
- git_oid branch_oid;
+ git_reference *branch;
git_object *target = NULL;
git_repository *repo = NULL;
int error, force = 0;
@@ -54,21 +77,22 @@ static VALUE rb_git_branch_create(int argc, VALUE *argv, VALUE self)
force = rugged_parse_bool(rb_force);
}
- error = git_branch_create(&branch_oid, repo, StringValueCStr(rb_name), target, force);
-
+ error = git_branch_create(&branch, repo, StringValueCStr(rb_name), target, force);
git_object_free(target);
rugged_exception_check(error);
- return rugged_create_oid(&branch_oid);
+ return rugged_branch_new(rb_repo, branch);
}
-static VALUE rb_git_branch_delete(int argc, VALUE *argv, VALUE self)
+static VALUE rb_git_branch_lookup(int argc, VALUE *argv, VALUE self)
{
+ git_reference *branch;
+ git_repository *repo;
+
VALUE rb_repo, rb_name, rb_type;
- git_repository *repo = NULL;
- ID id_type;
- int error, type;
+ int error;
+ int branch_type = GIT_BRANCH_LOCAL;
rb_scan_args(argc, argv, "21", &rb_repo, &rb_name, &rb_type);
@@ -79,99 +103,115 @@ static VALUE rb_git_branch_delete(int argc, VALUE *argv, VALUE self)
Data_Get_Struct(rb_repo, git_repository, repo);
Check_Type(rb_name, T_STRING);
+
+ if (!NIL_P(rb_type))
+ branch_type = parse_branch_type(rb_type);
- if (!NIL_P(rb_type)) {
- Check_Type(rb_type, T_SYMBOL);
- id_type = SYM2ID(rb_type);
-
- if (id_type == rb_intern("local")) {
- type = GIT_BRANCH_LOCAL;
- } else if (id_type == rb_intern("remote")) {
- type = GIT_BRANCH_REMOTE;
- } else {
- rb_raise(rb_eTypeError,
- "Invalid branch type. Expected `:remote`, `:local` or `nil`");
- }
- } else {
- type = GIT_BRANCH_LOCAL;
- }
-
- error = git_branch_delete(repo, StringValueCStr(rb_name), type);
+ error = git_branch_lookup(&branch, repo, StringValueCStr(rb_name), branch_type);
+ if (error == GIT_ENOTFOUND)
+ return Qnil;
rugged_exception_check(error);
+ return rugged_branch_new(rb_repo, branch);
+}
+
+static VALUE rb_git_branch_delete(VALUE self)
+{
+ git_reference *branch = NULL;
+
+ RUGGED_UNPACK_REFERENCE(self, branch);
+
+ rugged_exception_check(
+ git_branch_delete(branch)
+ );
+
+ DATA_PTR(self) = NULL; /* this reference has been free'd */
+ rugged_set_owner(self, Qnil); /* and is no longer owned */
return Qnil;
}
-static int cb_branch__each(const char *branch_name, git_branch_t branch_type, void *payload)
+static int cb_branch__each_name(const char *branch_name, git_branch_t branch_type, void *payload)
{
- rb_funcall((VALUE)payload, rb_intern("call"), 1, rugged_str_new2(branch_name, rb_utf8_encoding()));
+ rb_yield(rugged_str_new2(branch_name, rb_utf8_encoding()));
return GIT_OK;
}
-static VALUE rb_git_branch_each(int argc, VALUE *argv, VALUE self)
+static int cb_branch__each_obj(const char *branch_name, git_branch_t branch_type, void *payload)
+{
+ VALUE rb_repo = (VALUE)payload;
+
+ git_reference *branch;
+ git_repository *repo;
+
+ Data_Get_Struct(rb_repo, git_repository, repo);
+
+ rugged_exception_check(
+ git_branch_lookup(&branch, repo, branch_name, branch_type)
+ );
+
+ rb_yield(rugged_branch_new(rb_repo, branch));
+ return GIT_OK;
+}
+
+static VALUE each_branch(int argc, VALUE *argv, VALUE self, int branch_names_only)
{
VALUE rb_repo, rb_filter;
- ID id_filter;
git_repository *repo;
- int error, i, filter;
+ int error;
+ int filter = (GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE);
rb_scan_args(argc, argv, "11", &rb_repo, &rb_filter);
+ if (!rb_block_given_p()) {
+ VALUE symbol = branch_names_only ? CSTR2SYM("each_name") : CSTR2SYM("each");
+ return rb_funcall(self, rb_intern("to_enum"), 3, symbol, rb_repo, rb_filter);
+ }
+
if (!rb_obj_is_kind_of(rb_repo, rb_cRuggedRepo)) {
rb_raise(rb_eTypeError, "Expecting a Rugged::Repository instance");
}
- if (!rb_block_given_p()) {
- return rb_funcall(self, rb_intern("to_enum"), 3, CSTR2SYM("each"), rb_repo, rb_filter);
- }
+ if (!NIL_P(rb_filter))
+ filter = parse_branch_type(rb_filter);
+
+ Data_Get_Struct(rb_repo, git_repository, repo);
- if (!NIL_P(rb_filter)) {
- Check_Type(rb_filter, T_SYMBOL);
- id_filter = SYM2ID(rb_filter);
-
- if (id_filter == rb_intern("local")) {
- filter = GIT_BRANCH_LOCAL;
- } else if (id_filter == rb_intern("remote")) {
- filter = GIT_BRANCH_REMOTE;
- } else {
- rb_raise(rb_eTypeError,
- "Invalid branch filter. Expected `:remote`, `:local` or `nil`");
- }
+ if (branch_names_only) {
+ error = git_branch_foreach(repo, filter, &cb_branch__each_name, NULL);
} else {
- filter = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE;
+ error = git_branch_foreach(repo, filter, &cb_branch__each_obj, (void *)rb_repo);
}
- Data_Get_Struct(rb_repo, git_repository, repo);
-
- error = git_branch_foreach(repo, filter, &cb_branch__each, (void *)rb_block_proc());
rugged_exception_check(error);
-
return Qnil;
}
-static VALUE rb_git_branch_move(int argc, VALUE *argv, VALUE self)
+static VALUE rb_git_branch_each_name(int argc, VALUE *argv, VALUE self)
{
- VALUE rb_repo, rb_old_branch_name, rb_new_branch_name, rb_force;
- git_repository *repo = NULL;
- int error, force;
+ return each_branch(argc, argv, self, 1);
+}
- rb_scan_args(argc, argv, "31", &rb_repo, &rb_old_branch_name, &rb_new_branch_name, &rb_force);
+static VALUE rb_git_branch_each(int argc, VALUE *argv, VALUE self)
+{
+ return each_branch(argc, argv, self, 0);
+}
- if (!rb_obj_is_kind_of(rb_repo, rb_cRuggedRepo)) {
- rb_raise(rb_eTypeError, "Expecting a Rugged::Repository instance");
- }
+static VALUE rb_git_branch_move(int argc, VALUE *argv, VALUE self)
+{
+ VALUE rb_new_branch_name, rb_force;
+ git_reference *old_branch = NULL;
+ int error, force = 0;
- Data_Get_Struct(rb_repo, git_repository, repo);
+ rb_scan_args(argc, argv, "11", &rb_new_branch_name, &rb_force);
- Check_Type(rb_old_branch_name, T_STRING);
+ RUGGED_UNPACK_REFERENCE(self, old_branch);
Check_Type(rb_new_branch_name, T_STRING);
if (!NIL_P(rb_force))
force = rugged_parse_bool(rb_force);
- error = git_branch_move(repo, StringValueCStr(rb_old_branch_name), StringValueCStr(rb_new_branch_name), force);
-
+ error = git_branch_move(old_branch, StringValueCStr(rb_new_branch_name), force);
rugged_exception_check(error);
return Qnil;
@@ -179,10 +219,14 @@ static VALUE rb_git_branch_move(int argc, VALUE *argv, VALUE self)
void Init_rugged_branch()
{
- rb_cRuggedBranch = rb_define_class_under(rb_mRugged, "Branch", rb_cObject);
+ rb_cRuggedBranch = rb_define_class_under(rb_mRugged, "Branch", rb_cRuggedReference);
- rb_define_singleton_method(rb_cRuggedBranch, "each", rb_git_branch_each, -1);
- rb_define_singleton_method(rb_cRuggedBranch, "delete", rb_git_branch_delete, -1);
rb_define_singleton_method(rb_cRuggedBranch, "create", rb_git_branch_create, -1);
- rb_define_singleton_method(rb_cRuggedBranch, "move", rb_git_branch_move, -1);
+ rb_define_singleton_method(rb_cRuggedBranch, "lookup", rb_git_branch_lookup, -1);
+ rb_define_singleton_method(rb_cRuggedBranch, "each_name", rb_git_branch_each_name, -1);
+ rb_define_singleton_method(rb_cRuggedBranch, "each", rb_git_branch_each, -1);
+
+ rb_define_method(rb_cRuggedBranch, "delete!", rb_git_branch_delete, 0);
+ rb_define_method(rb_cRuggedBranch, "rename", rb_git_branch_move, -1);
+ rb_define_method(rb_cRuggedBranch, "move", rb_git_branch_move, -1);
}
View
12 ext/rugged/rugged_config.c
@@ -284,18 +284,18 @@ static VALUE rb_git_config_to_hash(VALUE self)
/*
* call-seq:
- * Config.open_global() -> new_config
+ * Config.global() -> new_config
*
- * Open the global config file as a new +Rugged::Config+ object.
+ * Open the default global config file as a new +Rugged::Config+ object.
* An exception will be raised if the global config file doesn't
* exist.
*/
-static VALUE rb_git_config_open_global(VALUE klass)
+static VALUE rb_git_config_open_default(VALUE klass)
{
git_config *cfg;
int error;
- error = git_config_open_global(&cfg);
+ error = git_config_open_default(&cfg);
rugged_exception_check(error);
return rugged_config_new(klass, Qnil, cfg);
@@ -308,7 +308,9 @@ void Init_rugged_config()
*/
rb_cRuggedConfig = rb_define_class_under(rb_mRugged, "Config", rb_cObject);
rb_define_singleton_method(rb_cRuggedConfig, "new", rb_git_config_new, 1);
- rb_define_singleton_method(rb_cRuggedConfig, "open_global", rb_git_config_open_global, 0);
+
+ rb_define_singleton_method(rb_cRuggedConfig, "global", rb_git_config_open_default, 0);
+ rb_define_singleton_method(rb_cRuggedConfig, "open_global", rb_git_config_open_default, 0);
rb_define_method(rb_cRuggedConfig, "delete", rb_git_config_delete, 1);
View
29 ext/rugged/rugged_reference.c
@@ -24,13 +24,6 @@
#include "rugged.h"
-#define UNPACK_REFERENCE(_rb_obj, _rugged_obj) {\
- if (DATA_PTR(_rb_obj) == NULL)\
- rb_raise(rb_eRuntimeError,\
- "This Git Reference has been deleted and no longer exists on the repository");\
- Data_Get_Struct(_rb_obj, git_reference, _rugged_obj);\
-}
-
extern VALUE rb_mRugged;
extern VALUE rb_cRuggedRepo;
VALUE rb_cRuggedReference;
@@ -235,7 +228,7 @@ static VALUE rb_git_ref_target(VALUE self)
{
git_reference *ref;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
if (git_reference_type(ref) == GIT_REF_OID) {
return rugged_create_oid(git_reference_oid(ref));
@@ -265,7 +258,7 @@ static VALUE rb_git_ref_set_target(VALUE self, VALUE rb_target)
git_reference *ref;
int error;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
Check_Type(rb_target, T_STRING);
if (git_reference_type(ref) == GIT_REF_OID) {
@@ -292,7 +285,7 @@ static VALUE rb_git_ref_set_target(VALUE self, VALUE rb_target)
static VALUE rb_git_ref_type(VALUE self)
{
git_reference *ref;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
switch (git_reference_type(ref)) {
case GIT_REF_OID:
return CSTR2SYM("direct");
@@ -312,7 +305,7 @@ static VALUE rb_git_ref_type(VALUE self)
static VALUE rb_git_ref_packed(VALUE self)
{
git_reference *ref;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
return git_reference_is_packed(ref) ? Qtrue : Qfalse;
}
@@ -327,7 +320,7 @@ static VALUE rb_git_ref_reload(VALUE self)
{
int error;
git_reference *ref;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
error = git_reference_reload(ref);
@@ -350,7 +343,7 @@ static VALUE rb_git_ref_reload(VALUE self)
static VALUE rb_git_ref_name(VALUE self)
{
git_reference *ref;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
return rugged_str_new2(git_reference_name(ref), rb_utf8_encoding());
}
@@ -373,7 +366,7 @@ static VALUE rb_git_ref_resolve(VALUE self)
git_reference *resolved;
int error;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
error = git_reference_resolve(&resolved, ref);
rugged_exception_check(error);
@@ -398,7 +391,7 @@ static VALUE rb_git_ref_rename(int argc, VALUE *argv, VALUE self)
VALUE rb_name, rb_force;
int error, force = 0;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
rb_scan_args(argc, argv, "11", &rb_name, &rb_force);
Check_Type(rb_name, T_STRING);
@@ -427,7 +420,7 @@ static VALUE rb_git_ref_delete(VALUE self)
git_reference *ref;
int error;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
error = git_reference_delete(ref);
rugged_exception_check(error);
@@ -495,7 +488,7 @@ static VALUE rb_git_reflog(VALUE self)
VALUE rb_log;
unsigned int i, ref_count;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
error = git_reflog_read(&reflog, ref);
rugged_exception_check(error);
@@ -533,7 +526,7 @@ static VALUE rb_git_reflog_write(int argc, VALUE *argv, VALUE self)
git_oid oid;
- UNPACK_REFERENCE(self, ref);
+ RUGGED_UNPACK_REFERENCE(self, ref);
rb_scan_args(argc, argv, "11", &rb_committer, &rb_message);
View
32 lib/rugged/branch.rb
@@ -1,36 +1,18 @@
module Rugged
- class Branch
- def self.lookup(repo, name)
- if name == "HEAD" || name.match(%r{^(refs/heads/|refs/remotes/)})
- ref = repo.ref(name)
- else
- ref = repo.ref("refs/heads/#{name}") || repo.ref("refs/remotes/#{name}")
- end
-
- Branch.new(repo, ref, ref.name) if ref
- end
-
- attr_reader :repository, :canonical_name
-
- def initialize(repo, reference, name)
- @repository = repo
- @reference = reference
- @canonical_name = name
+ class Branch < Rugged::Reference
+ def tip
+ @owner.lookup(self.resolve.target)
end
def ==(other)
other.instance_of?(Rugged::Branch) &&
- other.canonical_name == self.canonical_name &&
- other.tip == self.tip
+ other.canonical_name == self.canonical_name
end
- def name
- @canonical_name.gsub(%r{^(refs/heads/|refs/remotes/)}, '')
- end
+ alias_method 'canonical_name', 'name'
- def tip
- ref = @reference.type == :symbolic ? @reference.resolve : @reference
- @repository.lookup(ref.target)
+ def name
+ super.gsub(%r{^(refs/heads/|refs/remotes/)}, '')
end
end
end
View
13 lib/rugged/repository.rb
@@ -122,7 +122,7 @@ def remotes
end
def branches
- Rugged::Branch.each(self).map { |name| Rugged::Branch.lookup(self, name) }
+ Rugged::Branch.each(self)
end
def create_branch(name, sha_or_ref = "HEAD")
@@ -138,7 +138,6 @@ def create_branch(name, sha_or_ref = "HEAD")
end
Branch.create(self, name, target)
- Branch.lookup(self, name)
end
# Get the content of a file at a specific revision.
@@ -149,13 +148,13 @@ def create_branch(name, sha_or_ref = "HEAD")
# Returns a String.
def file_at(revision, path)
tree = Rugged::Commit.lookup(self, revision).tree
- begin
- blob_data = tree.path(path)
- rescue Rugged::IndexerError
+ begin
+ blob_data = tree.path(path)
+ rescue Rugged::IndexerError
return nil
- end
+ end
blob = Rugged::Blob.lookup(self, blob_data[:oid])
- (blob.type == :blob) ? blob.content : nil
+ (blob.type == :blob) ? blob.content : nil
end
end
end
View
50 test/branch_test.rb
@@ -1,7 +1,7 @@
# encoding: UTF-8
require "test_helper"
-context "Rugged::Branch.each" do
+context "Rugged::Branch.each_name" do
setup do
@path = temp_repo("testrepo.git")
@repo = Rugged::Repository.new(@path)
@@ -12,20 +12,20 @@
"master",
"origin/HEAD",
"origin/master",
- "origin/packed"
- ], Rugged::Branch.each(@repo).sort
+ "origin/packed",
+ ], Rugged::Branch.each_name(@repo).sort
end
test "can list only local branches" do
- assert_equal ["master"], Rugged::Branch.each(@repo, :local).sort
+ assert_equal ["master"], Rugged::Branch.each_name(@repo, :local).sort
end
test "can list only remote branches" do
assert_equal [
"origin/HEAD",
"origin/master",
- "origin/packed"
- ], Rugged::Branch.each(@repo, :remote).sort
+ "origin/packed",
+ ], Rugged::Branch.each_name(@repo, :remote).sort
end
end
@@ -58,26 +58,8 @@
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", branch.tip.oid
end
- test "can look up a local branch by its canonical name" do
- branch = Rugged::Branch.lookup(@repo, "refs/heads/master")
- refute_nil branch
-
- assert_equal "master", branch.name
- assert_equal "refs/heads/master", branch.canonical_name
- assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", branch.tip.oid
- end
-
test "can look up remote branches" do
- branch = Rugged::Branch.lookup(@repo, "origin/packed")
- refute_nil branch
-
- assert_equal "origin/packed", branch.name
- assert_equal "refs/remotes/origin/packed", branch.canonical_name
- assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", branch.tip.oid
- end
-
- test "can look up a local branch by its canonical name" do
- branch = Rugged::Branch.lookup(@repo, "refs/remotes/origin/packed")
+ branch = Rugged::Branch.lookup(@repo, "origin/packed", :remote)
refute_nil branch
assert_equal "origin/packed", branch.name
@@ -103,8 +85,8 @@
end
test "deletes a branch from the repository" do
- @repo.create_branch("test_branch")
- Rugged::Branch.delete(@repo, "test_branch")
+ branch = @repo.create_branch("test_branch")
+ branch.delete!
assert_nil Rugged::Branch.lookup(@repo, "test_branch")
end
end
@@ -116,9 +98,10 @@
end
test "renames a branch" do
- @repo.create_branch("test_branch")
+ branch = @repo.create_branch("test_branch")
+
+ branch.move('other_branch')
- Rugged::Branch.move(@repo, "test_branch", "other_branch")
assert_nil Rugged::Branch.lookup(@repo, "test_branch")
refute_nil Rugged::Branch.lookup(@repo, "other_branch")
end
@@ -144,16 +127,17 @@
end
test "can create branches with non 7-bit ASCII names" do
- new_branch = @repo.create_branch("Ångström", "5b5b025afb0b4c913b4c338a42934a3863bf3644")
+ branch_name = "A\314\212ngstro\314\210m"
+ new_branch = @repo.create_branch(branch_name, "5b5b025afb0b4c913b4c338a42934a3863bf3644")
refute_nil new_branch
- assert_equal "Ångström", new_branch.name
- assert_equal "refs/heads/Ångström", new_branch.canonical_name
+ assert_equal branch_name, new_branch.name
+ assert_equal "refs/heads/#{branch_name}", new_branch.canonical_name
refute_nil new_branch.tip
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", new_branch.tip.oid
- refute_nil @repo.branches.find { |p| p.name == "Ångström" }
+ refute_nil @repo.branches.find { |p| p.name == branch_name }
end
test "can create a new branch with an abbreviated sha" do
View
2  test/config_test.rb
@@ -17,7 +17,7 @@
end
test "can read the global config file" do
- config = Rugged::Config.open_global
+ config = Rugged::Config.global
assert_not_nil config['user.name']
assert_nil config['core.bare']
end
View
5 test/reference_test.rb
@@ -18,9 +18,10 @@
end
test "can list references with non 7-bit ASCII characters" do
- Rugged::Reference.create(@repo, "refs/heads/Ångström", "refs/heads/master")
+ unicode_branch = "A\314\212ngstro\314\210m"
+ Rugged::Reference.create(@repo, "refs/heads/#{unicode_branch}", "refs/heads/master")
refs = @repo.refs.map { |r| r.name.gsub("refs/", '') }.sort.join(':')
- assert_equal "heads/master:heads/packed:heads/Ångström:tags/v0.9:tags/v1.0", refs
+ assert_equal "heads/#{unicode_branch}:heads/master:heads/packed:tags/v0.9:tags/v1.0", refs
@arthurschreiber Collaborator

I'm not sure whether this is correct here. The underlying issue is that Mac OS X handles unciode normalization differently. Has this been fixed in libgit2? And is this test still passing under Linux?

@vmg Owner
vmg added a note

This is a work-around for the unicode normalization in Mac OS X, which unfortunately hasn't been fixed in libgit2 yet. The tests do pass on Linux. I'll revisit this once the upsteam fix is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end
test "can list filtered references from regex" do
@arthurschreiber

I'm not sure whether this is correct here. The underlying issue is that Mac OS X handles unciode normalization differently. Has this been fixed in libgit2? And is this test still passing under Linux?

@vmg

This is a work-around for the unicode normalization in Mac OS X, which unfortunately hasn't been fixed in libgit2 yet. The tests do pass on Linux. I'll revisit this once the upsteam fix is ready.

Please sign in to comment.
Something went wrong with that request. Please try again.