Code

rerere: Fix use of an empty strbuf.buf
[git.git] / builtin-add.c
index 866d19dd77e693a1ba77baa802c0e3f3ea85a305..f9a65803d8dcbb9ae7eb3a3c61d8ac345b84d1cd 100644 (file)
@@ -71,12 +71,8 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec,
        baselen = common_prefix(pathspec);
        path = ".";
        base = "";
-       if (baselen) {
-               char *common = xmalloc(baselen + 1);
-               memcpy(common, *pathspec, baselen);
-               common[baselen] = 0;
-               path = base = common;
-       }
+       if (baselen)
+               path = base = xmemdupz(*pathspec, baselen);
 
        /* Read the directory and prune it */
        read_directory(dir, path, base, baselen, pathspec);
@@ -95,7 +91,7 @@ static void update_callback(struct diff_queue_struct *q,
                const char *path = p->one->path;
                switch (p->status) {
                default:
-                       die("unexpacted diff status %c", p->status);
+                       die("unexpected diff status %c", p->status);
                case DIFF_STATUS_UNMERGED:
                case DIFF_STATUS_MODIFIED:
                case DIFF_STATUS_TYPE_CHANGED: