Subject: bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory

From: Andrii Kolomoiets <[email-masked]>
Date: Mon, 16 Dec 2019 21:43:39 +0200

Dmitry Gutov <[email-masked]> writes:

>> Though point is stil moves to the word "dir" on the second line after
>> step 3.
>> And directory "dir" status is not updated when:
>> 2. C-x v d
>> 3. n
>> 4. v
>> Should it be different bug reports for those cases?
>
> Yes.
>
> These would have to be fixed in vc-dir rather than vc-git, and they
> would require some more investigation about the proper behavior and
> the places to fix.
>
> Regarding the moving of point, personally, I'm not sure which of the
> behaviors is more correct.

It's `vc-dir-move-to-goal-column' called after `vc-register'. I will
make dedicated bug report.

> The latter is caused basically by:
>
> - Git returning a directory in the file status list.
> - Directories not having an actual VCS status in our system.

How about to list files and not directories? This will allow to register
untracked files under untracked directory with single `v'. Please see
attached patch.
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 71307cdffd..e40dcadf56 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -615,8 +615,7 @@ vc-git-dir-status-goto-stage
                        "ls-files" "-z" "-u" "--"))
       ('ls-files-unknown
        (vc-git-command (current-buffer) 'async files
-                       "ls-files" "-z" "-o" "--directory"
-                       "--no-empty-directory" "--exclude-standard" "--"))
+                       "ls-files" "-z" "-o" "--exclude-standard" "--"))
       ('ls-files-ignored
        (vc-git-command (current-buffer) 'async files
                        "ls-files" "-z" "-o" "-i" "--directory"