X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-add.c;h=b8e6094b21599051c543b1f77c991363d9dfe181;hb=e2b7eaf0ca3897940961d23392d4ff718867ea9f;hp=0d7d0ce4209114245ca07842d7d5a4546e5b6cfd;hpb=0341091a9ec47576a2fdfab181145fa94c04b810;p=git.git diff --git a/builtin-add.c b/builtin-add.c index 0d7d0ce42..b8e6094b2 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -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)