git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-submodule.sh: shorten submodule SHA-1s using rev-parse

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 22, 2019, 15:24 UTC
Message-ID
<nycvar.QRO.7.76.6.1901221623370.41@tvgsbejvaqbjf.bet>
In-Reply-To
<20190120204653.3224-1-svenvh@gmail.com>
Hi Sven,
On Sun, 20 Jan 2019, Sven van Haastregt wrote:
> Until now, `git submodule summary` was always emitting 7-character
> SHA-1s that have a higher chance of being ambiguous for larger
> repositories.  Use `git rev-parse --short` instead, which will
> determine suitable short SHA-1 lengths.
Good point. Just one suggestion:
Show 11 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)

How about `git -C "$name" rev-parse --short`? That would less likely run over 80 columns/line, either.

Ciao, Johannes

Show 8 quoted lines
> +		sha1_abbr_dst=$(GIT_DIR="$name/.git" git rev-parse --short $sha1_dst)
>  		if test $status = T
>  		then
>  			blob="$(gettext "blob")"
> -- 
> 2.20.1.dirty
> 
> 
Previous: Sven van HaastregtNext: Junio C Hamano
Message 2 of 7 in “git-submodule.sh: shorten submodule SHA-1s using rev-parse”
  1. git-submodule.sh: shorten submodule SHA-1s using rev-parseSven van Haastregt, Jan 20, 2019
  2. Johannes SchindelinJan 22, 2019
  3. Junio C HamanoJan 22, 2019
  4. Jeff KingJan 24, 2019
  5. Johannes SchindelinJan 25, 2019
  6. Junio C HamanoJan 22, 2019
  7. Sven van HaastregtJan 22, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.