# [PATCH] [submodule] Remove duplicate call to set_rev_name

3 messages from 2013-06-17 to 2013-06-21. Participants: Fredrik Gustafsson, Heiko Voigt, Junio C Hamano.
Thread: https://gitlist.dev/t/34173

## Fredrik Gustafsson, 2013-06-17 09:55

Subject: [PATCH] [submodule] Remove duplicate call to set_rev_name
Message-ID: <1371462936-9672-1-git-send-email-iveqy@iveqy.com>
URL: https://gitlist.dev/e/1371462936-9672-1-git-send-email-iveqy%40iveqy.com

```
set_rev_name is a possible expensive operation. If a submodule has
changes in it, set_rev_name was called twice.

Solution is to move set_rev_name so it's only called once, no matter the
codepath taken.

Signed-off-by: Fredrik Gustafsson <iveqy@iveqy.com>
---
 git-submodule.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 79bfaac..75feaf1 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -1129,16 +1129,16 @@ cmd_status()
 			say "-$sha1 $displaypath"
 			continue;
 		fi
-		set_name_rev "$sm_path" "$sha1"
 		if git diff-files --ignore-submodules=dirty --quiet -- "$sm_path"
 		then
+			set_name_rev "$sm_path" "$sha1"
 			say " $sha1 $displaypath$revname"
 		else
 			if test -z "$cached"
 			then
 				sha1=$(clear_local_git_env; cd "$sm_path" && git rev-parse --verify HEAD)
-				set_name_rev "$sm_path" "$sha1"
 			fi
+			set_name_rev "$sm_path" "$sha1"
 			say "+$sha1 $displaypath$revname"
 		fi
 
-- 
1.8.0

```

## Heiko Voigt, 2013-06-20 21:58

Subject: Re: [PATCH] [submodule] Remove duplicate call to set_rev_name
Message-ID: <20130620215812.GA2687@sandbox-ub>
URL: https://gitlist.dev/e/20130620215812.GA2687%40sandbox-ub
In-Reply-To: <1371462936-9672-1-git-send-email-iveqy@iveqy.com>

```
Hi,

On Mon, Jun 17, 2013 at 11:55:36AM +0200, Fredrik Gustafsson wrote:
> set_rev_name is a possible expensive operation. If a submodule has
> changes in it, set_rev_name was called twice.
> 
> Solution is to move set_rev_name so it's only called once, no matter the
> codepath taken.

Looks good to me.

Cheers Heiko

```

## Junio C Hamano, 2013-06-21 17:03

Subject: Re: [PATCH] [submodule] Remove duplicate call to set_rev_name
Message-ID: <7vy5a3mm4v.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vy5a3mm4v.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20130620215812.GA2687@sandbox-ub>

```
Heiko Voigt <hvoigt@hvoigt.net> writes:

> Hi,
>
> On Mon, Jun 17, 2013 at 11:55:36AM +0200, Fredrik Gustafsson wrote:
>> set_rev_name is a possible expensive operation. If a submodule has
>> changes in it, set_rev_name was called twice.
>> 
>> Solution is to move set_rev_name so it's only called once, no matter the
>> codepath taken.
>
> Looks good to me.

Thanks.

```
