Code

Merge branch 'master' into pb/gitpm
[git.git] / builtin-diff.c
index dca223235de6ef61407bd7e7625687ab71918186..1075855102fdb9d49f923edc4b62ddb75aa8027c 100644 (file)
@@ -23,7 +23,7 @@ struct blobinfo {
 };
 
 static const char builtin_diff_usage[] =
-"diff <options> <rev>{0,2} -- <path>*";
+"git-diff <options> <rev>{0,2} -- <path>*";
 
 static int builtin_diff_files(struct rev_info *revs,
                              int argc, const char **argv)
@@ -125,9 +125,6 @@ static int builtin_diff_blobs(struct rev_info *revs,
                              int argc, const char **argv,
                              struct blobinfo *blob)
 {
-       /* Blobs: the arguments are reversed when setup_revisions()
-        * picked them up.
-        */
        unsigned mode = canon_mode(S_IFREG | 0644);
 
        if (argc > 1)
@@ -135,8 +132,8 @@ static int builtin_diff_blobs(struct rev_info *revs,
 
        stuff_change(&revs->diffopt,
                     mode, mode,
-                    blob[1].sha1, blob[0].sha1,
-                    blob[0].name, blob[0].name);
+                    blob[0].sha1, blob[1].sha1,
+                    blob[0].name, blob[1].name);
        diffcore_std(&revs->diffopt);
        diff_flush(&revs->diffopt);
        return 0;
@@ -221,7 +218,7 @@ void add_head(struct rev_info *revs)
        add_pending_object(revs, obj, "HEAD");
 }
 
-int cmd_diff(int argc, const char **argv, char **envp)
+int cmd_diff(int argc, const char **argv, const char *prefix)
 {
        int i;
        struct rev_info rev;
@@ -250,9 +247,8 @@ int cmd_diff(int argc, const char **argv, char **envp)
         * Other cases are errors.
         */
 
-       init_revisions(&rev);
        git_config(git_diff_ui_config);
-       diff_setup(&rev.diffopt);
+       init_revisions(&rev, prefix);
 
        argc = setup_revisions(argc, argv, &rev, NULL);
        if (!rev.diffopt.output_format) {