git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] [submodule] Remove duplicate call to set_rev_name
@ 2013-06-17  9:55 Fredrik Gustafsson
  2013-06-20 21:58 ` Heiko Voigt
  0 siblings, 1 reply; 3+ messages in thread
From: Fredrik Gustafsson @ 2013-06-17  9:55 UTC (permalink / raw)
  To: iveqy; +Cc: git, gitster

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [submodule] Remove duplicate call to set_rev_name
  2013-06-17  9:55 [PATCH] [submodule] Remove duplicate call to set_rev_name Fredrik Gustafsson
@ 2013-06-20 21:58 ` Heiko Voigt
  2013-06-21 17:03   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Voigt @ 2013-06-20 21:58 UTC (permalink / raw)
  To: Fredrik Gustafsson; +Cc: git, gitster

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [submodule] Remove duplicate call to set_rev_name
  2013-06-20 21:58 ` Heiko Voigt
@ 2013-06-21 17:03   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2013-06-21 17:03 UTC (permalink / raw)
  To: Heiko Voigt; +Cc: Fredrik Gustafsson, git

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-21 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17  9:55 [PATCH] [submodule] Remove duplicate call to set_rev_name Fredrik Gustafsson
2013-06-20 21:58 ` Heiko Voigt
2013-06-21 17:03   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).