How do you get the list of files included in diff?

I have a patch file containing the output from git diff. I want to get a summary of all the files that were added or changed according to the patch file. Which team can I use to achieve this?

+3
source share
3 answers

patchutilsincludes utility lsdiff.

+12
source

grep '+++' mydiff.patch seems to be doing the trick.

I can also use git diff --names-onlywhich is probably the best approach.

+2
source
grep '+++' mydiff.patch|perl -pe 's/\+\+\+ //g'

:

git diff

+++ b/file

, grep,

grep '+++' mydiff.patch

, "+++" (3 ).

- . , perl/regex .

grep '+++' mydiff.patch|perl -pe 's/\+\+\+ //g'

For patch files created using diff -Naur, the mydiff.patch file contains entries with the file name and date (indicates the space character of the tab)

+++ b/file<tab>2013-07-03 13:58:45.000000000 +0200

To extract the file names for this, use

grep '+++' mydiff.patch|perl -pe 's/\+\+\+ (.*)\t.*/\1/g'
+1
source

Source: https://habr.com/ru/post/1769857/


All Articles