PortMan
PortMan

Reputation: 4523

How to get just the file blob information for a commit

For use in a script, I need to know the files modified or added in a commit, as well as the sha1 for the blob.

I can get that information, and much more, with the following command: git log -1 --raw --no-abbrev -m master

Author: [author]
Date:   Wed Oct 11 07:55:45 2017 -0700

    This is the commit message

:000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A      file1.txt
:000000 100644 0000000000000000000000000000000000000000 f73ff92ea32371a270e5af81dc2cac4cbe98890f A      file2.txt

I can parse what I need from this, but it feels... untidy.

Is there some command to give me those last lines, without the Author, Date, or Commit Message?

Upvotes: 1

Views: 42

Answers (1)

Chilledrat
Chilledrat

Reputation: 2605

Does the Tree hash format give you what you want?

e.g.

git log -1 --raw --no-abbrev -m develop --pretty="%T"

7a71fcb99a6f6db609c7ccf4adfd828524f517a7

:100644 100644 a406bed252cede3cafa2c770f80b425a538cb8a2 7ea0f7d4f279da379e4be5da32446d2f2a2dafe8 M      .gitignore 
:100644 100644 8cadfaf41ec7adf0203b4e22fad5ffad1aed6226 82f44d4c26698de807234ff453ccda94300f7e82 M      Gemfile 
:100644 100644 952ea9cd117aa2c1bce82196bbada4da3975eb45 8c4024ffd6e46d3e7c9190a40eea3766c2bb91a1 M      Gemfile.lock 
:100644 100644 e07c5a830f77cc94a7a7e89025319b449838d899 7e14284b6e6990af6a30e75102122475c561220c M      app/assets/javascripts/application.js 
:100644 100644 9a8fd51e80d6edbda707b54032451d2bbb16b16f 048f753543aef4915367f91176ee07d5340a43ae M      app/assets/stylesheets/application.css 
:000000 100644 0000000000000000000000000000000000000000 7c8d04594c075d5cc1f29b501010ea8ee5c81324 A      app/assets/stylesheets/foundation_and_overrides.scss

If that isn't quite the right output there are plenty of other options for --pretty listed in the git manual

Upvotes: 1

Related Questions