Skip to content

Commit 3854d1a

Browse files
committed
Cleaner way to check for empty repo path
1 parent b736983 commit 3854d1a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ext/rugged/rugged_repo.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,13 +1174,12 @@ static VALUE rb_git_repo_get_head(VALUE self)
11741174
static VALUE rb_git_repo_path(VALUE self)
11751175
{
11761176
git_repository *repo;
1177-
Data_Get_Struct(self, git_repository, repo);
1177+
const char *path;
11781178

1179-
const char *path = git_repository_path(repo);
1180-
if (path == NULL)
1181-
return Qnil;
1179+
Data_Get_Struct(self, git_repository, repo);
1180+
path = git_repository_path(repo);
11821181

1183-
return rb_str_new_utf8(path);
1182+
return path ? rb_str_new_utf8(path) : Qnil;
11841183
}
11851184

11861185
/*

0 commit comments

Comments
 (0)