diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 17c1067e9..186fad525 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -254,8 +254,8 @@ class Git(Base): commits.append(str(a_commit)) commits.append(str(b_commit)) else: - a_commit = self.git.head.commit - b_commit = self.git.commit(a_ref) + a_commit = self.git.commit(a_ref) + b_commit = self.git.head.commit commits.append(str(a_commit)) commits.append(str(b_commit)) trees[DIFF_A_TREE] = self.get_tree(commits[0]) diff --git a/tests/test_diff.py b/tests/test_diff.py index b9c6d5975..37e2af358 100644 --- a/tests/test_diff.py +++ b/tests/test_diff.py @@ -27,22 +27,22 @@ class TestDiff(TestDvc): def test(self): out = self.dvc.scm.get_diff_trees(self.a_ref) self.assertFalse(out[git.DIFF_EQUAL]) - self.assertEqual(str(self.a_ref), out[git.DIFF_B_REF]) - self.assertEqual(str(self.git.head.commit), out[git.DIFF_A_REF]) + self.assertEqual(str(self.a_ref), out[git.DIFF_A_REF]) + self.assertEqual(str(self.git.head.commit), out[git.DIFF_B_REF]) class TestDiffRepo(TestDiff): def test(self): result = self.dvc.diff(self.new_file, a_ref=self.a_ref) test_dct = { - git.DIFF_B_REF: str(self.a_ref), - git.DIFF_A_REF: str(self.git.head.commit), + git.DIFF_A_REF: str(self.a_ref), + git.DIFF_B_REF: str(self.git.head.commit), git.DIFF_LIST: [ { git.DIFF_TARGET: self.new_file, - git.DIFF_OLD_FILE: self.new_file, - git.DIFF_OLD_CHECKSUM: "c81fec3d710806070bcd67f182d1279c", - git.DIFF_SIZE: -13, + git.DIFF_NEW_FILE: self.new_file, + git.DIFF_NEW_CHECKSUM: "c81fec3d710806070bcd67f182d1279c", + git.DIFF_SIZE: 13, } ], } @@ -76,34 +76,34 @@ class TestDiffDir(TestDvc): def test(self): out = self.dvc.scm.get_diff_trees(self.a_ref) self.assertFalse(out[git.DIFF_EQUAL]) - self.assertEqual(str(self.a_ref), out[git.DIFF_B_REF]) - self.assertEqual(str(self.git.head.commit), out[git.DIFF_A_REF]) + self.assertEqual(str(self.a_ref), out[git.DIFF_A_REF]) + self.assertEqual(str(self.git.head.commit), out[git.DIFF_B_REF]) class TestDiffDirRepo(TestDiffDir): def test(self): result = self.dvc.diff(self.DATA_DIR, a_ref=self.a_ref) test_dct = { - git.DIFF_B_REF: str(self.a_ref), - git.DIFF_A_REF: str(self.git.head.commit), + git.DIFF_A_REF: str(self.a_ref), + git.DIFF_B_REF: str(self.git.head.commit), git.DIFF_LIST: [ { git.DIFF_CHANGE: 0, - git.DIFF_DEL: 1, + git.DIFF_DEL: 0, git.DIFF_IDENT: 2, git.DIFF_MOVE: 0, - git.DIFF_NEW: 0, + git.DIFF_NEW: 1, git.DIFF_IS_DIR: True, git.DIFF_TARGET: self.DATA_DIR, - git.DIFF_OLD_FILE: self.DATA_DIR, - git.DIFF_OLD_CHECKSUM: ( - "d5782f3072167ad3a53ee80b92b30718.dir" - ), git.DIFF_NEW_FILE: self.DATA_DIR, git.DIFF_NEW_CHECKSUM: ( + "d5782f3072167ad3a53ee80b92b30718.dir" + ), + git.DIFF_OLD_FILE: self.DATA_DIR, + git.DIFF_OLD_CHECKSUM: ( "bff5a787d16460f32e9f2e62b183b1cc.dir" ), - git.DIFF_SIZE: -30, + git.DIFF_SIZE: 30, } ], }