This file is indexed.

/usr/lib/python3/dist-packages/diffoscope/comparators/git.py is in diffoscope 93ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2016 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.

import re
import os
import struct
import binascii

from diffoscope.difference import Difference

from .utils.file import File


class GitIndexFile(File):
    DESCRIPTION = "Git repositories"
    FILE_TYPE_RE = re.compile(r'^Git index')

    def compare_details(self, other, source=None):
        return [Difference.from_text(
            describe_index(self.path),
            describe_index(other.path),
            self.path,
            other.path,
        )]


def parse_index(f):
    _, version = struct.unpack('>LL', f.read(4 * 2))

    return {
        'version': version,
        'entries': list(parse_entries(f)),
    }


def parse_entries(f):
    num_entries = struct.unpack('>L', f.read(4))[0]

    for _ in range(num_entries):
        x = {}

        pos = f.tell()

        x['ctime'], x['ctime_nano'], x['mtime'], x['mtime_nano'], \
            x['dev'], x['inode'], x['mode'], x['uid'], x['gid'], \
            x['size'], x['sha'], x['flags'] = \
            struct.unpack('>LLLLLLLLLL20sH', f.read((4 * 10) + 20 + 2))

        x['path'] = f.read(x['flags'] & 0x0fff)

        f.read((pos + ((f.tell() - pos + 8) & ~7)) - f.tell())

        yield x


def describe_index(filename):
    with open(filename, 'rb') as f:
        index = parse_index(f)

    return """
Version: {version}

Entries:
{entries_fmt}
""".format(
        entries_fmt=''.join(describe_entry(x) for x in index['entries']),
        **index
    )


def describe_entry(x):
    return """
Path:      {x[path]}
SHA:       {hexsha}
Size:      {x[size]}
Flags:     {x[flags]:#b}
User ID:   {x[uid]}
Group ID:  {x[gid]}
Created:   {x[ctime]}.{x[ctime_nano]}
Modified:  {x[mtime]}.{x[mtime_nano]}
Inode:     {x[inode]}
Device ID: ({major}, {minor})
""".format(
        x=x,
        major=os.major(x['dev']),
        minor=os.minor(x['dev']),
        hexsha=binascii.b2a_hex(x['sha']).decode('utf-8'),
    )