From: "Alex Riesen" <raa.lkml@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Cc: "Junio C Hamano" <junkio@cox.net>
Subject: print errors from git-update-ref
Date: Tue, 18 Jul 2006 15:13:48 +0200 [thread overview]
Message-ID: <81b0412b0607180613t603551b8t865b407c40ab8aef@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 529 bytes --]
...otherwise it not clear what happened when update-ref fails.
E.g., git checkout -b a/b/c HEAD would print nothing if refs/heads/a
exists and is a directory (it does return 1, so scripts checking for
return code should be ok).
I'm attaching two patches, because I'm not quite sure where it should
be done: git-checkout is the least intrusive, but only builtin-update-ref.c
has enough info to help user to resolve the problem (errno is ENOTDIR,
which is selfexplanatory). And I happen to use git-update-ref directly
sometimes.
[-- Attachment #2: 0001-update-ref-print-errors-otherwise-it-not-clear-what-happened.txt --]
[-- Type: text/plain, Size: 1049 bytes --]
From 5398f0ee6bab039701912fdaf784792f4cf76afe Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Tue, 18 Jul 2006 14:52:15 +0200
Subject: [PATCH] update-ref: print errors
otherwise it not clear what happened
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
builtin-update-ref.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 83094ab..ad4a44d 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -50,10 +50,14 @@ int cmd_update_ref(int argc, const char
die("%s: not a valid old SHA1", oldval);
lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL, 0);
- if (!lock)
+ if (!lock) {
+ error("%s: %s", refname, strerror(errno));
return 1;
- if (write_ref_sha1(lock, sha1, msg) < 0)
+ }
+ if (write_ref_sha1(lock, sha1, msg) < 0) {
+ error("%s: %s", refname, strerror(errno));
return 1;
+ }
/* write_ref_sha1 always unlocks the ref, no need to do it explicitly */
return 0;
--
1.4.2.rc1.g22734
[-- Attachment #3: 0001-git-checkout.sh-print-errors-otherwise-it-is-not-clear-what-happened.txt --]
[-- Type: text/plain, Size: 939 bytes --]
From 7ea3177aec909e333bacccd00693f223997e2613 Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Tue, 18 Jul 2006 15:10:54 +0200
Subject: [PATCH] git-checkout.sh: print errors, otherwise it is not clear what happened
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
git-checkout.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-checkout.sh b/git-checkout.sh
index 5613bfc..7b335e5 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -198,7 +198,7 @@ if [ "$?" -eq 0 ]; then
mkdir -p $(dirname "$GIT_DIR/logs/refs/heads/$newbranch")
touch "$GIT_DIR/logs/refs/heads/$newbranch"
fi
- git-update-ref -m "checkout: Created from $new_name" "refs/heads/$newbranch" $new || exit
+ git-update-ref -m "checkout: Created from $new_name" "refs/heads/$newbranch" $new || die "failed to create branch $newbranch"
branch="$newbranch"
fi
[ "$branch" ] &&
--
1.4.2.rc1.g22734
next reply other threads:[~2006-07-18 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-18 13:13 Alex Riesen [this message]
2006-07-24 6:06 ` print errors from git-update-ref Junio C Hamano
2006-07-27 1:28 ` Shawn Pearce
2006-07-27 11:04 ` Johannes Schindelin
2006-07-28 6:27 ` Shawn Pearce
2006-07-28 7:26 ` Junio C Hamano
2006-07-29 3:44 ` Shawn Pearce
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=81b0412b0607180613t603551b8t865b407c40ab8aef@mail.gmail.com \
--to=raa.lkml@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).