]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jl/status-ignore-submodules'
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 Jun 2010 18:55:39 +0000 (11:55 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Jun 2010 18:55:39 +0000 (11:55 -0700)
* 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

1  2 
Documentation/git-status.txt
builtin/commit.c
diff.c
git-submodule.sh
t/t7508-status.sh
wt-status.c
wt-status.h

Simple merge
index c6b053a508facc2029df489d069e0667cfeb28fe,01817509262138bc453de401f63913d61f5b47d0..c101f006f6b5d7d185aa97081fb9717de92b09cd
@@@ -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(),
        };
  
  
        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 diff.c
Simple merge
Simple merge
index 9e081073fbed00da362137446d78a7be7f86350b,63d437e0e6b5a959b77c78072af1942d73fafe49..a72fe3ae640378350102a07124aee201fb1c637b
@@@ -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 <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
diff --cc wt-status.c
index 38754ad735e9e6b090eb23990d82926cd2d82396,894d66f8fc3e1175080345f0f068ee828663e664..2f9e33c8fa172b129fd956abc4f74a5bf5543ba7
@@@ -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 4cd74c4b32f51dbe575b0a04a894a520df79e9bf,192909691e70622fac8054716d5663ae128cc683..9df9c9fad2512d7c1d7d6456cdd645d641b5a089
@@@ -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;
 -      char color_palette[WT_STATUS_UNMERGED+1][COLOR_MAXLEN];
+       const char *ignore_submodule_arg;
 +      char color_palette[WT_STATUS_REMOTE_BRANCH+1][COLOR_MAXLEN];
  
        /* These are computed during processing of the individual sections */
        int commitable;