[Question] Signature calculation ignoring parts of binary files

4 messages, 2 authors, 2018-09-12 · open the first message on its own page

[Question] Signature calculation ignoring parts of binary files

From: Randall S. Becker <hidden>
Date: 2018-09-12 19:16:21

I feel really bad asking this, and I should know the answer, and yet.

I have a binary file that needs to go into a repo intact (unchanged). I also
have a program that interprets the contents, like a textconv, that can
output the relevant portions of the file in whatever format I like - used
for diff typically, dumps in 1K chunks by file section. What I'm looking for
is to have the SHA1 signature calculated with just the relevant portions of
the file so that two actually different files will be considered the same by
git during a commit or status. In real terms, I'm trying to ignore the
Creator metadata of a JPG because it is mutable and irrelevant to my repo
contents.

I'm sorry to ask, but I thought this was in .gitattributes but I can't
confirm the SHA1 behaviour.

Sheepishly,
Randall


-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.


Re: [Question] Signature calculation ignoring parts of binary files

From: Johannes Sixt <hidden>
Date: 2018-09-12 20:48:08

Am 12.09.18 um 21:16 schrieb Randall S. Becker:
I feel really bad asking this, and I should know the answer, and yet.

I have a binary file that needs to go into a repo intact (unchanged). I also
have a program that interprets the contents, like a textconv, that can
output the relevant portions of the file in whatever format I like - used
for diff typically, dumps in 1K chunks by file section. What I'm looking for
is to have the SHA1 signature calculated with just the relevant portions of
the file so that two actually different files will be considered the same by
git during a commit or status. In real terms, I'm trying to ignore the
Creator metadata of a JPG because it is mutable and irrelevant to my repo
contents.

I'm sorry to ask, but I thought this was in .gitattributes but I can't
confirm the SHA1 behaviour.
You are looking for a clean filter. See the 'filter' attribute in 
gitattributes(5). Your clean filter program or script should strip the 
unwanted metadata or set it to a constant known-good value.

(You shouldn't need a smudge filter.)

-- Hannes

RE: [Question] Signature calculation ignoring parts of binary files

From: Randall S. Becker <hidden>
Date: 2018-09-12 20:53:59

-----Original Message-----
From: git-owner@vger.kernel.org <redacted> On Behalf
Of Johannes Sixt
Sent: September 12, 2018 4:48 PM
To: Randall S. Becker <redacted>
Cc: git@vger.kernel.org
Subject: Re: [Question] Signature calculation ignoring parts of binary files

Am 12.09.18 um 21:16 schrieb Randall S. Becker:
quoted
I feel really bad asking this, and I should know the answer, and yet.

I have a binary file that needs to go into a repo intact (unchanged).
I also have a program that interprets the contents, like a textconv,
that can output the relevant portions of the file in whatever format I
like - used for diff typically, dumps in 1K chunks by file section.
What I'm looking for is to have the SHA1 signature calculated with
just the relevant portions of the file so that two actually different
files will be considered the same by git during a commit or status. In
real terms, I'm trying to ignore the Creator metadata of a JPG because
it is mutable and irrelevant to my repo contents.

I'm sorry to ask, but I thought this was in .gitattributes but I can't
confirm the SHA1 behaviour.
You are looking for a clean filter. See the 'filter' attribute in gitattributes(5).
Your clean filter program or script should strip the unwanted metadata or set
it to a constant known-good value.

(You shouldn't need a smudge filter.)

-- Hannes
Thanks Hannes. I thought about the clean filter, but I don't actually want to modify the file when going into git, just for SHA calculation. I need to be able to keep some origin metadata that might change with subsequent copies, so just cleaning the origin is not going to work - actually knowing the original author is important to our process. My objective is to keep the original file 100% exact as supplied and then ignore any changes to the metadata that I don't care about (like Creator) if the remainder of the file is the same.

Regards,
Randall

RE: [Question] Signature calculation ignoring parts of binary files

From: Randall S. Becker <hidden>
Date: 2018-09-12 22:20:13

On September 12, 2018 4:54 PM, I wrote:
On September 12, 2018 4:48 PM, Johannes Sixt wrote:
quoted
Am 12.09.18 um 21:16 schrieb Randall S. Becker:
quoted
I feel really bad asking this, and I should know the answer, and yet.

I have a binary file that needs to go into a repo intact (unchanged).
I also have a program that interprets the contents, like a textconv,
that can output the relevant portions of the file in whatever format
I like - used for diff typically, dumps in 1K chunks by file section.
What I'm looking for is to have the SHA1 signature calculated with
just the relevant portions of the file so that two actually
different files will be considered the same by git during a commit
or status. In real terms, I'm trying to ignore the Creator metadata
of a JPG because it is mutable and irrelevant to my repo contents.

I'm sorry to ask, but I thought this was in .gitattributes but I
can't confirm the SHA1 behaviour.
You are looking for a clean filter. See the 'filter' attribute in gitattributes(5).
Your clean filter program or script should strip the unwanted metadata
or set it to a constant known-good value.

(You shouldn't need a smudge filter.)

-- Hannes
Thanks Hannes. I thought about the clean filter, but I don't actually want to
modify the file when going into git, just for SHA calculation. I need to be able
to keep some origin metadata that might change with subsequent copies, so
just cleaning the origin is not going to work - actually knowing the original
author is important to our process. My objective is to keep the original file
100% exact as supplied and then ignore any changes to the metadata that I
don't care about (like Creator) if the remainder of the file is the same.
I had a thought that might be workable, opinions are welcome on this.

The commit of my rather weird project is done by a script so I have flexibility in my approach. What I could do is set up a diff textconv configuration so that the text diff of the two JPG files will show no differences if the immutable fields and the image are the same. I can then trigger a git add and git commit for only those files where git diff reports no differences. That way the actual original file is stored in git with 100% fidelity (no cleaning). It's not as elegant as I'd like, but it does solve what I'm trying to do. Does this sound reasonable and/or is there a better way?

Cheers,
Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.


Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help