GNU bug report logs -
#26066
vc-git-status gives wrong result when called from outside repository
Previous Next
Reported by: Jonathan Ganc <jonganc <at> gmail.com>
Date: Sun, 12 Mar 2017 02:45:02 UTC
Severity: minor
Tags: patch
Found in versions 25.2, 26.0.50, 24.5
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Jonathan Ganc <jonganc <at> gmail.com> writes:
>
> +(defun vc-git--git-status-to-vc-state (code-list)
> + (setq code-list (remq nil code-list))
> + (pcase code-list
> + ('nil 'up-to-date)
You seem to be handling nil in 2 different ways.
> + ;; have only seen this with a file that is only present in the
> + ;; index. let us call this `removed'
Comments should be full sentences (start with uppercase, end with
period), and sentences should be separated with double spaces.
> (defun vc-git-state (file)
> "Git-specific version of `vc-state'."
> +
> + (save-match-data
> + (let* ((default-directory (file-name-directory (expand-file-name file)))
> + (status
> + (vc-git--run-command-string file "status" "--porcelain" "-z"
> + "--untracked-files" "--ignored" "--"))
> + code-list)
> + (while (string-match "^\\(..\\)[^\0]+\0\\(\\(?:a\\|[^a]\\)*\\)$" status)
I think you're missing a space after the first 2 characters.
alternate -z format recommended for machine parsing. [...] Second, a
NUL (ASCII 0) follows each filename, [...] (but a space still
separates the status field from the first filename).
> + (add-to-list 'code-list (match-string 1 status) t 'ignore)
Don't use `add-to-list' on local variables. The usual idiom for
collecting a series of items in a list would be
(let ((code-list nil))
(while ...
(push ... code-list))
(setq code-list (nreverse code-list)))
> + (setq status (match-string 2 status)))
Instead of matching the rest of the string in the regexp, just set a
position variable to (match-end 0), and then pass that position as the
string-match's START parameter.
This bug report was last modified 4 years and 344 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.