unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: Nikolaj Schumacher <n_schumacher@web.de>
Cc: bug-gnu-emacs@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: diff-find-file-name and /dev/null
Date: Fri, 24 Aug 2007 21:54:35 -0400	[thread overview]
Message-ID: <kq1wdswf8k.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <m2wsvrw7wy.fsf@nschum.de> (Nikolaj Schumacher's message of "Sun,  19 Aug 2007 23:06:53 +0200")

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))
         ;; <foo>.rej patches implicitly apply to <foo>
--- 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))
         ;; <foo>.rej patches implicitly apply to <foo>

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

  reply	other threads:[~2007-08-25  1:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-17 22:53 diff-find-file-name and /dev/null Nikolaj Schumacher
2007-08-17 23:33 ` Michaël Cadilhac
2007-08-19 21:06   ` Nikolaj Schumacher
2007-08-25  1:54     ` Glenn Morris [this message]
2007-08-27  4:51       ` Stefan Monnier
2007-08-27  7:10         ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kq1wdswf8k.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=n_schumacher@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).