From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [elpa] master 8650a52 2/2: Issue #18: files considered different if they have different sizes Date: Mon, 26 Dec 2016 09:40:10 -0500 Message-ID: References: <20161226141926.26964.59272@vcs.savannah.gnu.org> <20161226141927.3D0D3220088@vcs.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1482763269 23290 195.159.176.226 (26 Dec 2016 14:41:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 26 Dec 2016 14:41:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: Alexey Veretennikov To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 26 15:41:04 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cLWSL-00041q-7z for ged-emacs-devel@m.gmane.org; Mon, 26 Dec 2016 15:40:53 +0100 Original-Received: from localhost ([::1]:50505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLWSP-0004q5-QP for ged-emacs-devel@m.gmane.org; Mon, 26 Dec 2016 09:40:57 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLWRj-0004pY-Kt for emacs-devel@gnu.org; Mon, 26 Dec 2016 09:40:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLWRf-0003xi-Qu for emacs-devel@gnu.org; Mon, 26 Dec 2016 09:40:15 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:45912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cLWRf-0003xT-Lc for emacs-devel@gnu.org; Mon, 26 Dec 2016 09:40:11 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DoAQAu3EVY/5WSWxddGgEBAQECAQEBAQgBAQEBgzgBAQEBAR+EW4pMlzABlFaCCBmGAwQCAoIRQBQBAgEBAQEBAQFiKIRpBlYjEAs0EhQYDYkmrRSLRAEBAQEGAgEkixmFFIR3HgWOf32KapsahjqSDx83eBMOhBCBYyCJLQEBAQ X-IPAS-Result: A0DoAQAu3EVY/5WSWxddGgEBAQECAQEBAQgBAQEBgzgBAQEBAR+EW4pMlzABlFaCCBmGAwQCAoIRQBQBAgEBAQEBAQFiKIRpBlYjEAs0EhQYDYkmrRSLRAEBAQEGAgEkixmFFIR3HgWOf32KapsahjqSDx83eBMOhBCBYyCJLQEBAQ X-IronPort-AV: E=Sophos;i="5.33,749,1477972800"; d="scan'208";a="283924515" Original-Received: from 23-91-146-149.cpe.pppoe.ca (HELO pastel.home) ([23.91.146.149]) by smtp.teksavvy.com with ESMTP; 26 Dec 2016 09:40:10 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 4784D64E88; Mon, 26 Dec 2016 09:40:10 -0500 (EST) In-Reply-To: <20161226141927.3D0D3220088@vcs.savannah.gnu.org> (Alexey Veretennikov's message of "Mon, 26 Dec 2016 14:19:27 +0000 (UTC)") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210817 Archived-At: > + (diff-cmd (concat diff-command " -q" " " > + (ztree-quotify-string file1-untrampified) > + " " > + (ztree-quotify-string file2-untrampified)))) > + (if (and > + (= (nth 7 (file-attributes file1-untrampified)) > + (nth 7 (file-attributes file2-untrampified))) > + (> (length (shell-command-to-string diff-cmd)) 2)) The function `process-file` should be able to do a better job than shell-command-to-string (among other things, no need for "quotify"). You'll probably want to run it something like (let* ((file1 (file-name-directory (expand-file-name file1))) (file2 (file-name-directory (expand-file-name file2))) (default-directory (file-name-directory file1)) (file1 (file-relative-name file1)) (file2 (file-relative-name file2)) (exit-code (process-file diff-command nil nil nil "-q" file1 file2))) (if (and (numberp exit-code) (= exit-code 0)) 'same 'diff)) BTW, a file with name hello"; rm -rf ~/. will probably not do what you wanted. Using process-file should fix this problem since it doesn't need to quote anything. But if you insist on using a shell command, then just use shell-quote-argument instead of ztree-quotify-string. Stefan