unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#35420: Support git in ediff-patch-file
@ 2019-04-24 21:38 Juri Linkov
  2019-04-25  6:14 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2019-04-24 21:38 UTC (permalink / raw)
  To: 35420

[-- Attachment #1: Type: text/plain, Size: 62 bytes --]

This patch adds support for git patches to ediff-patch-file:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ediff-ptch.git.patch --]
[-- Type: text/x-diff, Size: 995 bytes --]

diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el
index 4178b5a8c0..5c71c2c8cb 100644
--- a/lisp/vc/ediff-ptch.el
+++ b/lisp/vc/ediff-ptch.el
@@ -297,11 +297,15 @@ ediff-fixup-patch-map
 	      ;; file names. This is a heuristic intended to improve guessing
 	      (let ((default-directory (file-name-directory filename)))
 		(unless (or (file-name-absolute-p base-dir1)
-			    (file-name-absolute-p base-dir2)
-			    (not (file-exists-p base-dir1))
-			    (not (file-exists-p base-dir2)))
-		  (setq base-dir1 ""
-			base-dir2 "")))
+			    (file-name-absolute-p base-dir2))
+		  (if (and (file-exists-p base-dir1)
+			   (file-exists-p base-dir2))
+		      (setq base-dir1 ""
+			    base-dir2 "")
+		    (when (and (string-match-p "^a/" base-dir1)
+			       (string-match-p "^b/" base-dir2))
+		      (setq base-dir1 "a/"
+			    base-dir2 "b/")))))
 	      (or (string= (car proposed-file-names) "/dev/null")
 		  (setcar proposed-file-names
 			  (ediff-file-name-sans-prefix

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* bug#35420: Support git in ediff-patch-file
  2019-04-24 21:38 bug#35420: Support git in ediff-patch-file Juri Linkov
@ 2019-04-25  6:14 ` Eli Zaretskii
  2019-04-25  7:53   ` Robert Pluim
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2019-04-25  6:14 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 35420

> From: Juri Linkov <juri@linkov.net>
> Date: Thu, 25 Apr 2019 00:38:43 +0300
> 
> +		    (when (and (string-match-p "^a/" base-dir1)
> +			       (string-match-p "^b/" base-dir2))
> +		      (setq base-dir1 "a/"
> +			    base-dir2 "b/")))))

I think I saw the file names begin with i/ and w/ instead of a/ and
b/.  Not sure when/why this happens.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#35420: Support git in ediff-patch-file
  2019-04-25  6:14 ` Eli Zaretskii
@ 2019-04-25  7:53   ` Robert Pluim
  2019-04-25  8:46     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Pluim @ 2019-04-25  7:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 35420, Juri Linkov

>>>>> On Thu, 25 Apr 2019 09:14:21 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Juri Linkov <juri@linkov.net> Date: Thu, 25 Apr 2019
    >> 00:38:43 +0300
    >> 
    >> + (when (and (string-match-p "^a/" base-dir1) + (string-match-p
    >> "^b/" base-dir2)) + (setq base-dir1 "a/" + base-dir2 "b/")))))

    Eli> I think I saw the file names begin with i/ and w/ instead of
    Eli> a/ and b/.  Not sure when/why this happens.

You get i/, w/ and/or c/ when you run 'git diff' inside your working
tree, depending on whether the changed file is in the 'i'ndex,
'w'orking tree, or 'c'ache (also known as the staging area). Things
like 'git format-patch' and 'git show' use a/ and b/ by default.

And of course, since this is git, you can tell it to use other
prefixes using '--src-prefix' and '--dst-prefix'.

Robert





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#35420: Support git in ediff-patch-file
  2019-04-25  7:53   ` Robert Pluim
@ 2019-04-25  8:46     ` Eli Zaretskii
  2019-04-25  9:12       ` Robert Pluim
  2019-05-05 19:51       ` Juri Linkov
  0 siblings, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2019-04-25  8:46 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 35420, juri

> From: Robert Pluim <rpluim@gmail.com>
> Cc: Juri Linkov <juri@linkov.net>,  35420@debbugs.gnu.org
> Date: Thu, 25 Apr 2019 09:53:16 +0200
> 
> You get i/, w/ and/or c/ when you run 'git diff' inside your working
> tree, depending on whether the changed file is in the 'i'ndex,
> 'w'orking tree, or 'c'ache (also known as the staging area). Things
> like 'git format-patch' and 'git show' use a/ and b/ by default.
> 
> And of course, since this is git, you can tell it to use other
> prefixes using '--src-prefix' and '--dst-prefix'.

Thanks.  I guess we'd like to support these use cases as well, right?

Also, what's the situation with hg?  Is it similar?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#35420: Support git in ediff-patch-file
  2019-04-25  8:46     ` Eli Zaretskii
@ 2019-04-25  9:12       ` Robert Pluim
  2019-05-05 19:51       ` Juri Linkov
  1 sibling, 0 replies; 6+ messages in thread
From: Robert Pluim @ 2019-04-25  9:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 35420, juri

>>>>> On Thu, 25 Apr 2019 11:46:33 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Robert Pluim <rpluim@gmail.com> Cc: Juri Linkov
    >> <juri@linkov.net>, 35420@debbugs.gnu.org Date: Thu, 25 Apr 2019
    >> 09:53:16 +0200
    >> 
    >> You get i/, w/ and/or c/ when you run 'git diff' inside your
    >> working tree, depending on whether the changed file is in the
    >> 'i'ndex, 'w'orking tree, or 'c'ache (also known as the staging
    >> area). Things like 'git format-patch' and 'git show' use a/ and
    >> b/ by default.
    >> 
    >> And of course, since this is git, you can tell it to use other
    >> prefixes using '--src-prefix' and '--dst-prefix'.

    Eli> Thanks.  I guess we'd like to support these use cases as
    Eli> well, right?

Yes, that would be a good improvement.

    Eli> Also, what's the situation with hg?  Is it similar?

I donʼt use hg, but based on a quick test it uses a/ and b/

Robert





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#35420: Support git in ediff-patch-file
  2019-04-25  8:46     ` Eli Zaretskii
  2019-04-25  9:12       ` Robert Pluim
@ 2019-05-05 19:51       ` Juri Linkov
  1 sibling, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2019-05-05 19:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Pluim, 35420-done

>> You get i/, w/ and/or c/ when you run 'git diff' inside your working
>> tree, depending on whether the changed file is in the 'i'ndex,
>> 'w'orking tree, or 'c'ache (also known as the staging area). Things
>> like 'git format-patch' and 'git show' use a/ and b/ by default.
>> 
>> And of course, since this is git, you can tell it to use other
>> prefixes using '--src-prefix' and '--dst-prefix'.
>
> Thanks.  I guess we'd like to support these use cases as well, right?

I implemented support for these cases as well and pushed to master.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-05 19:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 21:38 bug#35420: Support git in ediff-patch-file Juri Linkov
2019-04-25  6:14 ` Eli Zaretskii
2019-04-25  7:53   ` Robert Pluim
2019-04-25  8:46     ` Eli Zaretskii
2019-04-25  9:12       ` Robert Pluim
2019-05-05 19:51       ` Juri Linkov

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).