Skip to content

builtin/blame.c: bit field constants into bit shift format #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

harry-hov
Copy link

@harry-hov harry-hov commented Oct 9, 2019

we are looking at bitfield constants, and elsewhere in the Git source code, such cases are handled via bit shift operators rather than octal numbers, which also makes it easier to spot holes in the range (if, say, 1<<5 was missing, it is easier to spot it between 1<<4 and 1<<6 than it is to spot a missing 040 between a 020 and a 0100).
Also, bit shifts lead to low-level optimizations because they require fewer calculations for the CPU.

Special Thanks to @dscho for helping me out throughout the process.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 9, 2019

Welcome to GitGitGadget

Hi @harry-hov, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.

Please make sure that this Pull Request has a good description, as it will be used as cover letter.

Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:

  • the lines should not exceed 76 columns,
  • the first line should be like a header and typically start with a prefix like "tests:" or "commit:", and
  • the commit messages' body should be describing the "why?" of the change.
  • Finally, the commit messages should end in a Signed-off-by: line matching the commits' author.

It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.

Contributing the patches

Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a PR comment of the form /allow <username>.

Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment /submit.

After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions.

If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox ("raw") file corresponding to the mail you want to reply to from the Git mailing list. If you use GMail, you can upload that raw mbox file via:

curl -g --user "<EMailAddress>:<Password>" --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt

@harry-hov
Copy link
Author

harry-hov commented Oct 9, 2019

Hey @dscho here is my first contribution to the Git.
Although, I have read the coding guidelines. Still there is a possibility that I may have missed some points.
I would love to have your review.

Regarding #357

@dscho
Copy link
Member

dscho commented Oct 10, 2019

/allow

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 10, 2019

User harry-hov is now allowed to use GitGitGadget.

@dscho
Copy link
Member

dscho commented Oct 10, 2019

Regarding #357

You could put this into the commit message, as "This addresses #357". That would make it easier for reviewers on the Git mailing list (who do not necessarily frequent GitHub let alone this here fork), and it would also close the ticket automatically once the Git maintainer merges the patch into master.

@dscho
Copy link
Member

dscho commented Oct 10, 2019

Turing preprocessor constants

This made me chuckle :-) I know you meant "Turning", not https://en.wikipedia.org/wiki/Alan_Turing.

The commit message could possibly repeat a little bit from the ticket that inspired you. If you look around in Git's commit history, we really like detailed commit messages.

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

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

I think it would be fine for contributing as-is, but of course you could always improve the commit message (not only the typo, but also a more detailed explanation, e.g. explaining how this helps type safety, concretely) and you could use the 1<<0 style for the constants and align them.

Also keep in mind that the PR description will be sent as cover letter.

@harry-hov
Copy link
Author

Thanks, @dscho for the suggestions and comments.
I will implement the changes as suggested by you.

@dscho
Copy link
Member

dscho commented Oct 11, 2019

dscho force-pushed the gitgitgadget:pu branch from 8d9027f to ef2d425 7 hours ago

Oh. I see that you made pu the base branch. That branch is rewritten multiple times per day, though, and force-pushed. Therefore, it is too moving a target.

How about rebasing your commit to master and then editing the base branch in this PR?

@harry-hov harry-hov changed the base branch from pu to master October 11, 2019 16:15
@harry-hov harry-hov force-pushed the enum branch 2 times, most recently from 52f7a4a to 988033e Compare October 12, 2019 20:26
@harry-hov harry-hov changed the title Preprocessor constants into enums builtin/blame.c: bit field constants into bit shift format Oct 12, 2019
@harry-hov
Copy link
Author

Hey @dscho!
Just made some changes
Please have a look 😀

@harry-hov
Copy link
Author

harry-hov commented Oct 12, 2019

@dscho resolved those comments
am I doing it right ??

builtin/blame.c Outdated
#define OUTPUT_LINE_PORCELAIN 01000
#define OUTPUT_COLOR_LINE 02000
#define OUTPUT_SHOW_AGE_WITH_COLOR 04000
#define OUTPUT_ANNOTATE_COMPAT (1<<0)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I should have been clearer: I meant to align the values (i.e. 1<<0, 1<<1, etc), with spaces, and not the keys. There should not be more than one single space between the #define and the OUTPUT_ANNOTATE_COMPAT and friends.

@harry-hov harry-hov force-pushed the enum branch 2 times, most recently from 1e4e65d to 5dc8543 Compare October 14, 2019 19:27
@harry-hov
Copy link
Author

Hey @dscho
It's me again, looking forward to your review.

PS:- Sorry for bothering you again and again.

@dscho
Copy link
Member

dscho commented Oct 14, 2019

Hey @dscho
It's me again, looking forward to your review.

Sure.

The patch is in a good shape, now let's focus on the commit message:

As most of the preprocessor bit field constant are in bit shift format. e.g. a<<b

So, Converting these bit field constant into bit shift format makes them look more like bit fields constants.

These seem to be slightly incomplete sentences with little power to explain the motivation behind the patch.

Maybe a better way would be to say that we are looking at bitfield constants, and elsewhere in the Git source code, such cases are handled via bit shift operators rather than octal numbers, which also makes it easier to spot holes in the range (if, say, 1<<5 was missing, it is easier to spot it between 1<<4 and 1<<6 than it is to spot a missing 040 between a 020 and a 0100).

@harry-hov
Copy link
Author

Maybe a better way would be to say that we are looking at bitfield constants, and elsewhere in the Git source code, such cases are handled via bit shift operators rather than octal numbers, which also makes it easier to spot holes in the range (if, say, 1<<5 was missing, it is easier to spot it between 1<<4 and 1<<6 than it is to spot a missing 040 between a 020 and a 0100).

Thanks @dscho
Done changes to the commit message.

@dscho
Copy link
Member

dscho commented Oct 16, 2019

Looks good! :shipit:

@dscho
Copy link
Member

dscho commented Oct 16, 2019

:shipit:

BTW if you are as puzzled as I was why the "shipit" emoji is a squirrel: https://www.quora.com/On-GitHub-what-is-the-significance-of-the-Ship-It-squirrel

@harry-hov
Copy link
Author

:shipit:

BTW if you are as puzzled as I was why the "shipit" emoji is a squirrel: https://www.quora.com/On-GitHub-what-is-the-significance-of-the-Ship-It-squirrel

No doubt why you are popular amongst Git Contributors 😄

@harry-hov
Copy link
Author

Hi,

Thanks for your comments. I've modified the patch.
(i.e replaced "int" with "unsigned int").

Regards
Hariom Verma

@harry-hov
Copy link
Author

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 17, 2019

@harry-hov
Copy link
Author

Hi @dscho
I'm having some confusions regarding replying to comments in PATCH using this tool.

@dscho
Copy link
Member

dscho commented Oct 18, 2019

I'm having some confusions regarding replying to comments in PATCH using this tool.

I tried to describe it a little bit in https://github.com/gitgitgadget/gitgitgadget/wiki/ReplyToThis (you will see this in every mirrored response linked as "(reply to this)"). There are also instructions for command-line nerds at the bottom of every public-inbox page, see e.g. https://public-inbox.org/git/xmqqr23b7ref.fsf@gitster-ct.c.googlers.com

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 21, 2019

This branch is now known as hv/bitshift-constants-in-blame.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 21, 2019

This patch series was integrated into pu via git@0926ab8.

@gitgitgadget gitgitgadget bot added the pu label Oct 21, 2019
@gitgitgadget
Copy link

gitgitgadget bot commented Oct 22, 2019

This patch series was integrated into pu via git@2a11dc1.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 23, 2019

This patch series was integrated into pu via git@ce72ff0.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 23, 2019

This patch series was integrated into pu via git@76c5e9d.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 24, 2019

This patch series was integrated into pu via git@136476c.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 24, 2019

This patch series was integrated into next via git@bc84aae.

@gitgitgadget gitgitgadget bot added the next label Oct 24, 2019
@gitgitgadget
Copy link

gitgitgadget bot commented Oct 24, 2019

This patch series was integrated into pu via git@70a25b5.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 28, 2019

This patch series was integrated into pu via git@aba629c.

@gitgitgadget
Copy link

gitgitgadget bot commented Oct 30, 2019

This patch series was integrated into pu via git@ed8ceb6.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 2, 2019

This patch series was integrated into pu via git@bc27da4.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 4, 2019

This patch series was integrated into pu via git@4feb4a6.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 6, 2019

This patch series was integrated into pu via git@04454b5.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 7, 2019

This patch series was integrated into pu via git@c93af32.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 8, 2019

This patch series was integrated into pu via git@d6a9d32.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 10, 2019

This patch series was integrated into pu via git@d40095a.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2019

This patch series was integrated into pu via git@8f40d89.

@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2019

This patch series was integrated into master via git@8f40d89.

@gitgitgadget gitgitgadget bot added the master label Nov 11, 2019
@gitgitgadget gitgitgadget bot closed this Nov 11, 2019
@gitgitgadget
Copy link

gitgitgadget bot commented Nov 11, 2019

Closed via 8f40d89.

@harry-hov harry-hov deleted the enum branch November 23, 2019 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants