Skip to content

Rebase to v2.47.0 #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 240 commits into from
Oct 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
6138534
builtin/gc: fix crash when running `git maintenance start`
pks-t Oct 8, 2024
a3d7a50
t: remove advice from some tests
derrickstolee Jul 16, 2024
394eed4
sparse-index.c: fix use of index hashes in expand_index
vdye Sep 20, 2023
7bcd46a
t5300: confirm failure of git index-pack when non-idx suffix requested
jeffhostetler Aug 25, 2023
f2db492
t1092: add test for untracked files and directories
vdye Sep 20, 2023
69b5eb8
index-pack: disable rev-index if index file has non .idx suffix
jeffhostetler Aug 25, 2023
fd1e3c2
trace2: prefetch value of GIT_TRACE2_DST_DEBUG at startup
jeffhostetler Jun 26, 2024
7715abe
survey: calculate more stats on refs
jeffhostetler Apr 29, 2024
00f402c
amend! survey: add --top=<N> option and config
dscho Oct 7, 2024
01146de
survey: show some commits/trees/blobs histograms
jeffhostetler Apr 29, 2024
56703e7
survey: add vector of largest objects for various scaling dimensions
jeffhostetler May 1, 2024
6e58ef5
survey: add pathname of blob or tree to large_item_vec
jeffhostetler May 15, 2024
d012ace
survey: add commit-oid to large_item detail
jeffhostetler May 15, 2024
65e4955
survey: add commit name-rev lookup to each large_item
jeffhostetler May 20, 2024
9d157fd
survey: add --no-name-rev option
jeffhostetler Jun 4, 2024
36931e9
survey: started TODO list at bottom of source file
jeffhostetler Jun 17, 2024
cbc6815
survey: expanded TODO list at the bottom of the source file
jeffhostetler Jun 28, 2024
75357a3
survey: expanded TODO with more notes
jeffhostetler Jul 1, 2024
590936c
Merge branch 'jh/experimental-survey'
dscho Jul 1, 2024
ea74993
Merge branch 'backport-sparse-index-advice'
dscho Jul 17, 2024
ce904bd
Fix `sparse-checkout set` crashes (#607)
vdye Sep 20, 2023
ee760f9
Fix rev index in 2.42.0 series (#600)
jeffhostetler Aug 29, 2023
fae8d7d
trace2: prefetch value of GIT_TRACE2_DST_DEBUG at startup (#663)
dscho Jun 26, 2024
3d1112f
Add the experimental git survey command to analyze (large) local repo…
dscho Jul 2, 2024
590aed4
reset --stdin: trim carriage return from the paths
Apr 5, 2017
5e80a3a
Identify microsoft/git via a distinct version suffix
dscho Apr 23, 2024
a0ff411
gvfs: ensure that the version is based on a GVFS tag
dscho Apr 4, 2017
6ef6540
gvfs: add a GVFS-specific header file
Jan 24, 2017
030b553
git_config_set_multivar_in_file_gently(): add a lock timeout
dscho May 18, 2021
b73befa
scalar: set the config write-lock timeout to 150ms
dscho May 18, 2021
d081111
scalar: add docs from microsoft/scalar
derrickstolee Jun 16, 2021
c3eb6fc
Merge branch 'scalar-gentler-config-locking'
dscho May 19, 2021
bbbbf56
Merge branch 'scalar-extra-docs'
dscho Nov 16, 2021
7b212db
scalar (Windows): use forward slashes as directory separators
dscho May 10, 2022
8521b1a
scalar: add retry logic to run_git()
derrickstolee Jun 17, 2021
d97b7b2
scalar: support the `config` command for backwards compatibility
dscho May 27, 2021
a9de9d0
sequencer: avoid progress when stderr is redirected
derrickstolee Sep 23, 2021
e3d9c14
gvfs: add the core.gvfs config setting
Jan 24, 2017
dd7004d
gvfs: add the feature to skip writing the index' SHA-1
Jan 24, 2017
f9b8c1e
gvfs: add the feature that blobs may be missing
Jan 24, 2017
c7ee926
gvfs: prevent files to be deleted outside the sparse checkout
May 18, 2016
d25865c
gvfs: optionally skip reachability checks/upload pack during fetch
May 30, 2016
162137d
gvfs: ensure all filters and EOL conversions are blocked
Jun 15, 2016
2516df2
gvfs: allow "virtualizing" objects
Jan 10, 2017
06584ba
Hydrate missing loose objects in check_and_freshen()
Mar 15, 2017
f3f8f88
sha1_file: when writing objects, skip the read_object_hook
dscho Sep 8, 2017
ec080b0
gvfs: add global command pre and post hook procs
May 24, 2016
348aec0
t0400: verify that the hook is called correctly from a subdirectory
dscho Mar 16, 2017
af565b2
Pass PID of git process to hooks.
alepauly Apr 10, 2017
0e0264e
pre-command: always respect core.hooksPath
dscho Aug 7, 2017
2b67c6a
sparse-checkout: update files with a modify/delete conflict
Feb 22, 2017
3191f6e
sparse-checkout: avoid writing entries with the skip-worktree bit
Mar 1, 2017
481bff4
Do not remove files outside the sparse-checkout
Apr 5, 2017
31d7cc7
send-pack: do not check for sha1 file when GVFS_MISSING_OK set
Nov 16, 2018
d24c5ab
cache-tree: remove use of strbuf_addf in update_one
Jul 3, 2017
f681e1a
gvfs: block unsupported commands when running in a GVFS repo
benpeart Dec 6, 2018
46eca79
worktree: allow in Scalar repositories
derrickstolee Sep 30, 2022
04634cf
gvfs: allow overriding core.gvfs
derrickstolee Apr 15, 2020
b8f54a1
Add virtual file system settings and hook proc
benpeart Jan 11, 2018
8289b81
BRANCHES.md: Add explanation of branches and using forks
Jul 27, 2018
b09c255
virtualfilesystem: don't run the virtual file system hook if the inde…
benpeart Aug 1, 2018
dcb6eee
virtualfilesystem: check if directory is included
Oct 9, 2018
f2621e5
backwards-compatibility: support the post-indexchanged hook
dscho May 28, 2019
5e58e1f
gvfs: verify that the built-in FSMonitor is disabled
dscho Jun 18, 2021
ce2abce
wt-status: add trace2 data for sparse-checkout percentage
jeffhostetler Jun 21, 2024
7821224
wt-status: add VFS hydration percentage to normal `git status` output
jeffhostetler Jun 24, 2024
326915f
status: add status serialization mechanism
jeffhostetler Aug 22, 2017
315f2e1
Teach ahead-behind and serialized status to play nicely together
jamill Jan 10, 2018
0ff0247
status: serialize to path
jeffhostetler Feb 2, 2018
5fe3d3d
status: reject deserialize in V2 and conflicts
jeffhostetler Feb 7, 2018
fe9f2d8
serialize-status: serialize global and repo-local exclude file metadata
jeffhostetler Jul 20, 2018
3777145
status: deserialization wait
jeffhostetler Jul 25, 2018
2f09a38
merge-recursive: avoid confusing logic in was_dirty()
dscho May 21, 2019
de4dcad
merge-recursive: add some defensive coding to was_dirty()
dscho May 21, 2019
eccf801
merge-recursive: teach was_dirty() about the virtualfilesystem
dscho May 21, 2019
1e410a6
status: deserialize with -uno does not print correct hint
jeffhostetler Jun 25, 2019
a1eee56
fsmonitor: check CE_FSMONITOR_VALID in ce_uptodate
kewillford Nov 21, 2019
b0d651c
fsmonitor: add script for debugging and update script for tests
kewillford Nov 21, 2019
d9b0c4d
status: disable deserialize when verbose output requested.
jeffhostetler Apr 11, 2020
7ebc9cf
t7524: add test for verbose status deserialzation
jeffhostetler Apr 11, 2020
1518949
gvfs:trace2:data: add trace2 tracing around read_object_process
jeffhostetler Sep 26, 2018
894c6fa
deserialize-status: silently fallback if we cannot read cache file
jeffhostetler May 13, 2020
0591475
gvfs:trace2:data: status deserialization information
jeffhostetler Sep 26, 2018
d754327
gvfs:trace2:data: status serialization
jeffhostetler Jan 7, 2019
b05adb3
gvfs:trace2:data: add vfs stats
jeffhostetler Nov 19, 2018
9f20d58
trace2: refactor setting process starting time
jeffhostetler Apr 15, 2019
4728e16
trace2:gvfs:experiment: clear_ce_flags_1
jeffhostetler Apr 30, 2019
e5c9e72
trace2:gvfs:experiment: report_tracking
jeffhostetler Apr 30, 2019
310ca5b
trace2:gvfs:experiment: read_cache: annotate thread usage in read-cache
jeffhostetler Jun 14, 2019
dc05480
trace2:gvfs:experiment: read-cache: time read/write of cache-tree ext…
jeffhostetler Jul 9, 2019
41289c2
trace2:gvfs:experiment: add region to apply_virtualfilesystem()
jeffhostetler Jul 16, 2019
a0f0ff0
trace2:gvfs:experiment: add region around unpack_trees()
jeffhostetler Jul 16, 2019
98907ca
trace2:gvfs:experiment: add region to cache_tree_fully_valid()
jeffhostetler Jul 16, 2019
a3ae6c2
trace2:gvfs:experiment: add unpack_entry() counter to unpack_trees() …
jeffhostetler Jul 16, 2019
aeaecb8
trace2:gvfs:experiment: increase default event depth for unpack-tree …
jeffhostetler Jul 25, 2019
bc6777b
trace2:gvfs:experiment: add data for check_updates() in unpack_trees()
jeffhostetler Jul 25, 2019
63867c1
credential: set trace2_child_class for credential manager children
jeffhostetler Oct 3, 2019
eebba67
sub-process: do not borrow cmd pointer from caller
jeffhostetler Sep 18, 2019
5c5978f
sub-process: add subprocess_start_argv()
jeffhostetler Sep 18, 2019
97677e8
Trace2:gvfs:experiment: capture more 'tracking' details
jeffhostetler Jul 26, 2019
e29fc35
sha1-file: add function to update existing loose object cache
jeffhostetler Sep 24, 2019
3f933ea
packfile: add install_packed_git_and_mru()
jeffhostetler Sep 25, 2019
84be3ac
index-pack: avoid immediate object fetch while parsing packfile
jeffhostetler Sep 24, 2019
c01af59
gvfs-helper: create tool to fetch objects using the GVFS Protocol
jeffhostetler Aug 13, 2019
18880ae
sha1-file: create shared-cache directory if it doesn't exist
jeffhostetler Oct 7, 2019
97241c5
gvfs-helper: better handling of network errors
jeffhostetler Oct 8, 2019
7671014
gvfs-helper-client: properly update loose cache with fetched OID
jeffhostetler Oct 8, 2019
498965d
gvfs-helper: V2 robust retry and throttling
jeffhostetler Oct 10, 2019
c26c30c
gvfs-helper: expose gvfs/objects GET and POST semantics
jeffhostetler Oct 21, 2019
e848049
gvfs-helper: dramatically reduce progress noise
derrickstolee Oct 24, 2019
a0660a8
gvfs-helper-client.h: define struct object_id
derrickstolee Nov 4, 2019
7ca6622
gvfs-helper: handle pack-file after single POST request
derrickstolee Nov 11, 2019
489690c
test-gvfs-prococol, t5799: tests for gvfs-helper
jeffhostetler Oct 25, 2019
fa34591
gvfs-helper: move result-list construction into install functions
jeffhostetler Nov 13, 2019
89eee09
t5799: add support for POST to return either a loose object or packfile
jeffhostetler Nov 13, 2019
79d9ca3
t5799: cleanup wc-l and grep-c lines
jeffhostetler Nov 13, 2019
0b1bb6b
gvfs-helper: verify loose objects after write
derrickstolee Sep 18, 2020
825246d
t7599: create corrupt blob test
jeffhostetler Sep 18, 2020
bcf4132
gvfs-helper: add prefetch support
jeffhostetler Nov 11, 2019
b09134e
gvfs-helper: add prefetch .keep file for last packfile
jeffhostetler Nov 26, 2019
310ecd2
gvfs-helper: do one read in my_copy_fd_len_tail()
derrickstolee Dec 16, 2019
d0434d9
gvfs-helper: move content-type warning for prefetch packs
derrickstolee Dec 16, 2019
fc04f4e
fetch: use gvfs-helper prefetch under config
derrickstolee Dec 17, 2019
2f45c5c
gvfs-helper: better support for concurrent packfile fetches
jeffhostetler Dec 18, 2019
74be436
remote-curl: do not call fetch-pack when using gvfs-helper
derrickstolee Feb 3, 2020
1bd9618
fetch: reprepare packs before checking connectivity
derrickstolee Mar 12, 2020
ab1bf56
gvfs-helper: retry when creating temp files
derrickstolee Dec 26, 2019
7c508fd
sparse: avoid warnings about known cURL issues in gvfs-helper.c
derrickstolee Aug 3, 2021
3c21eb8
gvfs-helper: add --max-retries to prefetch verb
jeffhostetler Apr 12, 2023
d926ead
t5799: add tests to detect corrupt pack/idx files in prefetch
jeffhostetler Apr 13, 2023
7187cdc
gvfs-helper: ignore .idx files in prefetch multi-part responses
jeffhostetler Apr 13, 2023
c8e85f0
t5799: explicitly test gvfs-helper --fallback and --no-fallback
jeffhostetler Jun 28, 2024
f33f916
gvfs-helper: don't fallback with new config
derrickstolee Jun 27, 2024
b277bb5
test-gvfs-protocol: add cache_http_503 to mayhem
jeffhostetler Jun 28, 2024
fdbe46e
t5799: add unit tests for new `gvfs.fallback` config setting
jeffhostetler Jun 28, 2024
d2a392b
maintenance: care about gvfs.sharedCache config
derrickstolee Dec 15, 2020
c5baf20
homebrew: add GitHub workflow to release Cask
mjcheetham Jul 24, 2020
d4809ce
unpack-trees:virtualfilesystem: Improve efficiency of clear_ce_flags
neerajsi-msft2 Feb 6, 2021
bb18f15
Adding winget workflows
Apr 29, 2021
e431fc0
release: create initial Windows installer build workflow
vdye Jul 16, 2021
a328f56
help: special-case HOST_CPU `universal`
jeffhostetler Oct 17, 2023
c4755a1
release: add Mac OSX installer build
vdye Jul 16, 2021
f18e4e9
Disable the `monitor-components` workflow in msft-git
dscho May 13, 2022
a06b3af
release: build unsigned Ubuntu .deb package
vdye Jul 16, 2021
d4f8fd7
.github: enable windows builds on microsoft fork
derrickstolee Mar 8, 2023
1b62d30
release: add signing step for .deb package
vdye Jul 16, 2021
22d8700
release: create draft GitHub release with packages & installers
vdye Jul 16, 2021
a53c642
build-git-installers: publish gpg public key
ldennington Oct 24, 2023
527d792
Makefile: allow specifying GIT_BUILT_FROM_COMMIT
vdye Nov 30, 2021
824cd31
release: continue pestering until user upgrades
derrickstolee Oct 6, 2021
e837cb1
dist: archive HEAD instead of HEAD^{tree}
vdye Dec 2, 2021
a7a9fcc
release: include GIT_BUILT_FROM_COMMIT in MacOS build
vdye Dec 2, 2021
35b06f4
update-microsoft-git: create barebones builtin
derrickstolee Apr 29, 2021
b417e25
release: add installer validation
ldennington Aug 17, 2022
3a503aa
.github: update ISSUE_TEMPLATE.md for microsoft/git
derrickstolee Mar 16, 2022
9124c6d
update-microsoft-git: Windows implementation
derrickstolee Apr 29, 2021
a95050d
.github: update PULL_REQUEST_TEMPLATE.md
derrickstolee Mar 16, 2022
ba18ed8
update-microsoft-git: use brew on macOS
derrickstolee Apr 29, 2021
58aeae2
Adjust README.md for microsoft/git
May 4, 2021
2f21521
Merge branch 'microsoft/vfs-2.35.0'
dscho Oct 7, 2021
9c6101e
scalar: implement a minimal JSON parser
dscho Apr 26, 2021
175f592
Merge branch 'scalar'
dscho Aug 24, 2021
eac9b64
scalar clone: support GVFS-enabled remote repositories
dscho Aug 24, 2021
f14c7d8
test-gvfs-protocol: also serve smart protocol
dscho Apr 16, 2021
c7f3e70
gvfs-helper: add the `endpoint` command
dscho Apr 26, 2021
c5f64c9
dir_inside_of(): handle directory separators correctly
dscho May 14, 2021
753c4cc
scalar: disable authentication in unattended mode
dscho May 6, 2021
a19292d
scalar: do initialize `gvfs.sharedCache`
dscho May 3, 2021
67c83f5
scalar diagnose: include shared cache info
dscho Jun 1, 2021
20265b8
scalar: only try GVFS protocol on https:// URLs
dscho Apr 28, 2021
b189c53
scalar: verify that we can use a GVFS-enabled repository
dscho Apr 16, 2021
d9857f4
scalar: add the `cache-server` command
dscho Apr 23, 2021
ef291fc
scalar: add a test toggle to skip accessing the vsts/info endpoint
dscho May 12, 2021
9fe3bbd
scalar: adjust documentation to the microsoft/git fork
dscho Jan 25, 2022
837148a
scalar: enable untracked cache unconditionally
derrickstolee Jun 21, 2021
434b583
scalar: parse `clone --no-fetch-commits-and-trees` for backwards comp…
dscho Aug 24, 2021
47281de
scalar: make GVFS Protocol a forced choice
derrickstolee May 1, 2024
8ee6ef5
scalar diagnose: accommodate Scalar's Functional Tests
dscho May 9, 2022
2769884
ci: run Scalar's Functional Tests
dscho Jun 8, 2021
0d0fe29
scalar: upgrade to newest FSMonitor config setting
vdye Apr 5, 2022
053aae8
abspath: make strip_last_path_component() global
derrickstolee Oct 4, 2022
5c9af56
scalar: configure maintenance during 'reconfigure'
derrickstolee Aug 21, 2023
7b65af4
scalar: .scalarCache should live above enlistment
derrickstolee Sep 30, 2022
eacf41e
Merge branch 'scalar-with-gvfs'
dscho May 3, 2021
d77e89a
Merge branch 'run-scalar-functional-tests'
dscho Nov 16, 2021
9fab7b7
Merge branch 'scalar-reconfigure'
dscho Jun 1, 2021
7d5587e
Merge branch 'scalar-and-non-interactive-authentication-in-maintenance'
dscho Jul 18, 2024
e34dfb6
Merge pull request #536: Allow --no-src during clones and git worktre…
dscho Oct 4, 2022
7bab9ee
sparse-checkout: add config to disable deleting dirs
derrickstolee Aug 22, 2021
a30259c
add/rm: allow adding sparse entries when virtual
derrickstolee Jun 29, 2021
cb1e354
diff: ignore sparse paths in diffstat
derrickstolee Jul 26, 2021
2a86fa7
Merge pull request #392: add: allow adding sparse entries when virtual
derrickstolee Jul 1, 2021
137bd5e
repo-settings: enable sparse index by default
derrickstolee Jun 15, 2021
57cfc32
Merge pull request #410: Sparse Index: latest integrations
derrickstolee Aug 24, 2021
6793418
diff(sparse-index): verify with partially-sparse
ldennington Sep 10, 2021
851349f
Merge pull request #414: Make sparse index the default
derrickstolee Aug 26, 2021
8f74178
stash: expand testing for `git stash -u`
vdye Sep 22, 2021
2e03aac
Merge pull request #419 from ldennington/sparse-index-diff
ldennington Sep 12, 2021
1fbb3e9
Merge pull request #430 from vdye/sparse-index/clean
vdye Sep 23, 2021
e0acaf0
Merge pull request #432: sequencer: avoid progress when stderr is red…
derrickstolee Sep 23, 2021
44b0cdb
reset: fix mixed reset when using virtual filesystem
Mar 15, 2017
362625b
sparse: add vfs-specific precautions
derrickstolee Oct 31, 2021
7db94e5
Merge pull request #494: reset: fix mixed reset when using virtual fi…
derrickstolee Apr 4, 2022
05689ee
Merge core VFS features
dscho Jun 11, 2018
e222b1f
Merge advanced VFS-specific features
dscho Jun 11, 2018
b02d986
Merge virtualfilesystem hook
dscho Jun 11, 2018
9b44aaa
Merge updates to serialized status
dscho Jun 11, 2018
95af07b
Merge trace2 experimental regions
jeffhostetler Apr 23, 2019
c06e60c
Merge first wave of gvfs-helper feature
jeffhostetler Nov 14, 2019
9a20ba6
Merge gvfs-helper prefetch feature
derrickstolee Dec 17, 2019
0cbb69a
Harden gvfs-helper to validate the packfiles in a multipart prefetch …
jeffhostetler Apr 17, 2023
53cf5d6
gvfs-helper: add gvfs.fallback and unit tests (#665)
dscho Jul 1, 2024
4b96a79
Merge pull request #301: Update 'git maintenance' to match upstream
derrickstolee Dec 15, 2020
a072362
Merge pull request #315: unpack-trees:virtualfilesystem: Improve effi…
derrickstolee Feb 16, 2021
d113326
Merge branch 'add-workflows'
derrickstolee Apr 30, 2021
bb1a361
Merge branch 'adjust-g4w-workflows'
dscho May 13, 2022
ece0577
Merge pull request #399 from vdye/feature/build-installers
vdye Jul 29, 2021
6e499ef
Merge pull request #472 from vdye/ms/macos-build-options
vdye Dec 6, 2021
42f2f5b
Merge pull request #329: Add `git update-microsoft-git`
derrickstolee Apr 30, 2021
6f1759d
Merge pull request #333: update microsoft/git README
derrickstolee May 17, 2021
2d9c105
Merge pull request #371 from dscho/run-scalar-functional-tests-and-fi…
dscho Jun 9, 2021
cf6e136
Merge branch 'sparse-index-stuff'
dscho Jun 17, 2022
3dc443c
fixup! sparse-checkout: update files with a modify/delete conflict
dscho Oct 8, 2024
dd84253
fixup! survey: show some commits/trees/blobs histograms
dscho Oct 8, 2024
7473add
fixup! survey: show some commits/trees/blobs histograms
dscho Oct 8, 2024
becfd0a
fixup! builtin/gc: fix crash when running `git maintenance start`
derrickstolee Oct 9, 2024
91bb76c
fixup! status: add status serialization mechanism
dscho Oct 9, 2024
cc10eb0
fixup! survey: add commit name-rev lookup to each large_item
dscho Oct 9, 2024
10b13c6
fixup! survey: add commit name-rev lookup to each large_item
dscho Oct 9, 2024
4ee891f
Merge branch 'derrickstolee/gc-fix-quick'
dscho Oct 9, 2024
e9974ed
sparse-index: add ensure_full_index_with_reason()
derrickstolee Sep 30, 2024
457a140
treewide: add reasons for expanding index
derrickstolee Sep 30, 2024
d35ad11
treewide: custom reasons for expanding index
derrickstolee Sep 30, 2024
f2ebd86
sparse-index: add macro for unaudited expansions
derrickstolee Sep 30, 2024
6d2316e
Docs: update sparse index plan with logging
derrickstolee Sep 30, 2024
8025aa2
sparse-index: log failure to clear skip-worktree
derrickstolee Sep 30, 2024
622f430
Sparse Index: log why the index is being expanded (#691)
dscho Oct 9, 2024
a934bbe
stash: use -f in checkout-index child process
derrickstolee Sep 30, 2024
777ce4d
sparse-index: do not copy hashtables during expansion
derrickstolee Sep 27, 2024
26ff51d
Fix rare segfault in sparse-index (#690)
dscho Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 87 additions & 3 deletions builtin/survey.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ref-filter.h"
#include "refs.h"
#include "revision.h"
#include "run-command.h"
#include "strbuf.h"
#include "strvec.h"
#include "trace2.h"
Expand Down Expand Up @@ -171,6 +172,12 @@ struct large_item {
* order).
*/
struct object_id containing_commit_oid;

/*
* Lookup `containing_commit_oid` using `git name-rev`.
* Lazy allocate this post-treewalk.
*/
struct strbuf name_rev;
};

struct large_item_vec {
Expand Down Expand Up @@ -207,8 +214,10 @@ static void free_large_item_vec(struct large_item_vec *vec)
if (!vec)
return;

for (size_t k = 0; k < vec->nr_items; k++)
for (size_t k = 0; k < vec->nr_items; k++) {
strbuf_release(&vec->items[k].name);
strbuf_release(&vec->items[k].name_rev);
}

free(vec->dimension_label);
free(vec->item_label);
Expand Down Expand Up @@ -243,6 +252,9 @@ static void maybe_insert_large_item(struct large_item_vec *vec,
* The last large_item in the vector is about to be
* overwritten by the previous one during the shift.
* Steal its allocated strbuf and reuse it.
*
* We can ignore .name_rev because it will not be
* allocated until after the treewalk.
*/
strbuf_release(&vec->items[vec->nr_items - 1].name);

Expand Down Expand Up @@ -764,7 +776,7 @@ static void survey_report_largest_vec(struct large_item_vec *vec)
return;

table.table_name = vec->dimension_label;
strvec_pushl(&table.header, "Size", "OID", "Name", "Commit", NULL);
strvec_pushl(&table.header, "Size", "OID", "Name", "Commit", "Name-Rev", NULL);

for (int k = 0; k < vec->nr_items; k++) {
struct large_item *pk = &vec->items[k];
Expand All @@ -775,6 +787,7 @@ static void survey_report_largest_vec(struct large_item_vec *vec)
insert_table_rowv(&table, size.buf, oid_to_hex(&pk->oid), pk->name.buf,
is_null_oid(&pk->containing_commit_oid) ?
"" : oid_to_hex(&pk->containing_commit_oid),
pk->name_rev.len ? pk->name_rev.buf : "",
NULL);
}
}
Expand Down Expand Up @@ -1125,6 +1138,73 @@ static void do_load_refs(struct survey_context *ctx,
ref_sorting_release(sorting);
}

/*
* Try to run `git name-rev` on each of the containing-commit-oid's
* in this large-item-vec to get a pretty name for each OID. Silently
* ignore errors if it fails because this info is nice to have but not
* essential.
*/
static void large_item_vec_lookup_name_rev(struct survey_context *ctx,
struct large_item_vec *vec)
{
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf in = STRBUF_INIT;
struct strbuf out = STRBUF_INIT;
const char *line;
size_t k;

if (!vec || !vec->nr_items)
return;

ctx->progress_total += vec->nr_items;
display_progress(ctx->progress, ctx->progress_total);

for (k = 0; k < vec->nr_items; k++)
strbuf_addf(&in, "%s\n", oid_to_hex(&vec->items[k].containing_commit_oid));

cp.git_cmd = 1;
strvec_pushl(&cp.args, "name-rev", "--name-only", "--annotate-stdin", NULL);
if (pipe_command(&cp, in.buf, in.len, &out, 0, NULL, 0)) {
strbuf_release(&in);
strbuf_release(&out);
return;
}

line = out.buf;
k = 0;
while (*line) {
const char *eol = strchrnul(line, '\n');

strbuf_init(&vec->items[k].name_rev, 0);
strbuf_add(&vec->items[k].name_rev, line, (eol - line));

line = eol + 1;
k++;
}

strbuf_release(&in);
strbuf_release(&out);
}

static void do_lookup_name_rev(struct survey_context *ctx)
{
if (ctx->opts.show_progress) {
ctx->progress_total = 0;
ctx->progress = start_progress(_("Resolving name-revs..."), 0);
}

large_item_vec_lookup_name_rev(ctx, ctx->report.reachable_objects.commits.vec_largest_by_nr_parents);
large_item_vec_lookup_name_rev(ctx, ctx->report.reachable_objects.commits.vec_largest_by_size_bytes);

large_item_vec_lookup_name_rev(ctx, ctx->report.reachable_objects.trees.vec_largest_by_nr_entries);
large_item_vec_lookup_name_rev(ctx, ctx->report.reachable_objects.trees.vec_largest_by_size_bytes);

large_item_vec_lookup_name_rev(ctx, ctx->report.reachable_objects.blobs.vec_largest_by_size_bytes);

if (ctx->opts.show_progress)
stop_progress(&ctx->progress);
}

/*
* The REFS phase:
*
Expand Down Expand Up @@ -1478,7 +1558,11 @@ static void survey_phase_objects(struct survey_context *ctx)

release_revisions(&revs);
trace2_region_leave("survey", "phase/objects", ctx->repo);
}


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hyper-nit: double newline

trace2_region_enter("survey", "phase/namerev", the_repository);
do_lookup_name_rev(ctx);
trace2_region_enter("survey", "phase/namerev", the_repository);}

int cmd_survey(int argc, const char **argv, const char *prefix, struct repository *repo)
{
Expand Down