X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=builtin-add.c;h=c8a114fefb60a106dccffda5c703f2f00fa30ce9;hb=08a19d873c16aa6127bf4c40cf99a9dd19558a0c;hp=0cb9c812006ba4826122b57b9732e895b0eed905;hpb=f3c5b39567535a41a371aad8a6affbeea0d4c0b9;p=git.git diff --git a/builtin-add.c b/builtin-add.c index 0cb9c8120..c8a114fef 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -3,8 +3,6 @@ * * Copyright (C) 2006 Linus Torvalds */ -#include - #include "cache.h" #include "builtin.h" #include "dir.h" @@ -70,7 +68,6 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) base = ""; if (baselen) { char *common = xmalloc(baselen + 1); - common = xmalloc(baselen + 1); memcpy(common, *pathspec, baselen); common[baselen] = 0; path = base = common; @@ -95,9 +92,6 @@ int cmd_add(int argc, const char **argv, const char *prefix) newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1); - if (read_cache() < 0) - die("index file corrupt"); - for (i = 1; i < argc; i++) { const char *arg = argv[i]; @@ -132,6 +126,9 @@ int cmd_add(int argc, const char **argv, const char *prefix) return 0; } + if (read_cache() < 0) + die("index file corrupt"); + for (i = 0; i < dir.nr; i++) add_file_to_index(dir.entries[i]->name, verbose);