From: Jacob Moody <moody@mail.posixcafe.org>
To: 9front@9front.org
Subject: [9front] [PATCH] embed git head hash as /dev/head
Date: Fri, 10 Jun 2022 01:32:18 -0600 [thread overview]
Message-ID: <e606daf1-d5ef-e497-9fab-4ff88472b999@posixcafe.org> (raw)
This embeds the current commit hash for HEAD
in to devcons as /dev/head. Thought this could be
handy, curious to hear what others think.
thanks,
moody
---
diff 13065e16b3c4fba4d9200ed7fec89ee49338f12a uncommitted
--- a//sys/src/9/port/devcons.c
+++ b//sys/src/9/port/devcons.c
@@ -329,11 +329,13 @@
Qzero,
Qmordor,
Qconfig,
+ Qhead,
};
enum
{
VLNUMSIZE= 22,
+ HEADSIZE= 41,
};
static Dirtab consdir[]={
@@ -360,6 +362,7 @@
"zero", {Qzero}, 0, 0444,
"config", {Qconfig}, 0, 0444,
"mordor", {Qmordor}, 0, 0666,
+ "head", {Qhead}, HEADSIZE, 0444,
};
int
@@ -466,6 +469,7 @@
int i, k, id;
vlong offset = off;
extern char configfile[];
+ extern char headhash[];
if(n <= 0)
return n;
@@ -623,6 +627,8 @@
snprint(tmp, sizeof tmp, "2000");
n = readstr((ulong)offset, buf, n, tmp);
return n;
+ case Qhead:
+ return readstr((ulong)offset, buf, n, headhash);
default:
print("consread %#llux\n", c->qid.path);
@@ -787,6 +793,9 @@
case Qmordor:
error("one does not simply write into mordor");
+ return 0;
+ case Qhead:
+ error(Eperm);
return 0;
default:
--- a//sys/src/9/port/portmkfile
+++ b//sys/src/9/port/portmkfile
@@ -55,6 +55,11 @@
sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
echo 0,
echo '};'} >> $CONF.c
+ {echo 'uchar headhash[]={'
+ xd -1x /dist/plan9front/.git/`{awk '{ print $2 }' /dist/plan9front/.git/HEAD} |
+ sed -e 's/^[0-9a-f]+ //' -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
+ echo 0,
+ echo '};'} >> $CONF.c
errstr.h:D: ../port/mkerrstr ../port/error.h
rc ../port/mkerrstr > errstr.h
next reply other threads:[~2022-06-10 7:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 7:32 Jacob Moody [this message]
2022-06-10 14:07 ` ori
2022-06-10 16:03 ` Jacob Moody
2022-06-14 17:32 ` Lyndon Nerenberg (VE7TFX/VE6BBM)
2022-06-14 19:37 ` Jacob Moody
2022-06-10 19:01 ` mkf9
2022-06-10 19:13 ` Jacob Moody
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=e606daf1-d5ef-e497-9fab-4ff88472b999@posixcafe.org \
--to=moody@mail.posixcafe.org \
--cc=9front@9front.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).