Permalink
Browse files

Check only once if git repo is empty. Faster.

  • Loading branch information...
1 parent 32c084f commit 15c7ac6ac97854c1f998eafc765ac7759dafab07 @thomie thomie committed Aug 15, 2010
Showing with 6 additions and 7 deletions.
  1. +6 −7 darcs-to-git
View
@@ -211,7 +211,6 @@ class CommitHistory
end
def find_git_commit(is_tag, git_tag_name, identifier)
- return nil if empty_repo?
if is_tag
(output_of("git", "tag", "-l") rescue "").split(/\r?\n/).include?(git_tag_name) &&
output_of("git", "rev-list", "--max-count=1", "tags/#{git_tag_name}").strip
@@ -220,12 +219,12 @@ class CommitHistory
end
end
- private
-
def empty_repo?
!system("git rev-parse --verify HEAD >/dev/null 2>&1")
end
+ private
+
def fill_from_darcs_hash_comments
return if empty_repo?
Array(output_of("git", "log", "--grep=darcs-hash:", "--nocolor").split(/^commit /m)[1..-1]).each do |entry|
@@ -473,10 +472,10 @@ if OPTIONS[:list_authors]
exit(0)
end
-patches_available = []
-while patch = patches.pop
- next if patch.id_in_git_repo
- patches_available.unshift(patch)
+if COMMIT_HISTORY.empty_repo?
+ patches_available = patches
+else
+ patches_available = patches.find_all { |p| not p.id_in_git_repo }
end
patches_to_pull = if OPTIONS[:num_patches]

0 comments on commit 15c7ac6

Please sign in to comment.