[PATCH] [submodule] Remove duplicate call to set_rev_name

Subsystems: the rest

STALE3721d

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] [submodule] Remove duplicate call to set_rev_name

From: Fredrik Gustafsson <hidden>
Date: 2016-06-15 22:57:46

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 <redacted>
---
 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

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

From: Heiko Voigt <hidden>
Date: 2016-06-15 22:57:51

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help