Refactor handling of error_string in receive-pack
[gitweb.git] / diff-lib.c
index 75ff0dd93d79ea77877151c50ae30580f1f00342..778cf58244d64b1e1b14ead43c2fdf5735bd717f 100644 (file)
@@ -248,7 +248,19 @@ int setup_diff_no_index(struct rev_info *revs,
                                die("invalid diff option/value: %s", argv[i]);
                        i += j;
                }
-       revs->diffopt.paths = argv + argc - 2;
+
+       if (prefix) {
+               int len = strlen(prefix);
+
+               revs->diffopt.paths = xcalloc(2, sizeof(char*));
+               for (i = 0; i < 2; i++) {
+                       const char *p;
+                       p = prefix_filename(prefix, len, argv[argc - 2 + i]);
+                       revs->diffopt.paths[i] = xstrdup(p);
+               }
+       }
+       else
+               revs->diffopt.paths = argv + argc - 2;
        revs->diffopt.nr_paths = 2;
        revs->max_count = -2;
        return 0;
@@ -400,6 +412,9 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
                    S_ISREG(newmode) && S_ISREG(oldmode) &&
                    ((newmode ^ oldmode) == 0111))
                        newmode = oldmode;
+               else if (!has_symlinks &&
+                   S_ISREG(newmode) && S_ISLNK(oldmode))
+                       newmode = oldmode;
                diff_change(&revs->diffopt, oldmode, newmode,
                            ce->sha1, (changed ? null_sha1 : ce->sha1),
                            ce->name, NULL);