Merge branch 'sg/completion'
[gitweb.git] / builtin / diff.c
index b7a9405d9fbec46edf99637557d7499fb58c4d77..3d64b8533732b5d4af971e6b1cd23ff66123e8e9 100644 (file)
@@ -45,12 +45,9 @@ static void stuff_change(struct diff_options *opt,
                return;
 
        if (DIFF_OPT_TST(opt, REVERSE_DIFF)) {
-               unsigned tmp;
-               const unsigned char *tmp_u;
-               const char *tmp_c;
-               tmp = old_mode; old_mode = new_mode; new_mode = tmp;
-               tmp_u = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_u;
-               tmp_c = old_name; old_name = new_name; new_name = tmp_c;
+               SWAP(old_mode, new_mode);
+               SWAP(old_sha1, new_sha1);
+               SWAP(old_name, new_name);
        }
 
        if (opt->prefix &&
@@ -301,20 +298,21 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        break;
        }
 
-       if (!no_index)
-               prefix = setup_git_directory_gently(&nongit);
+       prefix = setup_git_directory_gently(&nongit);
 
-       /*
-        * Treat git diff with at least one path outside of the
-        * repo the same as if the command would have been executed
-        * outside of a git repository.  In this case it behaves
-        * the same way as "git diff --no-index <a> <b>", which acts
-        * as a colourful "diff" replacement.
-        */
-       if (nongit || ((argc == i + 2) &&
-                      (!path_inside_repo(prefix, argv[i]) ||
-                       !path_inside_repo(prefix, argv[i + 1]))))
-               no_index = DIFF_NO_INDEX_IMPLICIT;
+       if (!no_index) {
+               /*
+                * Treat git diff with at least one path outside of the
+                * repo the same as if the command would have been executed
+                * outside of a git repository.  In this case it behaves
+                * the same way as "git diff --no-index <a> <b>", which acts
+                * as a colourful "diff" replacement.
+                */
+               if (nongit || ((argc == i + 2) &&
+                              (!path_inside_repo(prefix, argv[i]) ||
+                               !path_inside_repo(prefix, argv[i + 1]))))
+                       no_index = DIFF_NO_INDEX_IMPLICIT;
+       }
 
        if (!no_index)
                gitmodules_config();