Re: [PATCH] git-submodule.sh: shorten submodule SHA-1s using rev-parse
- From
Sven van Haastregt <svenvh@gmail.com>
- Date
- Jan 22, 2019, 21:38 UTC
- Message-ID
- <5C478D44.2070405@gmail.com>
- In-Reply-To
- <xmqqfttkfnmy.fsf@gitster-ct.c.googlers.com>
On 22/01/19 20:22, Junio C Hamano wrote:
Show 5 quoted lines
> One thing it is not clear to me is that this codepath is prepared to > handle sha1_src and sha1_dst referring to an object that does not > exist (i.e. $missing_(src|dst)=t); the original code will still give > us 7 hexdigit to show on the headline, but does the updated code > that uses "rev-parse --short" give us a reasonable output?
Good point, I expect it will output an error message in that case. I suppose we can fallback to the old echo and cut if the object does not exist; I'll update the patch.
Show 16 quoted lines
>> diff --git a/git-submodule.sh b/git-submodule.sh
>> index 5e608f8bad..a422b0728d 100755
>> --- a/git-submodule.sh
>> +++ b/git-submodule.sh
>> @@ -850,8 +850,8 @@ 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)
>> + sha1_abbr_dst=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_dst)
>> if test $status = T
>> then
>> blob="$(gettext "blob")"
>