git-status-tree 3.4.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e72a53ce9c7b68969449ed0e65909a4f84df8492c99417be1d08b5a1be3596f1
4
- data.tar.gz: 8faf28a46bfec51cd09586c9919399f290fec1c8ffa9c315bba07bd53c09cd5d
3
+ metadata.gz: 92b497a283f3b3e3c260ea64423ad9350acc0973821ebad9b69fe2368cdf0324
4
+ data.tar.gz: 8fec32b7303b4de5e2390655b1d20ee53c4c7197cedba99fa17db348fbe942e8
5
5
  SHA512:
6
- metadata.gz: d8ade1eb0d039538f1e97efa83aa6c7272fceba8411fa78b448b75d929aaf9d7bf06c7bb44286ff6e8c862c77b2d5e4a48bb006b7db4d8746e27cce92f5e57aa
7
- data.tar.gz: be24abac2836936e3d4d75b9bd3fd054ed0817c26efbdff44ebcc3dbf301d2cb016ce53966453d42ebb31861ff33c45f19e5f00fbb289f3452a850e3eb497ad4
6
+ metadata.gz: d551f8f7cb67163edde8680402d0092bb590ade73a4c4ec4ad97cf7551937e6d983f71e261eca8c5b27773bb9a51d7782a9c6096d80ef01a2afa4cd3947c74db
7
+ data.tar.gz: f1eb272a459af1b52b8c13c59fd1d510ff43c213692ed6159a53e4e468405b96711d3b5b7314acd6d2d45df7ae666c3a289149143381a50ba20d5e3fab659de0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.4.0
1
+ 3.5.1
data/bin/git-status-tree CHANGED
@@ -18,6 +18,10 @@ parser = OptionParser.new do |opts|
18
18
  options[:collapse] = true
19
19
  end
20
20
 
21
+ opts.on('-u', '--untracked-files', 'Show untracked files in new directories') do
22
+ options[:untracked_files] = true
23
+ end
24
+
21
25
  opts.on('-v', '--version', 'Show version') do
22
26
  puts "git-status-tree #{GitStatusTree::VERSION}"
23
27
  exit 0
@@ -13,7 +13,7 @@ class GitStatusTree
13
13
  def initialize(options = {})
14
14
  Node.indent = indent(options)
15
15
  Node.collapse_dirs = collapse(options)
16
- @files = `git status --porcelain`.split("\n")
16
+ @files = parse_status(`git status --porcelain -z#{untracked_files(options)}`)
17
17
  @nodes = files.map { |file| Node.create_from_string file }
18
18
  @tree = nodes.reduce { |a, i| (a + i).nodes[0] }
19
19
  end
@@ -28,6 +28,38 @@ class GitStatusTree
28
28
 
29
29
  private
30
30
 
31
+ # Parse NUL-terminated `git status --porcelain -z` output into porcelain
32
+ # entry strings. Unlike the default output, -z never quotes or escapes
33
+ # paths, so names with spaces, non-ASCII characters, quotes, backslashes
34
+ # or tabs survive intact. Rename/copy entries span two NUL-separated
35
+ # tokens ("<XY> <dest>\0<orig>\0") and are reassembled into the
36
+ # "<XY> <orig> -> <dest>" form the node parser expects.
37
+ def parse_status(raw)
38
+ # Paths are emitted as raw UTF-8 bytes; tag them so names display literally.
39
+ tokens = raw.force_encoding('UTF-8').split("\0")
40
+ files = []
41
+ index = 0
42
+ while index < tokens.length
43
+ entry = tokens[index]
44
+ index += 1
45
+ next if entry.nil? || entry.empty?
46
+
47
+ if rename_or_copy?(entry)
48
+ orig = tokens[index]
49
+ index += 1
50
+ files << "#{entry[0, 3]}#{orig} -> #{entry[3..]}"
51
+ else
52
+ files << entry
53
+ end
54
+ end
55
+ files
56
+ end
57
+
58
+ def rename_or_copy?(entry)
59
+ status = entry[0, 2]
60
+ status.include?('R') || status.include?('C')
61
+ end
62
+
31
63
  def indent(options)
32
64
  indent = options[:indent] || config || 4
33
65
  indent = 2 if indent < 2
@@ -42,6 +74,11 @@ class GitStatusTree
42
74
  config_collapse?
43
75
  end
44
76
 
77
+ def untracked_files(options)
78
+ # Show untracked files in new directories, like `git status --untracked-files`
79
+ options[:untracked_files] ? ' --untracked-files=all' : ''
80
+ end
81
+
45
82
  def config
46
83
  config = `git config --global status-tree.indent`.strip
47
84
  config =~ /\A\d+\z/ ? config.to_i : nil
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-status-tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wolfgang Teuber
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-07-03 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: git-status-tree is a command line tool that shows git repository changes
14
13
  in a file tree.
@@ -39,7 +38,6 @@ licenses:
39
38
  metadata:
40
39
  source_code_uri: https://github.com/wteuber/git-status-tree
41
40
  rubygems_mfa_required: 'true'
42
- post_install_message:
43
41
  rdoc_options: []
44
42
  require_paths:
45
43
  - lib
@@ -47,15 +45,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
45
  requirements:
48
46
  - - ">="
49
47
  - !ruby/object:Gem::Version
50
- version: '3.3'
48
+ version: '3.4'
51
49
  required_rubygems_version: !ruby/object:Gem::Requirement
52
50
  requirements:
53
51
  - - ">="
54
52
  - !ruby/object:Gem::Version
55
53
  version: '0'
56
54
  requirements: []
57
- rubygems_version: 3.0.3.1
58
- signing_key:
55
+ rubygems_version: 3.6.9
59
56
  specification_version: 4
60
57
  summary: git status in file tree format
61
58
  test_files: []