Skip to content

Commit daeb338

Browse files
repo: extend info paths and structure statistics
Improve git repo info by adding path-oriented keys that match values users currently obtain from git rev-parse, including common directory, git directory, top-level, superproject working tree, and additional git-path based locations. Teach git repo info to accept category keys like layout and path, and add --path-format=(absolute|relative) so scripts can request the desired path style explicitly. The command now uses repository context passed to the command path instead of relying on global state. Extend git repo structure with deeper repository metrics inspired by git-sizer, including per-type maximum inflated and on-disk object sizes, maximum commit parent count, maximum tree entry count, longest/deepest blob path, and deepest annotated tag chain. Update documentation and tests to cover new keys, formats, and metrics. Signed-off-by: eslam-reda-div <eslam.reda.div@gmail.com>
1 parent 7c02d39 commit daeb338

File tree

4 files changed

+962
-26
lines changed

4 files changed

+962
-26
lines changed

Documentation/git-repo.adoc

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-repo - Retrieve information about the repository
88
SYNOPSIS
99
--------
1010
[synopsis]
11-
git repo info [--format=(keyvalue|nul) | -z] [--all | <key>...]
11+
git repo info [--format=(keyvalue|nul) | -z] [--path-format=(absolute|relative)] [--all | <key>...]
1212
git repo structure [--format=(table|keyvalue|nul) | -z]
1313

1414
DESCRIPTION
@@ -44,6 +44,11 @@ supported:
4444
+
4545
`-z` is an alias for `--format=nul`.
4646

47+
`--path-format=(absolute|relative)`:::
48+
Controls formatting for keys in the `path` category. The default is
49+
`absolute`. This option may be specified multiple times; the last one
50+
specified takes effect.
51+
4752
`structure [--format=(table|keyvalue|nul) | -z]`::
4853
Retrieve statistics about the current repository structure. The
4954
following kinds of information are reported:
@@ -52,6 +57,12 @@ supported:
5257
* Reachable object counts categorized by type
5358
* Total inflated size of reachable objects by type
5459
* Total disk size of reachable objects by type
60+
* Largest inflated reachable object size by type
61+
* Largest disk size of a reachable object by type
62+
* Largest parent count among reachable commits
63+
* Largest entry count among reachable trees
64+
* Longest and deepest path among reachable blobs
65+
* Deepest annotated tag chain
5566
+
5667
The output format can be chosen through the flag `--format`. Three formats are
5768
supported:
@@ -64,6 +75,7 @@ supported:
6475
`keyvalue`:::
6576
Each line of output contains a key-value pair for a repository stat.
6677
The '=' character is used to delimit between the key and the value.
78+
Both aggregate metrics and per-type metrics are included.
6779
Values containing "unusual" characters are quoted as explained for the
6880
configuration variable `core.quotePath` (see linkgit:git-config[1]).
6981

@@ -78,9 +90,11 @@ supported:
7890

7991
INFO KEYS
8092
---------
81-
In order to obtain a set of values from `git repo info`, you should provide
82-
the keys that identify them. Here's a list of the available keys and the
83-
values that they return:
93+
In order to obtain values from `git repo info`, provide either individual keys
94+
or category names. A category returns all keys within that category. For
95+
example, `layout` returns both `layout.bare` and `layout.shallow`.
96+
97+
Here's a list of the available keys and the values that they return:
8498

8599
`layout.bare`::
86100
`true` if this is a bare repository, otherwise `false`.
@@ -91,6 +105,51 @@ values that they return:
91105
`object.format`::
92106
The object format (hash algorithm) used in the repository.
93107

108+
`path.common-dir`::
109+
The path to the common git directory.
110+
111+
`path.config-file`::
112+
The path to the `config` file in the git directory.
113+
114+
`path.git-dir`::
115+
The path to the git directory.
116+
117+
`path.git-prefix`::
118+
The path of the current working directory relative to the top-level
119+
directory.
120+
121+
`path.grafts-file`::
122+
The path to the `info/grafts` file.
123+
124+
`path.hooks-directory`::
125+
The path to the `hooks` directory.
126+
127+
`path.index-file`::
128+
The path to the index file.
129+
130+
`path.logs-directory`::
131+
The path to the `logs` directory.
132+
133+
`path.objects-directory`::
134+
The path to the objects directory.
135+
136+
`path.packed-refs-file`::
137+
The path to the `packed-refs` file.
138+
139+
`path.refs-directory`::
140+
The path to the `refs` directory.
141+
142+
`path.shallow-file`::
143+
The path to the `shallow` file.
144+
145+
`path.superproject-working-tree`::
146+
The path to the superproject's working tree root, or an empty string
147+
when the repository is not used as a submodule.
148+
149+
`path.toplevel`::
150+
The path to the top-level working tree directory, or an empty string
151+
for bare repositories.
152+
94153
`references.format`::
95154
The reference storage format. The valid values are:
96155
+

0 commit comments

Comments
 (0)