From: Junio C Hamano Date: Wed, 30 Jun 2010 18:55:39 +0000 (-0700) Subject: Merge branch 'jl/status-ignore-submodules' X-Git-Tag: v1.7.2-rc1~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a76b2084fb9c7e788108717fdce4c91227808980;p=git.git Merge branch 'jl/status-ignore-submodules' * jl/status-ignore-submodules: Add the option "--ignore-submodules" to "git status" git submodule: ignore dirty submodules for summary and status Conflicts: builtin/commit.c t/t7508-status.sh wt-status.c wt-status.h --- a76b2084fb9c7e788108717fdce4c91227808980 diff --cc builtin/commit.c index c6b053a50,018175092..c101f006f --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -71,8 -66,8 +71,8 @@@ static char *edit_message, *use_message 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 @@@ -1057,8 -1031,9 +1057,11 @@@ int cmd_status(int argc, const char **a "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(), }; @@@ -1079,16 -1053,9 +1082,17 @@@ 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) diff --cc t/t7508-status.sh index 9e081073f,63d437e0e..a72fe3ae6 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@@ -793,19 -693,131 +793,146 @@@ test_expect_success 'commit --dry-run s 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 ..." to update what will be committed) + # (use "git checkout -- ..." to discard changes in working directory) + # + # modified: dir1/modified + # + # Untracked files: + # (use "git add ..." 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 ..." to update what will be committed) + # (use "git checkout -- ..." 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 ..." 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 ..." to update what will be committed) + # (use "git checkout -- ..." 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 ..." 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 ..." to update what will be committed) + # (use "git checkout -- ..." to discard changes in working directory) + # + # modified: dir1/modified + # + # Untracked files: + # (use "git add ..." 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 diff --cc wt-status.c index 38754ad73,894d66f8f..2f9e33c8f --- a/wt-status.c +++ b/wt-status.c @@@ -9,7 -9,7 +9,8 @@@ #include "quote.h" #include "run-command.h" #include "remote.h" +#include "refs.h" + #include "submodule.h" static char default_wt_status_colors[][COLOR_MAXLEN] = { GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */ diff --cc wt-status.h index 4cd74c4b3,192909691..9df9c9fad --- a/wt-status.h +++ b/wt-status.h @@@ -43,9 -41,9 +43,10 @@@ struct wt_status int use_color; int relative_paths; int submodule_summary; + int show_ignored_files; enum untracked_status_type show_untracked_files; + const char *ignore_submodule_arg; - char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN]; + char color_palette[WT_STATUS_REMOTE_BRANCH+1][COLOR_MAXLEN]; /* These are computed during processing of the individual sections */ int commitable;