From ee5c1e5aa0c124b0250555beb89e224d47122d8a Mon Sep 17 00:00:00 2001 From: aero-z Date: Thu, 12 Jun 2014 02:47:56 -0400 Subject: [PATCH] Changing the output for git status when there is a rename and modify at the same time --- lib/git/status_shortcuts.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/git/status_shortcuts.rb b/lib/git/status_shortcuts.rb index d5c8886..2b656db 100644 --- a/lib/git/status_shortcuts.rb +++ b/lib/git/status_shortcuts.rb @@ -127,7 +127,12 @@ end @stat_hash[group] << {:msg => msg, :col => col, :file => file} if msg # Work tree modification states - if y == "M" + if x == "R" && y == "M" + # Extract the second file name from the format x -> y + quoted, unquoted = /^(?:"(?:[^"\\]|\\.)*"|[^"].*) -> (?:"((?:[^"\\]|\\.)*)"|(.*[^"]))$/.match(file)[1..2] + renamed_file = quoted || unquoted + @stat_hash[:unstaged] << {:msg => " modified", :col => :mod, :file => renamed_file} + elsif x != "R" && y == "M" @stat_hash[:unstaged] << {:msg => " modified", :col => :mod, :file => file} elsif y == "D" && x != "D" && x != "U" # Don't show deleted 'y' during a merge conflict.