]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-add.c
Merge branch 'maint'
[git.git] / builtin-add.c
index 0d7d0ce4209114245ca07842d7d5a4546e5b6cfd..b8e6094b21599051c543b1f77c991363d9dfe181 100644 (file)
@@ -44,6 +44,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p
                        die("pathspec '%s' did not match any files",
                                        pathspec[i]);
        }
+        free(seen);
 }
 
 static void fill_directory(struct dir_struct *dir, const char **pathspec,
@@ -71,12 +72,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);
@@ -139,6 +136,7 @@ static void refresh(int verbose, const char **pathspec)
                if (!seen[i])
                        die("pathspec '%s' did not match any files", pathspec[i]);
        }
+        free(seen);
 }
 
 static int git_add_config(const char *var, const char *value)