unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory
@ 2019-12-14 12:41 Andrii Kolomoiets
  2019-12-16  1:25 ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2019-12-14 12:41 UTC (permalink / raw)
  To: 38615

0. mkdir test && cd test
   git init
   touch file
   git add file
   git commit -m "initial"
   mkdir dir
   touch dir/file1
1. emacs -Q
2. C-x v d
   "dir/" is listed with "unregistered" status.
3. v
   "dir/" has "added" status.
4. g
   "dir/file1" is listed with "up-to-date" status.  Shouldn't it have
   "added" status?
5. g
   Now "dir/file1" properly has "added" status.

Also:
- After step 3 point is moved to word "dir" on second line.
- Press "n" before step 3 to move point to "dir/". After step 3 "dir/"
  status is not updated and remains "unregistered".





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

* bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory
  2019-12-14 12:41 bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory Andrii Kolomoiets
@ 2019-12-16  1:25 ` Dmitry Gutov
  2019-12-16  8:00   ` Andrii Kolomoiets
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2019-12-16  1:25 UTC (permalink / raw)
  To: Andrii Kolomoiets, 38615

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

Hi Andrii,

On 14.12.2019 14:41, Andrii Kolomoiets wrote:
> 0. mkdir test && cd test
>     git init
>     touch file
>     git add file
>     git commit -m "initial"
>     mkdir dir
>     touch dir/file1
> 1. emacs -Q
> 2. C-x v d
>     "dir/" is listed with "unregistered" status.
> 3. v
>     "dir/" has "added" status.
> 4. g
>     "dir/file1" is listed with "up-to-date" status.  Shouldn't it have
>     "added" status?
> 5. g
>     Now "dir/file1" properly has "added" status.
> 
> Also:
> - After step 3 point is moved to word "dir" on second line.
> - Press "n" before step 3 to move point to "dir/". After step 3 "dir/"
>    status is not updated and remains "unregistered".

Thanks for the repro. This problem seems to have been with us for a while.

vc-git's dir-status-files code is a bit hard to follow, but here's a 
patch you can try. I'll commit it in the next few days if nothing comes up.

[-- Attachment #2: vc-git-dir-status-files+added.diff --]
[-- Type: text/x-patch, Size: 1488 bytes --]

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 71307cdffd..9e02a820ac 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -521,14 +521,17 @@ vc-git-after-dir-status-stage
       ('ls-files-up-to-date
        (setq next-stage 'ls-files-unknown)
        (while (re-search-forward "\\([0-7]\\{6\\}\\) [0-9a-f]\\{40\\} \\([0-3]\\)\t\\([^\0]+\\)\0" nil t)
-         (let ((perm (string-to-number (match-string 1) 8))
-               (state (match-string 2))
-               (name (match-string 3)))
-           (vc-git-dir-status-update-file
-            git-state name (if (equal state "0")
-                               'up-to-date
-                             'conflict)
-            (vc-git-create-extra-fileinfo perm perm)))))
+         (let* ((perm (string-to-number (match-string 1) 8))
+                (state (match-string 2))
+                (name (match-string 3))
+                (file-info (vc-git-create-extra-fileinfo perm perm)))
+           (if (equal state "0")
+               (unless (gethash name (vc-git-dir-status-state->hash git-state))
+                 ;; `diff-index' has not produced a more precise info.
+                 (vc-git-dir-status-update-file
+                  git-state name 'up-to-date file-info))
+             (vc-git-dir-status-update-file
+              git-state name 'conflict file-info)))))
       ('ls-files-conflict
        (setq next-stage 'ls-files-unknown)
        ;; It's enough to look for "3" to notice a conflict.

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

* bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory
  2019-12-16  1:25 ` Dmitry Gutov
@ 2019-12-16  8:00   ` Andrii Kolomoiets
  2019-12-16 13:23     ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2019-12-16  8:00 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 38615

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 14.12.2019 14:41, Andrii Kolomoiets wrote:
>> 0. mkdir test && cd test
>>     git init
>>     touch file
>>     git add file
>>     git commit -m "initial"
>>     mkdir dir
>>     touch dir/file1
>> 1. emacs -Q
>> 2. C-x v d
>>     "dir/" is listed with "unregistered" status.
>> 3. v
>>     "dir/" has "added" status.
>> 4. g
>>     "dir/file1" is listed with "up-to-date" status.  Shouldn't it have
>>     "added" status?
>> 5. g
>>     Now "dir/file1" properly has "added" status.
>> Also:
>> - After step 3 point is moved to word "dir" on second line.
>> - Press "n" before step 3 to move point to "dir/". After step 3 "dir/"
>>    status is not updated and remains "unregistered".
>
> Thanks for the repro. This problem seems to have been with us for a while.
>
> vc-git's dir-status-files code is a bit hard to follow, but here's a
> patch you can try. I'll commit it in the next few days if nothing
> comes up.

Thanks, file status is "added" after step 4 now.

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?





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

* bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory
  2019-12-16  8:00   ` Andrii Kolomoiets
@ 2019-12-16 13:23     ` Dmitry Gutov
  2019-12-16 19:43       ` Andrii Kolomoiets
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2019-12-16 13:23 UTC (permalink / raw)
  To: Andrii Kolomoiets; +Cc: 38615

On 16.12.2019 10:00, Andrii Kolomoiets wrote:

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

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.





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

* bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory
  2019-12-16 13:23     ` Dmitry Gutov
@ 2019-12-16 19:43       ` Andrii Kolomoiets
  2019-12-16 23:53         ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Andrii Kolomoiets @ 2019-12-16 19:43 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 38615

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

Dmitry Gutov <dgutov@yandex.ru> 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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vc-git-ls-files-in-untracked-dir.diff --]
[-- Type: text/x-patch, Size: 667 bytes --]

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"

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

* bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory
  2019-12-16 19:43       ` Andrii Kolomoiets
@ 2019-12-16 23:53         ` Dmitry Gutov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2019-12-16 23:53 UTC (permalink / raw)
  To: Andrii Kolomoiets; +Cc: 38615-done

On 16.12.2019 21:43, Andrii Kolomoiets wrote:

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

Thanks.

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

Okay, let's try this, thank you.

I believe the original idea was to avoid overwhelming the user when 
there are a lot of unregistered files (build artefacts and the like), 
but that's what gitignore is for.

Both patches are pushed, closing.





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

end of thread, other threads:[~2019-12-16 23:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-14 12:41 bug#38615: 27.0.50; vc-git: Wrong status in vc-dir after registering directory Andrii Kolomoiets
2019-12-16  1:25 ` Dmitry Gutov
2019-12-16  8:00   ` Andrii Kolomoiets
2019-12-16 13:23     ` Dmitry Gutov
2019-12-16 19:43       ` Andrii Kolomoiets
2019-12-16 23:53         ` Dmitry Gutov

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