static char *author_name, *author_email, *author_date;
static int all, edit_flag, also, interactive, only, amend, signoff;
static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
-static int no_post_rewrite;
+static int no_post_rewrite, allow_empty_message;
- static char *untracked_files_arg, *force_date;
+ static char *untracked_files_arg, *force_date, *ignore_submodule_arg;
/*
* The default commit message cleanup mode will remove the lines
* beginning with # (shell comments) and leading and trailing
"mode",
"show untracked files, optional modes: all, normal, no. (Default: all)",
PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+ OPT_BOOLEAN(0, "ignored", &show_ignored_in_status,
+ "show ignored files"),
+ { OPTION_STRING, 0, "ignore-submodules", &ignore_submodule_arg, "when",
+ "ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)",
+ PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
OPT_END(),
};
read_cache_preload(s.pathspec);
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL);
+
+ fd = hold_locked_index(&index_lock, 0);
+ if (0 <= fd) {
+ if (!write_cache(fd, active_cache, active_nr))
+ commit_locked_index(&index_lock);
+ rollback_lock_file(&index_lock);
+ }
+
s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
s.in_merge = in_merge;
+ s.ignore_submodule_arg = ignore_submodule_arg;
wt_status_collect(&s);
if (s.relative_paths)
test_cmp expect output
'
+test_expect_success POSIXPERM 'status succeeds in a read-only repository' '
+ (
+ chmod a-w .git &&
+ # make dir1/tracked stat-dirty
+ >dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
+ git status -s >output &&
+ ! grep dir1/tracked output &&
+ # make sure "status" succeeded without writing index out
+ git diff-files | grep dir1/tracked
+ )
+ status=$?
+ chmod 775 .git
+ (exit $status)
+'
+
+ cat > expect << EOF
+ # On branch master
+ # Changed but not updated:
+ # (use "git add <file>..." to update what will be committed)
+ # (use "git checkout -- <file>..." to discard changes in working directory)
+ #
+ # modified: dir1/modified
+ #
+ # Untracked files:
+ # (use "git add <file>..." to include in what will be committed)
+ #
+ # dir1/untracked
+ # dir2/modified
+ # dir2/untracked
+ # expect
+ # output
+ # untracked
+ no changes added to commit (use "git add" and/or "git commit -a")
+ EOF
+
+ test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+ echo modified > sm/untracked &&
+ git status --ignore-submodules=untracked > output &&
+ test_cmp expect output
+ '
+
+ test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
+ git status --ignore-submodules=dirty > output &&
+ test_cmp expect output
+ '
+
+ test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
+ echo modified > sm/foo &&
+ git status --ignore-submodules=dirty > output &&
+ test_cmp expect output
+ '
+
+ cat > expect << EOF
+ # On branch master
+ # Changed but not updated:
+ # (use "git add <file>..." to update what will be committed)
+ # (use "git checkout -- <file>..." to discard changes in working directory)
+ # (commit or discard the untracked or modified content in submodules)
+ #
+ # modified: dir1/modified
+ # modified: sm (modified content)
+ #
+ # Untracked files:
+ # (use "git add <file>..." to include in what will be committed)
+ #
+ # dir1/untracked
+ # dir2/modified
+ # dir2/untracked
+ # expect
+ # output
+ # untracked
+ no changes added to commit (use "git add" and/or "git commit -a")
+ EOF
+
+ test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+ git status --ignore-submodules=untracked > output &&
+ test_cmp expect output
+ '
+
+ head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
+
+ cat > expect << EOF
+ # On branch master
+ # Changed but not updated:
+ # (use "git add <file>..." to update what will be committed)
+ # (use "git checkout -- <file>..." to discard changes in working directory)
+ #
+ # modified: dir1/modified
+ # modified: sm (new commits)
+ #
+ # Submodules changed but not updated:
+ #
+ # * sm $head...$head2 (1):
+ # > 2nd commit
+ #
+ # Untracked files:
+ # (use "git add <file>..." to include in what will be committed)
+ #
+ # dir1/untracked
+ # dir2/modified
+ # dir2/untracked
+ # expect
+ # output
+ # untracked
+ no changes added to commit (use "git add" and/or "git commit -a")
+ EOF
+
+ test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+ git status --ignore-submodules=untracked > output &&
+ test_cmp expect output
+ '
+
+ test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
+ git status --ignore-submodules=dirty > output &&
+ test_cmp expect output
+ '
+
+ cat > expect << EOF
+ # On branch master
+ # Changed but not updated:
+ # (use "git add <file>..." to update what will be committed)
+ # (use "git checkout -- <file>..." to discard changes in working directory)
+ #
+ # modified: dir1/modified
+ #
+ # Untracked files:
+ # (use "git add <file>..." to include in what will be committed)
+ #
+ # dir1/untracked
+ # dir2/modified
+ # dir2/untracked
+ # expect
+ # output
+ # untracked
+ no changes added to commit (use "git add" and/or "git commit -a")
+ EOF
+
+ test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+ git status --ignore-submodules=all > output &&
+ test_cmp expect output
+ '
+
test_done