Skip to content

signature: distinguish +0000 and -0000 UTC offsets - #4408

Merged
pks-t merged 1 commit into
libgit2:masterfrom
hkleynhans:pos_neg_zero_offset_sig
Nov 12, 2017
Merged

signature: distinguish +0000 and -0000 UTC offsets#4408
pks-t merged 1 commit into
libgit2:masterfrom
hkleynhans:pos_neg_zero_offset_sig

Conversation

@hkleynhans

Copy link
Copy Markdown

Git considers '-0000' a valid offset for signature lines. They need to
be treated as not equal to a '+0000' signature offset. Parsing a
signature line stores the offset in a signed integer which does not
distinguish between +0 and -0.

This patch adds an additional flag sign to the git_time in the
signature object which is populated with the sign of the offset. In
addition to exposing this information to the user, this information is
also used to compare signatures.

/cc @pks-t @ethomson

@pks-t pks-t left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really mind about that trailing newline. But the commit message could be improved in two things:

  1. we don't use trailer-lines in commit messages
  2. we try to prepend the subsystem to the subject line, like e.g. "signature: distinguish positive and negative UTC offsets"

Otherwise this looks fine to me, thanks a lot!

Comment thread tests/commit/signature.c Outdated
git_signature_free((git_signature *)with_neg_zero);
git_signature_free((git_signature *)with_pos_zero);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nitpicky: there's a trailing newline here

Git considers '-0000' a valid offset for signature lines.  They need to
be treated as _not_ equal to a '+0000' signature offset.  Parsing a
signature line stores the offset in a signed integer which does not
distinguish between `+0` and `-0`.

This patch adds an additional flag `sign` to the `git_time` in the
`signature` object which is populated with the sign of the offset.  In
addition to exposing this information to the user, this information is
also used to compare signatures.

/cc @pks-t @ethomson
@hkleynhans
hkleynhans force-pushed the pos_neg_zero_offset_sig branch from eb78b42 to f063daf Compare November 12, 2017 12:03
@hkleynhans hkleynhans changed the title Distinguish -0000 and +0000 in signature offset signature: distinguish +0000 and -0000 UTC offsets Nov 12, 2017
@pks-t
pks-t merged commit fd1492e into libgit2:master Nov 12, 2017
@pks-t

pks-t commented Nov 12, 2017

Copy link
Copy Markdown
Member

Thanks a lot for your fixup!

@hkleynhans

Copy link
Copy Markdown
Author

👍

@pks-t pks-t added the backport label Jan 11, 2018
@pks-t pks-t mentioned this pull request Jan 12, 2018
@carlosmn carlosmn mentioned this pull request Jan 17, 2018
13 tasks
@carlosmn carlosmn removed the backport label Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants