{"thread":{"id":"6056","subject":"[PATCH] fix vc git","startedAt":"2006-12-21T11:25:54Z","lastAt":"2006-12-22T15:17:55Z","messageCount":10,"participants":["Duncan Mak","Jakub Narebski","Junio C Hamano","Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"29934","messageId":"8e745ecf0612210325m72a569d7k370dd5953ccf6f27@mail.gmail.com","threadId":"6056","inReplyTo":null,"subject":"[PATCH] fix vc git","fromName":"Duncan Mak","fromEmail":"duncan@a-chinaman.com","sentAt":"2006-12-21T11:25:54Z","receivedAt":"2006-12-21T11:25:54Z","isPatch":true,"sender":{"key":"duncan@a-chinaman.com","avatar":"https://gravatar.com/avatar/5b00f3a0e47788d7ccf12c60effe50aa7bc0c509b908efde8974804753653a52?d=mp&s=160"},"body":"Fix vc-git.el to not cd into a non-existent directory.\n\n---\n\n contrib/emacs/vc-git.el |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\nbase 54851157acf707eb953eada2a84830897dde5c1d\nlast 9172c26ece749fc4289eeb89ef45c35936c5a869\ndiff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el\nindex 8b6361922fd6e6a2fcd9acb20fd54f5b645b36f0..d3ba93325255aea3dc52187dd703d7a8\n63cd6e5d 100644\n--- a/contrib/emacs/vc-git.el\n+++ b/contrib/emacs/vc-git.el\n@@ -58,7 +58,7 @@\n   (with-temp-buffer\n     (let* ((dir (file-name-directory file))\n            (name (file-relative-name file dir)))\n-      (when dir (cd dir))\n+      (if (file-exists-p dir) (cd dir))\n       (and (ignore-errors (eq 0 (call-process \"git\" nil '(t nil) nil \"ls-files\"\n \"-c\" \"-z\" \"--\" name)))\n            (let ((str (buffer-string)))\n              (and (> (length str) (length name))\n-- \n1.4.4.1\n"},{"id":"29936","messageId":"emdr6v$9ma$1@sea.gmane.org","threadId":"6056","inReplyTo":"8e745ecf0612210325m72a569d7k370dd5953ccf6f27@mail.gmail.com","subject":"Re: [PATCH] fix vc git","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-21T11:32:16Z","receivedAt":"2006-12-21T11:32:16Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Duncan Mak wrote:\n\n> -      (when dir (cd dir))\n> +      (if (file-exists-p dir) (cd dir))\n\nAdding `file-exist-p' is good, but there is no need to change\n`when' to `if'.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"29942","messageId":"8e745ecf0612210359j3f895521r1fff497a512253d3@mail.gmail.com","threadId":"6056","inReplyTo":"emdr6v$9ma$1@sea.gmane.org","subject":"Re: [PATCH] fix vc git","fromName":"Duncan Mak","fromEmail":"duncan@a-chinaman.com","sentAt":"2006-12-21T11:59:37Z","receivedAt":"2006-12-21T11:59:37Z","isPatch":true,"sender":{"key":"duncan@a-chinaman.com","avatar":"https://gravatar.com/avatar/5b00f3a0e47788d7ccf12c60effe50aa7bc0c509b908efde8974804753653a52?d=mp&s=160"},"body":"Fix vc-git.el to not cd into a non-existent directory.\n\n---\n\n contrib/emacs/vc-git.el |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\nbase 54851157acf707eb953eada2a84830897dde5c1d\nlast c2af9380cd8ec0170b9b251c0ee8a5efa63bac87\ndiff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el\nindex 8b6361922fd6e6a2fcd9acb20fd54f5b645b36f0..b3c8040dd766c9b15e1d0a9247b6343fdf0a8caf\n100644\n--- a/contrib/emacs/vc-git.el\n+++ b/contrib/emacs/vc-git.el\n@@ -58,7 +58,7 @@\n   (with-temp-buffer\n     (let* ((dir (file-name-directory file))\n            (name (file-relative-name file dir)))\n-      (when dir (cd dir))\n+      (when (file-exists-p dir) (cd dir))\n       (and (ignore-errors (eq 0 (call-process \"git\" nil '(t nil) nil\n\"ls-files\" \"-c\" \"-z\" \"--\" name)))\n            (let ((str (buffer-string)))\n              (and (> (length str) (length name))\n-- \n1.4.4.1\n"},{"id":"29986","messageId":"7vhcvo92fx.fsf@assigned-by-dhcp.cox.net","threadId":"6056","inReplyTo":"8e745ecf0612210359j3f895521r1fff497a512253d3@mail.gmail.com","subject":"Re: [PATCH] fix vc git","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-22T00:52:50Z","receivedAt":"2006-12-22T00:52:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Duncan Mak\" <duncan@a-chinaman.com> writes:\n\n> --- a/contrib/emacs/vc-git.el\n> +++ b/contrib/emacs/vc-git.el\n> @@ -58,7 +58,7 @@\n>   (with-temp-buffer\n>     (let* ((dir (file-name-directory file))\n>            (name (file-relative-name file dir)))\n> -      (when dir (cd dir))\n> +      (when (file-exists-p dir) (cd dir))\n>       (and (ignore-errors (eq 0 (call-process \"git\" nil '(t nil) nil\n> \"ls-files\" \"-c\" \"-z\" \"--\" name)))\n>            (let ((str (buffer-string)))\n>              (and (> (length str) (length name))\n\nI wonder what would happen when (file-name-directory file)\nreturns nil with this change...\n"},{"id":"30007","messageId":"8e745ecf0612212011q26f81d91uce143b4212fc5e8b@mail.gmail.com","threadId":"6056","inReplyTo":"7vhcvo92fx.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] fix vc git","fromName":"Duncan Mak","fromEmail":"duncan@a-chinaman.com","sentAt":"2006-12-22T04:11:32Z","receivedAt":"2006-12-22T04:11:32Z","isPatch":true,"sender":{"key":"duncan@a-chinaman.com","avatar":"https://gravatar.com/avatar/5b00f3a0e47788d7ccf12c60effe50aa7bc0c509b908efde8974804753653a52?d=mp&s=160"},"body":"I don't think vc-git-registered-file will ever be called with a\nfilename without a directory, as it is used as a hook on\nvc-next-action, which works on a real file.\n\nEither way, it's a modified patch:\n\nFix vc-git.el to not cd into a non-existent directory.\n\n---\n\n contrib/emacs/vc-git.el |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\nbase c902c9a608c1b727160d6fbb04fa363d9418cd00\nlast 96e9944b714094ab81f8091711a92506886b8004\ndiff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el\nindex 8b6361922fd6e6a2fcd9acb20fd54f5b645b36f0..668bd4a98653046aadf91e7a91af6cd76ba044d4\n100644\n--- a/contrib/emacs/vc-git.el\n+++ b/contrib/emacs/vc-git.el\n@@ -58,7 +58,7 @@\n   (with-temp-buffer\n     (let* ((dir (file-name-directory file))\n            (name (file-relative-name file dir)))\n-      (when dir (cd dir))\n+      (when (and dir (file-exists-p dir)) (cd dir))\n       (and (ignore-errors (eq 0 (call-process \"git\" nil '(t nil) nil\n\"ls-files\" \"-c\" \"-z\" \"--\" name)))\n            (let ((str (buffer-string)))\n              (and (> (length str) (length name))\n-- \n1.4.4.1\n"},{"id":"30010","messageId":"7vvek47cph.fsf@assigned-by-dhcp.cox.net","threadId":"6056","inReplyTo":"8e745ecf0612212011q26f81d91uce143b4212fc5e8b@mail.gmail.com","subject":"Re: [PATCH] fix vc git","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-22T04:54:02Z","receivedAt":"2006-12-22T04:54:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Duncan Mak\" <duncan@a-chinaman.com> writes:\n\n> I don't think vc-git-registered-file will ever be called with a\n> filename without a directory, as it is used as a hook on\n> vc-next-action, which works on a real file.\n\nI am showing my ignorance, but\n\n (1) if it works on a real file then can it ever give you a file\n     that is in nonexisting directory?\n\n (2) when it works on a file at the root level of the project\n     tree, say, just \"Makefile\" wouldn't dir which is the result\n     of (file-name-directory file) be sometimes nil?  I suspect\n     that is the reason of the original (when dir ...)\n\nIn either case, your change would not break anything.  I am just\nbeing curious.\n"},{"id":"30054","messageId":"87ejqsumu3.fsf@wine.dyndns.org","threadId":"6056","inReplyTo":"8e745ecf0612212011q26f81d91uce143b4212fc5e8b@mail.gmail.com","subject":"Re: [PATCH] fix vc git","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2006-12-22T12:39:00Z","receivedAt":"2006-12-22T12:39:00Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"\"Duncan Mak\" <duncan@a-chinaman.com> writes:\n\n> I don't think vc-git-registered-file will ever be called with a\n> filename without a directory, as it is used as a hook on\n> vc-next-action, which works on a real file.\n\nWell, if it's a real file I'd expect the directory to exist, and if it\ndoesn't, I'm not sure there's much point in calling git-ls-files at\nall. In which case do you get a non-existent directory here?\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"},{"id":"30052","messageId":"8e745ecf0612220451v367479dq13af2d829a9547c2@mail.gmail.com","threadId":"6056","inReplyTo":"87ejqsumu3.fsf@wine.dyndns.org","subject":"Re: [PATCH] fix vc git","fromName":"Duncan Mak","fromEmail":"duncan@a-chinaman.com","sentAt":"2006-12-22T12:51:45Z","receivedAt":"2006-12-22T12:51:45Z","isPatch":true,"sender":{"key":"duncan@a-chinaman.com","avatar":"https://gravatar.com/avatar/5b00f3a0e47788d7ccf12c60effe50aa7bc0c509b908efde8974804753653a52?d=mp&s=160"},"body":"On 12/22/06, Alexandre Julliard <julliard@winehq.org> wrote:\n>\n> Well, if it's a real file I'd expect the directory to exist, and if it\n> doesn't, I'm not sure there's much point in calling git-ls-files at\n> all. In which case do you get a non-existent directory here?\n>\n\nYeah, but the issue is that, as you know, to create a new file in\nemacs, you give find-file  a non-existent file and emacs will open up\na buffer for you and let you save it when you're done.\n\nOnce I installed the git vc backend, that feature stopped working for\nme - that's the reason why I made this patch.\n\nDuncan.\n"},{"id":"30056","messageId":"87ac1guj9c.fsf@wine.dyndns.org","threadId":"6056","inReplyTo":"8e745ecf0612220451v367479dq13af2d829a9547c2@mail.gmail.com","subject":"Re: [PATCH] fix vc git","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2006-12-22T13:56:15Z","receivedAt":"2006-12-22T13:56:15Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"\"Duncan Mak\" <duncan@a-chinaman.com> writes:\n\n> Yeah, but the issue is that, as you know, to create a new file in\n> emacs, you give find-file  a non-existent file and emacs will open up\n> a buffer for you and let you save it when you're done.\n\nOK, but in that case vc-git-registered needs to return failure, you\ncannot call git-ls-files as it may find the file in the wrong\ndirectory. I'd suggest something like this:\n\n\n>From abf4311add221102957145255d5418a7ec06fe1d Mon Sep 17 00:00:00 2001\nFrom: Alexandre Julliard <julliard@winehq.org>\nDate: Fri, 22 Dec 2006 14:51:23 +0100\nSubject: [PATCH] vc-git: Ignore errors caused by a non-existent directory in vc-git-registered.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n contrib/emacs/vc-git.el |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el\nindex 8b63619..3eb4bd1 100644\n--- a/contrib/emacs/vc-git.el\n+++ b/contrib/emacs/vc-git.el\n@@ -58,8 +58,9 @@\n   (with-temp-buffer\n     (let* ((dir (file-name-directory file))\n            (name (file-relative-name file dir)))\n-      (when dir (cd dir))\n-      (and (ignore-errors (eq 0 (call-process \"git\" nil '(t nil) nil \"ls-files\" \"-c\" \"-z\" \"--\" name)))\n+      (and (ignore-errors\n+             (when dir (cd dir))\n+             (eq 0 (call-process \"git\" nil '(t nil) nil \"ls-files\" \"-c\" \"-z\" \"--\" name)))\n            (let ((str (buffer-string)))\n              (and (> (length str) (length name))\n                   (string= (substring str 0 (1+ (length name))) (concat name \"\\0\"))))))))\n-- \n1.4.4.2.g28ce\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"},{"id":"30062","messageId":"8e745ecf0612220717v5c7b3a02v55b36f865278ea9c@mail.gmail.com","threadId":"6056","inReplyTo":"87ac1guj9c.fsf@wine.dyndns.org","subject":"Re: [PATCH] fix vc git","fromName":"Duncan Mak","fromEmail":"duncan@a-chinaman.com","sentAt":"2006-12-22T15:17:55Z","receivedAt":"2006-12-22T15:17:55Z","isPatch":true,"sender":{"key":"duncan@a-chinaman.com","avatar":"https://gravatar.com/avatar/5b00f3a0e47788d7ccf12c60effe50aa7bc0c509b908efde8974804753653a52?d=mp&s=160"},"body":"On 12/22/06, Alexandre Julliard <julliard@winehq.org> wrote:\n>\n> OK, but in that case vc-git-registered needs to return failure, you\n> cannot call git-ls-files as it may find the file in the wrong\n> directory. I'd suggest something like this:\n>\n\nAh, okay. I agree, that is a better patch.\n\nWould you be committing it  soon?\n\nThanks,\n\nDuncan.\n"}]}