From e01439e8192d6440e30ef8b94ade5642f68745fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Wed, 20 Dec 2017 15:05:52 +0100 Subject: nil-guard --- lib/gitlab/git/repository.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 964439ffcd6..f960732d172 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -1087,10 +1087,12 @@ module Gitlab def update_ref(ref_path, ref, old_ref: nil, force: false) raise ArgumentError, "invalid ref_path #{ref_path.inspect}" if ref_path.include?(' ') raise ArgumentError, "invalid ref #{ref.inspect}" if ref.include?("\x00") - raise ArgumentError, "invalid old_ref #{old_ref.inspect}" if old_ref.include?("\x00") + raise ArgumentError, "invalid old_ref #{old_ref.inspect}" if old_ref && old_ref.include?("\x00") ref = "refs/heads/#{ref}" unless ref.start_with?("refs") || ref =~ /\A[a-f0-9]+\z/i - old_ref = "refs/heads/#{old_ref}" unless old_ref.start_with?("refs") || old_ref =~ /\A[a-f0-9]+\z/i + if old_ref + old_ref = "refs/heads/#{old_ref}" unless old_ref.start_with?("refs") || old_ref =~ /\A[a-f0-9]+\z/i + end run_git!(%W[update-ref --stdin -z]) do |stdin| stdin.write("update #{ref_path}\x00#{ref}\x00#{old_ref}\x00") -- cgit v1.2.1