rebase -m: do not trigger pre-commit verification
[gitweb.git] / builtin-diff.c
index 1b615991e1fc6aaa329811cc9f7b615e20b00917..8d7a5697f2b429f6240a89e28422f48ef18aee3b 100644 (file)
@@ -176,18 +176,6 @@ static int builtin_diff_combined(struct rev_info *revs,
        return 0;
 }
 
-void add_head(struct rev_info *revs)
-{
-       unsigned char sha1[20];
-       struct object *obj;
-       if (get_sha1("HEAD", sha1))
-               return;
-       obj = parse_object(sha1);
-       if (!obj)
-               return;
-       add_pending_object(revs, obj, "HEAD");
-}
-
 static void refresh_index_quietly(void)
 {
        struct lock_file *lock_file;
@@ -202,7 +190,7 @@ static void refresh_index_quietly(void)
        refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
 
        if (active_cache_changed &&
-           !write_cache(fd, active_cache, active_nr) && !close(fd))
+           !write_cache(fd, active_cache, active_nr))
                commit_locked_index(lock_file);
 
        rollback_lock_file(lock_file);
@@ -256,7 +244,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
        DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
 
-       /* If the user asked for our exit code then don't start a
+       /*
+        * If the user asked for our exit code then don't start a
         * pager or we would end up reporting its exit code instead.
         */
        if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
@@ -272,7 +261,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                        if (!strcmp(arg, "--"))
                                break;
                        else if (!strcmp(arg, "--cached")) {
-                               add_head(&rev);
+                               add_head_to_pending(&rev);
                                if (!rev.pending.nr)
                                        die("No HEAD commit to compare with (yet)");
                                break;
@@ -363,9 +352,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        else
                result = builtin_diff_combined(&rev, argc, argv,
                                             ent, ents);
-       if (DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
-               result = DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES) != 0;
-
+       result = diff_result_code(&rev.diffopt, result);
        if (1 < rev.diffopt.skip_stat_unmatch)
                refresh_index_quietly();
        return result;