]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/commit.c
Merge branch 'gt/add-u-commit-i-pathspec-check'
[thirdparty/git.git] / builtin / commit.c
index 7ba7201cfb9160dc062e50f64b875e59d0405c6a..6e1484446b0cc2c98ccade5f8285ad81747c6416 100644 (file)
@@ -441,16 +441,21 @@ static const char *prepare_index(const char **argv, const char *prefix,
         * (B) on failure, rollback the real index.
         */
        if (all || (also && pathspec.nr)) {
+               char *ps_matched = xcalloc(pathspec.nr, 1);
                repo_hold_locked_index(the_repository, &index_lock,
                                       LOCK_DIE_ON_ERROR);
                add_files_to_cache(the_repository, also ? prefix : NULL,
-                                  &pathspec, 0, 0);
+                                  &pathspec, ps_matched, 0, 0);
+               if (!all && report_path_error(ps_matched, &pathspec))
+                       exit(128);
+
                refresh_cache_or_die(refresh_flags);
                cache_tree_update(&the_index, WRITE_TREE_SILENT);
                if (write_locked_index(&the_index, &index_lock, 0))
                        die(_("unable to write new index file"));
                commit_style = COMMIT_NORMAL;
                ret = get_lock_file_path(&index_lock);
+               free(ps_matched);
                goto out;
        }