From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: Re: diff-find-file-name and /dev/null Date: Fri, 24 Aug 2007 21:54:35 -0400 Message-ID: References: <878x89ag8z.fsf@lrde.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1188017658 27722 80.91.229.12 (25 Aug 2007 04:54:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 25 Aug 2007 04:54:18 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org, Stefan Monnier To: Nikolaj Schumacher Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Aug 25 06:54:16 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IOnf4-0000mr-2D for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Aug 2007 06:54:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IOnf3-0004h9-40 for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Aug 2007 00:54:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IOnf1-0004g5-5d for bug-gnu-emacs@gnu.org; Sat, 25 Aug 2007 00:54:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IOnez-0004dn-LR for bug-gnu-emacs@gnu.org; Sat, 25 Aug 2007 00:54:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IOnez-0004d2-Fb for bug-gnu-emacs@gnu.org; Sat, 25 Aug 2007 00:54:09 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IOkrG-0001GD-Bw for bug-gnu-emacs@gnu.org; Fri, 24 Aug 2007 21:54:38 -0400 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1IOkrD-0006hF-VB; Fri, 24 Aug 2007 21:54:35 -0400 X-Spook: brigand Forte Mantis Cocaine interception Area 51 enemy X-Ran: Jy6A?VSEvV@V/R'LG.L2PwC?~sjKX]I1QMmgFD|#Z (Nikolaj Schumacher's message of "Sun, 19 Aug 2007 23:06:53 +0200") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16440 Archived-At: Nikolaj Schumacher wrote: > Since there's nothing to view or edit in /dev/null. How about this patch then: diff -c -c -w -r1.99.2.3 diff-mode.el *** diff-mode.el 6 Aug 2007 20:08:07 -0000 1.99.2.3 --- diff-mode.el 25 Aug 2007 01:41:53 -0000 *************** *** 646,652 **** ((or (null files) (setq file (do* ((files files (cdr files)) (file (car files) (car files))) ! ((or (null file) (file-exists-p file)) file)))) file)) ;; .rej patches implicitly apply to --- 646,652 ---- ((or (null files) (setq file (do* ((files files (cdr files)) (file (car files) (car files))) ! ((or (null file) (file-regular-p file)) file)))) file)) ;; .rej patches implicitly apply to > Also in a usual diff file > > --- /dev/null 2007-08-17 06:03:27.000000000 +0200 > +++ /foo/bar.c 2007-08-18 00:48:25.000000000 +0200 > > `diff-goto-source' would visit /foo/bar.c It's easy to produce a non-git diff that has the same behaviour. Just do a diff between /dev/null and a relative filename: diff -u /dev/null foo/somefile > foo/some.diff Then open foo/some.diff in Emacs and try to jump to source. I'd never make a hideous diff like that though... > I admit the actual fault could be the fact that it looks for first > one at all (or at least _before_ chopping off prefixes of the second > one), even when diff-jump-to-old-file is nil. /dev/null is just the > only cause of such behavior. Yes, I don't see why diff-find-file-name does that, and I don't think /dev/null is the only cause. Eg repeating the above example, but with regular files: diff -u /tmp/file1 foo/file2 > foo/file.diff diff-goto-source will open file1 rather than file2. Stefan, is there a reason why diff-find-file-name can return the old file, even when OLD is nil? Why doesn't it just consider (car (diff-hunk-file-names old))? If it should consider both old and new in each case, should it not try dropping the directory entries from the new/old file first, before going on to check the old/new one in the same way only it it does not find a match?