Merge branch 'sh/submodule-summary-abbrev-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 7 Feb 2019 06:05:27 +0000 (22:05 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Feb 2019 06:05:27 +0000 (22:05 -0800)
The "git submodule summary" subcommand showed shortened commit
object names by mechanically truncating them at 7-hexdigit, which
has been improved to let "rev-parse --short" scale the length of
the abbreviation with the size of the repository.

* sh/submodule-summary-abbrev-fix:
git-submodule.sh: shorten submodule SHA-1s using rev-parse

1  2 
git-submodule.sh
diff --combined git-submodule.sh
index 02a0d728174a0201c966abd73299d03c198d03b4,e26146e72115551ac69af22b2045905e490b3635..b5f2beee60ab59a04b5b236da8df39403009db1b
@@@ -548,7 -548,7 +548,7 @@@ cmd_update(
        do
                die_if_unmatched "$quickabort" "$sha1"
  
 -              git submodule--helper ensure-core-worktree "$sm_path"
 +              git submodule--helper ensure-core-worktree "$sm_path" || exit 1
  
                update_module=$(git submodule--helper update-module-mode $just_cloned "$sm_path" $update)
  
@@@ -850,8 -850,11 +850,11 @@@ cmd_summary() 
                        ;;
                esac
  
-               sha1_abbr_src=$(echo $sha1_src | cut -c1-7)
-               sha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)
+               sha1_abbr_src=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_src 2>/dev/null ||
+                       echo $sha1_src | cut -c1-7)
+               sha1_abbr_dst=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_dst 2>/dev/null ||
+                       echo $sha1_dst | cut -c1-7)
                if test $status = T
                then
                        blob="$(gettext "blob")"