* [PATCH] clone: Supply the right commit hash to post-checkout when -b is used
@ 2009-10-13 22:11 Björn Steinbrink
2009-10-14 0:06 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Björn Steinbrink @ 2009-10-13 22:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, ranguvar, Jeff King
When we use -b <branch>, we may checkout something else than what the
remote's HEAD references, but we still used remote_head to supply the
new ref value to the post-checkout hook, which is wrong.
So instead of using remote_head to find the value to be passed to the
post-checkout hook, we have to use our_head_points_at, which is always
correctly setup, even if -b is not used.
This also fixes a segfault when "clone -b <branch>" is used with a
remote repo that doesn't have a valid HEAD, as in such a case
remote_head is NULL, but we still tried to access it.
Reported-by: Devin Cofer <ranguvar@archlinux.us>
Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
---
builtin-clone.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index 4992c25..5762a6f 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -641,7 +641,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
die("unable to write new index file");
err |= run_hook(NULL, "post-checkout", sha1_to_hex(null_sha1),
- sha1_to_hex(remote_head->old_sha1), "1", NULL);
+ sha1_to_hex(our_head_points_at->old_sha1), "1",
+ NULL);
if (!err && option_recursive)
err = run_command_v_opt(argv_submodule, RUN_GIT_CMD);
--
1.6.5.7.g9ecb2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] clone: Supply the right commit hash to post-checkout when -b is used
2009-10-13 22:11 [PATCH] clone: Supply the right commit hash to post-checkout when -b is used Björn Steinbrink
@ 2009-10-14 0:06 ` Jeff King
2009-10-14 9:13 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2009-10-14 0:06 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: Junio C Hamano, git, ranguvar
On Wed, Oct 14, 2009 at 12:11:09AM +0200, Björn Steinbrink wrote:
> When we use -b <branch>, we may checkout something else than what the
> remote's HEAD references, but we still used remote_head to supply the
> new ref value to the post-checkout hook, which is wrong.
>
> So instead of using remote_head to find the value to be passed to the
> post-checkout hook, we have to use our_head_points_at, which is always
> correctly setup, even if -b is not used.
>
> This also fixes a segfault when "clone -b <branch>" is used with a
> remote repo that doesn't have a valid HEAD, as in such a case
> remote_head is NULL, but we still tried to access it.
>
> Reported-by: Devin Cofer <ranguvar@archlinux.us>
> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Acked-by: Jeff King <peff@peff.net>
Thanks.
When splitting remote_head versus our_head, I tried to find every use of
the remote head and pick the appropriate variable, but I think I just
missed this one. I gave the code another once-over and didn't see any
other spots that needed fixing.
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clone: Supply the right commit hash to post-checkout when -b is used
2009-10-14 0:06 ` Jeff King
@ 2009-10-14 9:13 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2009-10-14 9:13 UTC (permalink / raw)
To: Jeff King; +Cc: Björn Steinbrink, Junio C Hamano, git, ranguvar
Jeff King <peff@peff.net> writes:
>> Reported-by: Devin Cofer <ranguvar@archlinux.us>
>> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
>
> Acked-by: Jeff King <peff@peff.net>
>
> Thanks.
Thanks; will queue on 'maint' for 1.6.5.1.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-14 9:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-13 22:11 [PATCH] clone: Supply the right commit hash to post-checkout when -b is used Björn Steinbrink
2009-10-14 0:06 ` Jeff King
2009-10-14 9:13 ` Junio C Hamano
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).