git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Segmentation Fault on non-commit --branch clone

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 2, 2019, 10:16 UTC
Message-ID
<xmqqh83m1t3c.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191101193558.GA1169@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> I don't know how often this would actually help users, though. It _is_ a
> pretty rare situation to ask for a non-commit. So maybe it's all
> over-engineering, and we should start with just die(). If somebody comes
> along later and wants to enhance it, it should be pretty
> straightforward.

I like that; after update_head() finishes, there are a few clean-up things that the caller wants to do besides a checkout() call, but if we make update_head() return a failure, perhaps the caller side change would be as small as the attached patch. That would go nicely with the "make the result just barely usable" approach of leaving an unborn master branch I suggested in a separate message, I would think.

 builtin/clone.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index c46ee29f0a..fa0558fa3e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1246,7 +1246,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			   branch_top.buf, reflog_msg.buf, transport,
 			   !is_local, filter_options.choice);
 
-	update_head(our_head_points_at, remote_head, reflog_msg.buf);
+	err = update_head(our_head_points_at, remote_head, reflog_msg.buf) < 0;
 
 	/*
 	 * We want to show progress for recursive submodule clones iff
@@ -1265,8 +1265,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	}
 
 	junk_mode = JUNK_LEAVE_REPO;
-	fetch_if_missing = 1;
-	err = checkout(submodule_progress);
+	if (!err) {
+		fetch_if_missing = 1;
+		err = checkout(submodule_progress);
+	}
 
 	strbuf_release(&reflog_msg);
 	strbuf_release(&branch_top);
Previous: Jeff KingNext: Davide Berardi
Message 4 of 14 in “Segmentation Fault on non-commit --branch clone”
  1. Segmentation Fault on non-commit --branch cloneDavide Berardi, Nov 1, 2019
  2. Johannes SchindelinNov 1, 2019
  3. Jeff KingNov 1, 2019
  4. Junio C HamanoNov 2, 2019
  5. Davide BerardiNov 3, 2019
  6. Junio C HamanoNov 4, 2019
  7. Junio C HamanoNov 2, 2019
  8. Jeff KingNov 1, 2019
  9. Junio C HamanoNov 2, 2019
  10. clone: Don't segfault on -b specifing a non-commitDavide Berardi, Nov 3, 2019
  11. Jeff KingNov 5, 2019
  12. Junio C HamanoNov 6, 2019
  13. Jeff KingNov 6, 2019
  14. Junio C HamanoNov 6, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.