diff --git a/lib/git/base.rb b/lib/git/base.rb index 30cf386f..c902f0a5 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -290,6 +290,7 @@ def reset_hard(commitish = nil, opts = {}) # options: # :force # :d + # :ff # def clean(opts = {}) self.lib.clean(opts) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 4d0daef7..5641e4eb 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -684,6 +684,7 @@ def reset(commit, opts = {}) def clean(opts = {}) arr_opts = [] arr_opts << '--force' if opts[:force] + arr_opts << '-ff' if opts[:ff] arr_opts << '-d' if opts[:d] arr_opts << '-x' if opts[:x] diff --git a/tests/units/test_index_ops.rb b/tests/units/test_index_ops.rb index fd47e609..c033735b 100644 --- a/tests/units/test_index_ops.rb +++ b/tests/units/test_index_ops.rb @@ -49,6 +49,11 @@ def test_clean g.add g.commit("first commit") + FileUtils.mkdir_p("nested") + Dir.chdir('nested') do + Git.init + end + new_file('file-to-clean', 'blablahbla') FileUtils.mkdir_p("dir_to_clean") @@ -76,6 +81,11 @@ def test_clean g.clean(:force => true, :x => true) assert(!File.exist?('ignored_file')) + + assert(File.exist?('nested')) + + g.clean(:ff => true, :d => true) + assert(!File.exist?('nested')) end end end