Merge branch 'rs/submodule-summary-limit'
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 16:34:46 +0000 (09:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Apr 2013 16:34:46 +0000 (09:34 -0700)
"submodule summary --summary-limit" option did not support
"--option=value" form.

* rs/submodule-summary-limit:
submodule summary: support --summary-limit=<n>

1  2 
git-submodule.sh
diff --combined git-submodule.sh
index 204bc78a9fdffcd11c397a85f94636bb17529b91,b3108b8ea9983c524eb06831972c22773b3a56b1..275c664ff55f2d669ad302f0b11d8629b2d7d1ec
@@@ -8,7 -8,6 +8,7 @@@ dashless=$(basename "$0" | sed -e 's/-
  USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
     or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
     or: $dashless [--quiet] init [--] [<path>...]
 +   or: $dashless [--quiet] deinit [-f|--force] [--] <path>...
     or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
     or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
     or: $dashless [--quiet] foreach [--recursive] <command>
@@@ -267,6 -266,11 +267,11 @@@ module_clone(
        (clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b")
  }
  
+ isnumber()
+ {
+       n=$(($1 + 0)) 2>/dev/null && test "$n" = "$1"
+ }
  #
  # Add a new submodule to the working tree, .gitmodules and the index
  #
@@@ -547,80 -551,6 +552,80 @@@ cmd_init(
        done
  }
  
 +#
 +# Unregister submodules from .git/config and remove their work tree
 +#
 +# $@ = requested paths (use '.' to deinit all submodules)
 +#
 +cmd_deinit()
 +{
 +      # parse $args after "submodule ... deinit".
 +      while test $# -ne 0
 +      do
 +              case "$1" in
 +              -f|--force)
 +                      force=$1
 +                      ;;
 +              -q|--quiet)
 +                      GIT_QUIET=1
 +                      ;;
 +              --)
 +                      shift
 +                      break
 +                      ;;
 +              -*)
 +                      usage
 +                      ;;
 +              *)
 +                      break
 +                      ;;
 +              esac
 +              shift
 +      done
 +
 +      if test $# = 0
 +      then
 +              die "$(eval_gettext "Use '.' if you really want to deinitialize all submodules")"
 +      fi
 +
 +      module_list "$@" |
 +      while read mode sha1 stage sm_path
 +      do
 +              die_if_unmatched "$mode"
 +              name=$(module_name "$sm_path") || exit
 +
 +              # Remove the submodule work tree (unless the user already did it)
 +              if test -d "$sm_path"
 +              then
 +                      # Protect submodules containing a .git directory
 +                      if test -d "$sm_path/.git"
 +                      then
 +                              echo >&2 "$(eval_gettext "Submodule work tree '\$sm_path' contains a .git directory")"
 +                              die "$(eval_gettext "(use 'rm -rf' if you really want to remove it including all of its history)")"
 +                      fi
 +
 +                      if test -z "$force"
 +                      then
 +                              git rm -n "$sm_path" ||
 +                              die "$(eval_gettext "Submodule work tree '\$sm_path' contains local modifications; use '-f' to discard them")"
 +                      fi
 +                      rm -rf "$sm_path" || say "$(eval_gettext "Could not remove submodule work tree '\$sm_path'")"
 +              fi
 +
 +              mkdir "$sm_path" || say "$(eval_gettext "Could not create empty submodule directory '\$sm_path'")"
 +
 +              # Remove the .git/config entries (unless the user already did it)
 +              if test -n "$(git config --get-regexp submodule."$name\.")"
 +              then
 +                      # Remove the whole section so we have a clean state when
 +                      # the user later decides to init this submodule again
 +                      url=$(git config submodule."$name".url)
 +                      git config --remove-section submodule."$name" 2>/dev/null &&
 +                      say "$(eval_gettext "Submodule '\$name' (\$url) unregistered for path '\$sm_path'")"
 +              fi
 +      done
 +}
 +
  #
  # Update each submodule path to correct revision, using clone and checkout as needed
  #
@@@ -889,14 -819,14 +894,14 @@@ cmd_summary() 
                        for_status="$1"
                        ;;
                -n|--summary-limit)
-                       if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
-                       then
-                               :
-                       else
-                               usage
-                       fi
+                       summary_limit="$2"
+                       isnumber "$summary_limit" || usage
                        shift
                        ;;
+               --summary-limit=*)
+                       summary_limit="${1#--summary-limit=}"
+                       isnumber "$summary_limit" || usage
+                       ;;
                --)
                        shift
                        break
@@@ -1237,7 -1167,7 +1242,7 @@@ cmd_sync(
  while test $# != 0 && test -z "$command"
  do
        case "$1" in
 -      add | foreach | init | update | status | summary | sync)
 +      add | foreach | init | deinit | update | status | summary | sync)
                command=$1
                ;;
        -q|--quiet)