← Back to team overview

ubuntu-elisp team mailing list archive

[Bug 1315551] [NEW] vc-git.el vc-git-grep does not work with git 1.9 in trusty

 

Public bug reported:

For emacs to properly parse the result of git grep it must not be fed
through a pager (like less) and it must not include colourization escape
codes.

If a pager is spawned, it might blow up with this:

git grep -n -e ClkIB -- *
WARNING: terminal is not fully functional
-  (press RETURN)

If colourization is turned on then the output from git no longer matches
the grep filename regex. For instance grepping for 'COPYRIGHT' gives
colourized lines like this:

Makefile.[36m:.[m2.[36m:.[m# .[1;31mCOPYRIGHT.[m (c) 2011-2012 O

(where [ is the ESC). Git has colour'd the : characters as well as the
matching string. The standard emacs grep regex is not prepared to handle
the escape characters.

Within vc-git.el/vc-git-grep, setting the environment PAGER="" used to
be enough:

      (when command
        (let ((default-directory dir)
              (compilation-environment '("PAGER=")))
          ;; Setting process-setup-function makes exit-message-function work
          ;; even when async processes aren't supported.
          (compilation-start command 'grep-mode))

But for whatever reason with git 1.9 this still spawns a pager.

Updating to GIT_PAGER="" does not spawn a pager, but still colourizes
the output.

The only fix I can find would be to replace:

              (grep-expand-template "git grep -n -e <R> -- <F>" regexp
files))

with:

              (grep-expand-template "git --no-pager grep --no-color -n
-e <R> -- <F>" regexp files))

This restores the behaviour older git's had with PAGER="" and allows
emacs to properly parse the result.

However, I would expect that it won't be compatible with older gits.

Since Ubuntu does not ship older gits it seems reasonable to patch vc-
git.el and let upstream figure out how to make this generic.

emacs23-el:
  Installed: 23.4+1-4.1ubuntu1
  Candidate: 23.4+1-4.1ubuntu1
  Version table:
 *** 23.4+1-4.1ubuntu1 0

** Affects: emacs23 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Emacs Lisp, which is subscribed to emacs23 in Ubuntu.
https://bugs.launchpad.net/bugs/1315551

Title:
  vc-git.el vc-git-grep does not work with git 1.9 in trusty

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/emacs23/+bug/1315551/+subscriptions


Follow ups

References