Debian Bug report logs - #26675
patch .rej's should be udiff

version graph

Package: patch; Maintainer for patch is Laszlo Boszormenyi (GCS) <gcs@debian.org>; Source for patch is src:patch.

Reported by: Peter Samuelson <psamuels@sampo.creighton.edu>

Date: Sun, 13 Sep 1998 12:18:06 UTC

Severity: wishlist

Tags: patch, upstream, wontfix

Found in version 2.5-2

Fixed in version patch/2.5.9-4

Done: Christoph Berg <myon@debian.org>

Bug is archived. No further changes may be made.

Forwarded to bug-gnu-utils@prep.ai.mit.edu

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Darren Stalder <torin@daft.com>:
Bug#26675; Package patch. Full text and rfc822 format available.

Acknowledgement sent to Peter Samuelson <psamuels@sampo.creighton.edu>:
New bug report received and forwarded. Copy sent to Darren Stalder <torin@daft.com>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Peter Samuelson <psamuels@sampo.creighton.edu>
To: submit@bugs.debian.org
Subject: patch .rej's should be udiff
Date: Sun, 13 Sep 1998 07:08:23 -0500 (CDT)
Package: patch
Version: 2.5-2
Severity: wishlist

For a long time now I've noticed that patch(1) can read unified diff
files but, when outputting its .rej files, still uses context diffs.  I
guess it's a historic thing, since patch(1) predates udiff format by a
few years (and thus patch hunks are stored internally in a cdiff-like
format), but to me this is inconsistent and annoying, since udiffs are
IMHO much easier to read.

Hence the included patch, which causes patch(1) to write .rej files in
unified diff format, unless
  - you say --reject-file-compat, or
  - you define $POSIXLY_CORRECT.

If you agree with me here, put this in slink and send it on upstream.
I can't think how this change could break anything (besides POSIX, and
that's what POSIXLY_CORRECT is for) -- what programs automatically
parse .rej files anyway? -- but if you want to be more cautious, you
could apply this but reverse the sense of my command-line option
(i.e. default to the current behavior).

(Also: my patch is probably too small to worry about, but if anyone
cares, I hereby put it in the public domain.)

Peter Samuelson
<psamuels@sampo.creighton.edu>



diff -urN patch-2.5-2/common.h patch-2.5-2p/common.h
--- patch-2.5-2/common.h	Fri Jun 13 01:28:37 1997
+++ patch-2.5-2p/common.h	Sun Sep 13 00:35:12 1998
@@ -179,6 +179,7 @@
 XTERN int patch_get;
 XTERN int set_time;
 XTERN int set_utc;
+XTERN int write_rej_udiff;
 
 enum diff
   {
diff -urN patch-2.5-2/patch.c patch-2.5-2p/patch.c
--- patch-2.5-2/patch.c	Sat Sep 12 23:46:28 1998
+++ patch-2.5-2p/patch.c	Sun Sep 13 05:56:50 1998
@@ -66,6 +66,8 @@
 static char const *make_temp PARAMS ((int));
 static int numeric_string PARAMS ((char const *, int, char const *));
 static void abort_hunk PARAMS ((void));
+static void abort_hunk_cdiff PARAMS ((void));
+static void abort_hunk_udiff PARAMS ((void));
 static void cleanup PARAMS ((void));
 static void get_some_switches PARAMS ((void));
 static void init_output PARAMS ((char const *, struct outstate *));
@@ -129,7 +131,7 @@
     strippath = INT_MAX;
 
     posixly_correct = getenv ("POSIXLY_CORRECT") != 0;
-    backup_if_mismatch = ! posixly_correct;
+    write_rej_udiff = backup_if_mismatch = ! posixly_correct;
     patch_get = ((val = getenv ("PATCH_GET"))
 		 ? numeric_string (val, 1, "PATCH_GET value")
 		 : posixly_correct - 1);
@@ -499,6 +501,7 @@
   {"help", no_argument, NULL, 132},
   {"backup-if-mismatch", no_argument, NULL, 133},
   {"no-backup-if-mismatch", no_argument, NULL, 134},
+  {"reject-file-compat", no_argument, NULL, 135},
   {NULL, no_argument, NULL, 0}
 };
 
@@ -552,6 +555,7 @@
 "  -s  --quiet  --silent  Work silently unless an error occurs.",
 "  --verbose  Output extra information about the work being done.",
 "  --dry-run  Do not actually change any files; just print what would happen.",
+"  --reject-file-compat  Write rejected patches in context diff format.",
 "",
 "  -d DIR  --directory=DIR  Change the working directory to DIR first.",
 #if HAVE_SETMODE
@@ -737,6 +741,9 @@
 	    case 134:
 		backup_if_mismatch = 0;
 		break;
+	    case 135:
+		write_rej_udiff = 0;
+		break;
 	    default:
 		usage (stderr, 2);
 	}
@@ -885,6 +892,17 @@
 
 static void
 abort_hunk()
+{
+    /* IMHO udiff rej files should be default even with a cdiff patchfile */
+    /* if(write_rej_diff && diff_type >= UNI_DIFF) */
+    if(write_rej_udiff)
+        abort_hunk_udiff();
+    else
+        abort_hunk_cdiff();
+}
+
+static void
+abort_hunk_cdiff()
 {
     register LINENUM i;
     register LINENUM pat_end = pch_end ();
@@ -931,6 +949,53 @@
     }
 }
 
+static void
+abort_hunk_udiff()
+{
+    register LINENUM i, j;
+    register LINENUM pat_end = pch_end ();
+    /* add in last_offset to guess the same as the previous successful hunk */
+    LINENUM oldfirst = pch_first() + last_offset;
+    LINENUM newfirst = pch_newfirst() + last_offset;
+    LINENUM oldlines = pch_ptrn_lines();
+    LINENUM newlines = pch_repl_lines();
+    int tmp;
+
+    i=1;
+    j=oldlines+2;
+
+    /* print hunk header */
+    tmp = sprintf(buf, "@@ -%ld", oldfirst - (oldlines==0));
+    if(oldlines != 1)
+	tmp += sprintf(buf+tmp, ",%ld", oldlines);
+    tmp += sprintf(buf+tmp, " +%ld", newfirst - (newlines==0));
+    if(newlines != 1)
+	tmp += sprintf(buf+tmp, ",%ld", newlines);
+    sprintf(buf+tmp, " @@\n");
+    fputs(buf, rejfp);
+
+    /* print hunk itself */
+    for(tmp = 1; tmp;) {
+	tmp = 0;
+	while(i <= oldlines && strchr("!-", pch_char(i))) {	/* old line */
+	    fputc('-', rejfp);
+	    pch_write_line(i++, rejfp);
+	    tmp = 1;
+	}
+	while(j <= pat_end && strchr("!+", pch_char(j))) {	/* new line */
+	    fputc('+', rejfp);
+	    pch_write_line(j++, rejfp);
+	    tmp = 1;
+	}
+	while(j <= pat_end && strchr(" \n", pch_char(i))
+	      && strchr(" \n", pch_char(j))) {			/* unch line */
+	    fputc(' ', rejfp);
+	    pch_write_line(i++, rejfp);
+	    tmp = j++;
+	}
+    }
+}
+
 /* We found where to apply it (we hope), so do it. */
 
 static bool


Information forwarded to debian-bugs-dist@lists.debian.org, Adrian Bunk <bunk@fs.tum.de>:
Bug#26675; Package patch. Full text and rfc822 format available.

Acknowledgement sent to Paul Eggert <eggert@twinsun.com>:
Extra info received and forwarded to list. Copy sent to Adrian Bunk <bunk@fs.tum.de>. Full text and rfc822 format available.

Message #10 received at 26675@bugs.debian.org (full text, mbox):

From: Paul Eggert <eggert@twinsun.com>
To: Peter Samuelson <psamuels@sampo.creighton.edu>
Cc: bug-patch@gnu.org, bunk@fs.tum.de
Subject: Re: patch .rej's should be udiff
Date: Sun, 18 Jun 2000 13:59:26 -0700 (PDT)
   From: Peter Samuelson <psamuels@sampo.creighton.edu>

   For a long time now I've noticed that patch(1) can read unified diff
   files but, when outputting its .rej files, still uses context diffs.  I
   guess it's a historic thing

Yes.  When "patch" was originally written, context diffs were the
clearly the best format, so that's what "patch" output.  Nowadays most
people prefer unidiffs though there are some exceptions (notably, RMS
prefers context diffs), so it's not so clear.  POSIX.2 requires
context formats of course.

Note to current "patch" maintainer: if you accept this change, you
should also update the man page, as it specifies that rejects are
always written in context format.




Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#26675; Package patch. Full text and rfc822 format available.

Acknowledgement sent to Adrian Bunk <bunk@fs.tum.de>:
Extra info received and forwarded to list. Full text and rfc822 format available.

Message #15 received at 26675@bugs.debian.org (full text, mbox):

From: Adrian Bunk <bunk@fs.tum.de>
To: Paul Eggert <eggert@twinsun.com>
Cc: Peter Samuelson <psamuels@sampo.creighton.edu>, bug-patch@gnu.org, 26675@bugs.debian.org
Subject: Re: patch .rej's should be udiff
Date: Sat, 24 Jun 2000 03:35:43 +0200 (CEST)
On Sun, 18 Jun 2000, Paul Eggert wrote:

>    From: Peter Samuelson <psamuels@sampo.creighton.edu>
> 
>    For a long time now I've noticed that patch(1) can read unified diff
>    files but, when outputting its .rej files, still uses context diffs.  I
>    guess it's a historic thing
>...
> Note to current "patch" maintainer: if you accept this change, you
> should also update the man page, as it specifies that rejects are
> always written in context format.

I won't accept the change, because it is a wish and not a bug, and I don't
plan to let the Debian package behave differently from the upstream
version of patch.

cu,
Adrian

-- 
A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.
                -- Mahatma Ghandi




Information forwarded to debian-bugs-dist@lists.debian.org, Adrian Bunk <bunk@fs.tum.de>:
Bug#26675; Package patch. Full text and rfc822 format available.

Acknowledgement sent to Peter Samuelson <peter@cadcamlab.org>:
Extra info received and forwarded to list. Copy sent to Adrian Bunk <bunk@fs.tum.de>. Full text and rfc822 format available.

Message #20 received at 26675@bugs.debian.org (full text, mbox):

From: Peter Samuelson <peter@cadcamlab.org>
To: Paul Eggert <eggert@twinsun.com>, 26675@bugs.debian.org
Cc: bug-patch@gnu.org
Subject: Re: Bug#26675: patch .rej's should be udiff
Date: Fri, 23 Jun 2000 22:49:34 -0500 (CDT)
[Paul Eggert <eggert@twinsun.com>]
> When "patch" was originally written, context diffs were the clearly
> the best format, so that's what "patch" output.  Nowadays most people
> prefer unidiffs though there are some exceptions (notably, RMS
> prefers context diffs), so it's not so clear.

I figured as much.  And it's not surprising that someone hacking on
Emacs as long as I've been alive would prefer an older format....

> POSIX.2 requires context formats of course.

When I submitted the patch patch I didn't bother to check POSIX, but I
thought it might have something to say on the matter, so I made sure to
support `posixly_correct' just in case....

Note also that the patch patch isn't really "right".  The resulting
udiff should really have filename headers (patch spits out a warning
about this, though a harmless one).  I think I omitted them because at
the time I didn't see any easy way to get at the filenames in question.

(Beyond that, patch is just asking for a rewrite anyway.  I'm not a
neat freak myself and I don't care *that* much about data hiding, but
patch is so "global variable" it's not even funny.  Which surprised me,
considering that lwall was hardly a neophyte, even back then....)

Peter



Tags added: wontfix Request was from Martin Michlmayr <tbm@cyrius.com> to control@bugs.debian.org. Full text and rfc822 format available.

Noted your statement that Bug has been forwarded to bug-gnu-utils@prep.ai.mit.edu. Request was from Adrian Bunk <bunk@fs.tum.de> to control@bugs.debian.org. Full text and rfc822 format available.

Tags added: upstream Request was from Michael Fedrowitz <michael@fedrowitz.de> to control@bugs.debian.org. Full text and rfc822 format available.

Tags added: patch Request was from Matt Zimmerman <mdz@debian.org> to control@bugs.debian.org. Full text and rfc822 format available.

Reply sent to Christoph Berg <myon@debian.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Peter Samuelson <psamuels@sampo.creighton.edu>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #33 received at 26675-close@bugs.debian.org (full text, mbox):

From: Christoph Berg <myon@debian.org>
To: 26675-close@bugs.debian.org
Subject: Bug#26675: fixed in patch 2.5.9-4
Date: Sat, 28 Jan 2006 10:47:07 -0800
Source: patch
Source-Version: 2.5.9-4

We believe that the bug you reported is fixed in the latest version of
patch, which is due to be installed in the Debian FTP archive:

patch_2.5.9-4.diff.gz
  to pool/main/p/patch/patch_2.5.9-4.diff.gz
patch_2.5.9-4.dsc
  to pool/main/p/patch/patch_2.5.9-4.dsc
patch_2.5.9-4_i386.deb
  to pool/main/p/patch/patch_2.5.9-4_i386.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 26675@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Christoph Berg <myon@debian.org> (supplier of updated patch package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Sat, 28 Jan 2006 18:46:28 +0100
Source: patch
Binary: patch
Architecture: source i386
Version: 2.5.9-4
Distribution: unstable
Urgency: low
Maintainer: Christoph Berg <myon@debian.org>
Changed-By: Christoph Berg <myon@debian.org>
Description: 
 patch      - Apply a diff file to an original
Closes: 26675 349323
Changes: 
 patch (2.5.9-4) unstable; urgency=low
 .
   * New maintainer (Closes: #349323).
   * Use dpatch, add patches:
     + unified-reject-files: write unified reject files (Closes: #26675).
     + global-reject-file: write a global reject file.
     + manpage-char: fix weird character.
   * Suggests: diff-doc.
   * Bump Standards-Version.
Files: 
 49ddebe3e1b1d288fe79b85799a527ef 565 utils standard patch_2.5.9-4.dsc
 3350c53628d52bfdbbcdf16bb901b6ca 54673 utils standard patch_2.5.9-4.diff.gz
 3f59451efcd69aff0afc8e31151cd0fc 99464 utils standard patch_2.5.9-4_i386.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFD27nZxa93SlhRC1oRAtyPAJ9a/VsWNrpVtz42kG5QG9IpCiO7eQCcCCKS
Ed8clIvxLnqGIz6cwQMBxVc=
=q7KE
-----END PGP SIGNATURE-----




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 26 Jun 2007 13:59:23 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Apr 24 06:50:42 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.