git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] [submodule] Remove duplicate call to set_rev_name

From
Fredrik Gustafsson <iveqy@iveqy.com>
Date
Jun 17, 2013, 09:55 UTC
Message-ID
<1371462936-9672-1-git-send-email-iveqy@iveqy.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
Next: Heiko Voigt
Message 1 of 3 in “[submodule] Remove duplicate call to set_rev_name”
  1. [submodule] Remove duplicate call to set_rev_nameFredrik Gustafsson, Jun 17, 2013
  2. Heiko VoigtJun 20, 2013
  3. Junio C HamanoJun 21, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.