Commits

ZyX_I  committed b4f47d0

@aurum/drivers/git: Fixed rf-status() with non-0 arguments
test: Initial git tests implementation

  • Participants
  • Parent commits ff2710b

Comments (0)

Files changed (8)

File doc/aurum.txt

        with "default/" part removed.
     2. Svn revisions are not supported at all, |aurum-cs.hex| in driver is 
        replaced with static string "HEAD".
-|aurum-rf-status|:
-    For non-python driver this function does not support names containing 
-    newlines.
-|aurum-rf-grep|
-    For non-python driver filenames that look like {smth}:{num>=0}:{num>0} are 
-    not supported and will lead to invalid results.
+|aurum-rf-status|: For non-python driver this function does not support names 
+    containing newlines.
+|aurum-rf-grep|: For non-python driver filenames that look like 
+    {smth}:{num>=0}:{num>0} are not supported and will lead to invalid 
+    results.
 Python driver was not tested under windows (wine) at all.
 
 Git:
 |aurum-rf-label|: Supported labels: tag, branch (both non-local).
 
 |aurum-cs.branch| always contains string "default".
-|aurum-cs.tags|:
-    Contains list of all references pointing to given commit, not just tags.
+|aurum-cs.tags| contains list of all references pointing to given commit, not 
+    just tags.
 |aurum-cs.rev| contains truncated hash (for use in |aurum://annotate|).
 |aurum-repo.cslist| is always empty
-|aurum-rf-status|:
-    If two first optional arguments are given and are non-zero, then unknown 
-    and deleted files won’t be shown (if any).
+|aurum-rf-status|: If two first optional arguments are given and are non-zero, 
+    then unknown and deleted files won’t be shown (if any).
 |aurum-rf-gettiphex|: Same as |aurum-rf-getworkhex|.
-|aurum-rf-diff|: Options "git", "iblanks", "showfunc" are not supported.
+|aurum-rf-diff|: Options "git", "iblanks", "showfunc", "dates" are not 
+    supported.
 |aurum-rf-checkdir| does not support bare repositories.
-|aurum-rf-setcsprop|:
-    Is not able to get real renames, copies, changes, files and removes for 
-    merge changesets (“real” here means “generated by merge conflicts”: if 
-    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-setcsprop|: is not able to get real renames, copies, changes, files 
+    and removes for merge changesets (“real” here means “generated by merge 
+    conflicts”: if 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 not modifying |aurum-repo.cslist|.
-|aurum-rf-grep|
-    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.
+|aurum-rf-grep| 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.
     Note: This function always uses extended regular expressions.
-|aurum-rf-annotate|
-    Won’t output annotation of file in working directory, it is always 
-    returning annotation of file at given revision.
+|aurum-rf-annotate| won’t output annotation of file in working directory, it 
+    is always returning annotation of file at given revision.
 
 ==============================================================================
 11. Changelog                                                *aurum-changelog*

File plugin/aurum/drivers/git.vim

 let s:statchars={
             \'A': 'added',
             \'M': 'modified',
-            \'R': 'removed',
+            \'D': 'removed',
         \}
 let s:initstatdct={
             \'modified': [],
 function s:git.status(repo, ...)
     let r=deepcopy(s:initstatdct)
     if a:0 && (a:1 isnot 0 || (a:0>1 && a:2 isnot 0))
-        " FIXME This is not going to show status for unknown files. Document it.
         let args=((a:0>2 && !empty(a:3))?(['--']+a:3):([]))
         let rspec=[]
+        let reverse=0
         if a:1 is 0
             if a:0>1 && a:2 isnot 0
                 let reverse=1
             let rspec+=[a:2]
         endif
         call insert(args, join(rspec, '..'))
-        let kwargs={'diff-filter': 'ADM', 'name-status': 1, 'no-renames': 1}
+        let kwargs={'diff-filter': 'AMD', 'name-status': 1, 'no-renames': 1}
         let d=s:F.git(a:repo, 'diff', args, kwargs, 0, 'sdifff')[:-2]
-        let files=map(copy(d), 's:F.refile[v:val[2:]]')
+        let files=map(copy(d), 's:F.refile(v:val[2:])')
         call map(copy(d), 'add(r[s:statchars[v:val[0]]], files[v:key])')
         if reverse
             let [r.deleted, r.unknown]=[r.unknown, r.deleted]

File test/creategitrepo.zsh

+#!/bin/zsh
+local -x TZ=UTC
+local -x LANG=ru_RU.UTF-8
+(
+    test -d gittestrepo && rm -rf gittestrepo
+    git init gittestrepo
+    cd gittestrepo
+    mkdir subdir
+    echo 'This is a file with newlines in filename' > $'\nstrange\nfilename\n'
+    echo 'This is a file with “ -> ” in filename' > $'abc -> def'
+    echo 'This is a file with a colon in filename' > $'HEAD:abc:10:def'
+    echo 'This is a file with backslash in filename' > $'subdir/\\abc\\def\\'
+    echo 'This is a file with name starting with dashes' > $'--force'
+    echo 'This is a file with asterisk in filename' > '*'
+    git add -- **/*
+    git commit -m $'Added files with strange filenames:\n - filename with newline\n - filename containing “->”\n - filename with a colon\n - filename with "\\\\"\n - filename that looks like a command-line option\n - filename that looks like a glob' \
+        --author 'Bob <bob@example.com>' --date '1990-01-01 12:00:00'
+    git mv -- $'HEAD:abc:10:def' $'abc:10:def'
+    git commit -m 'Moved HEAD:abc:10:def to abc:10:def' \
+        --author 'Bob <bob@example.com>' --date '1990-01-01 12:01:00'
+    git checkout HEAD^
+    git checkout -b next
+    git mv -- $'abc -> def' $'ghi -> jkl'
+    git commit -m 'Moved “abc -> def” to “ghi -> jkl”' \
+        --author 'Alice <alice@example.org>' --date '1990-01-01 13:01:25'
+    git merge --no-commit master
+    git commit -m 'Merge of branch master' \
+        --author 'C <c@example.net>' --date '1990-01-01 13:04:47'
+    git checkout master
+    git merge --no-commit next^
+    git commit -m 'Merge of branch next (next^)' \
+        --author 'C <c@example.net>' --date '1990-01-01 13:05:08'
+    git checkout next^^
+    git checkout -b next2
+    cp -- $'abc -> def' $'mno -> pqr'
+    git add $'mno -> pqr'
+    git commit -m 'Copied “abc -> def” to “mno -> pqr”' \
+        --author 'Bob <bob@example.org>' --date '1990-01-01 12:21:25'
+    git mv $'mno -> pqr' $'\\*'
+    git commit -m 'Moved “mno -> pqr” to “\*”' \
+        --author 'E <e@example.na>' --date '1990-01-01 12:24:24'
+    git tag erevision
+    git merge --no-commit next master
+    git commit -m 'Merge of branch next and master' \
+        --author 'C <c@example.net>' --date '1990-01-01 13:38:44'
+    cd ..
+    tar -cJvf gittestrepo.tar.xz gittestrepo
+)

File test/gentests-setuptestrepos.zsh

 emulate -L zsh
 tar xJf testrepo.tar.xz
 
+tar xJf gittestrepo.tar.xz
+tar xJf gitteststatusrepo.tar.xz
+
 for test in annotate-buffers commit record stat statmaps vimdiff diff update \
             prevmessage vimdiff-usewin vimdiff-full
 do
 done
 hg clone testrepo testrepo-cloned
 for test in *.in ; do
+    [[ $test == git.in ]] && continue
     test=$test:r
     [[ -d ${test}repo ]] && continue
     mkdir ${test}repo
+:W{{{1 Log: nomerges
+:Run! AuLog ./gittestrepo/ nomerges
+:bwipeout!
+:W{{{1 Log: files
+:Run! AuLog ./gittestrepo/ showfiles
+:bwipeout!
+:W{{{1 Log: everything
+:Run! AuLog ./gittestrepo/ stat patch showfiles showrenames showcopies
+:bwipeout!
+:W{{{1 Status: current
+:Run! AuStatus ./gitteststatusrepo/
+:bwipeout!
+:W{{{1 Status: relative to other (1)
+:Run! AuStatus ./gitteststatusrepo/ rev1 HEAD^
+:bwipeout!
+:W{{{1 Status: relative to other (2)
+:Run! AuStatus ./gitteststatusrepo/ rev2 HEAD^
+:bwipeout!
+:W{{{1 Status: between two revisions
+:Run! AuStatus ./gittestrepo/ rev1 erevision rev2 next
+:bwipeout!

File test/git.ok

Binary file added.

File test/gittestrepo.tar.xz

Binary file added.

File test/gitteststatusrepo.tar.xz

Binary file added.