[PATCH] git-{parse-remote,pull}: throw away stderr of git-symbolic-ref

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We look up the destination of the HEAD symref in order to get the
default remote and merge head for the current branch. However, if we
have a detached HEAD, there is no current branch. We handle this
situation by looking up branch..remote, which is empty.
Unfortunately, git-symbolic-ref complained to stderr, potentially
scaring users.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 git-parse-remote.sh |    4 ++--
 git-pull.sh         |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index d2e4c2b..bc2485f 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -49,7 +49,7 @@ get_remote_url () {
 }
 
 get_default_remote () {
-	curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
+	curr_branch=$(git-symbolic-ref HEAD 2>/dev/null | sed -e 's|^refs/heads/||')
 	origin=$(git-repo-config --get "branch.$curr_branch.remote")
 	echo ${origin:-origin}
 }
@@ -137,7 +137,7 @@ canon_refs_list_for_fetch () {
 		shift
 		if test "$remote" = "$(get_default_remote)"
 		then
-			curr_branch=$(git-symbolic-ref HEAD | \
+			curr_branch=$(git-symbolic-ref HEAD 2>/dev/null | \
 			    sed -e 's|^refs/heads/||')
 			merge_branches=$(git-repo-config \
 			    --get-all "branch.${curr_branch}.merge")
diff --git a/git-pull.sh b/git-pull.sh
index 9592617..f0cc023 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -83,7 +83,7 @@ merge_head=$(sed -e '/	not-for-merge	/d' \
 
 case "$merge_head" in
 '')
-	curr_branch=$(git-symbolic-ref HEAD | \
+	curr_branch=$(git-symbolic-ref HEAD 2>/dev/null | \
 		sed -e 's|^refs/heads/||')
 	echo >&2 "Warning: No merge candidate found because value of config option
          \"branch.${curr_branch}.merge\" does not match any remote branch fetched."
-- 
1.5.0.rc1.gd61e-dirty
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]