* [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation
@ 2009-08-20 1:24 Brandon Casey
2009-08-20 6:56 ` Johan Herland
0 siblings, 1 reply; 5+ messages in thread
From: Brandon Casey @ 2009-08-20 1:24 UTC (permalink / raw)
To: gitster; +Cc: git, Brandon Casey
From: Brandon Casey <drafnel@gmail.com>
The substring expansion notation is a bashism that we have not so far
adopted. There is precedence for using the 'cut' utility for extracting
a substring. So do so here.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
t/t7407-submodule-foreach.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index de1730d..44ea8ac 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -207,8 +207,8 @@ cat > expect <<EOF
$nested2sha1 nested1/nested2 (heads/master)
$nested3sha1 nested1/nested2/nested3 (heads/master)
$submodulesha1 nested1/nested2/nested3/submodule (heads/master)
- $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))
$sub3sha1 sub3 (heads/master)
EOF
--
1.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation
2009-08-20 1:24 [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation Brandon Casey
@ 2009-08-20 6:56 ` Johan Herland
2009-08-20 7:34 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Johan Herland @ 2009-08-20 6:56 UTC (permalink / raw)
To: git; +Cc: Brandon Casey, gitster, Brandon Casey
On Thursday 20 August 2009, Brandon Casey wrote:
> From: Brandon Casey <drafnel@gmail.com>
>
> The substring expansion notation is a bashism that we have not so far
> adopted. There is precedence for using the 'cut' utility for extracting
> a substring. So do so here.
>
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
> ---
> t/t7407-submodule-foreach.sh | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
> index de1730d..44ea8ac 100755
> --- a/t/t7407-submodule-foreach.sh
> +++ b/t/t7407-submodule-foreach.sh
> @@ -207,8 +207,8 @@ cat > expect <<EOF
> $nested2sha1 nested1/nested2 (heads/master)
> $nested3sha1 nested1/nested2/nested3 (heads/master)
> $submodulesha1 nested1/nested2/nested3/submodule (heads/master)
> - $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>
Thanks,
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation
2009-08-20 6:56 ` Johan Herland
@ 2009-08-20 7:34 ` Junio C Hamano
2009-08-20 9:24 ` Johan Herland
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2009-08-20 7:34 UTC (permalink / raw)
To: Johan Herland; +Cc: git, Brandon Casey, Brandon Casey
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation
2009-08-20 7:34 ` Junio C Hamano
@ 2009-08-20 9:24 ` Johan Herland
2009-08-20 16:59 ` Brandon Casey
0 siblings, 1 reply; 5+ messages in thread
From: Johan Herland @ 2009-08-20 9:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Brandon Casey, Brandon Casey
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.
Suggested-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Johan Herland <johan@herland.net>
---
t/t7407-submodule-foreach.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index 25ec281..2a52775 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -201,14 +201,16 @@ submodulesha1=$(cd clone3/nested1/nested2/nested3/submodule && git rev-parse HEA
sub1sha1=$(cd clone3/sub1 && git rev-parse HEAD)
sub2sha1=$(cd clone3/sub2 && git rev-parse HEAD)
sub3sha1=$(cd clone3/sub3 && git rev-parse HEAD)
+sub1sha1_short=$(cd clone3/sub1 && git rev-parse --short HEAD)
+sub2sha1_short=$(cd clone3/sub2 && git rev-parse --short HEAD)
cat > expect <<EOF
$nested1sha1 nested1 (heads/master)
$nested2sha1 nested1/nested2 (heads/master)
$nested3sha1 nested1/nested2/nested3 (heads/master)
$submodulesha1 nested1/nested2/nested3/submodule (heads/master)
- $sub1sha1 sub1 (${sub1sha1:0:7})
- $sub2sha1 sub2 (${sub1sha1:0:7})
+ $sub1sha1 sub1 ($sub1sha1_short)
+ $sub2sha1 sub2 ($sub2sha1_short)
$sub3sha1 sub3 (heads/master)
EOF
--
1.6.4.304.g1365c.dirty
--
Johan Herland, <johan@herland.net>
www.herland.net
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation
2009-08-20 9:24 ` Johan Herland
@ 2009-08-20 16:59 ` Brandon Casey
0 siblings, 0 replies; 5+ messages in thread
From: Brandon Casey @ 2009-08-20 16:59 UTC (permalink / raw)
To: Johan Herland; +Cc: Junio C Hamano, git, Brandon Casey
Johan Herland wrote:
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-08-20 17:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-20 1:24 [PATCH next] t7407: use 'cut' utility rather than bash's substring expansion notation Brandon Casey
2009-08-20 6:56 ` Johan Herland
2009-08-20 7:34 ` Junio C Hamano
2009-08-20 9:24 ` Johan Herland
2009-08-20 16:59 ` Brandon Casey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox