Skip to contentSkip to conversation

git-submodule: Error messages from 'git describe' shouldn't end up on the terminal

PATCH In review Emil Medve 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Emil Medve

author
#0 lore raw

PATCH 1/1 git-submodule: Error messages from 'git describe' shouldn't end up on the terminal

As of now a failure to locate the closest tag to a commit (e.g because there is no tag in the repository) is handled explicitly by displaying an 'undefined' tag error message. However when git describe fails it will still display an undesirable "fatal: cannot describe SHA1" message. This patch hides that message as git-submodule has an alternative and explicit error handling method in place for this situation

---
 git-submodule.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
git-submodule.sh +1 -1
index 1f0cb99..3804f18 100755
@@ -233,7 +233,7 @@ modules_list()
 			say "-$sha1 $path"
 			continue;
 		fi
-		revname=$(unset GIT_DIR && cd "$path" && git describe --tags $sha1)
+		revname=$(unset GIT_DIR && cd "$path" && git describe --tags $sha1 2>/dev/null)
 		set_name_rev "$path" "$sha1"
 		if git diff-files --quiet -- "$path"
 		then
Signature · 1 line
1.5.3.rc2.38.g11308-dirty
#1 lore raw
Quoted 17 lines · Emil Medve

As of now a failure to locate the closest tag to a commit (e.g because there is no tag in the repository) is handled explicitly by displaying an 'undefined' tag error message. However when git describe fails it will still display an undesirable "fatal: cannot describe SHA1" message. This patch hides that message as git-submodule has an alternative and explicit error handling method in place for this situation

---
 git-submodule.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
git-submodule.sh +0 -0
index 1f0cb99..3804f18 100755

git-submodule.sh modules_list() · line 239

Quoted 8 lines
git-submodule.sh +1 -1
@@ -233,7 +233,7 @@ modules_list()
 			say "-$sha1 $path"
 			continue;
 		fi
-		revname=$(unset GIT_DIR && cd "$path" && git describe --tags $sha1)
+		revname=$(unset GIT_DIR && cd "$path" && git describe --tags $sha1 2>/dev/null)
 		set_name_rev "$path" "$sha1"
 		if git diff-files --quiet -- "$path"
 		then

It appears that set_name_rev does the moral equivalent of that line you touched but more elaborately, to set the same variable. Shouldn't we be simply removing that line instead?