Skip to content

Conversation

@Therzok
Copy link
Member

@Therzok Therzok commented Jun 3, 2014

I'm still on a Mono which can't build so I'll be using travis to run the unit tests. :D

Copy link
Member Author

Choose a reason for hiding this comment

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

I could make it so if you set CommentChar, PrettifyMessage is set to true.

Copy link
Member

Choose a reason for hiding this comment

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

How about making this a char??

Copy link
Member Author

Choose a reason for hiding this comment

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

What would the benefit of having a nullable do here? We're using default(char) which is \0, same for the defaults in the functions like CreateCommit and prettify_message.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is nothing gained from this change. We still have to supply a character to prettify_message and it's the same: default(char) aka \0.

Copy link
Member

Choose a reason for hiding this comment

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

How about CommentaryChar or CommentaryMarkerChar?

/cc @carlosmn @dahlbyk

Copy link
Member

Choose a reason for hiding this comment

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

There is nothing gained from this change. We still have to supply a character to prettify_message and it's the same: default(char) aka \0.

The defaults are supposed to be set in the constructor of the xxxOptions type. I'd rather not expose \0 as an already set property. Beside this, I see \0 as a libgit2 implementation detail and I'm sure it would make much sense to expose this at at the LibGit2Sharp API level.

@Therzok
Copy link
Member Author

Therzok commented Jun 3, 2014

This introduces changes in the test data since prettifying was defaulting to true in CreateCommit.

@Therzok
Copy link
Member Author

Therzok commented Jun 3, 2014

/cc @nulltoken

Copy link
Member

Choose a reason for hiding this comment

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

True to prettify the message by stripping leading and trailing empty lines, trailing whitespace, and collapsing consecutive empty lines, false otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

Please use the constructor to set the default values. I'd suggest to go with PrettifyMessage set to true and CommentaryChar to null. Could you please also describe the default behavior as xml doc on the constructor (see MergeOptions for some inspiration 😉)?

Copy link
Member Author

Choose a reason for hiding this comment

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

We should default prettify to true? Okay then, I guess that would revert the changes done to the mock object ids I changed.

@Therzok
Copy link
Member Author

Therzok commented Jun 3, 2014

Updated.

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather see this as a nullable char and pass \0 to libgit2 when it's indeed null.

Copy link
Member

Choose a reason for hiding this comment

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

IIRC we should also check that the char is a single byte one.

Two options:

  • Either check it at the CommitOptions level (but I feel weird about throwing in a setter)
  • Or check it at this level and throw an InvalidOperationException with an explicit message

/cc @ethomson @carlosmn

Copy link
Member Author

Choose a reason for hiding this comment

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

Converting from char to sbyte when the char is 2-byte sized will throw an overflow exception. Wouldn't that suffice?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure an OverflowException would be that useful for the consumer API. The user wouldn't be able to easily understand what he should do to fix this. I think a special casing here with an explicit message may better communicate what's wrong here.

@Therzok
Copy link
Member Author

Therzok commented Jun 3, 2014

I think I fixed everything. I'm not explicitly setting CommentaryChar to null since that's redundant. default(Nullable) is null.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm now generating an exception here. Please tell me if the text below should be changed.

Copy link
Member

Choose a reason for hiding this comment

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

How about

Only single byte characters are allowed as commentary characters in a message (eg. '#').

@nulltoken nulltoken merged commit 2f52a40 into libgit2:vNext Jun 3, 2014
@nulltoken
Copy link
Member

Very nice work! Thanks! ✨✨✨

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