X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=builtin-add.c;h=f9a65803d8dcbb9ae7eb3a3c61d8ac345b84d1cd;hb=c2e6b6d0d1e97c5bc2db24388e247bef62faf917;hp=0d7d0ce4209114245ca07842d7d5a4546e5b6cfd;hpb=39bd2eb56af89d43a08ba54699d9a1849ab57b39;p=git.git diff --git a/builtin-add.c b/builtin-add.c index 0d7d0ce42..f9a65803d 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -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);