@@ -1478,18 +1478,33 @@ end
14781478function GitAdapter :rev_to_args (left , right )
14791479 assert (
14801480 not (left .type == RevType .LOCAL and right .type == RevType .LOCAL ),
1481- " Can't diff LOCAL against LOCAL!"
1481+ " InvalidArgument :: Can't diff LOCAL against LOCAL!"
14821482 )
14831483
14841484 if left .type == RevType .COMMIT and right .type == RevType .COMMIT then
14851485 return { left .commit .. " .." .. right .commit }
1486- elseif left .type == RevType .STAGE and right .type == RevType .LOCAL then
1487- return {}
1486+
14881487 elseif left .type == RevType .COMMIT and right .type == RevType .STAGE then
14891488 return { " --cached" , left .commit }
1490- else
1491- return { left .commit }
1489+
1490+ elseif right .type == RevType .LOCAL then
1491+ if left .type == RevType .STAGE then
1492+ return {}
1493+ elseif left .type == RevType .COMMIT then
1494+ return { left .commit }
1495+ end
1496+
1497+ elseif left .type == RevType .LOCAL then
1498+ -- WARN: these require special handling when creating the diff file list.
1499+ -- I.e. the stats for 'additions' and 'deletions' need to be swapped.
1500+ if right .type == RevType .STAGE then
1501+ return { " --cached" }
1502+ elseif right .type == RevType .COMMIT then
1503+ return { right .commit }
1504+ end
14921505 end
1506+
1507+ error (fmt (" InvalidArgument :: Unsupported rev range: '%s..%s'!" , left , right ))
14931508end
14941509
14951510
@@ -1790,7 +1805,7 @@ GitAdapter.tracked_files = async.wrap(function(self, left, right, args, kind, op
17901805 end
17911806
17921807 for _ , v in ipairs (data ) do
1793- table.insert ( files , FileEntry .with_layout (opt .default_layout , {
1808+ local file = FileEntry .with_layout (opt .default_layout , {
17941809 adapter = self ,
17951810 path = v .name ,
17961811 oldpath = v .oldname ,
@@ -1801,7 +1816,17 @@ GitAdapter.tracked_files = async.wrap(function(self, left, right, args, kind, op
18011816 a = left ,
18021817 b = right ,
18031818 }
1804- }))
1819+ })
1820+
1821+ if left and left .type == RevType .LOCAL then
1822+ -- Special handling is required here. The rev range `LOCAL..{REV}` can't be
1823+ -- expressed in Git's rev syntax, but logically it should be the same as
1824+ -- just `{REV}`, but with the diff stats swapped (as we want the diff from
1825+ -- the perspective of LOCAL).
1826+ file .stats .additions , file .stats .deletions = file .stats .deletions , file .stats .additions
1827+ end
1828+
1829+ table.insert (files , file )
18051830 end
18061831
18071832 callback (nil , files , conflicts )
0 commit comments