From: Sergey Organov <sorganov@gmail.com>
To: git@vger.kernel.org
Subject: "git diff" surprising default output
Date: Wed, 01 Mar 2023 21:25:43 +0300 [thread overview]
Message-ID: <871qm849co.fsf@osv.gnss.ru> (raw)
Hello,
By default, 'git diff' produces an output that is often rather
surprising and difficult to grok, here is a simple example:
$ git diff --no-index -- f0.txt f1.txt
diff --git a/f0.txt b/f1.txt
index 3af00a929..35478f7bd 100644
--- a/f0.txt
+++ b/f1.txt
@@ -3,9 +3,6 @@
#endif
#if CANOPEN > 0
IMD_CANOPEN,
-#endif
-#if MDL_LASER > 0
- IMD_LASER,
#endif
IMD_AUTO,
IMD_NONE,
I figured the offender is --indent-heuristic that is described in the
manual as:
Enable the heuristic that shifts diff hunk boundaries to make
patches easier to read. This is the default.
but apparently rather makes patches harder to read, at least at some
conditions. Turning it off helps to get the expected result:
$ git diff --no-index --no-indent-heuristic -- f0.txt f1.txt
diff --git a/f0.txt b/f1.txt
index 3af00a929..35478f7bd 100644
--- a/f0.txt
+++ b/f1.txt
@@ -4,9 +4,6 @@
#if CANOPEN > 0
IMD_CANOPEN,
#endif
-#if MDL_LASER > 0
- IMD_LASER,
-#endif
IMD_AUTO,
IMD_NONE,
IMD_COUNT
Changing --diff-algorithm doesn't change the outcome.
So the questions are:
- Is there an example of an advantage the option has?
- Is it possible to flip the default?
Thanks,
-- Sergey Organov
next reply other threads:[~2023-03-01 18:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 18:25 Sergey Organov [this message]
2023-03-01 19:40 ` "git diff" surprising default output Junio C Hamano
2023-03-01 20:28 ` Sergey Organov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qm849co.fsf@osv.gnss.ru \
--to=sorganov@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.