Skip to content
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

Count lines added deleted from Merge Commit #148

Open
chiliang7 opened this issue Jul 19, 2023 · 1 comment
Open

Count lines added deleted from Merge Commit #148

chiliang7 opened this issue Jul 19, 2023 · 1 comment

Comments

@chiliang7
Copy link

Is your feature request related to a problem? Please describe.

Perhaps, the functionality exists but I couldn't find it but it would be nice to include lines added/deleted from the merge commits

Describe the solution you'd like
The final output should include the line stats from merge commit

Thanks

@nnzv
Copy link

nnzv commented Oct 12, 2023

I use a one-liner to extract info from a git command. For example, with git show, you get more data than needed. To filter it, use --shortstat and --format=, resulting in this:

 6 files changed, 366 insertions(+), 2 deletions(-)

You can use awk to extract numbers from text by specifying -F '[^0-9]+' as the field separator, which separates digits from non-digits in the input line. This allows you to isolate the numeric values.

awk -F '[^0-9]+' '{print $2","$3","$4}'

So, awk extracts the second (we skip the first field as it's a space), third, and fourth fields from the input. These fields contain the numbers we need, and awk prints them with commas in between:commas between:

6,366,2

Here's the complete command:

git show --shortstat --format= | awk -F '[^0-9]+' '{print $2","$3","$4}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants