Skip site navigation (1)Skip section navigation (2)
Date:      11 Mar 2001 03:10:24 +0100
From:      Dag-Erling Smorgrav <des@ofug.org>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        Jordan Hubbard <jkh@osd.bsdi.com>, mwlucas@blackhelicopters.org, hackers@FreeBSD.ORG
Subject:   Re: context or unified diffs in PRs?
Message-ID:  <xzpae6trr73.fsf@flood.ping.uio.no>
In-Reply-To: Poul-Henning Kamp's message of "Sat, 10 Mar 2001 21:50:40 %2B0100"
References:  <40511.984257440@critter>

next in thread | previous in thread | raw e-mail | index | archive | help
Poul-Henning Kamp <phk@critter.freebsd.dk> writes:
> In message <20010310124052O.jkh@osd.bsdi.com>, Jordan Hubbard writes:
> > Both context and unidiffs show surrounding context, it's simply the
> > meta-data format which changes. [...]
> I repeat, with added emphasis: [...]

You're both either slightly off, or not expressing yourselves clearly.
Context diffs are called that because they show context around the
changes. Unified diffs are also context diffs, but they're unified
because they show removed and added lines in a single block instead of
separate blocks:

des@flood ~% diff -c old new
*** old Sun Mar 11 03:04:43 2001
--- new Sun Mar 11 03:05:02 2001
***************
*** 1,7 ****
  one
  two
  three
! fore
  five
  six
  seven
--- 1,7 ----
  one
  two
  three
! four
  five
  six
  seven
des@flood ~% diff -u old new
--- old Sun Mar 11 03:04:43 2001
+++ new Sun Mar 11 03:05:02 2001
@@ -1,7 +1,7 @@
 one
 two
 three
-fore
+four
 five
 six
 seven

Unified diffs are almost always easier to read, because you don't have
to move your eyes back and forth so much. Context diffs are easier to
read in the rare cases where a large nearly-contiguous block of text
has changed and diff(1) screws up because it finds that some of lines
in the new text are identical to some of the lines in the old text,
while in fact they're not related:

des@flood ~% diff -c old new
*** old Sun Mar 11 03:07:31 2001
--- new Sun Mar 11 03:08:08 2001
***************
*** 1,7 ****
! the
  little
! horse
! jumped
! over
! the
! fence
--- 1,7 ----
! three
! ducks
! swim
! in
! a
  little
! pond
des@flood ~% diff -u old new
--- old Sun Mar 11 03:07:31 2001
+++ new Sun Mar 11 03:08:08 2001
@@ -1,7 +1,7 @@
-the
+three
+ducks
+swim
+in
+a
 little
-horse
-jumped
-over
-the
-fence
+pond

DES
-- 
Dag-Erling Smorgrav - des@ofug.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpae6trr73.fsf>