Skip to content

Commit

Permalink
DiffDelta.is_binary may return None
Browse files Browse the repository at this point in the history
If we don't know yet whether the delta is binary or text.

Issue #962
  • Loading branch information
jdavid committed Oct 28, 2021
1 parent 98e3d1f commit 464836c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,22 @@ DiffDelta_status_char(DiffDelta *self)
return Py_BuildValue("C", status);
}

PyDoc_STRVAR(DiffDelta_is_binary__doc__, "True if binary data, False if not.");
PyDoc_STRVAR(DiffDelta_is_binary__doc__,
"True if binary data, False if text, None if not (yet) known."
);

PyObject *
DiffDelta_is_binary__get__(DiffDelta *self)
{
if (!(self->flags & GIT_DIFF_FLAG_NOT_BINARY) &&
(self->flags & GIT_DIFF_FLAG_BINARY))
if (self->flags & GIT_DIFF_FLAG_BINARY)
Py_RETURN_TRUE;
Py_RETURN_FALSE;

if (self->flags & GIT_DIFF_FLAG_NOT_BINARY)
Py_RETURN_FALSE;

// This means the file has not been loaded, so we don't know whether it's
// binary or text
Py_RETURN_NONE;
}

static void
Expand Down

0 comments on commit 464836c

Please sign in to comment.