From: Pavel Roskin <proski@gnu.org>
To: git <git@vger.kernel.org>
Subject: [PATCH] Making cg-seek more robust
Date: Tue, 03 May 2005 20:08:32 -0400 [thread overview]
Message-ID: <1115165312.22116.8.camel@dv.roinet.com> (raw)
Hello!
This patch does following:
If .git/HEAD is not a link, it's detected early, so that basename is not
called without arguments.
.git/HEAD is not deleted until validity of the branch is verified.
.git/blocked is deleted by "rm -f" to suppress unneeded error message if
it's missing.
Signed-off-by: Pavel Roskin <proski@gnu.org>
--- aa6233be6d1b8bf42797c409a7c23b50593afc99/cg-seek (mode:100755 sha1:111f7842e5ec20a1e0714e162ca221da5e06ce33)
+++ uncommitted/cg-seek (mode:100755)
@@ -29,18 +29,23 @@
if [ -s .git/blocked ]; then
branch=$(grep '^seeked from ' .git/blocked | sed 's/^seeked from //')
else
- branch=$(basename $(readlink .git/HEAD)) || die "HEAD is not on branch"
+ tmp=$(readlink .git/HEAD)
+ [ "$tmp" ] || die "HEAD is not on branch"
+ branch=$(basename "$tmp")
fi
curcommit=$(commit-id)
-rm .git/HEAD
if [ ! "$dstcommit" ] || [ "$dstcommit" = "$branch" ]; then
+ rm .git/HEAD
ln -s "refs/heads/$branch" .git/HEAD
- rm .git/blocked
+ rm -f .git/blocked
dstcommit=$(commit-id)
else
- echo $(commit-id "$dstcommit") >.git/HEAD
+ tmp=$(commit-id "$dstcommit")
+ [ "$tmp" ] || die "branch $dstcommit not found"
+ rm .git/HEAD
+ echo "$tmp" >.git/HEAD
[ -s .git/blocked ] || echo "seeked from $branch" >.git/blocked
fi
--
Regards,
Pavel Roskin
reply other threads:[~2005-05-04 0:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1115165312.22116.8.camel@dv.roinet.com \
--to=proski@gnu.org \
--cc=git@vger.kernel.org \
/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).