Thread (10 messages) flat view 10 messages, 6 authors, 2016-06-15

Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was

From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:47:33

On Wed, 14 Oct 2009, Jeff King wrote:
On Wed, Oct 14, 2009 at 12:44:34AM -0400, Daniel Barkalow wrote:
quoted
+char *get_detached_head_string(void)
+{
+	char *filename = git_path("DETACH_NAME");
+	struct stat st;
+	if (stat(filename, &st) || !S_ISREG(st.st_mode))
+		return NULL;
+	struct strbuf buf = STRBUF_INIT;
+	strbuf_read_file(&buf, filename, st.st_size);
+	strbuf_trim(&buf);
+	return strbuf_detach(&buf, 0);
+}
Would it hurt to tuck this information into HEAD itself, as we already
put arbitrary text into FETCH_HEAD?
I don't know; I'll have to try that and see if the tools that handle HEAD 
are happy with extra text there. If it works, it's a good solution.

I think I tried it at some point and things failed all over the place, but 
that may have been before symrefs, when you could get the actual sha1 
hash out of HEAD with "$(cat .git/HEAD)".

	-Daniel
*This .sig left intentionally blank*
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help