Subject: bug#2678: 23.0.91; vc-next-action in vc-dir acts strangely when only adds are necessary

From: Dan Nicolaescu <[email-masked]>
Date: Fri, 20 Mar 2009 09:15:07 -0700 (PDT)

Miles Bader <[email-masked]> writes:

  > [Note: I have Dan's patch for fixing whole-directory vc-dir commit in
  > Git applied, though I don't think it should affect the following, as it
  > relates to final commit.]
  > 
  > If I have a vc-dir buffer showing a tree where the only entries are new
  > files (not yet registered with source-control):
  > 
  >    VC backend : Git
  >    Working dir: /tmp/zonk/
  >    Branch     : master
  > 
  >                             ./
  >         unregistered        llll
  >         unregistered        oiuoiu
  > 
  > Then hitting "v" on the first line of the buffer acts strangely -- I'd
  > expect it to simply register all these files with source control, but in
  > fact, it simply appears to do nothing.
  > 
  > There are actually several behaviors (though it always does nothing in
  > the end).  If this is the first time I've tried to do this, it just
  > displays a message like "Registering (/tmp/zonk/)... done" [where
  > "/tmp/zonk2" is the root of the working directory in question] but
  > doesn't seem to really do it.
  > 
  > If I then try the "v" command again, it will first show the message:
  > 
  >    Previous master file has vanished.  Make a new one? (y or n) 
  > 
  > If I enter "n" it just gives an error and aborts.
  > 
  > If I type "y", then it will either display a "Registering
  > (/tmp/zonk/)... done" message like the initial time (and again have no
  > real result), or show a *vc-log* buffer to prompt for an "initial
  > comment"; in the latter case, when I then hit C-c C-c to continue, the
  > *vc-log* buffer goes away -- but nothing further appears to happen.
  > [I'm not sure what causes it to open a *vc-log* buffer or not ... in my
  > initial tests it did, but when I tried again with emacs -Q, it didn't.]
  > 
  > Anyway, the end result is always the same, no registered files.
  > 
  > 
  > To reproduce:
  > 
  >   (1) Execute the following shell script to create a test repo in
  >       "/tmp/zonk2":
  > 
  > #!/bin/sh
  > cd /tmp
  > rm -rf zonk2
  > mkdir zonk2
  > cd zonk2
  > git init
  > echo plugh > ppling
  > git add .
  > git commit -m'Init' -a
  > echo Fnord >> newf1
  > echo Chnevy >> newf2

Given that you are familiar with git, the function to fix to get this
working is the one liner `vc-git-register':

(defun vc-git-register (files &optional rev comment)
  "Register FILE into the git version-control system."
  (vc-git-command nil 0 files "update-index" "--add" "--"))

just add the correct command(s) to run to vc-git-command, and it should
work.

In case above vc-git-register is called like this:

(vc-git-register "/tmp/zonk2/")