From: Junio C Hamano <gitster@pobox.com>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] "git checkout -- paths..." should signal error
Date: Wed, 28 May 2008 14:19:38 -0700 [thread overview]
Message-ID: <7vtzgirus5.fsf_-_@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7v7idetb1h.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 28 May 2008 13:43:06 -0700")
When "git checkout -- paths..." cannot update work tree for whatever
reason, checkout_entry() correctly issued an error message for the path to
the end user, but the command ignored the error, causing the entire
command to succeed. This fixes it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* Now that we detect this failure, post-checkout-hook _might_ want to
know that what we have is an incomplete checkout. Not calling the hook
in such a case may be another option, but we always called the hook and
that would be a change in behaviour.
builtin-checkout.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 1ea017f..00dc8ca 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -84,6 +84,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
unsigned char rev[20];
int flag;
struct commit *head;
+ int errs = 0;
int newfd;
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
@@ -106,13 +107,14 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
if (report_path_error(ps_matched, pathspec, 0))
return 1;
+ /* Now we are committed to check them out */
memset(&state, 0, sizeof(state));
state.force = 1;
state.refresh_cache = 1;
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
if (pathspec_match(pathspec, NULL, ce->name, 0)) {
- checkout_entry(ce, &state, NULL);
+ errs |= checkout_entry(ce, &state, NULL);
}
}
@@ -123,7 +125,8 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec)
resolve_ref("HEAD", rev, 0, &flag);
head = lookup_commit_reference_gently(rev, 1);
- return post_checkout_hook(head, head, 0);
+ errs |= post_checkout_hook(head, head, 0);
+ return errs;
}
static void show_local_changes(struct object *head)
next prev parent reply other threads:[~2008-05-28 21:20 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-26 14:01 Commit cce8d6fdb introduces file t/t5100/nul, git tree is now incompatible with Cygwin (and probably Windows) Mark Levedahl
2008-05-26 14:25 ` Johannes Schindelin
2008-05-26 17:37 ` Mark Levedahl
2008-05-26 21:28 ` Johannes Schindelin
2008-05-26 22:49 ` Mark Levedahl
2008-05-26 23:10 ` Johannes Schindelin
2008-05-26 23:15 ` Johannes Schindelin
[not found] ` <483ADA17.3080401@viscovery.net>
2008-05-26 21:21 ` [PATCH] Makefile: wt-status.h is also a lib header Johannes Schindelin
2008-05-26 21:54 ` Junio C Hamano
2008-05-26 23:03 ` Johannes Schindelin
2008-05-27 13:26 ` Commit cce8d6fdb introduces file t/t5100/nul, git tree is now incompatible with Cygwin (and probably Windows) Eric Blake
2008-05-28 6:12 ` Junio C Hamano
2008-05-28 9:46 ` Wincent Colaiuta
2008-05-28 15:53 ` Lea Wiemann
2008-05-28 15:58 ` Wincent Colaiuta
2008-05-28 21:39 ` Jakub Narebski
2008-05-29 13:22 ` Johannes Schindelin
2008-05-29 14:58 ` Wincent Colaiuta
2008-05-29 16:05 ` Johannes Schindelin
2008-05-29 16:15 ` Wincent Colaiuta
2008-05-31 17:37 ` Steffen Prohaska
2008-05-31 18:28 ` [PATCH] gitweb: Remove gitweb/test/ directory Jakub Narebski
2008-05-31 18:49 ` Wincent Colaiuta
2008-05-31 23:19 ` Johannes Schindelin
2008-06-01 0:19 ` Jakub Narebski
2008-06-01 9:42 ` Kay Sievers
2008-06-01 19:07 ` Wincent Colaiuta
2008-06-01 1:06 ` Junio C Hamano
2008-06-01 1:59 ` Jakub Narebski
2008-05-28 16:33 ` Commit cce8d6fdb introduces file t/t5100/nul, git tree is now incompatible with Cygwin (and probably Windows) Avery Pennarun
2008-05-28 17:24 ` Junio C Hamano
2008-05-28 17:46 ` Sverre Rabbelier
2008-05-28 17:52 ` Avery Pennarun
2008-05-28 18:27 ` Junio C Hamano
2008-05-28 18:19 ` Daniel Barkalow
2008-05-28 18:37 ` Junio C Hamano
2008-05-28 20:06 ` Daniel Barkalow
2008-05-28 20:43 ` Junio C Hamano
2008-05-28 21:19 ` Junio C Hamano [this message]
2008-05-29 6:28 ` [PATCH] "git checkout -- paths..." should signal error Marius Storm-Olsen
2008-05-29 13:05 ` Daniel Barkalow
2008-05-28 21:41 ` Commit cce8d6fdb introduces file t/t5100/nul, git tree is now incompatible with Cygwin (and probably Windows) Daniel Barkalow
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=7vtzgirus5.fsf_-_@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=barkalow@iabervon.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).