Skip to content

Accessing files committed by initial commit with GitPython #364

Closed

Description

@sztankatt

I'm using GitPython for working with a git repository. To list the files added/deleted/changed I use the following code:

diff_files = []
for parent in commit.parents:
    diff_files += [x.b_path for x in commit.diff(parent)]

However, the first commit doesn't have any parents, so this approach fails. Any ideas how might I do it in a different way?

Activity

  1. Byron commented on Nov 30, 2015

    @Byron
    Member

    Maybe the questions are related, but do you think the edit portion of this question on stackoverflow answers your question ?

    EMPTY_TREE_SHA = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
    
    if not i.parents:
        diff = i.diff(EMPTY_TREE_SHA, create_patch=True, **diffArgs)
    else:
        diff = i.diff(i.parents[0], create_patch=True, **diffArgs)
  2. Byron commented on Jul 23, 2016

    @Byron
    Member

    Closed due to inactivity. Please comment to get it reopened.

  3. sztankatt commented on Jul 26, 2016

    @sztankatt
    Author

    Yes, sorry, since the I solved it similarly as you described in your comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions