git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* print errors from git-update-ref
@ 2006-07-18 13:13 Alex Riesen
  2006-07-24  6:06 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Alex Riesen @ 2006-07-18 13:13 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

[-- 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-07-29  3:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-18 13:13 print errors from git-update-ref Alex Riesen
2006-07-24  6:06 ` 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

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).