File: no_color_pipes.diff

package info (click to toggle)
ruby-git 1.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 2,496 kB
  • ctags: 567
  • sloc: ruby: 3,052; sh: 226; makefile: 7
file content (56 lines) | stat: -rw-r--r-- 1,915 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Subject: Use “--no-color” on certain Git commands
From: Michael Schutte <michi@debian.org>
Bug-Debian: http://bugs.debian.org/592673

“color.* = always” settings in the users’ Git configuration messes up
ruby-git’s parsing of the output of commands like “git branch” and “git
diff”.  Avoid the problem by overriding this behaviour through the
“--no-color” switch.

--- devel.orig/lib/git/lib.rb
+++ devel/lib/git/lib.rb
@@ -224,7 +224,7 @@
     
     def branches_all
       arr = []
-      command_lines('branch', '-a').each do |b| 
+      command_lines('branch', ['--no-color', '-a']).each do |b|
         current = (b[0, 2] == '* ')
         arr << [b.gsub('* ', '').strip, current]
       end
@@ -249,7 +249,7 @@
     def grep(string, opts = {})
       opts[:object] ||= 'HEAD'
 
-      grep_opts = ['-n']
+      grep_opts = ['--no-color', '-n']
       grep_opts << '-i' if opts[:ignore_case]
       grep_opts << '-v' if opts[:invert_match]
       grep_opts << '-e'
@@ -268,7 +268,7 @@
     end
     
     def diff_full(obj1 = 'HEAD', obj2 = nil, opts = {})
-      diff_opts = ['-p']
+      diff_opts = ['--no-color', '-p']
       diff_opts << obj1
       diff_opts << obj2 if obj2.is_a?(String)
       diff_opts << '--' << opts[:path_limiter] if opts[:path_limiter].is_a? String
@@ -277,7 +277,7 @@
     end
     
     def diff_stats(obj1 = 'HEAD', obj2 = nil, opts = {})
-      diff_opts = ['--numstat']
+      diff_opts = ['--no-color', '--numstat']
       diff_opts << obj1
       diff_opts << obj2 if obj2.is_a?(String)
       diff_opts << '--' << opts[:path_limiter] if opts[:path_limiter].is_a? String
@@ -544,7 +544,7 @@
 
     def unmerged
       unmerged = []
-      command_lines('diff', ["--cached"]).each do |line|
+      command_lines('diff', ['--no-color', "--cached"]).each do |line|
         unmerged << $1 if line =~ /^\* Unmerged path (.*)/
       end
       unmerged