GNU bug report logs - #21166
24.4; vc-mode and git error on newly added file to new repository

Previous Next

Package: emacs;

Reported by: Ed Avis <eda <at> waniasset.com>

Date: Fri, 31 Jul 2015 14:44:02 UTC

Severity: minor

Tags: confirmed

Found in versions 24.5, 24.4

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21166 in the body.
You can then email your comments to 21166 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#21166; Package emacs. (Fri, 31 Jul 2015 14:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ed Avis <eda <at> waniasset.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 31 Jul 2015 14:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ed Avis <eda <at> waniasset.com>
To: "'bug-gnu-emacs <at> gnu.org'" <bug-gnu-emacs <at> gnu.org>
Subject: 24.4; vc-mode and git error on newly added file to new repository
Date: Fri, 31 Jul 2015 14:43:29 +0000
At the shell make an empty git working tree and add one file to it,
but without committing, then edit it in Emacs:

% mkdir test
% cd test
% git init
Initialized empty Git repository in /home/eda/test/.git/
% echo >a
% git add a
% emacs -Q a

Type some text in the buffer, save with C-x C-s, then ask for a diff
with C-x v =.  This fails with the following text at the bottom of the screen:

-UU-:----F1  a              All L1    Git <at> master  (Fundamental) ---
fatal: bad revision 'HEAD'

-UUU:**--F1  *vc-diff*      All L1     (Fundamental from a) ----
Running git --no-pager diff-index --exit-code -p HEAD  -- a...FAILED (status 128)


In GNU Emacs 24.4.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9)
 of 2014-11-03 on wcl-linux04.wcl.local
Configured using:
 `configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
 --with-gpm=no build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
 -fstack-protector-strong --param=ssp-buffer-size=4
 -grecord-gcc-switches -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ''

Important settings:
  value of $LC_COLLATE: C
  value of $LC_CTYPE: en_GB.UTF-8
  value of $LC_MESSAGES: en_GB.UTF-8
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
p C-a ESC f DEL DEL DEL DEL c a t DEL DEL DEL e c h 
o SPC ' # ! / b i n / s h ' RET e c h o SPC C-a C-k 
r DEL l n SPC - s SPC / b i TAB f a TAB l TAB C-a C-k 
r m SPC . g i TAB h o TAB p r e TAB - c TAB RET l n 
SPC - s SPC / h DEL b i TAB f a TAB l TAB s e SPC . 
g i TAB h o TAB p r e - c o TAB DEL DEL DEL DEL DEL 
DEL DEL DEL RET e c h o SPC > a RET g t DEL i t SPC 
a d d SPC a RET C-x C-f a RET h e l l o RET C-x C-s 
C-x v = q C-g C-g ESC x s h e l l RET ESC > g i t SPC 
s t a t u s RET C-x 1 c d SPC . . RET r m SPC - r f 
SPC t e s t RET c d SPC t e s t C-a C-k m k d i r SPC 
t e s t RET c d SPC t e s t RET g i t SPC i n i t RET 
e c j h SPC DEL DEL DEL h SPC o > DEL DEL DEL o SPC 
> a RET g i t SPC a d d SPC a RET C-x C-f a RET y e 
s RET a C-x C-s C-x v = C-x b RET C-x 1 C-x b a RET 
ESC x r e p o r t SPC e SPC b RET

Recent messages:
Finding changes in /home/eda/test/a...
vc-do-command: Running git --no-pager diff-index --exit-code -p HEAD  -- a...FAILED (status 128)
call-interactively: Buffer is read-only: #<buffer *vc-diff*>
Quit [2 times]
Mark set
~ 
~/test 
Saving file /home/eda/test/a...
Wrote /home/eda/test/a
Finding changes in /home/eda/test/a...
vc-do-command: Running git --no-pager diff-index --exit-code -p HEAD  -- a...FAILED (status 128)

Load-path shadows:
None found.

Features:
(shadow sort emacsbug sendmail apropos vc-bzr vc-sccs vc-svn vc-cvs
vc-rcs rect macros debug network-stream starttls tls mail-extr etags
sh-script smie executable smerge-mode edmacro kmacro sql view mule-util
python json dired tabify imenu man help-mode log-view diff-mode vc
vc-dispatcher cus-edit wid-edit cus-start cus-load perl-mode dabbrev
nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc
rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok ffap
thingatpt url-parse auth-source eieio eieio-core gnus-util
password-cache url-vars misearch multi-isearch vc-git pcmpl-unix xterm
time-date log-edit easy-mmode message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log server csharp-mode advice help-fns byte-opt bytecomp
byte-compile cconv cc-langs cc-mode cc-fonts easymenu cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs zoom-frm frame-cmds
frame-fns cl-macs avoid cl gv cl-loaddefs cl-lib compile shell pcomplete
comint ring ansi-color tooltip electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 2123160 189079)
 (symbols 48 30370 0)
 (miscs 40 1280 7066)
 (strings 32 74802 19252)
 (string-bytes 1 3893095)
 (vectors 16 42168)
 (vector-slots 8 1773808 319851)
 (floats 8 1683 1258)
 (intervals 56 365598 3016)
 (buffers 960 190)
 (heap 1024 107029 5604))

Please ignore autogenerated disclaimer below this point.


This email is intended only for the person to whom it is addressed and may contain confidential information. Any retransmission, copying, disclosure or other use of, this information by persons other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the material. This email is for information only and is not intended as an offer or solicitation for the purchase or sale of any financial instrument. Wadhwani Asset Management LLP is a Limited Liability Partnership registered in England (OC303168) with registered office at 40 Berkeley Square, 3rd Floor, London, W1J 5AL. It is authorised and regulated by the Financial Conduct Authority.




bug Marked as found in versions 24.5. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 31 Jul 2015 15:28:02 GMT) Full text and rfc822 format available.

Severity set to 'minor' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 31 Jul 2015 15:28:02 GMT) Full text and rfc822 format available.

Added tag(s) confirmed. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 31 Jul 2015 15:28:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21166; Package emacs. (Fri, 31 Jul 2015 17:26:01 GMT) Full text and rfc822 format available.

Message #14 received at 21166 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Ed Avis <eda <at> waniasset.com>, 21166 <at> debbugs.gnu.org
Subject: Re: bug#21166: 24.4; vc-mode and git error on newly added file to new
 repository
Date: Fri, 31 Jul 2015 20:25:33 +0300
On 07/31/2015 05:43 PM, Ed Avis wrote:

> Type some text in the buffer, save with C-x C-s, then ask for a diff
> with C-x v =.  This fails with the following text at the bottom of the screen:
>
> -UU-:----F1  a              All L1    Git <at> master  (Fundamental) ---
> fatal: bad revision 'HEAD'

Indeed, I can reproduce this.

But it's a relatively rare situation (no commits in the repo yet), and 
the git diff output will be less useful than usual, since it's a given 
that all your files are either added or simply unregistered.

To fix this, it seems we'll have to add an extra process call to 
determine whether HEAD is a valid reference (Git internals apparently do 
that). I'm not sure it's worth it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21166; Package emacs. (Fri, 31 Jul 2015 17:28:01 GMT) Full text and rfc822 format available.

Message #17 received at 21166 <at> debbugs.gnu.org (full text, mbox):

From: Ed Avis <eda <at> waniasset.com>
To: "'dgutov <at> yandex.ru'" <dgutov <at> yandex.ru>, "'21166 <at> debbugs.gnu.org'"
 <21166 <at> debbugs.gnu.org>
Subject: Re: bug#21166: 24.4; vc-mode and git error on newly added file to
 new repository
Date: Fri, 31 Jul 2015 17:27:10 +0000
I guess you don't have to add an extra process call but just check for this error message, and if so, show the diff as from an empty tree. 

This email is intended only for the person to whom it is addressed and may contain confidential information. Any retransmission, copying, disclosure or other use of, this information by persons other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the material. This email is for information only and is not intended as an offer or solicitation for the purchase or sale of any financial instrument. Wadhwani Asset Management LLP is a Limited Liability Partnership registered in England (OC303168) with registered office at 40 Berkeley Square, 3rd Floor, London, W1J 5AL. It is authorised and regulated by the Financial Conduct Authority.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21166; Package emacs. (Fri, 31 Jul 2015 17:45:01 GMT) Full text and rfc822 format available.

Message #20 received at 21166 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Ed Avis <eda <at> waniasset.com>, 21166 <at> debbugs.gnu.org
Subject: Re: bug#21166: 24.4; vc-mode and git error on newly added file to new
 repository
Date: Fri, 31 Jul 2015 20:44:16 +0300
On 07/31/2015 08:27 PM, Ed Avis wrote:
> I guess you don't have to add an extra process call but just check for this error message, and if so, show the diff as from an empty tree.

That's a good point, but doing an extra process call depending on the 
result of the first is also non-trivial here, because the first call is 
often asynchronous, and we handle those in a not particularly composable 
way.

For instance, this patch doesn't work reliably:

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 9522328..b556de1 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1032,13 +1032,18 @@ or BRANCH^ (where \"^\" can be repeated)."
                command
                "--exit-code"
                (append (vc-switches 'git 'diff)
-                       (list "-p" (or rev1 "HEAD") rev2 "--")))
+                       (list "-p" rev1 rev2 "--")))
       (vc-git-command (or buffer "*vc-diff*") 1 files
                       "difftool" "--exit-code" "--no-prompt" "-x"
                       (concat "diff "
                               (mapconcat 'identity
                                          (vc-switches nil 'diff) " "))
-                      rev1 rev2 "--"))))
+                      rev1 rev2 "--"))
+    (vc-run-delayed
+      (when (looking-at "fatal: bad revision 'HEAD'")
+        (let ((inhibit-read-only t))
+          (erase-buffer)
+          (vc-git-diff files "4b825dc642cb6eb9a060e54bf8d69288fbee4904" 
rev2 buffer async))))))

 (defun vc-git-revision-table (_files)
   ;; What about `files'?!?  --Stef





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21166; Package emacs. (Tue, 04 Aug 2015 14:59:02 GMT) Full text and rfc822 format available.

Message #23 received at 21166 <at> debbugs.gnu.org (full text, mbox):

From: Ed Avis <eda <at> waniasset.com>
To: 'Dmitry Gutov' <dgutov <at> yandex.ru>, "21166 <at> debbugs.gnu.org"
 <21166 <at> debbugs.gnu.org>
Subject: RE: bug#21166: 24.4; vc-mode and git error on newly added file to
 new repository
Date: Tue, 4 Aug 2015 14:58:10 +0000
How about this: check for the error message, and if found then just print 'empty tree, so no diff to print'.
That would be good enough.  No need for an extra process call either before or after.

-- 
Ed Avis <eda <at> waniasset.com>

This email is intended only for the person to whom it is addressed and may contain confidential information. Any retransmission, copying, disclosure or other use of, this information by persons other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the material. This email is for information only and is not intended as an offer or solicitation for the purchase or sale of any financial instrument. Wadhwani Asset Management LLP is a Limited Liability Partnership registered in England (OC303168) with registered office at 40 Berkeley Square, 3rd Floor, London, W1J 5AL. It is authorised and regulated by the Financial Conduct Authority.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21166; Package emacs. (Tue, 25 Aug 2020 09:05:01 GMT) Full text and rfc822 format available.

Message #26 received at 21166 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ed Avis <eda <at> waniasset.com>
Cc: "21166 <at> debbugs.gnu.org" <21166 <at> debbugs.gnu.org>,
 'Dmitry Gutov' <dgutov <at> yandex.ru>
Subject: Re: bug#21166: 24.4; vc-mode and git error on newly added file to
 new repository
Date: Tue, 25 Aug 2020 11:04:07 +0200
Ed Avis <eda <at> waniasset.com> writes:

> How about this: check for the error message, and if found then just
> print 'empty tree, so no diff to print'.
> That would be good enough.  No need for an extra process call either
> before or after.

This was five years ago.  I tried this in Emacs 28, and the problem is
still present.

As Dmitry says, this is a quite unusual situation, so perhaps the
current error message

fatal: bad revision 'HEAD'

is fine?  It's slightly confusing...  but not very.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#21166; Package emacs. (Sun, 11 Oct 2020 03:08:01 GMT) Full text and rfc822 format available.

Message #29 received at 21166 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ed Avis <eda <at> waniasset.com>
Cc: 'Dmitry Gutov' <dgutov <at> yandex.ru>,
 "21166 <at> debbugs.gnu.org" <21166 <at> debbugs.gnu.org>
Subject: Re: bug#21166: 24.4; vc-mode and git error on newly added file to
 new repository
Date: Sun, 11 Oct 2020 05:07:47 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> This was five years ago.  I tried this in Emacs 28, and the problem is
> still present.
>
> As Dmitry says, this is a quite unusual situation, so perhaps the
> current error message
>
> fatal: bad revision 'HEAD'
>
> is fine?  It's slightly confusing...  but not very.

No further comments in six weeks, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 21166 <at> debbugs.gnu.org and Ed Avis <eda <at> waniasset.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 11 Oct 2020 03:09:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 08 Nov 2020 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 168 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.