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

Re: [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Aug 20, 2009, 16:59 UTC
Message-ID
<5cqGRKnaah8NEt1Sx1jHwTRuuDfhT5e-wsLOzZOw4Hf1ady-n-TFfg@cipher.nrlssc.navy.mil>
In-Reply-To
<200908201124.54193.johan@herland.net>
Johan Herland wrote:
Show 34 quoted lines
> On Thursday 20 August 2009, Junio C Hamano wrote:
>> Johan Herland <johan@herland.net> writes:
>>>> - $sub1sha1 sub1 (${sub1sha1:0:7})
>>>> - $sub2sha1 sub2 (${sub1sha1:0:7})
>>>> + $sub1sha1 sub1 ($(echo $sub1sha1 | cut -c 1-7))
>>>> + $sub2sha1 sub2 ($(echo $sub1sha1 | cut -c 1-7))
>>> Typo (both in the original, and the patch), should be:
>>> 	$sub2sha1 sub2 ($(echo $sub2sha1 | cut -c 1-7))
>>>
>>>>   $sub3sha1 sub3 (heads/master)
>>>>  EOF
>>> Otherwise:
>>>
>>> Acked-by: Johan Herland <johan@herland.net>
>> Hmm, what does the command use to shorten these object names?  It may be
>> safer and more correct to use "rev-parse --short" in case these object
>> names were ambigous in their first 7 hexdigits.
> 
> git submodule status (which is what we're testing here) uses
> 'git describe' to generate the short object name (see
> set_name_rev in git-submodule.sh). In this case, it falls back
> to 'git describe --all --always', which calls find_unique_abbrev()
> on the SHA1. 'git rev-parse --short' ends up calling the same
> find_unique_abbrev(), so I guess it is better to use it here.
> 
> Try this instead:
> 
> From: Johan Herland <johan@herland.net>
> 
> Subject: [PATCH] t7407: Use 'rev-parse --short' rather than bash's substring expansion notation
> 
> The substring expansion notation is a bashism that we have not so far
> adopted.  Use 'git rev-parse --short' instead, as this also handles
> the case where the unique abbreviation is longer than 7 characters.
Works for me.
Maybe it should be mentioned that a typo was fixed too.
-brandon
Previous: Johan Herland
Message 5 of 5 in “t7407: use 'cut' utility rather than bash's substring expansion notation”
  1. t7407: use 'cut' utility rather than bash's substring expansion notationBrandon Casey, Aug 20, 2009
  2. Johan HerlandAug 20, 2009
  3. Junio C HamanoAug 20, 2009
  4. Johan HerlandAug 20, 2009
  5. Brandon CaseyAug 20, 2009

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.