]> git.proxmox.com Git - libgit2.git/commitdiff
Minor bug fixes in diff code
authorRussell Belfer <rb@github.com>
Wed, 22 Aug 2012 20:57:57 +0000 (13:57 -0700)
committerRussell Belfer <rb@github.com>
Wed, 22 Aug 2012 20:57:57 +0000 (13:57 -0700)
In looking at PR #878, I found a few small bugs in the diff code,
mostly related to work that can be avoided when processing tree-
to-tree diffs that was always being carried out.  This commit has
some small fixes in it.

src/diff.c
src/diff_output.c
tests-clar/diff/diff_helpers.c

index a5bf07a65ea4f1bc7fb96e38e0adc360892fd0ca..9abf8b9f55379e53e17665a808e40dcf337c35b7 100644 (file)
@@ -470,7 +470,8 @@ static int maybe_modified(
 
        /* on platforms with no symlinks, preserve mode of existing symlinks */
        if (S_ISLNK(omode) && S_ISREG(nmode) &&
-               !(diff->diffcaps & GIT_DIFFCAPS_HAS_SYMLINKS))
+               !(diff->diffcaps & GIT_DIFFCAPS_HAS_SYMLINKS) &&
+               new_iter->type == GIT_ITERATOR_WORKDIR)
                nmode = omode;
 
        /* on platforms with no execmode, just preserve old mode */
index bd8e8eddae4cf1c8007b5471a0b43c09b7df57b3..d269a4ceea9a61a94938d18f62de29c6ee1bdcff 100644 (file)
@@ -162,7 +162,7 @@ static int file_is_binary_by_attr(
        mirror_new = (delta->new_file.path == delta->old_file.path ||
                                  strcmp(delta->new_file.path, delta->old_file.path) == 0);
        if (mirror_new)
-               delta->new_file.flags &= (delta->old_file.flags & BINARY_DIFF_FLAGS);
+               delta->new_file.flags |= (delta->old_file.flags & BINARY_DIFF_FLAGS);
        else
                error = update_file_is_binary_by_attr(diff->repo, &delta->new_file);
 
@@ -397,6 +397,7 @@ int git_diff_foreach(
 
                                if (error < 0)
                                        goto cleanup;
+                               delta->new_file.flags |= GIT_DIFF_FILE_VALID_OID;
 
                                /* since we did not have the definitive oid, we may have
                                 * incorrect status and need to skip this item.
index 18daa080b0c686ca84e17b51356ddd308864fb3c..7b391262dd49f6f2f2da2c03fb5cbedbae7c7185 100644 (file)
@@ -30,7 +30,8 @@ int diff_file_fn(
 
        GIT_UNUSED(progress);
 
-       e->     at_least_one_of_them_is_binary = delta->binary;
+       if (delta->binary)
+               e->at_least_one_of_them_is_binary = true;
 
        e->files++;
        switch (delta->status) {