submodule-config: verify submodule names as paths
[gitweb.git] / builtin / diff.c
index 4c0811d6fcec3009b6243e8f53ec9c32ad6a7728..5e7c6428c91203fa1f3fb0c7790364987a623fc0 100644 (file)
 static const char builtin_diff_usage[] =
 "git diff [<options>] [<commit> [<commit>]] [--] [<path>...]";
 
+static const char *blob_path(struct object_array_entry *entry)
+{
+       return entry->path ? entry->path : entry->name;
+}
+
 static void stuff_change(struct diff_options *opt,
                         unsigned old_mode, unsigned new_mode,
                         const struct object_id *old_oid,
@@ -85,7 +90,8 @@ static int builtin_diff_b_f(struct rev_info *revs,
                     blob[0]->mode, canon_mode(st.st_mode),
                     &blob[0]->item->oid, &null_oid,
                     1, 0,
-                    path, path);
+                    blob[0]->path ? blob[0]->path : path,
+                    path);
        diffcore_std(&revs->diffopt);
        diff_flush(&revs->diffopt);
        return 0;
@@ -110,7 +116,7 @@ static int builtin_diff_blobs(struct rev_info *revs,
                     blob[0]->mode, blob[1]->mode,
                     &blob[0]->item->oid, &blob[1]->item->oid,
                     1, 1,
-                    blob[0]->name, blob[1]->name);
+                    blob_path(blob[0]), blob_path(blob[1]));
        diffcore_std(&revs->diffopt);
        diff_flush(&revs->diffopt);
        return 0;