0

I'm trying to write how many lines of code difference are there between 2 git branches. So i ran the git command for the difference, on terminal, where it output the file location along with the number of different lines between two branches.

Although, i know the command to write the terminal output into a file. I've used the below mentioned command to write the terminal output into a file 'code_mismatch.txt':

git diff --compact-summary --ignore-space-change remotes/dev_admin/master origin/master &> code_mismatch.txt

A glance on the code_mismatch.txt file:

 application/models/admin/Template_model.php | 97 +- application/models/admin/Ticket_model.php | 75 +- .../models/admin/Tickets_v2/Channel_model.php | 10 +- .../models/admin/Tickets_v2/Superadminmodel.php | 30 +- .../models/admin/Tickets_v2/Template_model.php | 26 +- .../models/admin/Tickets_v2/Ticket_model.php | 4 +- .../merchant/dashboard/ticket_destinations.php | 16 +- .../ticket_list.php (gone) | 94 - application/views/activity_overview.php | 2 +- application/views/admin/channel.php | 15 +- .../views/admin/company/companysettings_v1.php | 57 +- 

But the problem i'm facing is, if the file location written inside the 'code_mismatch.txt' file is a bit long, then it replaces the starting part of the file location with dots like this '...'.

If i try to run the same command without writing the output into code_mismatch.txt file then on the terminal i'm getting full location of the file.

git diff --compact-summary --ignore-space-change remotes/dev_admin/master origin/master

A glance on terminal output:

 application/models/admin/Template_model.php | 97 +- application/models/admin/Ticket_model.php | 75 +- application/models/admin/Tickets_v2/Channel_model.php | 10 +- application/models/admin/Tickets_v2/Superadminmodel.php | 30 +- application/models/admin/Tickets_v2/Template_model.php | 26 +- application/models/admin/Tickets_v2/Ticket_model.php | 4 +- application/views/V1/codes/merchant/dashboard/ticket_destinations.php | 16 +- application/views/V1/ticket_destinations_list/ticket_list.php (gone) | 94 - application/views/activity_overview.php | 2 +- application/views/admin/channel.php | 15 +- application/views/admin/company/companysettings_v1.php | 57 +- application/views/admin/company/create_new_company.php | 456 ++- 

Is there a way i can write my file same as the terminal output..??

Thanks!

3
  • Does it work if you add --stat=0? Commented Dec 22, 2021 at 12:41
  • When i added --stat=0 then even in the terminal i'm getting the result same as the result wrote in the file Commented Dec 22, 2021 at 12:50
  • 1
    What about --stat=10000 ? stackoverflow.com/a/10460154/7976758 Commented Dec 22, 2021 at 16:32

1 Answer 1

3

Don't use the convenience commands, the so-called "porcelain", for scripting. Use the core commands, the ones the convenience commands are built on.

git diff-tree --ignore-space-change --numstat remotes/dev_admin/master origin/master 

will produce output with all the tradeoffs between readability by computers and humans decided in the computer's favor rather than the other way round.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.