From: Jeff King <peff@peff.net>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org, andyparkins@gmail.com
Subject: [PATCH] git-{parse-remote,pull}: throw away stderr of git-symbolic-ref
Date: Mon, 15 Jan 2007 16:24:43 -0500 [thread overview]
Message-ID: <20070115212442.GA7409@coredump.intra.peff.net> (raw)
In-Reply-To: <200701151009.51868.andyparkins@gmail.com>
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@peff.net>
---
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
next prev parent reply other threads:[~2007-01-15 21:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-15 10:09 git-fetch while on "(no branch)" Andy Parkins
2007-01-15 21:24 ` Jeff King [this message]
2007-01-15 22:07 ` [PATCH] git-{parse-remote,pull}: throw away stderr of git-symbolic-ref Junio C Hamano
2007-01-15 22:25 ` [PATCH] git-pull: disallow implicit merging to detached HEAD Jeff King
2007-01-15 22:28 ` Jeff King
2007-01-15 21:56 ` git-fetch while on "(no branch)" Junio C Hamano
2007-01-15 22:01 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070115212442.GA7409@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=andyparkins@gmail.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).