diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/commit.c | 16 | ||||
-rw-r--r-- | builtin/read-tree.c | 5 | ||||
-rw-r--r-- | builtin/rev-parse.c | 4 |
3 files changed, 13 insertions, 12 deletions
diff --git a/builtin/commit.c b/builtin/commit.c index c101f006f6..a78dbd83bf 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -343,9 +343,13 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int if (!pathspec || !*pathspec) { fd = hold_locked_index(&index_lock, 1); refresh_cache_or_die(refresh_flags); - if (write_cache(fd, active_cache, active_nr) || - commit_locked_index(&index_lock)) - die("unable to write new_index file"); + if (active_cache_changed) { + if (write_cache(fd, active_cache, active_nr) || + commit_locked_index(&index_lock)) + die("unable to write new_index file"); + } else { + rollback_lock_file(&index_lock); + } commit_style = COMMIT_AS_IS; return get_index_file(); } @@ -1085,9 +1089,11 @@ int cmd_status(int argc, const char **argv, const char *prefix) fd = hold_locked_index(&index_lock, 0); if (0 <= fd) { - if (!write_cache(fd, active_cache, active_nr)) + if (active_cache_changed && + !write_cache(fd, active_cache, active_nr)) commit_locked_index(&index_lock); - rollback_lock_file(&index_lock); + else + rollback_lock_file(&index_lock); } s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; diff --git a/builtin/read-tree.c b/builtin/read-tree.c index 8bdcab1138..9ad1e66916 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -219,14 +219,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix) * "-m ent" or "--reset ent" form), we can obtain a fully * valid cache-tree because the index must match exactly * what came from the tree. - * - * The same holds true if we are switching between two trees - * using read-tree -m A B. The index must match B after that. */ if (nr_trees == 1 && !opts.prefix) prime_cache_tree(&active_cache_tree, trees[0]); - else if (nr_trees == 2 && opts.merge) - prime_cache_tree(&active_cache_tree, trees[1]); if (write_cache(newfd, active_cache, active_nr) || commit_locked_index(&lock_file)) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index b676e29635..a5a1c86e92 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -407,8 +407,8 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix) ALLOC_GROW(opts, onb + 1, osz); memset(opts + onb, 0, sizeof(opts[onb])); argc = parse_options(argc, argv, prefix, opts, usage, - keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0 | - stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0 | + (keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0) | + (stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0) | PARSE_OPT_SHELL_EVAL); strbuf_addf(&parsed, " --"); |