diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-24 02:20:13 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-24 02:20:13 -0800 |
commit | efdfd6c8d418a2c12f31cacb50fa8a91b2b868c8 (patch) | |
tree | 93a5eea7b3887a2a58583bf249f1d556019ba418 /builtin-update-index.c | |
parent | d516c2d11945cf13ed3d961fa63817c60b7a566b (diff) | |
parent | b4e1e4a787d3771f617182b3344dcdd9224bd0cb (diff) | |
download | git-efdfd6c8d418a2c12f31cacb50fa8a91b2b868c8.tar.gz |
Evil Merge branch 'jc/status' (early part) into js/diff-ni
* 'jc/status' (early part):
run_diff_{files,index}(): update calling convention.
update-index: do not die too early in a read-only repository.
git-status: do not be totally useless in a read-only repository.
This is to resolve semantic conflict (which is not textual) that
changes the calling convention of run_diff_files() early.
Diffstat (limited to 'builtin-update-index.c')
-rw-r--r-- | builtin-update-index.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin-update-index.c b/builtin-update-index.c index 772aaba7bb..65246dad8d 100644 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@ -487,6 +487,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) int prefix_length = prefix ? strlen(prefix) : 0; char set_executable_bit = 0; unsigned int refresh_flags = 0; + int lock_error = 0; struct lock_file *lock_file; git_config(git_default_config); @@ -494,7 +495,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) /* We can't free this memory, it becomes part of a linked list parsed atexit() */ lock_file = xcalloc(1, sizeof(struct lock_file)); - newfd = hold_lock_file_for_update(lock_file, get_index_file(), 1); + newfd = hold_lock_file_for_update(lock_file, get_index_file(), 0); + if (newfd < 0) + lock_error = errno; entries = read_cache(); if (entries < 0) @@ -651,6 +654,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) finish: if (active_cache_changed) { + if (newfd < 0) { + if (refresh_flags & REFRESH_QUIET) + exit(128); + die("unable to create '%s.lock': %s", + get_index_file(), strerror(lock_error)); + } if (write_cache(newfd, active_cache, active_nr) || close(newfd) || commit_lock_file(lock_file)) die("Unable to write new index file"); |