[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#26675: marked as done (patch .rej's should be udiff)



Your message dated Sat, 28 Jan 2006 10:47:07 -0800
with message-id <E1F2v6J-0003Mt-Hp@spohr.debian.org>
and subject line Bug#26675: fixed in patch 2.5.9-4
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 13 Sep 1998 12:08:33 +0000
Received: (qmail 24805 invoked from network); 13 Sep 1998 12:08:33 -0000
Received: from sampo.creighton.edu (147.134.145.90)
  by debian.novare.net with SMTP; 13 Sep 1998 12:08:33 -0000
Received: (from psamuels@localhost)
	by sampo.creighton.edu (8.9.1/8.9.1) id HAA22930;
	Sun, 13 Sep 1998 07:08:23 -0500 (CDT)
Date: Sun, 13 Sep 1998 07:08:23 -0500 (CDT)
Message-Id: <199809131208.HAA22930@sampo.creighton.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Peter Samuelson <psamuels@sampo.creighton.edu>
To: submit@bugs.debian.org
Subject: patch .rej's should be udiff
X-Mailer: VM 6.33 under Emacs 19.34.1
Reply-To: Peter Samuelson <psamuels@sampo.creighton.edu>

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
---------------------------------------
Received: (at 26675-close) by bugs.debian.org; 28 Jan 2006 18:50:27 +0000
>From katie@ftp-master.debian.org Sat Jan 28 10:50:25 2006
Return-path: <katie@ftp-master.debian.org>
Received: from katie by spohr.debian.org with local (Exim 4.50)
	id 1F2v6J-0003Mt-Hp; Sat, 28 Jan 2006 10:47:07 -0800
From: Christoph Berg <myon@debian.org>
To: 26675-close@bugs.debian.org
X-Katie: $Revision: 1.65 $
Subject: Bug#26675: fixed in patch 2.5.9-4
Message-Id: <E1F2v6J-0003Mt-Hp@spohr.debian.org>
Sender: Archive Administrator <katie@ftp-master.debian.org>
Date: Sat, 28 Jan 2006 10:47:07 -0800
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-6.0 required=4.0 tests=BAYES_00,HAS_BUG_NUMBER 
	autolearn=no version=2.60-bugs.debian.org_2005_01_02

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-----



Reply to: