mirror of
https://github.com/git/git
synced 2024-09-13 13:24:41 +00:00
commit: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
893d839970
commit
6654c8894e
|
@ -284,17 +284,17 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct string_list partial;
|
struct string_list partial;
|
||||||
const char **pathspec = NULL;
|
struct pathspec pathspec;
|
||||||
char *old_index_env = NULL;
|
char *old_index_env = NULL;
|
||||||
int refresh_flags = REFRESH_QUIET;
|
int refresh_flags = REFRESH_QUIET;
|
||||||
|
|
||||||
if (is_status)
|
if (is_status)
|
||||||
refresh_flags |= REFRESH_UNMERGED;
|
refresh_flags |= REFRESH_UNMERGED;
|
||||||
|
parse_pathspec(&pathspec, 0,
|
||||||
|
PATHSPEC_PREFER_FULL,
|
||||||
|
prefix, argv);
|
||||||
|
|
||||||
if (*argv)
|
if (read_cache_preload(pathspec.raw) < 0)
|
||||||
pathspec = get_pathspec(prefix, argv);
|
|
||||||
|
|
||||||
if (read_cache_preload(pathspec) < 0)
|
|
||||||
die(_("index file corrupt"));
|
die(_("index file corrupt"));
|
||||||
|
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
|
@ -336,9 +336,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
|
||||||
* (A) if all goes well, commit the real index;
|
* (A) if all goes well, commit the real index;
|
||||||
* (B) on failure, rollback the real index.
|
* (B) on failure, rollback the real index.
|
||||||
*/
|
*/
|
||||||
if (all || (also && pathspec && *pathspec)) {
|
if (all || (also && pathspec.nr)) {
|
||||||
fd = hold_locked_index(&index_lock, 1);
|
fd = hold_locked_index(&index_lock, 1);
|
||||||
add_files_to_cache(also ? prefix : NULL, pathspec, 0);
|
add_files_to_cache(also ? prefix : NULL, pathspec.raw, 0);
|
||||||
refresh_cache_or_die(refresh_flags);
|
refresh_cache_or_die(refresh_flags);
|
||||||
update_main_cache_tree(WRITE_TREE_SILENT);
|
update_main_cache_tree(WRITE_TREE_SILENT);
|
||||||
if (write_cache(fd, active_cache, active_nr) ||
|
if (write_cache(fd, active_cache, active_nr) ||
|
||||||
|
@ -357,7 +357,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
|
||||||
* and create commit from the_index.
|
* and create commit from the_index.
|
||||||
* We still need to refresh the index here.
|
* We still need to refresh the index here.
|
||||||
*/
|
*/
|
||||||
if (!only && (!pathspec || !*pathspec)) {
|
if (!only && !pathspec.nr) {
|
||||||
fd = hold_locked_index(&index_lock, 1);
|
fd = hold_locked_index(&index_lock, 1);
|
||||||
refresh_cache_or_die(refresh_flags);
|
refresh_cache_or_die(refresh_flags);
|
||||||
if (active_cache_changed) {
|
if (active_cache_changed) {
|
||||||
|
@ -402,7 +402,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
|
||||||
|
|
||||||
memset(&partial, 0, sizeof(partial));
|
memset(&partial, 0, sizeof(partial));
|
||||||
partial.strdup_strings = 1;
|
partial.strdup_strings = 1;
|
||||||
if (list_paths(&partial, !current_head ? NULL : "HEAD", prefix, pathspec))
|
if (list_paths(&partial, !current_head ? NULL : "HEAD", prefix, pathspec.raw))
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
discard_cache();
|
discard_cache();
|
||||||
|
|
Loading…
Reference in a new issue