unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [elpa] master 8650a52 2/2: Issue #18: files considered different if they have different sizes
       [not found] ` <20161226141927.3D0D3220088@vcs.savannah.gnu.org>
@ 2016-12-26 14:40   ` Stefan Monnier
  2016-12-26 17:03     ` Alexey Veretennikov
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2016-12-26 14:40 UTC (permalink / raw)
  To: emacs-devel; +Cc: Alexey Veretennikov

> +         (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



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

* Re: [elpa] master 8650a52 2/2: Issue #18: files considered different if they have different sizes
  2016-12-26 14:40   ` [elpa] master 8650a52 2/2: Issue #18: files considered different if they have different sizes Stefan Monnier
@ 2016-12-26 17:03     ` Alexey Veretennikov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexey Veretennikov @ 2016-12-26 17:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Thanks! I'll experiment with process-file.

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> +         (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

-- 
Br,
/Alexey



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

end of thread, other threads:[~2016-12-26 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20161226141926.26964.59272@vcs.savannah.gnu.org>
     [not found] ` <20161226141927.3D0D3220088@vcs.savannah.gnu.org>
2016-12-26 14:40   ` [elpa] master 8650a52 2/2: Issue #18: files considered different if they have different sizes Stefan Monnier
2016-12-26 17:03     ` Alexey Veretennikov

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