diff --git a/Library/Homebrew/cmd/pull.rb b/Library/Homebrew/cmd/pull.rb
index ad70f01f40f418fb6102d60ce45a88b1cd4ab233..45c3bf76bd5118beb43773be8196075b2b89cc82 100644
--- a/Library/Homebrew/cmd/pull.rb
+++ b/Library/Homebrew/cmd/pull.rb
@@ -305,7 +305,7 @@ module Homebrew
       files << $1 if line =~ %r{^\+\+\+ b/(.*)}
     end
     files.each do |file|
-      if (tap.path/file).dirname == tap.formula_dir
+      if tap.formula_file?(file)
         formula_name = File.basename(file, ".rb")
         formulae << formula_name unless formulae.include?(formula_name)
       else
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index 712348d6035ba8cea838c2aeefed18eb25eff76e..08e85688db40e63724d2231f0157ead6c0f6edfc 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -247,6 +247,15 @@ class Tap
     end
   end
 
+  # return true if given path would present a {Formula} file in this {Tap}.
+  # accepts both absolute path and relative path (relative to this {Tap}'s path)
+  # @private
+  def formula_file?(file)
+    file = Pathname.new(file) unless file.is_a? Pathname
+    file = file.expand_path(path)
+    file.extname == ".rb" && file.parent == formula_dir
+  end
+
   # an array of all {Formula} names of this {Tap}.
   def formula_names
     @formula_names ||= formula_files.map { |f| formula_file_to_name(f) }
diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb
index 6e497a07059fa317aca578dfc467ba671dd70697..1159eb99218f35952428cfed6b598d53d9d98fb0 100644
--- a/Library/Homebrew/test/test_tap.rb
+++ b/Library/Homebrew/test/test_tap.rb
@@ -95,6 +95,10 @@ class TapTest < Homebrew::TestCase
     assert_equal @tap.formula_renames, "oldname" => "foo"
     assert_equal [@cmd_file], @tap.command_files
     assert_kind_of Hash, @tap.to_hash
+    assert_equal true, @tap.formula_file?(@formula_file)
+    assert_equal true, @tap.formula_file?("Formula/foo.rb")
+    assert_equal false, @tap.formula_file?("bar.rb")
+    assert_equal false, @tap.formula_file?("Formula/baz.sh")
   end
 
   def test_remote