X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-rm.c;h=33d04bd015e43965a1bc44bb281908298f152f6c;hb=c56f243e20ce48ae50caf841ada8435a21c2a8bf;hp=8af3d7eb48e70dc9a640c2e96a058903fb9fddd8;hpb=022f25e8d4bd3eaed6bb6d80a242f8930687d483;p=git.git diff --git a/builtin-rm.c b/builtin-rm.c index 8af3d7eb4..33d04bd01 100644 --- a/builtin-rm.c +++ b/builtin-rm.c @@ -32,7 +32,7 @@ static int remove_file(const char *name) ret = unlink(name); if (!ret && (slash = strrchr(name, '/'))) { - char *n = strdup(name); + char *n = xstrdup(name); do { n[slash - name] = 0; name = n; @@ -52,9 +52,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) git_config(git_default_config); - newfd = hold_lock_file_for_update(&lock_file, get_index_file()); - if (newfd < 0) - die("unable to create new index file"); + newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1); if (read_cache() < 0) die("index file corrupt");