threads / patch / 34173

patch[submodule] Remove duplicate call to set_rev_name

Subject: [PATCH] [submodule] Remove duplicate call to set_rev_name

## tl;dr

3 messages between Jun 17, 2013 and Jun 21, 2013. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

Fredrik Gustafsson· Jun 17, 2013, 09:55 UTC · lore

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(-)
Show changes to git-submodule.sh +2 −2
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· Jun 20, 2013, 21:58 UTC · re: Fredrik Gustafsson · lore

Re: [PATCH] [submodule] Remove duplicate call to set_rev_name

Hi,
On Mon, Jun 17, 2013 at 11:55:36AM +0200, Fredrik Gustafsson wrote:
Show 5 quoted lines
> 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· Jun 21, 2013, 17:03 UTC · re: Heiko Voigt · lore

Re: [PATCH] [submodule] Remove duplicate call to set_rev_name

Heiko Voigt <hvoigt@hvoigt.net> writes:
Show 10 quoted lines
> 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.

← back to recent threads