submodule.c: tighten scope of changed_submodule_names struct
[gitweb.git] / builtin / pack-objects.c
index e7ea206c08c6d4e81c3649e3988faf4794ce013c..411aefd6875b2d35ee4a12d1a043ba50027021b3 100644 (file)
@@ -2786,9 +2786,11 @@ static void show_object(struct object *obj, const char *name, void *data)
 
        if (use_delta_islands) {
                const char *p;
-               unsigned depth = 0;
+               unsigned depth;
                struct object_entry *ent;
 
+               /* the empty string is a root tree, which is depth 0 */
+               depth = *name ? 1 : 0;
                for (p = strchr(name, '/'); p; p = strchr(p + 1, '/'))
                        depth++;