Class: Command::Diff

Inherits:
Base
  • Object
show all
Includes:
PrintDiff
Defined in:
lib/command/diff.rb

Constant Summary

Constants included from PrintDiff

PrintDiff::DIFF_FORMATS, PrintDiff::NULL_OID, PrintDiff::NULL_PATH

Instance Attribute Summary

Attributes inherited from Base

#status

Instance Method Summary collapse

Methods included from PrintDiff

#define_print_diff_options

Methods inherited from Base

#execute, #initialize

Constructor Details

This class inherits a constructor from Command::Base

Instance Method Details

#define_optionsObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/command/diff.rb', line 9

def define_options
  @options[:patch] = true
  define_print_diff_options

  @parser.on "--cached", "--staged" do
    @options[:cached] = true
  end

  @parser.on("-1", "--base")   { @options[:stage] = 1 }
  @parser.on("-2", "--ours")   { @options[:stage] = 2 }
  @parser.on("-3", "--theirs") { @options[:stage] = 3 }
end

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/command/diff.rb', line 22

def run
  repo.index.load
  @status = repo.status

  setup_pager

  if @options[:cached]
    diff_head_index
  else
    diff_index_workspace
  end

  exit 0
end