ZyX_I committed 1a061d5

@aurum/drivers/git: Made rf-grep() support filenames with newlines

  • Participants
  • Parent commits e893997

Comments (0)

Files changed (3)

File doc/aurum.txt

     file A was modified in both parents, then it is to be listed in 
     merge_cs.changes only if git was unable to merge changes and had to ask 
     user to do this).
-|aurum-rf-getchangesets| is always returning empty list.
+|aurum-rf-getchangesets| is not modifying |aurum-repo.cslist|.
     Will either search working directory (if no revisions were given) or given 
     revisions (mercurial driver is searching all revisions if no revisions are 
     given). Unlike mercurial where matching line will be shown only if they 
     were found in first revision in range or in line that was added/modified 
     in given revision, with this function you will see all matches in all 
-    revisions (really it is calling “git grep” multiple times).
+    revisions.
+    Note: This function always uses extended regular expressions.
     Won’t output annotation of file in working directory, it is always 
     returning annotation of file at given revision.

File plugin/aurum/drivers/git.vim

                 \   'lbf', a:type, a:label, a:rev)
 "▶1 git.grep :: repo, files, revisions, ignorecase, wdfiles::Bool → qflist
+"▶2 parsegrep :: lines → [(file, lnum, String)]
 function s:F.parsegrep(lines)
-    return map(a:lines, 'split(v:val, "\n", 1)')
+    let r=[]
+    let contline=0
+    while !empty(a:lines)
+        let sp=split(remove(a:lines, 0), "\n", 1)
+        if contline
+            let r[-1][0].="\n".sp[0]
+            if len(sp)>1
+                let r[-1]+=sp[1:]
+                let contline=0
+            endif
+        elseif len(sp)==1
+            let contline=1
+            let r+=[sp]
+        else
+            let r+=[sp]
+        endif
+    endwhile
+    call map(r, '[v:val[0], str2nr(v:val[1]), v:val[2]]')
+    return r
 function s:git.grep(repo, pattern, files, revisions, ic, wdfiles)
     let args=['-e', a:pattern, '--']+a:files
     let kwargs={'full-name': 1, 'extended-regexp': 1, 'n': 1, 'z': 1}

File python/

     except AurumError:
 def grep(path, pattern, files, revisions=None, ignore_case=False, wdfiles=True):
         if not revisions:
         kwargs={'rev': revisions, 'ignore_case': bool(ignore_case),
-                'line_number': True, 'follow': True}
+                'line_number': True, 'follow': True, 'print0': True}
         run_in_dir(repo.root, commands.grep, *args, **kwargs)