0

I try to unzip .git/objects' commit/blob files. I do it using zlib and nodeJS.

The result after unzipping e.g. index.html blob is ▼

enter image description here

enter image description here

Question: what this NUL character means? Am I doing something wrong while unzipping?

Dan
  • 177
  • 1
  • 11

2 Answers2

1

It's a byte of ordinal value 0. NUL bytes serve 4 usual purposes: In the context of programming with C they are the end-of-string terminator (NUL terminated string).

In files with text they're normally used to delimit fields of data. In files with binary data, they're usually just part of the data.

And they're used for padding data inside files to certain alignment. So for example to make it that 32 bit integers inside a binary file are aligned to 4 bytes, so that they can be trivially read and processed.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
1

In this case the NUL is terminating the string blob 14. From a description of the git internals:

Git first constructs a header which starts by identifying the type of object — in this case, a blob. To that first part of the header, Git adds a space followed by the size in bytes of the content, and adding a final null byte

Mark Adler
  • 101,978
  • 13
  • 118
  • 158