Reputation: 96491
I am troubleshooting a problem where something that used to work, does not, all of a sudden. Given a sha1
, how can i find out what files changed as part of it?
Upvotes: 3
Views: 89
Reputation: 1328172
git bisect
actually involves git diff-tree
, and it has improved with Git 2.22 (Q2 2019).
The final report from "git bisect
" used to show the suspected culprit using a raw "diff-tree
", with which there is no output for a merge commit.
This has been updated to use a more modern and human readable output that still is concise enough.
See commit b02be8b, commit 40ae3d3, commit 2008f29 (22 Feb 2019) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 1b8f4dc, 20 Mar 2019)
bisect
: makediff-tree
output prettierAfter completing a bisection, we print out the commit we found using an internal version of
diff-tree
.The result is aesthetically lacking:
it shows a raw diff, which is generally less informative for human readers than "
--stat --summary
" (which we already decided was nice for humans in format-patch's output).by not abbreviating hashes, the result is likely to wrap on most people's terminals
we don't use "
-r
", so if the commit touched files in a directory, you only get to see the top-level directory mentionedwe don't specify "
--cc
" or similar, so merges print nothing (not even the commit message!)Even though bisect might be driven by scripts, there's no reason to consider this part of the output as machine-readable (if anything, the initial "
$hash
is the first bad commit" might be parsed, but we won't touch that here).
Let's make it prettier and more informative for a human reading the output.While we're tweaking the options, let's also switch to using the diff "
ui
" config.
If we're accepting that this is human-readable output, then we should respect the user's options for how to display it.
Upvotes: 1
Reputation: 49583
Any of these should work:
git diff-tree --no-commit-id --name-only -r <COMMIT_SHA1>
git show --pretty="format:" --name-only <COMMIT_SHA1>
Example output:
foo
bar
baz
To also show the status of each file in the change, use --name-status
option instead:
git diff-tree --no-commit-id --name-status -r <COMMIT_SHA1>
git show --pretty="format:" --name-status <COMMIT_SHA1>
Example output:
A foo
M bar
D baz
Upvotes: 3
Reputation: 40894
git show --name-only <the-hex-sha1-string>
should do the trick.
Here I assume that sha1
you mention is the sha1 signature of the commit.
Consider reading about git bisect
for further troubleshooting.
Upvotes: 2