From MAILER-DAEMON Fri Mar 10 06:16:15 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cmIWt-0001qB-1b
	for mharc-bug-patch@gnu.org; Fri, 10 Mar 2017 06:16:15 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40677)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1cmIWq-0001ok-Js
	for bug-patch@gnu.org; Fri, 10 Mar 2017 06:16:13 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1cmIWl-0002Vw-KG
	for bug-patch@gnu.org; Fri, 10 Mar 2017 06:16:12 -0500
Received: from mx2.suse.de ([195.135.220.15]:53937)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jdelvare@suse.de>) id 1cmIWl-0002Vh-CT
	for bug-patch@gnu.org; Fri, 10 Mar 2017 06:16:07 -0500
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx2.suse.de (Postfix) with ESMTP id C6652AC3B
	for <bug-patch@gnu.org>; Fri, 10 Mar 2017 11:16:05 +0000 (UTC)
Message-ID: <1489144566.3806.108.camel@suse.de>
From: Jean Delvare <jdelvare@suse.de>
To: bug-patch <bug-patch@gnu.org>
Date: Fri, 10 Mar 2017 12:16:06 +0100
Organization: Suse Linux
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.20.5 
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
Subject: [bug-patch] How to handle read-only trees
X-BeenThere: bug-patch@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Bug reports, suggestions,
	general discussion for GNU patch." <bug-patch.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-patch/>
List-Post: <mailto:bug-patch@gnu.org>
List-Help: <mailto:bug-patch-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 10 Mar 2017 11:16:14 -0000

Hi all,

Where I work, we use GNU patch to work on read-only source trees. The
reason is that we work with hard-linked trees, and apply different
patch series to the different copies. We want to make sure nobody
accidentally affects another tree by changing a file without first
breaking the hard link.

While it works somewhat, there are still 2 issues left that I'd like to
solve.

1* Since April 2012 (commit=C2=A09a26fde226), patch complains when patche=
d
files are read-only. That's a lot better than failing, as was the case
between May 2010 (commit=C2=A0cabd1add57) and April 2012 (thanks Andreas =
for
fixing that!) but still not too convenient. I know that users can pass
option --read-only=3Dignore to get rid of the warning, but this option is
not supported on older versions of GNU patch, and our users may have to
work on older systems sometimes, so they have to change their habits
depending on the system they are working on.

More importantly, I believe it is conceptually wrong to complain about
patching a read-only file if the user also asks for the original file
to be backed up (which we always do.) If you keep a backup of the
original read-only file, then modifying a copy of that file is not
breaking the read-only paradigm.

So I would like to propose that option --read-only defaults to "ignore"
if --backup is passed, and to "warn" if not (as is the case today.)
What do you think?

2* After patching a read-only file, and even if --backup and --read-
only=3Dignore are passed, the patched file is still read-only. This means
that our users must manually chmod +w each patched file to which they
need to make further changes.

It seems conceptually wrong to me, as option --backup created a new
copy of the file and patched it, the contents are already modified so
the read-only nature of the file is already gone in practice.

So I would like to propose that patched files are always made writable
when option --backup is used. What do you think?

Thanks,
--=20
Jean Delvare
SUSE L3 Support


From MAILER-DAEMON Fri Mar 10 10:45:43 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cmMjf-0000oi-2X
	for mharc-bug-patch@gnu.org; Fri, 10 Mar 2017 10:45:43 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34533)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1cmMjc-0000mt-0p
	for bug-patch@gnu.org; Fri, 10 Mar 2017 10:45:41 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <andreas.gruenbacher@gmail.com>) id 1cmMja-0000qJ-ML
	for bug-patch@gnu.org; Fri, 10 Mar 2017 10:45:40 -0500
Received: from mail-it0-x235.google.com ([2607:f8b0:4001:c0b::235]:36157)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <andreas.gruenbacher@gmail.com>)
	id 1cmMja-0000pl-HM
	for bug-patch@gnu.org; Fri, 10 Mar 2017 10:45:38 -0500
Received: by mail-it0-x235.google.com with SMTP id h10so9585145ith.1
	for <bug-patch@gnu.org>; Fri, 10 Mar 2017 07:45:37 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
	h=mime-version:sender:in-reply-to:references:from:date:message-id
	:subject:to:cc;
	bh=OUjTCs+X2WjyYLx4GZwLKbh4HpWZml0joCJhMRtOrLY=;
	b=DHqDm17U5rNCUyiuWbTW8rnpog8plTM1cM89ym3VPTwgiHf1pJ27XVz0Fhsr65ZoDM
	nlHr+5gT0nXxZAwXduTzj8SD9pHahMa7KhQ6RbNNjf03UsLebqUE2xYGRNVXCvkC0oEN
	deYEJJ8AI4jV0EgQemnGRq1YA95M24yMqzzI55zsgzY5bdncV2LHy6lPZzGMlKRO8wSc
	ABwYkCTk4dj3oW+qf7PVtipoaFSqrdu6nZRXhQoapRFDZRlFCyI5n7L9L4dHLL9J+oxO
	ehgcSR/ZrMYFRC1ZQGUv/hqx4Jcof8CMIgjT1aED7P1vT66xHsddp+NmP/IMor/yL8zT
	AvrQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=1e100.net; s=20161025;
	h=x-gm-message-state:mime-version:sender:in-reply-to:references:from
	:date:message-id:subject:to:cc;
	bh=OUjTCs+X2WjyYLx4GZwLKbh4HpWZml0joCJhMRtOrLY=;
	b=q8rPbjIT3SmYc/nJJNmj5u+qbUTx7Xg0rCj68IWhAeJTNHdkzEIGTQcvF6JO0aWrkK
	9lBLlioadI1xhrfS9hZU9XdaD7V97bDK8tcWVxJy2OfrfBwAdKkVgPhPnUdraF3OgIIw
	Ma14usY4DxEDXeeq4IAPC+AMv+OwCvydLrgqF8z10W5Wz1PK65acl/DXE2du5qjynm6I
	1wy3h6ySxF51n04a+Tcsog+Vp3R6RMy8OTFi/t/9EiKEuiw7TIOJx4IFW1W/wkUJmI80
	7eJaj+MLR0Fttodg5IaA18M//L6VCCLO4l/3fWy92f/yAKMughpNOZXniXjvzDCiibz6
	wQDg==
X-Gm-Message-State: AFeK/H26bSfo8D9GnDtZLShVJ9HSmZnRAoWOup9XQedvXdO8Vsp1daNBz6LauZLffOD3QxTz7me7hYFbfUB5ww==
X-Received: by 10.36.4.67 with SMTP id 64mr2650269itb.19.1489160736377; Fri,
	10 Mar 2017 07:45:36 -0800 (PST)
MIME-Version: 1.0
Sender: andreas.gruenbacher@gmail.com
Received: by 10.107.138.211 with HTTP; Fri, 10 Mar 2017 07:45:35 -0800 (PST)
In-Reply-To: <1489144566.3806.108.camel@suse.de>
References: <1489144566.3806.108.camel@suse.de>
From: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= <agruen@gnu.org>
Date: Fri, 10 Mar 2017 16:45:35 +0100
X-Google-Sender-Auth: DB42PwrtF21irSnrH-UOIHhTMOc
Message-ID: <CAHpGcMKLcXx_Dzmy5n1ACzpO60+1O6jtC70txjDGpWvduNt3nQ@mail.gmail.com>
To: Jean Delvare <jdelvare@suse.de>
Cc: bug-patch <bug-patch@gnu.org>
Content-Type: text/plain; charset=UTF-8
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2607:f8b0:4001:c0b::235
Subject: Re: [bug-patch] How to handle read-only trees
X-BeenThere: bug-patch@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Bug reports, suggestions,
	general discussion for GNU patch." <bug-patch.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-patch/>
List-Post: <mailto:bug-patch@gnu.org>
List-Help: <mailto:bug-patch-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 10 Mar 2017 15:45:41 -0000

2017-03-10 12:16 GMT+01:00 Jean Delvare <jdelvare@suse.de>:
> Hi all,
>
> Where I work, we use GNU patch to work on read-only source trees. The
> reason is that we work with hard-linked trees, and apply different
> patch series to the different copies. We want to make sure nobody
> accidentally affects another tree by changing a file without first
> breaking the hard link.
>
> While it works somewhat, there are still 2 issues left that I'd like to
> solve.
>
> 1* Since April 2012 (commit 9a26fde226), patch complains when patched
> files are read-only. That's a lot better than failing, as was the case
> between May 2010 (commit cabd1add57) and April 2012 (thanks Andreas for
> fixing that!) but still not too convenient. I know that users can pass
> option --read-only=ignore to get rid of the warning, but this option is
> not supported on older versions of GNU patch, and our users may have to
> work on older systems sometimes, so they have to change their habits
> depending on the system they are working on.
>
> More importantly, I believe it is conceptually wrong to complain about
> patching a read-only file if the user also asks for the original file
> to be backed up (which we always do.) If you keep a backup of the
> original read-only file, then modifying a copy of that file is not
> breaking the read-only paradigm.
>
> So I would like to propose that option --read-only defaults to "ignore"
> if --backup is passed, and to "warn" if not (as is the case today.)
> What do you think?

The fact that quilt uses patch in a very particular way doesn't
actually create a connection between --backup and --read-only; those
two options serve entirely different purposes.

> 2* After patching a read-only file, and even if --backup and --read-
> only=ignore are passed, the patched file is still read-only. This means
> that our users must manually chmod +w each patched file to which they
> need to make further changes.
>
> It seems conceptually wrong to me, as option --backup created a new
> copy of the file and patched it, the contents are already modified so
> the read-only nature of the file is already gone in practice.
>
> So I would like to propose that patched files are always made writable
> when option --backup is used. What do you think?

I can follow the argument that files should be (owner) writable after
patch has modified them. But again I don't see the connection with
--backup.

A corner case with quilt is when a patch tries to modify a file but
doesn't actually end up changing anything. In that case, patch should
probably still create a backup and make the original file writable, if
only to make life easier for quilt.

Andreas


From MAILER-DAEMON Sun Mar 12 18:12:30 2017
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1cnBj4-0007GC-7y
	for mharc-bug-patch@gnu.org; Sun, 12 Mar 2017 18:12:30 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50233)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1cnBj1-0007ED-GA
	for bug-patch@gnu.org; Sun, 12 Mar 2017 18:12:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jdelvare@suse.de>) id 1cnBj0-0003iP-3p
	for bug-patch@gnu.org; Sun, 12 Mar 2017 18:12:27 -0400
Received: from mx2.suse.de ([195.135.220.15]:57494)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <jdelvare@suse.de>)
	id 1cnBiu-0003g3-6v; Sun, 12 Mar 2017 18:12:20 -0400
X-Virus-Scanned: by amavisd-new at test-mx.suse.de
Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])
	by mx2.suse.de (Postfix) with ESMTP id 385A5AC1A;
	Sun, 12 Mar 2017 22:12:18 +0000 (UTC)
Date: Sun, 12 Mar 2017 23:12:16 +0100
From: Jean Delvare <jdelvare@suse.de>
To: Andreas =?UTF-8?B?R3LDvG5iYWNoZXI=?= <agruen@gnu.org>
Cc: bug-patch <bug-patch@gnu.org>
Message-ID: <20170312231216.4ee919d1@endymion>
In-Reply-To: <CAHpGcMKLcXx_Dzmy5n1ACzpO60+1O6jtC70txjDGpWvduNt3nQ@mail.gmail.com>
References: <1489144566.3806.108.camel@suse.de>
	<CAHpGcMKLcXx_Dzmy5n1ACzpO60+1O6jtC70txjDGpWvduNt3nQ@mail.gmail.com>
Organization: SUSE Linux
X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.31; x86_64-suse-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no
	timestamps) [generic] [fuzzy]
X-Received-From: 195.135.220.15
Subject: Re: [bug-patch] How to handle read-only trees
X-BeenThere: bug-patch@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Bug reports, suggestions,
	general discussion for GNU patch." <bug-patch.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-patch/>
List-Post: <mailto:bug-patch@gnu.org>
List-Help: <mailto:bug-patch-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-patch>,
	<mailto:bug-patch-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 12 Mar 2017 22:12:28 -0000

Hi Andreas,

Thanks for your fast reply.

On Fri, 10 Mar 2017 16:45:35 +0100, Andreas Gr=C3=BCnbacher wrote:
> 2017-03-10 12:16 GMT+01:00 Jean Delvare <jdelvare@suse.de>:
> > Hi all,
> >
> > Where I work, we use GNU patch to work on read-only source trees. The
> > reason is that we work with hard-linked trees, and apply different
> > patch series to the different copies. We want to make sure nobody
> > accidentally affects another tree by changing a file without first
> > breaking the hard link.
> >
> > While it works somewhat, there are still 2 issues left that I'd like to
> > solve.
> >
> > 1* Since April 2012 (commit 9a26fde226), patch complains when patched
> > files are read-only. That's a lot better than failing, as was the case
> > between May 2010 (commit cabd1add57) and April 2012 (thanks Andreas for
> > fixing that!) but still not too convenient. I know that users can pass
> > option --read-only=3Dignore to get rid of the warning, but this option =
is
> > not supported on older versions of GNU patch, and our users may have to
> > work on older systems sometimes, so they have to change their habits
> > depending on the system they are working on.
> >
> > More importantly, I believe it is conceptually wrong to complain about
> > patching a read-only file if the user also asks for the original file
> > to be backed up (which we always do.) If you keep a backup of the
> > original read-only file, then modifying a copy of that file is not
> > breaking the read-only paradigm.
> >
> > So I would like to propose that option --read-only defaults to "ignore"
> > if --backup is passed, and to "warn" if not (as is the case today.)
> > What do you think?
>=20
> The fact that quilt uses patch in a very particular way doesn't
> actually create a connection between --backup and --read-only; those
> two options serve entirely different purposes.

What makes you consider that quilt uses patch in a "very particular"
way? I see quilt as calling patch exactly as a user would, just
automating things a lot to be more user-friendly and less error-prone.

There is no relation between files being read-only and using quilt.
Files being read-only is something specific to where I work, but
nothing prevents others from using a similar strategy.

Obviously options --backup and --read-only serve different purposes,
but that doesn't mean they are not (or should not) be related.

> > 2* After patching a read-only file, and even if --backup and --read-
> > only=3Dignore are passed, the patched file is still read-only. This mea=
ns
> > that our users must manually chmod +w each patched file to which they
> > need to make further changes.
> >
> > It seems conceptually wrong to me, as option --backup created a new
> > copy of the file and patched it, the contents are already modified so
> > the read-only nature of the file is already gone in practice.
> >
> > So I would like to propose that patched files are always made writable
> > when option --backup is used. What do you think?
>=20
> I can follow the argument that files should be (owner) writable after
> patch has modified them. But again I don't see the connection with
> --backup.

For me, --backup changes the notion of "original file". Without the
option, you overwrite the original file. With the option, you move the
original file, and create a new file with the original name.

Given that, patching a read-only file without using --backup is
"wrong", in that it breaks the restriction set by the file owner. But
patching a read-only file with --backup is "right" (in my eyes at
least), in that the original file is preserved. As a matter of fact, if
you patch a hard-linked file with --backup, the backed-up file keeps
the hard links while the patched file does not.

We have been working with read-only hard-linked trees for over a
decade. It was working just fine before patch was modified to complain
about this scenario.

I do believe that patch complaining about read-only files in the
absence of --backup makes a lot of sense, as the whole point of making
files read-only is to prevent them from being changed. In that sense
the change in behavior from commit cabd1add57 fixed a serious bug. But
in my opinion it introduced a regression in the --backup case
(mitigated by the commit 9a26fde226, but still.)

> A corner case with quilt is when a patch tries to modify a file but
> doesn't actually end up changing anything. In that case, patch should
> probably still create a backup and make the original file writable, if
> only to make life easier for quilt.

I'm sorry, I'm not sure I follow you here. Do yo mean for example a
no-op patch replacing a line with the exact same line? Or something
else?

Thanks,
--=20
Jean Delvare
SUSE L3 Support


