You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* From Git documentation (https://git-scm.com/docs/git-diff):
22
+
* Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes between two blob objects, or changes between two files on disk.
23
+
* git diff [--options] [--] [<path>…]
24
+
* This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell Git to further add to the index but you still haven’t. You can stage these changes by using git-add[1].
25
+
*
26
+
* git diff --no-index [--options] [--] [<path>…]
27
+
* This form is to compare the given two paths on the filesystem. You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git.
* This form is to view the changes you staged for the next commit relative to the named <commit>. Typically you would want comparison with the latest commit, so if you do not give <commit>, it defaults to HEAD. If HEAD does not exist (e.g. unborn branches) and <commit> is not given, it shows all staged changes. --staged is a synonym of --cached.
30
+
*
31
+
* git diff [--options] <commit> [--] [<path>…]
32
+
* This form is to view the changes you have in your working tree relative to the named <commit>. You can use HEAD to compare it with the latest commit, or a branch name to compare with the tip of a different branch.
* This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B". You can omit any one of <commit>, which has the same effect as using HEAD instead.
42
+
*
43
+
* Just in case if you are doing something exotic, it should be noted that all of the <commit> in the above description, except in the last two forms that use ".." notations, can be any <tree>.
44
+
*
45
+
* For a more complete list of ways to spell <commit>, see "SPECIFYING REVISIONS" section in gitrevisions[7]. However, "diff" is about comparing two endpoints, not ranges, and the range notations ("<commit>..<commit>" and "<commit>...<commit>") do not mean a range as defined in the "SPECIFYING RANGES" section in gitrevisions[7].
46
+
*
47
+
* git diff [options] <blob> <blob>
48
+
* This form is to view the differences between the raw contents of two blob objects.
20
49
*
21
50
* @author Paul Schweppe <paulschweppe@gmail.com>
22
51
*/
23
52
class GitDiffCommand extends AbstractGitCommand
24
53
{
25
-
/**
26
-
* Get diff based on Commit hash id.
27
-
*
28
-
* @return array()
29
-
*/
30
-
publicfunctiongetCommitDiff($commitHash)
31
-
{
32
-
$diffString = $this->command->runCommand('git --no-pager show --oneline '.escapeshellarg($commitHash));
33
-
$diffParser = newGitDiffParser($diffString);
34
-
$diffs = $diffParser->parse();
35
-
36
-
return$diffs;
37
-
}
38
54
39
55
/**
40
-
* Get diff on a file.
41
-
*
56
+
* Get diff on a file, that has changes that are not committed.
57
+
* git diff [--options] [--] [<path>…]
58
+
* This form is to view the changes you made relative to the index
59
+
* (staging area for the next commit). In other words, the differences
60
+
* are what you could tell Git to further add to the index but you still haven’t.
61
+
*
42
62
* @return array()
43
63
*/
44
64
publicfunctiongetDiffFile($filename)
@@ -67,7 +87,7 @@ public function getDiffFileBetweenCommits($filename, $previousCommitHash, $commi
67
87
/**
68
88
* Returns a list of files effected by a commit.
69
89
*
70
-
* @return array() Array of file paths
90
+
* @return array() Array of VersionControl\GitCommandBundle\Entity\GitCommitFile
71
91
*/
72
92
publicfunctiongetFilesInCommit($commitHash)
73
93
{
@@ -81,6 +101,13 @@ public function getFilesInCommit($commitHash)
81
101
return$files;
82
102
}
83
103
104
+
/**
105
+
* Gets the previous Commit Hash by from a commit has and related to a file
0 commit comments