]> git.proxmox.com Git - libgit2.git/commitdiff
Don't use weird return codes
authorBen Straub <bs@github.com>
Thu, 5 Dec 2013 22:47:04 +0000 (14:47 -0800)
committerBen Straub <bs@github.com>
Thu, 5 Dec 2013 22:47:04 +0000 (14:47 -0800)
src/diff_tform.c
tests/diff/rename.c

index 6f29f25da3ae382e5b5e41f94dec46b43be9cdce..0c9f961f2f2e3cb86dd01d7e71b0c64a3a6456a6 100644 (file)
@@ -293,8 +293,9 @@ static int normalize_find_opts(
                if (git_config_get_string(&val, cfg, "diff.renames") < 0)
                        giterr_clear();
                else if (val) {
-                       if (!strcasecmp(val, "false"))
-                               return GIT_PASSTHROUGH;
+                       int boolval;
+                       if (!git__parse_bool(&boolval, val) && !boolval)
+                               opts->flags = 0;
                        else if (!strcasecmp(val, "copies") || !strcasecmp(val, "copy"))
                                opts->flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES;
                        else
@@ -834,7 +835,11 @@ int git_diff_find_similar(
        git_diff_file swap;
 
        if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0)
-               return (error == GIT_PASSTHROUGH) ? 0 : error;
+               return error;
+
+       /* No flags set; nothing to do */
+       if ((opts.flags & GIT_DIFF_FIND_ALL) == 0)
+               return 0;
 
        num_deltas = diff->deltas.length;
 
index b304ec2539132d088df8d40d496bed2f10b19884..c08c1a8b4b5a9d63d040a5f303cc01be7e13a337 100644 (file)
@@ -919,6 +919,7 @@ void test_diff_rename__rejected_match_can_match_others(void)
        char *ptr;
 
        opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+       findopts.flags = GIT_DIFF_FIND_RENAMES;
 
        cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
        cl_git_pass(git_reference_symbolic_set_target(
@@ -1003,6 +1004,7 @@ void test_diff_rename__rejected_match_can_match_others_two(void)
        struct rename_expected expect = { 2, status, sources, targets };
 
        opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+       findopts.flags = GIT_DIFF_FIND_RENAMES;
 
        cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
        cl_git_pass(git_reference_symbolic_set_target(
@@ -1060,6 +1062,7 @@ void test_diff_rename__rejected_match_can_match_others_three(void)
        struct rename_expected expect = { 2, status, sources, targets };
 
        opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+       findopts.flags = GIT_DIFF_FIND_RENAMES;
 
        cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
        cl_git_pass(git_reference_symbolic_set_target(