From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iA1wLPWo0WC2KAAAgWs5BA (envelope-from ) for ; Tue, 22 Jun 2021 11:10:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id EPwlKPWo0WBpJgAA1q6Kng (envelope-from ) for ; Tue, 22 Jun 2021 09:10:13 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 72E6819DCF for ; Tue, 22 Jun 2021 11:10:13 +0200 (CEST) Received: from localhost ([::1]:49922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvcQ8-0002by-Gc for larch@yhetil.org; Tue, 22 Jun 2021 05:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvcPy-0002Z4-R1 for guix-patches@gnu.org; Tue, 22 Jun 2021 05:10:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvcPy-0003hD-IL for guix-patches@gnu.org; Tue, 22 Jun 2021 05:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lvcPy-0007qU-EY for guix-patches@gnu.org; Tue, 22 Jun 2021 05:10:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49169] [PATCH 09/11] utils: 'edit-expression' modifies the file only if necessary. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 22 Jun 2021 09:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49169 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49169@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 49169-submit@debbugs.gnu.org id=B49169.162435294530032 (code B ref 49169); Tue, 22 Jun 2021 09:10:02 +0000 Received: (at 49169) by debbugs.gnu.org; 22 Jun 2021 09:09:05 +0000 Received: from localhost ([127.0.0.1]:37820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvcP2-0007o9-TX for submit@debbugs.gnu.org; Tue, 22 Jun 2021 05:09:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32876) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvcOq-0007lT-Tt for 49169@debbugs.gnu.org; Tue, 22 Jun 2021 05:08:53 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:52828) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvcOl-0002r5-Nz; Tue, 22 Jun 2021 05:08:47 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=49370 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lvcOl-0000B8-GR; Tue, 22 Jun 2021 05:08:47 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 22 Jun 2021 11:08:28 +0200 Message-Id: <20210622090830.15561-9-ludo@gnu.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210622090830.15561-1-ludo@gnu.org> References: <20210622090830.15561-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624353013; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=nwrPPxf0+hQHK+h8bLAHGpR+y/By3vxqUM5YQxO2s5E=; b=kCLjI40rVhfEChdxwjZsfe9IDCOggCY85mCoYorIkdniEjh8oREfYu9T4k9KeMmtQ8xyUr uUFlpELc19C4TGvphy69tpXaatPzD4hDSOF6bscJfv0cG4lZxgFctp1UPoRnyxJXHX1X/r QhLeYsCCL21kTJYRyF5n+7qktfgQdwqRozjkhL5y8it2VC8dB1joizATjbHD6zcIPQVO3p S+5UUcCXveR7gFDCEH+tlxuXo+D8ADTv5oGbYEiffismNaKr5vSsTCW9Ax/Yd8VGgf15Fd rJuQyarRKSXJQqf7zRSuwzUL6Cv+XRHZ0NgeGext9nnm1skmUvUV1Jcgivc2vw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624353013; a=rsa-sha256; cv=none; b=g/9YYXaeTeg+bmQ4TWCzYzqVb9GfQ10mWNK++wgEvtYiJemz+HPTWWUGCLwmjJ4mGrKJed 3OPv6BfEoOOZHaDUYmgqRvDedpLeiIqgboaAJBnr1p0N2Wj9xqQcHU4KIcGsM0icZJw7A+ jxeKzgiznqGaJFFiDq0FSvYa9oYWQhk78xTVShwxaxAKkqvU/FvsgTIBZj/a8NCEkeXZgq G953AacDbM3lEWMPx+AzRxO9mAz9Z/a5r9eGGkpQ1UwoirubusTh0LWyh769IJJrHkA1Bg NYxXKnUMPAFiLO7C4GnCAEaRbyv1U12YDOKfHQkPqKLsU0C1rm4qRd+NLqLDVA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 2.07 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 72E6819DCF X-Spam-Score: 2.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: fWW2ZVclRx+3 * guix/utils.scm (edit-expression): Check whether STR* equals STR. --- guix/utils.scm | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/guix/utils.scm b/guix/utils.scm index f8f6672bb1..e6d0761679 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -423,17 +423,19 @@ This procedure returns #t on success." (port-encoding in))) (post-bv (get-bytevector-all in)) (str* (proc str))) - ;; Verify the edited expression is still a scheme expression. - (call-with-input-string str* read) - ;; Update the file with edited expression. - (with-atomic-file-output file - (lambda (out) - (put-bytevector out pre-bv) - (display str* out) - ;; post-bv maybe the end-of-file object. - (when (not (eof-object? post-bv)) - (put-bytevector out post-bv)) - #t)))))))) + ;; Modify FILE only if there are changes. + (unless (string=? str* str) + ;; Verify the edited expression is still a scheme expression. + (call-with-input-string str* read) + ;; Update the file with edited expression. + (with-atomic-file-output file + (lambda (out) + (put-bytevector out pre-bv) + (display str* out) + ;; post-bv maybe the end-of-file object. + (when (not (eof-object? post-bv)) + (put-bytevector out post-bv)) + #t))))))))) ;;; -- 2.32.0