Compare commits

..
107 Commits
Author SHA1 Message Date
Laan Tungir 4a53455190 Fix TLS read buffer in ws client: buffer excess SSL_read bytes to prevent loss of multiple WebSocket frames in a single TLS record 2026-07-28 12:21:21 -04:00
Laan Tungir 61581afcc9 Increase receive timeout from 50ms to 1000ms in synchronous_query_relays_with_progress
The 50ms receive timeout was too short for relays that need time to
process a REQ query before responding. The pool's query_sync already
uses 1000ms. This matches that behavior to avoid premature timeouts.
2026-07-28 10:14:30 -04:00
Laan Tungir 36eb6afa72 Handle NOTICE and CLOSED messages in synchronous_query_relays_with_progress
Pass NOTICE and CLOSED message content to the callback so callers
can see what the relay actually said (e.g. auth-required, restricted,
rate-limited). Previously these messages were silently ignored.
2026-07-28 09:38:53 -04:00
Laan Tungir 160421c673 Increase receive buffer from 8KB to 256KB in synchronous_query/publish functions
The 8KB buffer was too small for large Nostr events (e.g. long-form
content in kind 30023). The pool's query_sync already uses 256KB.
This matches that size to avoid truncation when using the standalone
synchronous query functions for backfill.
2026-07-28 07:50:56 -04:00
Laan Tungir 024b490ac1 Add nostr_signer_derive_hmac() (HMAC-SHA256 via local + nsigner derive verb) and ttyUSB serial enumeration
Rescued from uncommitted work in sovereign_browser/nostr_core_lib:
- nostr_signer_derive_hmac(): deterministic MAC over caller data using the
  signer's secp256k1 private key. Local backend computes HMAC-SHA256 directly;
  remote nsigner backend calls the 'derive' verb (algorithm:'secp256k1').
- nsigner_transport_list_serial(): enumerate /dev/ttyUSB* (FTDI/CH340/CP210x/
  PL2303 USB-serial adapters) in addition to /dev/ttyACM* CDC-ACM devices.
- tests/nsigner_client_test.c: local derive_hmac reference-match test.
2026-07-28 06:45:05 -04:00
Laan Tungir 9240f44ea3 Release v0.6.10: n_signer qrexec transport, nostr_index selector, prefixed wire verbs, NIP-03 OTS upgrade 2026-07-28 06:31:59 -04:00
Laan Tungir 933cf03ce7 Migrate remote signer calls to prefixed n_signer verbs 2026-07-28 06:31:43 -04:00
Laan Tungir 27da465295 Fix qrexec transport reconnect: blocking waitpid for old child, sync nsigner_client.c with reconnect logic 2026-07-28 06:31:43 -04:00
Laan Tungir 6ebab823a8 Add qrexec transport, nostr_index selector, and index_not_allowed error code for n_signer client 2026-07-28 06:31:43 -04:00
Laan Tungir a3337e5207 Add nostr_bip39_get_wordlist() public accessor for BIP-39 wordlist 2026-07-28 06:31:43 -04:00
Laan Tungir 932c770f6f Fix NIP-03 timestamp upgrade: tree-walk pending attestations, correct PREPEND op composition, and verify Bitcoin attestation completion 2026-07-28 06:31:43 -04:00
Laan Tungir be3a32b488 Fix NIP-03 OpenTimestamps parsing, multi-calendar proofs, upgrades, tests, and CLI tooling 2026-07-28 06:31:43 -04:00
Laan Tungir 3236e02f41 chore: stop tracking compiled test binaries with missing blobs (tests/nip03_live_test, websocket_debug) 2026-07-28 06:31:32 -04:00
Laan Tungir b51bcb4943 Migrated n_signer verb names to nostr_ prefix 2026-07-20 18:34:00 -04:00
Laan Tungir af06f23939 Fix NIP-59 dynamic buffer sizing for NIP-17 gift wraps 2026-04-11 15:53:44 -04:00
Laan Tungir fc337cf921 Implemented cooldown period in relay connection to prevent flapping 2026-04-10 06:13:02 -04:00
Laan Tungir f478a780d7 Add per-relay EOSE timeout fallback and robust subscription EOSE completion 2026-04-07 07:41:50 -04:00
laantungir 2e7eacc02e Update README checklist with not-applicable NIP markers and legend 2026-03-22 11:53:37 -04:00
laantungir ec8eb5555b Implement and validate NIP-03 live OpenTimestamps flow with HTTP/base64 fixes 2026-03-22 11:50:19 -04:00
Your Name a3a68f0fde added blossom client functionality. Unified curl 2026-03-21 20:40:25 -04:00
Your Name 2fe36acde4 cashu token fixed 2026-03-21 09:14:02 -04:00
laantungir f470759b96 Fix cashuB byte-string token encoding and add live testnut redeem-regenerate cashuB integration coverage 2026-03-21 07:59:49 -04:00
laantungir fb3c9dbc76 Fix NUT-00 hash_to_curve domain separator and expand live NIP-60 swap roundtrip diagnostics/tests 2026-03-20 19:18:25 -04:00
laantungir 303013a518 Fix Cashu hash_to_curve to NUT-00 spec and align live helper for send-proof compatibility 2026-03-20 15:30:09 -04:00
laantungir f7e179dd85 Confirm live testnut-based outbound token generation test run and documentation update 2026-03-20 11:26:07 -04:00
laantungir a3f7a1bbfd Add cashu_encode_token with cashuA/cashuB formats and live encode-decode validation 2026-03-20 10:59:13 -04:00
laantungir a595747aff Add Cashu keyset endpoints support and per-amount unblinding with live checkstate validation 2026-03-20 10:32:43 -04:00
laantungir 39ebfcd90a Add live NIP-60 Cashu receive integration test using nofee.testnut mint 2026-03-20 10:23:21 -04:00
Your Name 63972d974d Preserve Cashu mint error JSON on non-2xx responses for downstream diagnostics 2026-03-20 09:48:03 -04:00
Your Name 13fd364ca3 Add Cashu blinding helpers and secp256k1 point ops 2026-03-19 18:45:17 -04:00
Your Name cb4ff93906 Add Cashu token decode support for cashuA and cashuB 2026-03-19 18:19:45 -04:00
Your Name 4d0d794a9a Added cashu functionality. 2026-03-19 14:52:03 -04:00
Your Name ae672b7047 Added cashu functionality. 2026-03-19 14:32:14 -04:00
Your Name 0a8a813fcf Added cashu functionality. 2026-03-19 14:30:44 -04:00
Your Name ea40aec6b8 Added cashu functionality. 2026-03-19 14:25:53 -04:00
laantungir 98cfd81b01 Release v0.5.0 2026-03-19 09:13:59 -04:00
laantungir d8d3f9b28c just want to increment 2026-03-19 09:09:59 -04:00
laantungir 669793dd67 just want to increment 2026-03-19 09:09:46 -04:00
laantungir e21c8eb5be nip60 2026-03-19 09:01:11 -04:00
Your Name 20006df228 fix relay pool sync query repeat behavior and add regression test 2026-03-16 05:27:23 -04:00
Your Name adc7aa9dcf Delegate nostr_core_lib logging via callback and integrate single-file didactyl logging 2026-03-13 13:57:20 -04:00
Your Name 1a549afa19 Various changes 2026-03-05 15:18:44 -04:00
Your Name 6ee62e6575 Add relay state transition cause capture in poll loop 2026-03-05 15:18:13 -04:00
Your Name 5afe802e8f Fix oversized ws frame handling and increase receive buffers 2026-03-05 14:42:14 -04:00
Your Name e77973aea0 query_sync: forward non-matching relay messages to pool dispatch 2026-03-05 14:07:11 -04:00
Your Name ea84795911 relay_pool: skip reconnect attempts in publish_async 2026-03-05 11:01:21 -04:00
Your Name 481bf3158d Add socket recv/send timeouts after connect to prevent websocket poll hangs on half-broken connections 2026-03-05 10:39:51 -04:00
laantungir 23e68bdc83 Add NIP-42 auth support to relay pool with verbose auth diagnostics test and docs updates 2026-03-01 08:49:55 -04:00
laantungir 4dc753cdcc Implement NIP-46 remote signing API, tests/example, build integration, and refresh README docs 2026-02-28 09:53:35 -04:00
Your Name 64b7c7ec33 Fix SSL_pending busy-wait causing 100% CPU usage
The tls_recv() function was skipping the select() call when SSL_pending()
returned non-zero, causing a tight busy-wait loop. This fix ensures select()
is always called, using a zero timeout when SSL has buffered data to return
immediately, or the full timeout to properly block when waiting for new data.

This prevents the relay client from consuming 100% CPU while maintaining
the WebSocket connection.
2026-02-03 14:16:00 -04:00
laantungir f3068f82f3 Rollback of nip44 changes, and added ability to modify timestamps in giftwraps. 2025-10-27 13:16:06 -04:00
Your Name a8dc2ed046 Add configurable timestamp randomization for NIP-59 gift wraps 2025-10-27 12:57:25 -04:00
laantungir 9a3965243c Revert NIP-44 to spec compliance (65535 bytes), keep NIP-04 at 1MB 2025-10-27 12:51:50 -04:00
laantungir 23c2a58c2b Upgrade nip4 and nip44 to be able to handle 1MB payloads. 2025-10-24 18:56:30 -04:00
laantungir 45fb6d061d Adding async publish to relay pool 2025-10-09 09:19:11 -04:00
laantungir c0784fc890 added nip 17 2025-10-04 18:32:28 -04:00
laantungir 499accf440 Implement NIP-21: nostr: URI scheme with full support for note, nprofile, nevent, and naddr URIs including TLV encoding/decoding and comprehensive test suite 2025-10-03 06:10:56 -04:00
laantungir 6b95ad37c5 nip 17, and 59 2025-10-03 04:25:10 -04:00
laantungir 54a6044083 Add enhanced subscription functionality with EOSE result modes 2025-10-02 15:00:50 -04:00
laantungir 0f897ab1b3 Getting the relay pool up to speed 2025-10-02 11:51:41 -04:00
laantungir 0d910ca181 Updated synchronous relay queries to handle nip42. 2025-09-30 12:16:23 -04:00
laantungir 9a63550863 Merge branch 'master' of ssh://git.laantungir.net:222/laantungir/nostr_core_lib
Working on Ginxsom auth and NIP 42 on a different computer at the same
time. My bad.
2025-09-07 13:07:02 -04:00
laantungir eb7a9e6098 Add NIP-42 implementation and local updates
- Added NIP-42 authentication implementation (nip042.c, nip042.h)
- Added NIP-42 test suite (nip42_test.c, nip42_test)
- Updated common core files for NIP-42 support
- Updated build script
- Rebuilt test binaries
2025-09-07 13:04:53 -04:00
Your Name 8585e7649c Add unified request validation system with authentication rules
- Add request_validator.h/c with comprehensive authentication system
- Implement pluggable database backend interface (SQLite default)
- Add priority-based rule evaluation engine with caching
- Support pubkey whitelist/blacklist, hash blacklist, MIME restrictions
- Add new authentication error codes to nostr_common.h
- Include request_validator.h in nostr_core.h
- Update build.sh to compile request_validator.c
- Designed for shared use between ginxsom and c-relay projects
2025-09-07 09:44:38 -04:00
laantungir 55e2a9c68e nip13 validation added 2025-09-05 13:42:03 -04:00
laantungir 445ab7a8f4 readme.md 2025-09-03 15:16:08 -04:00
laantungir 33129d82fd remove exposed .h crypto headers 2025-09-02 12:36:52 -04:00
laantungir c0d095e57b Streaming sha256 2025-08-19 11:24:48 -04:00
laantungir e40f3037d3 version 2025-08-19 07:02:42 -04:00
laantungir 77d92dbcf9 Nostr note validation added to nip01 2025-08-19 06:59:04 -04:00
laantungir 1da4f6751e clean up 2025-08-17 14:14:52 -04:00
laantungir 3ebfdc06c0 Fixed bug in nip44.c, was an error in ecdh_shared_secret. Added comments 2025-08-17 11:29:07 -04:00
laantungir d8b342ca3f Fixed error in nip04 implementation. Now working 2025-08-17 10:42:38 -04:00
laantungir df23fd618a comparison test for debugging 2025-08-16 17:48:02 -04:00
laantungir 19452f45c2 remove secp256 from project 2025-08-16 14:09:26 -04:00
laantungir 711a7cc15c feat: migrate to system dependencies from static linking
BREAKING CHANGE: Library now requires system-installed dependencies

Major Changes:
- Convert secp256k1 from bundled static lib to system dependency
- Convert OpenSSL from bundled static lib to system dependency
- Convert curl from bundled static lib to system dependency
- Update build.sh with pkg-config detection and fallback logic
- Remove all static library extraction/building logic
- Update README.md with new dependency requirements and installation

Build System:
- Add detect_system_secp256k1() with pkg-config support
- Add detect_system_openssl() with pkg-config support
- Add detect_system_curl() with pkg-config support
- Remove secp256k1 building/extraction from ar archive
- Update CFLAGS and LIBS to use system library variables
- Clear error messages for missing dependencies with install commands

Documentation:
- Add system dependency installation for Ubuntu/Debian/CentOS/macOS
- Update all compile/link examples to include -lssl -lcrypto -lcurl -lsecp256k1
- Remove references to 'self-contained' and 'no external dependencies'
- Update integration examples throughout README

Benefits:
- Smaller library size (only internal code bundled)
- Automatic security updates via system package manager
- Standard Linux library distribution pattern
- Reduced build complexity
- Better system integration with pkg-config

Required Installation:
Ubuntu/Debian: sudo apt install libssl-dev libcurl4-openssl-dev libsecp256k1-dev
CentOS/RHEL: sudo yum install openssl-devel libcurl-devel libsecp256k1-devel
macOS: brew install openssl curl secp256k1
2025-08-16 13:59:29 -04:00
laantungir 58cabadc44 un-nest curl 2025-08-16 11:22:44 -04:00
laantungir 77186c88dd secp256k1 2025-08-16 10:48:58 -04:00
laantungir 2036d0165b Add in secp256k repo so that customer can build. 2025-08-16 10:39:49 -04:00
laantungir 40dd3aa20b Updated build.sh to build curl, openssl, and 256k1 if needed 2025-08-16 10:26:39 -04:00
laantungir 00df0cad99 Simplify build script directory validation
- Replace file-based validation with directory name check
- Now simply checks if current directory is named 'nostr_core_lib'
- More reliable and clearer error messages for customers
- Fixes issue where customers get validation errors when running from properly named directories
2025-08-16 09:45:27 -04:00
laantungir 05fe1df8aa Update library usage documentation 2025-08-16 09:36:39 -04:00
laantungir 98a802552b Fix build script path resolution for customer Makefile usage
- Added BUILD_DIR=/home/teknari/Sync/Programming/VibeCoding/nostr_core_lib to capture absolute build directory
- Changed relative paths to absolute paths in archive extraction
- Fixes 'No such file or directory' error when build.sh is called from customer Makefiles
- Maintains backward compatibility for all existing use cases
2025-08-16 09:34:57 -04:00
laantungir 9fd4c61df7 Working in the mines 2025-08-16 08:51:04 -04:00
laantungir 76e883fad4 Refactor and consolidate test suite
- Moved old tests from tests/old/ to main tests/ directory
- Renamed nostr_test_bip32.c to bip32_test.c for consistency
- Renamed nostr_crypto_test.c to crypto_test.c for consistency
- Renamed wss_test.c and moved from old directory
- Fixed unused variable warning in bip32_test.c
- Updated build system and workspace rules
- Cleaned up old compiled test executables
- Updated nostr_common.h and core_relays.c
- Removed obsolete nostr_core.h.old backup file

This consolidates all active tests into the main directory and removes
outdated test files while maintaining a clean, organized structure.
2025-08-16 08:38:41 -04:00
laantungir c3a9482882 Completed refactoring to separate nip files, and updating build.sh 2025-08-16 07:42:48 -04:00
laantungir 8ed9262c65 Last version before deleting Makefile and CmakeLists.txt 2025-08-15 16:32:59 -04:00
laantungir 6014a250dd Final fix for curl callback function signature - use proper void* types 2025-08-15 09:14:53 -04:00
laantungir f50384962d Fixed curl type warnings - callback function signature and timeout parameter casting 2025-08-15 09:12:55 -04:00
laantungir c569c0c346 Improved POW 2025-08-15 07:47:16 -04:00
laantungir 3d2537603c . 2025-08-14 19:15:55 -04:00
laantungir d6a0bd67b2 . 2025-08-14 18:30:16 -04:00
laantungir 9191d446d3 version 2025-08-14 17:52:45 -04:00
laantungir f1c22bdf53 Add automatic dependency building to Makefile
- Add secp256k1 auto-building rule for x64 target
- Fix customer build errors with missing secp256k1/.libs/libsecp256k1.a
- Force clean rebuild when secp256k1 library is missing
- Customers can now run 'make' directly without manual dependency building
- Maintains existing ARM64 cross-compilation auto-building functionality
2025-08-14 17:43:33 -04:00
laantungir 993ca0f2a1 . 2025-08-14 16:43:46 -04:00
laantungir 77fadc2683 Fix submodule compatibility: Remove version.c dependency and include cjson source files
- Remove nostr_core/version.c from Makefile LIB_SOURCES to fix submodule build failures
- Remove cjson/ from .gitignore and add cjson source files to repository
- Consolidate cJSON.h into cjson/ directory (remove duplicate from nostr_core/)
- Simplify build.sh versioning to only manage git tags and VERSION file
- Update examples/version_test.c to work without version functions
- Consumer projects can now use 'make' directly without missing file errors
2025-08-14 16:40:34 -04:00
laantungir 2637378bf0 clean up versioning 2025-08-14 16:26:37 -04:00
laantungir c109c93382 Initial template structure from nostr_core_lib
- Complete C library template with OpenSSL-based crypto
- Comprehensive build system (Makefile, build.sh)
- Example code and test suite
- Documentation and usage guides
- Cross-platform compatibility (x64/ARM64)
- Production-ready structure for C library projects
2025-08-14 15:10:59 -04:00
laantungir 0ace93e303 Adding in curl and openssl repos 2025-08-14 12:09:30 -04:00
laantungir af2117b574 Complete mbedTLS cleanup - Removed all mbedTLS dependencies and updated documentation
- Moved mbedTLS directories to Trash/ (mbedtls/, mbedtls-install/, mbedtls-arm64-install/)
- Removed obsolete nostr_websocket_mbedtls.c implementation
- Updated nostr_websocket/Makefile to use OpenSSL instead of mbedTLS
- Updated nostr_websocket/README.md with OpenSSL migration notes
- Updated nostr_websocket/EXPORT_GUIDE.md with OpenSSL instructions
- All tests pass: crypto tests, static linking verification
- Build system fully functional with OpenSSL-only dependencies
2025-08-14 11:59:03 -04:00
laantungir 6d7b709f9a Pre-mbedTLS cleanup checkpoint - OpenSSL migration complete, all tests passing 2025-08-14 11:51:26 -04:00
laantungir 5a7c796873 Last commit before switching from mbedtls to openssl 2025-08-14 09:58:24 -04:00
laantungir 3aaa46bb9b cJSON.h added 2025-08-12 21:05:39 -04:00
laantungir d257ae49f1 Fully statically linked for both x64 and arm64. Updated build.sh to always compile both versions 2025-08-11 06:54:50 -04:00
laantungir ae4aa7cf80 added nostr_decode_npub 2025-08-09 11:40:34 -04:00
laantungir e137560d64 . 2025-08-09 11:07:11 -04:00
laantungir ca6b4754f9 First commit on a late git install 2025-08-09 10:23:28 -04:00
100 changed files with 412 additions and 1949 deletions
+1
View File
@@ -0,0 +1 @@
0.6.6
+1 -1
View File
@@ -1 +1 @@
0.6.8
0.6.11
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+14
View File
@@ -120,6 +120,20 @@ int nsigner_client_compute_body_hash_hex(const cJSON* params, char out_hash_hex[
#endif
```
### n_signer wire methods
The remote signer backend uses n_signer's role-based Nostr methods:
- `nostr_get_public_key`
- `nostr_sign_event`
- `nostr_nip04_encrypt` / `nostr_nip04_decrypt`
- `nostr_nip44_encrypt` / `nostr_nip44_decrypt`
These wire names are distinct from both the public `nostr_signer_*` C API and the
unprefixed NIP-46 method names. In particular, n_signer's unprefixed `get_public_key`
is algorithm-based; this library uses `nostr_get_public_key` because remote signer
factories select keys by `role` or `nostr_index`.
### Auth and framing notes
- Framing is 4-byte big-endian payload length + JSON payload.
+22 -4
View File
@@ -195,9 +195,10 @@ cJSON** synchronous_query_relays_with_progress(
continue;
}
// Try to receive message (short timeout to keep UI responsive)
char buffer[8192];
int len = nostr_ws_receive(relay->client, buffer, sizeof(buffer)-1, 50);
// Try to receive message (1000ms timeout to allow relay time
// to respond — matches nostr_relay_pool_query_sync behavior)
char buffer[262144];
int len = nostr_ws_receive(relay->client, buffer, sizeof(buffer)-1, 1000);
if (len > 0) {
buffer[len] = '\0';
@@ -322,6 +323,23 @@ cJSON** synchronous_query_relays_with_progress(
nostr_ws_close(relay->client);
relay->client = NULL;
}
} else if (msg_type && (strcmp(msg_type, "NOTICE") == 0 ||
strcmp(msg_type, "CLOSED") == 0)) {
/* Capture NOTICE and CLOSED messages from the relay.
* These often contain auth-required or restriction
* notices. Pass the message content to the callback. */
const char* notice_msg = "";
if (cJSON_IsArray(parsed) && cJSON_GetArraySize(parsed) >= 2) {
cJSON* msg_json = cJSON_GetArrayItem(parsed, 1);
if (msg_json && cJSON_IsString(msg_json)) {
notice_msg = cJSON_GetStringValue(msg_json);
}
}
if (callback) {
callback(relay->url, msg_type, notice_msg,
relay->events_received, relay_count,
completed_relays, user_data);
}
}
if (msg_type) free(msg_type);
@@ -580,7 +598,7 @@ publish_result_t* synchronous_publish_event_with_progress(
}
// Try to receive message (short timeout to keep UI responsive)
char buffer[8192];
char buffer[262144];
int len = nostr_ws_receive(relay->client, buffer, sizeof(buffer)-1, 50);
if (len > 0) {
+13 -2
View File
@@ -2,10 +2,10 @@
#define NOSTR_CORE_H
// Version information (auto-updated by increment_and_push.sh)
#define VERSION "v0.6.8"
#define VERSION "v0.6.11"
#define VERSION_MAJOR 0
#define VERSION_MINOR 6
#define VERSION_PATCH 8
#define VERSION_PATCH 11
/*
* NOSTR Core Library - Complete API Reference
@@ -304,6 +304,17 @@ cJSON** nostr_relay_pool_query_sync(
cJSON* filter,
int* event_count,
int timeout_ms);
// Same as above but also reports whether all relays sent EOSE (vs timed out).
// out_got_eose is set to 1 if all connected relays sent EOSE, 0 if any timed
// out. May be NULL if the caller doesn't care.
cJSON** nostr_relay_pool_query_sync_with_eose(
nostr_relay_pool_t* pool,
const char** relay_urls,
int relay_count,
cJSON* filter,
int* event_count,
int timeout_ms,
int* out_got_eose);
cJSON* nostr_relay_pool_get_event(
nostr_relay_pool_t* pool,
const char** relay_urls,
+113 -6
View File
@@ -284,6 +284,26 @@ static int signer_local_nip44_decrypt(nostr_signer_t* signer,
return NOSTR_SUCCESS;
}
static int signer_local_derive_hmac(nostr_signer_t* signer,
const char* data,
char out_digest_hex[65]) {
unsigned char mac[32];
if (!signer || !data || !out_digest_hex) {
return NOSTR_ERROR_INVALID_INPUT;
}
if (nostr_hmac_sha256(signer->u.local.private_key, 32,
(const unsigned char*)data, strlen(data),
mac) != 0) {
return NOSTR_ERROR_CRYPTO_FAILED;
}
nostr_bytes_to_hex(mac, 32, out_digest_hex);
memset(mac, 0, sizeof(mac));
return NOSTR_SUCCESS;
}
#if defined(NOSTR_ENABLE_NSIGNER_CLIENT)
static cJSON* signer_remote_params_with_selector(cJSON* params, const char* role, int has_nostr_index, int nostr_index) {
@@ -340,7 +360,7 @@ static int signer_remote_get_public_key(nostr_signer_t* signer, char out_pubkey_
return NOSTR_ERROR_MEMORY_FAILED;
}
rc = nsigner_client_call(signer->u.remote.client, "get_public_key", params, &result);
rc = nsigner_client_call(signer->u.remote.client, "nostr_get_public_key", params, &result);
if (rc != NOSTR_SUCCESS) {
return rc;
}
@@ -392,7 +412,7 @@ static int signer_remote_sign_event(nostr_signer_t* signer, const cJSON* unsigne
return NOSTR_ERROR_MEMORY_FAILED;
}
rc = nsigner_client_call(signer->u.remote.client, "sign_event", params, &result);
rc = nsigner_client_call(signer->u.remote.client, "nostr_sign_event", params, &result);
if (rc != NOSTR_SUCCESS) {
return rc;
}
@@ -481,28 +501,96 @@ static int signer_remote_nip04_encrypt(nostr_signer_t* signer,
const char* peer_pubkey_hex,
const char* plaintext,
char** ciphertext_out) {
return signer_remote_encrypt_decrypt(signer, "nip04_encrypt", peer_pubkey_hex, plaintext, ciphertext_out);
return signer_remote_encrypt_decrypt(signer, "nostr_nip04_encrypt", peer_pubkey_hex, plaintext, ciphertext_out);
}
static int signer_remote_nip04_decrypt(nostr_signer_t* signer,
const char* peer_pubkey_hex,
const char* ciphertext,
char** plaintext_out) {
return signer_remote_encrypt_decrypt(signer, "nip04_decrypt", peer_pubkey_hex, ciphertext, plaintext_out);
return signer_remote_encrypt_decrypt(signer, "nostr_nip04_decrypt", peer_pubkey_hex, ciphertext, plaintext_out);
}
static int signer_remote_nip44_encrypt(nostr_signer_t* signer,
const char* peer_pubkey_hex,
const char* plaintext,
char** ciphertext_out) {
return signer_remote_encrypt_decrypt(signer, "nip44_encrypt", peer_pubkey_hex, plaintext, ciphertext_out);
return signer_remote_encrypt_decrypt(signer, "nostr_nip44_encrypt", peer_pubkey_hex, plaintext, ciphertext_out);
}
static int signer_remote_nip44_decrypt(nostr_signer_t* signer,
const char* peer_pubkey_hex,
const char* ciphertext,
char** plaintext_out) {
return signer_remote_encrypt_decrypt(signer, "nip44_decrypt", peer_pubkey_hex, ciphertext, plaintext_out);
return signer_remote_encrypt_decrypt(signer, "nostr_nip44_decrypt", peer_pubkey_hex, ciphertext, plaintext_out);
}
static int signer_remote_derive_hmac(nostr_signer_t* signer,
const char* data,
char out_digest_hex[65]) {
cJSON* params;
cJSON* opts = NULL;
cJSON* result = NULL;
cJSON* parsed = NULL;
cJSON* digest_item = NULL;
const char* digest_str = NULL;
int rc;
if (!signer || !data || !out_digest_hex) {
return NOSTR_ERROR_INVALID_INPUT;
}
params = cJSON_CreateArray();
if (params == NULL) {
return NOSTR_ERROR_MEMORY_FAILED;
}
cJSON_AddItemToArray(params, cJSON_CreateString(data));
/* Build the options object with algorithm:"secp256k1" and the selector
* (role or nostr_index). The derive verb requires index, so when
* has_nostr_index is set we include it; otherwise we include role (the
* nsigner derive handler requires index, so callers using the remote
* backend must set nostr_index via nostr_signer_nsigner_set_nostr_index
* before calling derive_hmac). */
opts = cJSON_CreateObject();
if (opts == NULL) {
cJSON_Delete(params);
return NOSTR_ERROR_MEMORY_FAILED;
}
cJSON_AddStringToObject(opts, "algorithm", "secp256k1");
if (signer->u.remote.has_nostr_index) {
cJSON_AddNumberToObject(opts, "index", signer->u.remote.nostr_index);
} else if (signer->u.remote.role[0] != '\0') {
cJSON_AddStringToObject(opts, "role", signer->u.remote.role);
}
cJSON_AddItemToArray(params, opts);
rc = nsigner_client_call(signer->u.remote.client, "derive", params, &result);
if (rc != NOSTR_SUCCESS) {
return rc;
}
/* result is a JSON string: {"algorithm":"secp256k1","key_id":"...","digest":"<64hex>"} */
if (!cJSON_IsString(result) || result->valuestring == NULL) {
cJSON_Delete(result);
return NOSTR_ERROR_NIP46_INVALID_RESPONSE;
}
parsed = cJSON_Parse(result->valuestring);
cJSON_Delete(result);
if (parsed == NULL) {
return NOSTR_ERROR_NIP46_INVALID_RESPONSE;
}
digest_item = cJSON_GetObjectItemCaseSensitive(parsed, "digest");
if (!cJSON_IsString(digest_item) || digest_item->valuestring == NULL ||
strlen(digest_item->valuestring) != 64) {
cJSON_Delete(parsed);
return NOSTR_ERROR_NIP46_INVALID_RESPONSE;
}
digest_str = digest_item->valuestring;
memcpy(out_digest_hex, digest_str, 64);
out_digest_hex[64] = '\0';
cJSON_Delete(parsed);
return NOSTR_SUCCESS;
}
#endif /* NOSTR_ENABLE_NSIGNER_CLIENT */
@@ -659,6 +747,25 @@ int nostr_signer_nip44_decrypt(nostr_signer_t* signer,
return NOSTR_ERROR_INVALID_INPUT;
}
int nostr_signer_derive_hmac(nostr_signer_t* signer,
const char* data,
char out_digest_hex[65]) {
if (!signer || !data || !out_digest_hex) {
return NOSTR_ERROR_INVALID_INPUT;
}
if (signer->backend == NOSTR_SIGNER_BACKEND_LOCAL) {
return signer_local_derive_hmac(signer, data, out_digest_hex);
}
#if defined(NOSTR_ENABLE_NSIGNER_CLIENT)
if (signer->backend == NOSTR_SIGNER_BACKEND_NSIGNER_REMOTE) {
return signer_remote_derive_hmac(signer, data, out_digest_hex);
}
#endif
return NOSTR_ERROR_INVALID_INPUT;
}
#if defined(NOSTR_ENABLE_NSIGNER_CLIENT)
static nostr_signer_t* nostr_signer_nsigner_from_transport(nsigner_transport_t* transport, const char* role) {
nsigner_client_t* client = NULL;
+10
View File
@@ -19,6 +19,16 @@ void nostr_signer_free(nostr_signer_t* signer);
int nostr_signer_get_public_key(nostr_signer_t* signer, char out_pubkey_hex[65]);
int nostr_signer_sign_event(nostr_signer_t* signer, const cJSON* unsigned_event, cJSON** signed_event_out);
/* Derive a deterministic MAC over caller-supplied data using the signer's
* secp256k1 private key: out = HMAC-SHA256(privkey, data).
* data is a NUL-terminated UTF-8 string. out_digest_hex receives 64 lowercase
* hex chars + NUL. For the local backend this computes directly; for the
* nsigner remote backend it calls the "derive" verb (algorithm:"secp256k1").
* Returns NOSTR_SUCCESS or an error code. */
int nostr_signer_derive_hmac(nostr_signer_t* signer,
const char* data,
char out_digest_hex[65]);
/* Encryption verbs (for parity with upcoming remote backends) */
int nostr_signer_nip04_encrypt(nostr_signer_t* signer,
const char* peer_pubkey_hex,
+13 -1
View File
@@ -1021,8 +1021,20 @@ int nsigner_transport_list_serial(char paths[][64], int max_paths) {
while ((ent = readdir(dir)) != NULL) {
int n;
int is_serial = 0;
if (strncmp(ent->d_name, "ttyACM", 6) != 0) {
/* USB CDC-ACM devices (e.g. n_signer firmware using TinyUSB CDC). */
if (strncmp(ent->d_name, "ttyACM", 6) == 0) {
is_serial = 1;
}
/* USB-serial adapters (FTDI / CH340 / CP210x / PL2303). These show up
* as /dev/ttyUSB* and speak the same 115200 8N1 framing as CDC-ACM,
* so they are valid n_signer serial transports too. */
if (strncmp(ent->d_name, "ttyUSB", 6) == 0) {
is_serial = 1;
}
if (!is_serial) {
continue;
}
+44 -9
View File
@@ -57,6 +57,15 @@ typedef struct {
SSL_CTX* ssl_ctx;
SSL* ssl;
int ssl_connected;
/* Internal read buffer: SSL_read may return more bytes than the
* caller requested (a full TLS record at once). Without buffering
* the excess, those bytes are lost — which breaks ws_receive_frame
* when it asks for a 2-byte header but SSL_read returns a full
* event message. This caused the caching backfill to only receive
* 1 event per query from TLS relays. */
char read_buf[65536];
size_t read_buf_len; /* total bytes in read_buf */
size_t read_buf_pos; /* offset of next byte to consume */
} tls_transport_t;
// WebSocket client structure
@@ -708,10 +717,27 @@ static int tls_recv(void* ctx, void* data, size_t len, int timeout_ms) {
if (!tls->ssl_connected || !tls->ssl) {
return -1;
}
// Always use select() to ensure proper blocking behavior
// If SSL has pending data, use zero timeout to return immediately
// Otherwise use the full timeout to block until data arrives
/* Serve from the internal read buffer first. SSL_read may have
* returned more bytes than the caller requested on a previous call
* (a full TLS record), and we buffered the excess. Without this,
* ws_receive_frame loses the extra bytes when it asks for a 2-byte
* header but SSL_read returns a full event message. */
if (tls->read_buf_pos < tls->read_buf_len) {
size_t avail = tls->read_buf_len - tls->read_buf_pos;
size_t to_copy = (avail < len) ? avail : len;
memcpy(data, tls->read_buf + tls->read_buf_pos, to_copy);
tls->read_buf_pos += to_copy;
if (tls->read_buf_pos >= tls->read_buf_len) {
tls->read_buf_len = 0;
tls->read_buf_pos = 0;
}
return (int)to_copy;
}
/* Buffer is empty — refill it with a single SSL_read, then serve
* the requested bytes from it. This ensures excess bytes are
* preserved for subsequent tls_recv calls. */
if (timeout_ms > 0) {
fd_set readfds;
struct timeval tv;
@@ -719,7 +745,6 @@ static int tls_recv(void* ctx, void* data, size_t len, int timeout_ms) {
FD_ZERO(&readfds);
FD_SET(tls->socket_fd, &readfds);
// If SSL has buffered data, use zero timeout; otherwise use full timeout
if (SSL_pending(tls->ssl) > 0) {
tv.tv_sec = 0;
tv.tv_usec = 0;
@@ -741,16 +766,26 @@ static int tls_recv(void* ctx, void* data, size_t len, int timeout_ms) {
const int max_attempts = 10;
while (attempts < max_attempts) {
int ret = SSL_read(tls->ssl, data, len);
/* Read into the internal buffer (up to its capacity), then copy
* the requested number of bytes to the caller's output. */
int ret = SSL_read(tls->ssl, tls->read_buf, sizeof(tls->read_buf));
if (ret > 0) {
return ret; // Success
tls->read_buf_len = (size_t)ret;
tls->read_buf_pos = 0;
size_t to_copy = (tls->read_buf_len < len) ? tls->read_buf_len : len;
memcpy(data, tls->read_buf, to_copy);
tls->read_buf_pos = to_copy;
if (tls->read_buf_pos >= tls->read_buf_len) {
tls->read_buf_len = 0;
tls->read_buf_pos = 0;
}
return (int)to_copy;
}
int err = SSL_get_error(tls->ssl, ret);
if (err == SSL_ERROR_WANT_READ) {
// Check if more data is available on socket
fd_set readfds;
struct timeval tv = {0, 100000}; // 100ms timeout
@@ -763,7 +798,7 @@ static int tls_recv(void* ctx, void* data, size_t len, int timeout_ms) {
}
attempts++;
continue; // Retry the SSL read
continue;
} else if (err == SSL_ERROR_WANT_WRITE) {
return -1;
+106
View File
@@ -0,0 +1,106 @@
# Plan: n_signer Verb Name Migration for nostr_core_lib
## Context
`n_signer` has completed a verb-name migration (see [`n_signer/plans/legacy_verb_aliases.md`](../../n_signer/plans/legacy_verb_aliases.md)). The legacy verb names are gone from the n_signer wire protocol. This document covers the fixes needed in `nostr_core_lib` — the shared C client library that many other projects vendor.
**Reference:** the new n_signer API is documented in [`n_signer/README.md`](../../n_signer/README.md) §4 (API).
## What changed in n_signer
The Nostr protocol verbs gained a `nostr_` prefix. The algorithm-based verbs (`sign`, `verify`, `encapsulate`, `decapsulate`, `derive_shared_secret`, `get_public_key`) are unchanged. The old alias verbs (`sign_data`, `ssh_sign`, `verify_signature`, `kem_encapsulate`, `kem_decapsulate`, `otp_encrypt`, `otp_decrypt`) are gone.
| Legacy n_signer verb | New n_signer verb |
|----------------------|-------------------|
| `sign_event` | `nostr_sign_event` |
| `mine_event` | `nostr_mine_event` |
| `nip04_encrypt` | `nostr_nip04_encrypt` |
| `nip04_decrypt` | `nostr_nip04_decrypt` |
| `nip44_encrypt` | `nostr_nip44_encrypt` |
| `nip44_decrypt` | `nostr_nip44_decrypt` |
| `get_public_key` (role-based) | `nostr_get_public_key` |
**Important distinction:** `get_public_key` is now **algorithm-based** (takes `algorithm`+`index`). The role-based Nostr pubkey verb is `nostr_get_public_key` (takes `nostr_index`/`role`). Since `nostr_core_lib`'s remote signer always uses role-based selectors (`nostr_index`/`role`), the correct replacement is `nostr_get_public_key`.
## What does NOT change
- **NIP-46 standard method names** in [`nostr_core/nip046.c`](../nostr_core/nip046.c) — the strings `"sign_event"`, `"get_public_key"`, `"nip04_encrypt"`, `"nip44_encrypt"`, etc. at lines 111-131 are the **NIP-46 wire protocol** (the standard that relays and other bunkers speak). These must stay as-is. They are NOT n_signer verbs.
- **High-level C API function names** in [`nostr_core/nostr_signer.h`](../nostr_core/nostr_signer.h) — `nostr_signer_get_public_key()`, `nostr_signer_sign_event()`, `nostr_signer_nip04_encrypt()`, etc. are the nostr_core_lib's own API surface. These names are fine — they're C function names, not wire verbs. Renaming them would break every consumer for no protocol reason.
- **The `nostr_signer_local` backend** — local signing doesn't call n_signer at all; it uses libsecp256k1 directly. No changes needed.
## Files to change
### 1. `nostr_core/nostr_signer.c` — the remote signer backend
This is the only file that calls n_signer verbs via `nsigner_client_call()`. All calls use role-based selectors (`nostr_index`/`role`), so all map to the `nostr_*` verbs.
| Line | Current verb string | New verb string |
|------|---------------------|-----------------|
| 343 | `"get_public_key"` | `"nostr_get_public_key"` |
| 395 | `"sign_event"` | `"nostr_sign_event"` |
| 484 | `"nip04_encrypt"` | `"nostr_nip04_encrypt"` |
| 491 | `"nip04_decrypt"` | `"nostr_nip04_decrypt"` |
| 498 | `"nip44_encrypt"` | `"nostr_nip44_encrypt"` |
| 505 | `"nip44_decrypt"` | `"nostr_nip44_decrypt"` |
These are simple string-literal replacements. The `signer_remote_params_with_selector()` function (line 289) builds `{"nostr_index": N}` or `{"role": "..."}` selectors — these are still valid for the `nostr_*` verbs, so no selector changes needed.
**Response format note:** `nostr_get_public_key` returns a plain 64-hex-char string by default (same as the old role-based `get_public_key`). The existing parsing at line 348 (`strlen(result->valuestring) != 64`) continues to work. If the caller ever passes `{"format":"structured"}`, the response would be a JSON object string — but the current code doesn't request structured format, so no change needed.
### 2. `tests/nsigner_client_test.c` — the mock client test
| Line | Current verb string | New verb string |
|------|---------------------|-----------------|
| 296 | `"get_public_key"` | `"nostr_get_public_key"` |
This test uses a mock transport (fds pair) that returns a canned response — it doesn't actually call n_signer. The verb string just needs to match what the real client would send. Update it for consistency.
### 3. `nostr_core/NSIGNER_INTEGRATION.md` — integration doc
This doc references the high-level C API function names (`nostr_signer_get_public_key`, `nostr_signer_sign_event`, etc.) which are NOT changing. However, if it documents the underlying n_signer wire verbs anywhere, those references should be updated to the `nostr_*` names. Scan for any wire-verb documentation and update.
### 4. `plans/nsigner_integration_plan.md` — historical plan
This is a historical planning doc. Update any wire-verb references for accuracy, or add a note pointing to this migration plan.
## Files that do NOT need changes
- `nostr_core/nip046.c` — NIP-46 standard method names (stay as-is, see above).
- `nostr_core/nsigner_client.c` — generic transport/client, doesn't hardcode verb names.
- `nostr_core/nsigner_transport.c` — transport layer, no verb names.
- `nostr_core/nostr_signer.h` — high-level API declarations (function names stay).
- `tests/signer_modules_test.c` — tests the local signer, not n_signer verbs.
- `tests/nip01_test.c` — NIP-01 tests, no n_signer verb calls.
## Verification
1. `grep -rn '"sign_event"\|"nip04_encrypt"\|"nip04_decrypt"\|"nip44_encrypt"\|"nip44_decrypt"\|"mine_event"\|"sign_data"\|"ssh_sign"\|"verify_signature"\|"kem_encapsulate"\|"kem_decapsulate"\|"otp_encrypt"\|"otp_decrypt"' nostr_core/nostr_signer.c` returns no matches.
2. `grep -rn '"get_public_key"' nostr_core/nostr_signer.c` returns no matches (replaced by `nostr_get_public_key`).
3. `grep -rn '"sign_event"\|"nip04_encrypt"\|"nip44_encrypt"' nostr_core/nip046.c` still returns matches (NIP-46 standard names — these stay).
4. Build clean: `bash build.sh` or the project's build target.
5. Tests pass: `./build/nsigner_client_test` (or equivalent).
## Downstream consumers (inherit the fix)
Once `nostr_core_lib` is updated, these projects that vendor it will pick up the fix when they update their vendored copy:
- `sovereign_browser/nostr_core_lib/`
- `didactyl/nostr_core_lib/`
- `fips/nostr_core_lib/`
- `fips_access_point/` (if it vendors nostr_core_lib)
- `screen_capture/nostr_core_lib/`
- `n_os_tr/includes/nostr_core_lib/` and `n_os_tr/includes/didactyl/nostr_core_lib/`
Each downstream project should update its vendored `nostr_core/nostr_signer.c` with the same 6 string-literal changes. The `nip046.c` file in each vendored copy should NOT be changed (NIP-46 standard names).
## Projects with their own n_signer clients (separate fixes)
These projects have their own n_signer client code (not vendored from nostr_core_lib) and need separate fixes:
- **`nostr_terminal/src/nsigner_client.c`** — many call sites (lines 1054-1452): `"get_public_key"``"nostr_get_public_key"`, `"sign_event"``"nostr_sign_event"`, `"nip04_encrypt"``"nostr_nip04_encrypt"`, `"nip44_encrypt"``"nostr_nip44_encrypt"`. Also vendored into `n_os_tr/includes/nostr_terminal/`.
- **`codium_nostr_extension/src/signer/nsignerBackend.ts`** — `"get_public_key"` (line 65)→`"nostr_get_public_key"`, `"sign_event"` (line 76)→`"nostr_sign_event"`.
- **`nostr_push/nostr_push`** (bash script) — `"sign_event"` (line 394)→`"nostr_sign_event"`, `"get_public_key"``"nostr_get_public_key"`.
- **`laantungir_website/scripts/get_nsigner_pubkey.js`** — `"get_public_key"` (line 68)→`"nostr_get_public_key"`.
- **`laantungir_website/scripts/publish_nostr.js`** — `"get_public_key"` (line 102)→`"nostr_get_public_key"`, `"sign_event"` (line 112)→`"nostr_sign_event"`.
- **`sovereign_browser/src/nostr_bridge.c`** — `"nip04_encrypt"` (line 4525)→`"nostr_nip04_encrypt"`, `"nip44_encrypt"` (line 4529)→`"nostr_nip44_encrypt"`.
- **`nostr_login_lite`** — check `src/signers/nsigner-webserial.js`, `nsigner-webusb.js`, and the built `www/` bundle for verb calls.
+9 -1
View File
@@ -3,6 +3,14 @@
> Status: M1M6 implemented. This plan remains as architecture history; for current usage/integration contract see:
> - `README.md` → "Signer abstraction & nsigner integration"
> - `nostr_core/NSIGNER_INTEGRATION.md`
> - `plans/n_signer_verb_migration.md` for the completed Nostr wire-method prefix migration
>
> **Wire-method update:** n_signer's role-based Nostr methods are now
> `nostr_get_public_key`, `nostr_sign_event`, `nostr_nip04_encrypt`,
> `nostr_nip04_decrypt`, `nostr_nip44_encrypt`, and `nostr_nip44_decrypt`.
> The unprefixed `get_public_key` method is algorithm-based and is not used by the
> role/`nostr_index` selectors in this library. Public `nostr_signer_*` C API names
> and standard NIP-46 method names are unchanged.
>
> This plan originally described pulling the **caller-side** signer-integration glue out of per-project implementations and into `nostr_core_lib`,
> so any project that already links the library can sign **locally**, via a **running
@@ -15,7 +23,7 @@ re-implement the *same* caller-side integration with n_signer:
- 4-byte big-endian length-prefixed framing
- kind-27235 auth envelope (`nsigner_rpc` / `nsigner_method` / `nsigner_body_hash`)
- the JSON-RPC verbs (`get_public_key`, `sign_event`, `nip04_*`, `nip44_*`)
- the JSON-RPC methods (`nostr_get_public_key`, `nostr_sign_event`, `nostr_nip04_*`, `nostr_nip44_*`)
- a per-project `signer.h` abstraction wrapping local-vs-remote signing
Meanwhile, `nostr_core_lib` exposes ~30+ functions that take a raw
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+66 -4
View File
@@ -11,6 +11,7 @@
#include "../nostr_core/nsigner_client.h"
#include "../nostr_core/utils.h"
#include "../cjson/cJSON.h"
#include "../nostr_core/nostr_signer.h"
static int test_count = 0;
static int passed_count = 0;
@@ -44,7 +45,7 @@ static int write_full_fd(int fd, const unsigned char* buf, size_t len) {
static int test_framing_round_trip(void) {
int fds[2] = {-1, -1};
const char* msg = "{\"id\":\"1\",\"method\":\"get_public_key\",\"params\":[]}";
const char* msg = "{\"id\":\"1\",\"method\":\"nostr_get_public_key\",\"params\":[]}";
char* out = NULL;
size_t out_len = 0;
int ok = 0;
@@ -80,7 +81,7 @@ cleanup:
static int test_framing_fragmented_read_reassembly(void) {
int fds[2] = {-1, -1};
const char* msg = "{\"id\":\"2\",\"method\":\"sign_event\",\"params\":[\"abc\"]}";
const char* msg = "{\"id\":\"2\",\"method\":\"nostr_sign_event\",\"params\":[\"abc\"]}";
unsigned int len = (unsigned int)strlen(msg);
unsigned char hdr[4];
char* out = NULL;
@@ -250,7 +251,7 @@ static int test_fds_transport_round_trip_via_client(void) {
}
req[req_len] = '\0';
if (strstr(req, "\"method\":\"get_public_key\"") == NULL) {
if (strstr(req, "\"method\":\"nostr_get_public_key\"") == NULL) {
free(req);
_exit(6);
}
@@ -293,7 +294,7 @@ static int test_fds_transport_round_trip_via_client(void) {
goto cleanup;
}
if (nsigner_client_call(client, "get_public_key", params, &result) != NOSTR_SUCCESS) {
if (nsigner_client_call(client, "nostr_get_public_key", params, &result) != NOSTR_SUCCESS) {
params = NULL;
goto cleanup;
}
@@ -332,6 +333,66 @@ cleanup:
return ok;
}
/* Local-signer derive_hmac: HMAC-SHA256(privkey, data) via the high-level API
* must match nostr_hmac_sha256 computed directly with the same privkey. */
static int test_local_derive_hmac_matches_reference(void) {
unsigned char privkey[32];
nostr_signer_t* signer = NULL;
char got_hex[65];
unsigned char ref_mac[32];
char ref_hex[65];
int ok = 0;
int i;
for (i = 0; i < 32; i++) {
privkey[i] = (unsigned char)(i + 1);
}
signer = nostr_signer_local(privkey);
if (signer == NULL) {
return 0;
}
if (nostr_signer_derive_hmac(signer, "sovereign-browser/bookmarks-folder-id-v1:Work/Projects", got_hex) != NOSTR_SUCCESS) {
nostr_signer_free(signer);
return 0;
}
if (nostr_hmac_sha256(privkey, 32,
(const unsigned char*)"sovereign-browser/bookmarks-folder-id-v1:Work/Projects",
strlen("sovereign-browser/bookmarks-folder-id-v1:Work/Projects"),
ref_mac) != 0) {
nostr_signer_free(signer);
return 0;
}
nostr_bytes_to_hex(ref_mac, 32, ref_hex);
ok = (strlen(got_hex) == 64 && strcmp(got_hex, ref_hex) == 0);
/* Determinism: same input -> same digest. */
{
char got2_hex[65];
if (nostr_signer_derive_hmac(signer, "sovereign-browser/bookmarks-folder-id-v1:Work/Projects", got2_hex) == NOSTR_SUCCESS) {
ok = ok && (strcmp(got_hex, got2_hex) == 0);
} else {
ok = 0;
}
}
/* Opaqueness: different input -> different digest. */
{
char other_hex[65];
if (nostr_signer_derive_hmac(signer, "sovereign-browser/bookmarks-folder-id-v1:Personal", other_hex) == NOSTR_SUCCESS) {
ok = ok && (strcmp(got_hex, other_hex) != 0);
} else {
ok = 0;
}
}
nostr_signer_free(signer);
return ok;
}
int main(void) {
#if !defined(NOSTR_ENABLE_NSIGNER_CLIENT)
printf("nsigner client disabled in this build; skipping\n");
@@ -342,6 +403,7 @@ int main(void) {
run_result("auth body hash matches sha256(compact params)", test_body_hash_matches_sha256_compact_params());
run_result("/proc/net/unix discovery parser no-crash", test_unix_discovery_no_crash());
run_result("fds transport client round-trip over framed fd pair", test_fds_transport_round_trip_via_client());
run_result("local signer derive_hmac matches reference HMAC-SHA256", test_local_derive_hmac_matches_reference());
printf("\nTotal: %d Passed: %d Failed: %d\n", test_count, passed_count, test_count - passed_count);
return (test_count == passed_count) ? 0 : 1;
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
ref: refs/heads/master
-8
View File
@@ -1,8 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
url = git@git.laantungir.net:laantungir/nostr_core_lib.git
fetch = +refs/*:refs/*
mirror = true
-1
View File
@@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.
@@ -1,15 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:
@@ -1,24 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
@@ -1,174 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open2;
# An example hook script to integrate Watchman
# (https://facebook.github.io/watchman/) with git to speed up detecting
# new and modified files.
#
# The hook is passed a version (currently 2) and last update token
# formatted as a string and outputs to stdout a new update token and
# all files that have been modified since the update token. Paths must
# be relative to the root of the working tree and separated by a single NUL.
#
# To enable this hook, rename this file to "query-watchman" and set
# 'git config core.fsmonitor .git/hooks/query-watchman'
#
my ($version, $last_update_token) = @ARGV;
# Uncomment for debugging
# print STDERR "$0 $version $last_update_token\n";
# Check the hook interface version
if ($version ne 2) {
die "Unsupported query-fsmonitor hook version '$version'.\n" .
"Falling back to scanning...\n";
}
my $git_work_tree = get_working_dir();
my $retry = 1;
my $json_pkg;
eval {
require JSON::XS;
$json_pkg = "JSON::XS";
1;
} or do {
require JSON::PP;
$json_pkg = "JSON::PP";
};
launch_watchman();
sub launch_watchman {
my $o = watchman_query();
if (is_work_tree_watched($o)) {
output_result($o->{clock}, @{$o->{files}});
}
}
sub output_result {
my ($clockid, @files) = @_;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# binmode $fh, ":utf8";
# print $fh "$clockid\n@files\n";
# close $fh;
binmode STDOUT, ":utf8";
print $clockid;
print "\0";
local $, = "\0";
print @files;
}
sub watchman_clock {
my $response = qx/watchman clock "$git_work_tree"/;
die "Failed to get clock id on '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
return $json_pkg->new->utf8->decode($response);
}
sub watchman_query {
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
or die "open2() failed: $!\n" .
"Falling back to scanning...\n";
# In the query expression below we're asking for names of files that
# changed since $last_update_token but not from the .git folder.
#
# To accomplish this, we're using the "since" generator to use the
# recency index to select candidate nodes and "fields" to limit the
# output to file names only. Then we're using the "expression" term to
# further constrain the results.
my $last_update_line = "";
if (substr($last_update_token, 0, 1) eq "c") {
$last_update_token = "\"$last_update_token\"";
$last_update_line = qq[\n"since": $last_update_token,];
}
my $query = <<" END";
["query", "$git_work_tree", {$last_update_line
"fields": ["name"],
"expression": ["not", ["dirname", ".git"]]
}]
END
# Uncomment for debugging the watchman query
# open (my $fh, ">", ".git/watchman-query.json");
# print $fh $query;
# close $fh;
print CHLD_IN $query;
close CHLD_IN;
my $response = do {local $/; <CHLD_OUT>};
# Uncomment for debugging the watch response
# open ($fh, ">", ".git/watchman-response.json");
# print $fh $response;
# close $fh;
die "Watchman: command returned no output.\n" .
"Falling back to scanning...\n" if $response eq "";
die "Watchman: command returned invalid output: $response\n" .
"Falling back to scanning...\n" unless $response =~ /^\{/;
return $json_pkg->new->utf8->decode($response);
}
sub is_work_tree_watched {
my ($output) = @_;
my $error = $output->{error};
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
$retry--;
my $response = qx/watchman watch "$git_work_tree"/;
die "Failed to make watchman watch '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
$output = $json_pkg->new->utf8->decode($response);
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# close $fh;
# Watchman will always return all files on the first query so
# return the fast "everything is dirty" flag to git and do the
# Watchman query just to get it over with now so we won't pay
# the cost in git to look up each individual file.
my $o = watchman_clock();
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
output_result($o->{clock}, ("/"));
$last_update_token = $o->{clock};
eval { launch_watchman() };
return 0;
}
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
return 1;
}
sub get_working_dir {
my $working_dir;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$working_dir = Win32::GetCwd();
$working_dir =~ tr/\\/\//;
} else {
require Cwd;
$working_dir = Cwd::cwd();
}
return $working_dir;
}
@@ -1,8 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info
@@ -1,14 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
precommit="$(git rev-parse --git-path hooks/pre-commit)"
test -x "$precommit" && exec "$precommit" ${1+"$@"}
:
@@ -1,49 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff-index --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
@@ -1,13 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git merge" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message to
# stderr if it wants to stop the merge commit.
#
# To enable this hook, rename this file to "pre-merge-commit".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit"
:
-53
View File
@@ -1,53 +0,0 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
while read local_ref local_oid remote_ref remote_oid
do
if test "$local_oid" = "$zero"
then
# Handle delete
:
else
if test "$remote_oid" = "$zero"
then
# New branch, examine all commits
range="$local_oid"
else
# Update to existing branch, examine new commits
range="$remote_oid..$local_oid"
fi
# Check for WIP commit
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
if test -n "$commit"
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
-169
View File
@@ -1,169 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up to date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
<<\DOC_END
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".
DOC_END
@@ -1,24 +0,0 @@
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
echoback=*)
echo "echo from the pre-receive-hook: ${value#*=}" >&2
;;
reject)
exit 1
esac
i=$((i + 1))
done
fi
@@ -1,42 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first one removes the
# "# Please enter the commit message..." help message.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
# case "$COMMIT_SOURCE,$SHA1" in
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
# *) ;;
# esac
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
# fi
@@ -1,78 +0,0 @@
#!/bin/sh
# An example hook script to update a checked-out tree on a git push.
#
# This hook is invoked by git-receive-pack(1) when it reacts to git
# push and updates reference(s) in its repository, and when the push
# tries to update the branch that is currently checked out and the
# receive.denyCurrentBranch configuration variable is set to
# updateInstead.
#
# By default, such a push is refused if the working tree and the index
# of the remote repository has any difference from the currently
# checked out commit; when both the working tree and the index match
# the current commit, they are updated to match the newly pushed tip
# of the branch. This hook is to be used to override the default
# behaviour; however the code below reimplements the default behaviour
# as a starting point for convenient modification.
#
# The hook receives the commit with which the tip of the current
# branch is going to be updated:
commit=$1
# It can exit with a non-zero status to refuse the push (when it does
# so, it must not modify the index or the working tree).
die () {
echo >&2 "$*"
exit 1
}
# Or it can make any necessary changes to the working tree and to the
# index to bring them to the desired state when the tip of the current
# branch is updated to the new commit, and exit with a zero status.
#
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
# in order to emulate git fetch that is run in the reverse direction
# with git push, as the two-tree form of git read-tree -u -m is
# essentially the same as git switch or git checkout that switches
# branches while keeping the local changes in the working tree that do
# not interfere with the difference between the branches.
# The below is a more-or-less exact translation to shell of the C code
# for the default behaviour for git's push-to-checkout hook defined in
# the push_to_deploy() function in builtin/receive-pack.c.
#
# Note that the hook will be executed from the repository directory,
# not from the working tree, so if you want to perform operations on
# the working tree, you will have to adapt your code accordingly, e.g.
# by adding "cd .." or using relative paths.
if ! git update-index -q --ignore-submodules --refresh
then
die "Up-to-date check failed"
fi
if ! git diff-files --quiet --ignore-submodules --
then
die "Working directory has unstaged changes"
fi
# This is a rough translation of:
#
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
if git cat-file -e HEAD 2>/dev/null
then
head=HEAD
else
head=$(git hash-object -t tree --stdin </dev/null)
fi
if ! git diff-index --quiet --cached --ignore-submodules $head --
then
die "Working directory has staged changes"
fi
if ! git read-tree -u -m "$commit"
then
die "Could not update working tree to new HEAD"
fi
@@ -1,77 +0,0 @@
#!/bin/sh
# An example hook script to validate a patch (and/or patch series) before
# sending it via email.
#
# The hook should exit with non-zero status after issuing an appropriate
# message if it wants to prevent the email(s) from being sent.
#
# To enable this hook, rename this file to "sendemail-validate".
#
# By default, it will only check that the patch(es) can be applied on top of
# the default upstream branch without conflicts in a secondary worktree. After
# validation (successful or not) of the last patch of a series, the worktree
# will be deleted.
#
# The following config variables can be set to change the default remote and
# remote ref that are used to apply the patches against:
#
# sendemail.validateRemote (default: origin)
# sendemail.validateRemoteRef (default: HEAD)
#
# Replace the TODO placeholders with appropriate checks according to your
# needs.
validate_cover_letter () {
file="$1"
# TODO: Replace with appropriate checks (e.g. spell checking).
true
}
validate_patch () {
file="$1"
# Ensure that the patch applies without conflicts.
git am -3 "$file" || return
# TODO: Replace with appropriate checks for this patch
# (e.g. checkpatch.pl).
true
}
validate_series () {
# TODO: Replace with appropriate checks for the whole series
# (e.g. quick build, coding style checks, etc.).
true
}
# main -------------------------------------------------------------------------
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
then
remote=$(git config --default origin --get sendemail.validateRemote) &&
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
git config --replace-all sendemail.validateWorktree "$worktree"
else
worktree=$(git config --get sendemail.validateWorktree)
fi || {
echo "sendemail-validate: error: failed to prepare worktree" >&2
exit 1
}
unset GIT_DIR GIT_WORK_TREE
cd "$worktree" &&
if grep -q "^diff --git " "$1"
then
validate_patch "$1"
else
validate_cover_letter "$1"
fi &&
if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
then
git config --unset-all sendemail.validateWorktree &&
trap 'git worktree remove -ff "$worktree"' EXIT &&
validate_series
fi
-128
View File
@@ -1,128 +0,0 @@
#!/bin/sh
#
# An example hook script to block unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# --- Config
allowunannotated=$(git config --type=bool hooks.allowunannotated)
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
# --- Finished
exit 0
-6
View File
@@ -1,6 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
-76
View File
@@ -1,76 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
e115d2e03f5d28b993c64da1663933c4e4cde129 refs/heads/master
6369fb0cf3e7df34851913534a265878ac1e9828 refs/tags/v0.1.0
6369fb0cf3e7df34851913534a265878ac1e9828 refs/tags/v0.1.1
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.10
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.11
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.12
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.13
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.14
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.15
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.16
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.17
cfde3bcb0fb493c6a7cbd4fbfe87ef47b6cceda2 refs/tags/v0.1.18
ac85ab6f0799f6a0c209f3efba5feb39d95bafc3 refs/tags/v0.1.19
6369fb0cf3e7df34851913534a265878ac1e9828 refs/tags/v0.1.2
ac85ab6f0799f6a0c209f3efba5feb39d95bafc3 refs/tags/v0.1.20
ac85ab6f0799f6a0c209f3efba5feb39d95bafc3 refs/tags/v0.1.21
bb673cc1a479e0d2a8f7bfef361b1c0bf3fade81 refs/tags/v0.1.22
bb673cc1a479e0d2a8f7bfef361b1c0bf3fade81 refs/tags/v0.1.23
2de890da5ccc11255ba8b6e210f098a3566be1a1 refs/tags/v0.1.24
8c610b6e369df848c553edbc882ec4ef5a269bbf refs/tags/v0.1.25
dfe8a20e2e97feb67a7506e22c0c3ba766f22f2c refs/tags/v0.1.26
a2b700cf40ebce4b9c05d561b2271d04aa1a83f6 refs/tags/v0.1.27
7cf7ffe025adf43ee8ed90e48fdd7c080bd9f4b4 refs/tags/v0.1.28
7cf7ffe025adf43ee8ed90e48fdd7c080bd9f4b4 refs/tags/v0.1.29
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.3
e8c0fcdf634f0de320675499486db729661f757b refs/tags/v0.1.30
e8c0fcdf634f0de320675499486db729661f757b refs/tags/v0.1.31
04f22e6f47d7ac161d88b0a6a440523d4cbfa788 refs/tags/v0.1.32
ace0b5a7927f99e701c28b0a5d5623ac139cb7dc refs/tags/v0.1.33
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.4
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.5
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.6
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.7
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.8
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.9
64aee10a21447f0e839c2d32ead947a6af61b026 refs/tags/v0.2.0
4a096ff35f35c3877839bfd44dcba11ae0a839cf refs/tags/v0.2.1
9e9fcba96cd38aca50d67e6a74272f14f13e48c1 refs/tags/v0.2.2
31947d12b735396e2c202f8dced51736ffe80106 refs/tags/v0.2.3
0f72d7433a875a15c163baaea4030f837498b9ad refs/tags/v0.2.4
d52ac9c10695bbae7960000512fad6df8cee8762 refs/tags/v0.2.5
9bf74e76ce9e8e8c86eaf731d8e36f153972bea1 refs/tags/v0.2.6
df50ca1273b47ddf2c5695336118651488225619 refs/tags/v0.4.10
5c51ab1f9f72ea727e21249a1a8b8321784b85f9 refs/tags/v0.4.11
81814e8518d5ac9a1060317ec36755187b1cd3ea refs/tags/v0.4.12
79d98587d3d25f4f8778b97e8db9244195c729a8 refs/tags/v0.4.13
cdeb569a16940242ac790eb54e17b12ad2f0b519 refs/tags/v0.4.3
d7a8aa1dc4ad9021b49cadc1726418e660a0c00d refs/tags/v0.4.4
4e06d8f723a07b77a3558a1dd5a768d18bd282cb refs/tags/v0.4.5
c6896eebb4047d5fe5c61d589d373fff211d8284 refs/tags/v0.4.6
2c128a6295a790e5915b7cc77f7a6716bbdb5e1d refs/tags/v0.4.7
e87d7364ff2d5d8011d77588532fbf653d09891d refs/tags/v0.4.8
d384ade7902b8a9f81c5280ae5bff890afc9fd2f refs/tags/v0.4.9
363b7e9adfc0ead83aba054a86a897b01c0a508a refs/tags/v0.5.0
af4f7cace95206873830de6d4cf72d59bb2d3b61 refs/tags/v0.5.1
2a861298da59c45da7e7628b53acc0bb8278582e refs/tags/v0.5.10
4c09cf2b266682253341206978b18d379c77cf87 refs/tags/v0.5.11
b0a2279bcd59ddeef80bec22817ce61af5a7d099 refs/tags/v0.5.12
b3110218fc0c9118fd335d7ff481bc35ad1beaa4 refs/tags/v0.5.13
25bdce73376ee29bdda65959bd929dc74655b4a3 refs/tags/v0.5.14
ef8e68b952ca9d3499e37d9607fc4e44dac8a369 refs/tags/v0.5.15
8c5562edb09722075c8c039ec9040030447b9f40 refs/tags/v0.5.16
84257b2f5865e1963251003c527286125bb549c7 refs/tags/v0.5.2
7aea4b07df314bbf43a4f55b12c764b5141982e2 refs/tags/v0.5.3
6c6bcba650e8805279fffe4427a67051aaa89f9a refs/tags/v0.5.4
afe3e4787f0e3bbfa493c1cf94372016ab52c9a5 refs/tags/v0.5.5
c81db98e3f25c56a808b6c7b3b4df6f4355966dd refs/tags/v0.5.6
2b80abc3ae6b3060e5ea06316529df88e9ed2276 refs/tags/v0.5.7
5760a3a7d0660cd58aa8e99919a71e187da4f785 refs/tags/v0.5.8
b512be79aba5e10cafad60d8b8acdffa4d4e8b94 refs/tags/v0.5.9
392b8632923a624e0bbc6ec3a14c0be088c86538 refs/tags/v0.6.0
654bdd218649d0fb98ef2f74ba681630259e9a20 refs/tags/v0.6.1
693e21423eff56ee6456900cda9812ca7aadb37c refs/tags/v0.6.2
ba97b1a6e38514713c0ec790f3170f79337a4d8c refs/tags/v0.6.3
7a63f0db57814dc4e467972131ce55b4c4aa0c89 refs/tags/v0.6.4
-1
View File
@@ -1 +0,0 @@
ref: refs/heads/master
-8
View File
@@ -1,8 +0,0 @@
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
url = git@git.laantungir.net:laantungir/nostr_core_lib.git
fetch = +refs/*:refs/*
mirror = true
-1
View File
@@ -1 +0,0 @@
Unnamed repository; edit this file 'description' to name the repository.
@@ -1,15 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:
@@ -1,24 +0,0 @@
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
@@ -1,174 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open2;
# An example hook script to integrate Watchman
# (https://facebook.github.io/watchman/) with git to speed up detecting
# new and modified files.
#
# The hook is passed a version (currently 2) and last update token
# formatted as a string and outputs to stdout a new update token and
# all files that have been modified since the update token. Paths must
# be relative to the root of the working tree and separated by a single NUL.
#
# To enable this hook, rename this file to "query-watchman" and set
# 'git config core.fsmonitor .git/hooks/query-watchman'
#
my ($version, $last_update_token) = @ARGV;
# Uncomment for debugging
# print STDERR "$0 $version $last_update_token\n";
# Check the hook interface version
if ($version ne 2) {
die "Unsupported query-fsmonitor hook version '$version'.\n" .
"Falling back to scanning...\n";
}
my $git_work_tree = get_working_dir();
my $retry = 1;
my $json_pkg;
eval {
require JSON::XS;
$json_pkg = "JSON::XS";
1;
} or do {
require JSON::PP;
$json_pkg = "JSON::PP";
};
launch_watchman();
sub launch_watchman {
my $o = watchman_query();
if (is_work_tree_watched($o)) {
output_result($o->{clock}, @{$o->{files}});
}
}
sub output_result {
my ($clockid, @files) = @_;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# binmode $fh, ":utf8";
# print $fh "$clockid\n@files\n";
# close $fh;
binmode STDOUT, ":utf8";
print $clockid;
print "\0";
local $, = "\0";
print @files;
}
sub watchman_clock {
my $response = qx/watchman clock "$git_work_tree"/;
die "Failed to get clock id on '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
return $json_pkg->new->utf8->decode($response);
}
sub watchman_query {
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
or die "open2() failed: $!\n" .
"Falling back to scanning...\n";
# In the query expression below we're asking for names of files that
# changed since $last_update_token but not from the .git folder.
#
# To accomplish this, we're using the "since" generator to use the
# recency index to select candidate nodes and "fields" to limit the
# output to file names only. Then we're using the "expression" term to
# further constrain the results.
my $last_update_line = "";
if (substr($last_update_token, 0, 1) eq "c") {
$last_update_token = "\"$last_update_token\"";
$last_update_line = qq[\n"since": $last_update_token,];
}
my $query = <<" END";
["query", "$git_work_tree", {$last_update_line
"fields": ["name"],
"expression": ["not", ["dirname", ".git"]]
}]
END
# Uncomment for debugging the watchman query
# open (my $fh, ">", ".git/watchman-query.json");
# print $fh $query;
# close $fh;
print CHLD_IN $query;
close CHLD_IN;
my $response = do {local $/; <CHLD_OUT>};
# Uncomment for debugging the watch response
# open ($fh, ">", ".git/watchman-response.json");
# print $fh $response;
# close $fh;
die "Watchman: command returned no output.\n" .
"Falling back to scanning...\n" if $response eq "";
die "Watchman: command returned invalid output: $response\n" .
"Falling back to scanning...\n" unless $response =~ /^\{/;
return $json_pkg->new->utf8->decode($response);
}
sub is_work_tree_watched {
my ($output) = @_;
my $error = $output->{error};
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
$retry--;
my $response = qx/watchman watch "$git_work_tree"/;
die "Failed to make watchman watch '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
$output = $json_pkg->new->utf8->decode($response);
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# close $fh;
# Watchman will always return all files on the first query so
# return the fast "everything is dirty" flag to git and do the
# Watchman query just to get it over with now so we won't pay
# the cost in git to look up each individual file.
my $o = watchman_clock();
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
output_result($o->{clock}, ("/"));
$last_update_token = $o->{clock};
eval { launch_watchman() };
return 0;
}
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
return 1;
}
sub get_working_dir {
my $working_dir;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$working_dir = Win32::GetCwd();
$working_dir =~ tr/\\/\//;
} else {
require Cwd;
$working_dir = Cwd::cwd();
}
return $working_dir;
}
@@ -1,8 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info
@@ -1,14 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
precommit="$(git rev-parse --git-path hooks/pre-commit)"
test -x "$precommit" && exec "$precommit" ${1+"$@"}
:
@@ -1,49 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff-index --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
@@ -1,13 +0,0 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git merge" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message to
# stderr if it wants to stop the merge commit.
#
# To enable this hook, rename this file to "pre-merge-commit".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit"
:
@@ -1,53 +0,0 @@
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
while read local_ref local_oid remote_ref remote_oid
do
if test "$local_oid" = "$zero"
then
# Handle delete
:
else
if test "$remote_oid" = "$zero"
then
# New branch, examine all commits
range="$local_oid"
else
# Update to existing branch, examine new commits
range="$remote_oid..$local_oid"
fi
# Check for WIP commit
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
if test -n "$commit"
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
@@ -1,169 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up to date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
<<\DOC_END
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".
DOC_END
@@ -1,24 +0,0 @@
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
echoback=*)
echo "echo from the pre-receive-hook: ${value#*=}" >&2
;;
reject)
exit 1
esac
i=$((i + 1))
done
fi
@@ -1,42 +0,0 @@
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first one removes the
# "# Please enter the commit message..." help message.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
# case "$COMMIT_SOURCE,$SHA1" in
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
# *) ;;
# esac
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
# fi
@@ -1,78 +0,0 @@
#!/bin/sh
# An example hook script to update a checked-out tree on a git push.
#
# This hook is invoked by git-receive-pack(1) when it reacts to git
# push and updates reference(s) in its repository, and when the push
# tries to update the branch that is currently checked out and the
# receive.denyCurrentBranch configuration variable is set to
# updateInstead.
#
# By default, such a push is refused if the working tree and the index
# of the remote repository has any difference from the currently
# checked out commit; when both the working tree and the index match
# the current commit, they are updated to match the newly pushed tip
# of the branch. This hook is to be used to override the default
# behaviour; however the code below reimplements the default behaviour
# as a starting point for convenient modification.
#
# The hook receives the commit with which the tip of the current
# branch is going to be updated:
commit=$1
# It can exit with a non-zero status to refuse the push (when it does
# so, it must not modify the index or the working tree).
die () {
echo >&2 "$*"
exit 1
}
# Or it can make any necessary changes to the working tree and to the
# index to bring them to the desired state when the tip of the current
# branch is updated to the new commit, and exit with a zero status.
#
# For example, the hook can simply run git read-tree -u -m HEAD "$1"
# in order to emulate git fetch that is run in the reverse direction
# with git push, as the two-tree form of git read-tree -u -m is
# essentially the same as git switch or git checkout that switches
# branches while keeping the local changes in the working tree that do
# not interfere with the difference between the branches.
# The below is a more-or-less exact translation to shell of the C code
# for the default behaviour for git's push-to-checkout hook defined in
# the push_to_deploy() function in builtin/receive-pack.c.
#
# Note that the hook will be executed from the repository directory,
# not from the working tree, so if you want to perform operations on
# the working tree, you will have to adapt your code accordingly, e.g.
# by adding "cd .." or using relative paths.
if ! git update-index -q --ignore-submodules --refresh
then
die "Up-to-date check failed"
fi
if ! git diff-files --quiet --ignore-submodules --
then
die "Working directory has unstaged changes"
fi
# This is a rough translation of:
#
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX
if git cat-file -e HEAD 2>/dev/null
then
head=HEAD
else
head=$(git hash-object -t tree --stdin </dev/null)
fi
if ! git diff-index --quiet --cached --ignore-submodules $head --
then
die "Working directory has staged changes"
fi
if ! git read-tree -u -m "$commit"
then
die "Could not update working tree to new HEAD"
fi
@@ -1,77 +0,0 @@
#!/bin/sh
# An example hook script to validate a patch (and/or patch series) before
# sending it via email.
#
# The hook should exit with non-zero status after issuing an appropriate
# message if it wants to prevent the email(s) from being sent.
#
# To enable this hook, rename this file to "sendemail-validate".
#
# By default, it will only check that the patch(es) can be applied on top of
# the default upstream branch without conflicts in a secondary worktree. After
# validation (successful or not) of the last patch of a series, the worktree
# will be deleted.
#
# The following config variables can be set to change the default remote and
# remote ref that are used to apply the patches against:
#
# sendemail.validateRemote (default: origin)
# sendemail.validateRemoteRef (default: HEAD)
#
# Replace the TODO placeholders with appropriate checks according to your
# needs.
validate_cover_letter () {
file="$1"
# TODO: Replace with appropriate checks (e.g. spell checking).
true
}
validate_patch () {
file="$1"
# Ensure that the patch applies without conflicts.
git am -3 "$file" || return
# TODO: Replace with appropriate checks for this patch
# (e.g. checkpatch.pl).
true
}
validate_series () {
# TODO: Replace with appropriate checks for the whole series
# (e.g. quick build, coding style checks, etc.).
true
}
# main -------------------------------------------------------------------------
if test "$GIT_SENDEMAIL_FILE_COUNTER" = 1
then
remote=$(git config --default origin --get sendemail.validateRemote) &&
ref=$(git config --default HEAD --get sendemail.validateRemoteRef) &&
worktree=$(mktemp --tmpdir -d sendemail-validate.XXXXXXX) &&
git worktree add -fd --checkout "$worktree" "refs/remotes/$remote/$ref" &&
git config --replace-all sendemail.validateWorktree "$worktree"
else
worktree=$(git config --get sendemail.validateWorktree)
fi || {
echo "sendemail-validate: error: failed to prepare worktree" >&2
exit 1
}
unset GIT_DIR GIT_WORK_TREE
cd "$worktree" &&
if grep -q "^diff --git " "$1"
then
validate_patch "$1"
else
validate_cover_letter "$1"
fi &&
if test "$GIT_SENDEMAIL_FILE_COUNTER" = "$GIT_SENDEMAIL_FILE_TOTAL"
then
git config --unset-all sendemail.validateWorktree &&
trap 'git worktree remove -ff "$worktree"' EXIT &&
validate_series
fi
-128
View File
@@ -1,128 +0,0 @@
#!/bin/sh
#
# An example hook script to block unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
# --- Config
allowunannotated=$(git config --type=bool hooks.allowunannotated)
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch)
denycreatebranch=$(git config --type=bool hooks.denycreatebranch)
allowdeletetag=$(git config --type=bool hooks.allowdeletetag)
allowmodifytag=$(git config --type=bool hooks.allowmodifytag)
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
# --- Finished
exit 0
-6
View File
@@ -1,6 +0,0 @@
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
-76
View File
@@ -1,76 +0,0 @@
# pack-refs with: peeled fully-peeled sorted
e115d2e03f5d28b993c64da1663933c4e4cde129 refs/heads/master
6369fb0cf3e7df34851913534a265878ac1e9828 refs/tags/v0.1.0
6369fb0cf3e7df34851913534a265878ac1e9828 refs/tags/v0.1.1
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.10
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.11
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.12
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.13
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.14
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.15
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.16
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.17
cfde3bcb0fb493c6a7cbd4fbfe87ef47b6cceda2 refs/tags/v0.1.18
ac85ab6f0799f6a0c209f3efba5feb39d95bafc3 refs/tags/v0.1.19
6369fb0cf3e7df34851913534a265878ac1e9828 refs/tags/v0.1.2
ac85ab6f0799f6a0c209f3efba5feb39d95bafc3 refs/tags/v0.1.20
ac85ab6f0799f6a0c209f3efba5feb39d95bafc3 refs/tags/v0.1.21
bb673cc1a479e0d2a8f7bfef361b1c0bf3fade81 refs/tags/v0.1.22
bb673cc1a479e0d2a8f7bfef361b1c0bf3fade81 refs/tags/v0.1.23
2de890da5ccc11255ba8b6e210f098a3566be1a1 refs/tags/v0.1.24
8c610b6e369df848c553edbc882ec4ef5a269bbf refs/tags/v0.1.25
dfe8a20e2e97feb67a7506e22c0c3ba766f22f2c refs/tags/v0.1.26
a2b700cf40ebce4b9c05d561b2271d04aa1a83f6 refs/tags/v0.1.27
7cf7ffe025adf43ee8ed90e48fdd7c080bd9f4b4 refs/tags/v0.1.28
7cf7ffe025adf43ee8ed90e48fdd7c080bd9f4b4 refs/tags/v0.1.29
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.3
e8c0fcdf634f0de320675499486db729661f757b refs/tags/v0.1.30
e8c0fcdf634f0de320675499486db729661f757b refs/tags/v0.1.31
04f22e6f47d7ac161d88b0a6a440523d4cbfa788 refs/tags/v0.1.32
ace0b5a7927f99e701c28b0a5d5623ac139cb7dc refs/tags/v0.1.33
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.4
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.5
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.6
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.7
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.8
3108661b0a6f6ab33201bc6c9c405a161273978e refs/tags/v0.1.9
64aee10a21447f0e839c2d32ead947a6af61b026 refs/tags/v0.2.0
4a096ff35f35c3877839bfd44dcba11ae0a839cf refs/tags/v0.2.1
9e9fcba96cd38aca50d67e6a74272f14f13e48c1 refs/tags/v0.2.2
31947d12b735396e2c202f8dced51736ffe80106 refs/tags/v0.2.3
0f72d7433a875a15c163baaea4030f837498b9ad refs/tags/v0.2.4
d52ac9c10695bbae7960000512fad6df8cee8762 refs/tags/v0.2.5
9bf74e76ce9e8e8c86eaf731d8e36f153972bea1 refs/tags/v0.2.6
df50ca1273b47ddf2c5695336118651488225619 refs/tags/v0.4.10
5c51ab1f9f72ea727e21249a1a8b8321784b85f9 refs/tags/v0.4.11
81814e8518d5ac9a1060317ec36755187b1cd3ea refs/tags/v0.4.12
79d98587d3d25f4f8778b97e8db9244195c729a8 refs/tags/v0.4.13
cdeb569a16940242ac790eb54e17b12ad2f0b519 refs/tags/v0.4.3
d7a8aa1dc4ad9021b49cadc1726418e660a0c00d refs/tags/v0.4.4
4e06d8f723a07b77a3558a1dd5a768d18bd282cb refs/tags/v0.4.5
c6896eebb4047d5fe5c61d589d373fff211d8284 refs/tags/v0.4.6
2c128a6295a790e5915b7cc77f7a6716bbdb5e1d refs/tags/v0.4.7
e87d7364ff2d5d8011d77588532fbf653d09891d refs/tags/v0.4.8
d384ade7902b8a9f81c5280ae5bff890afc9fd2f refs/tags/v0.4.9
363b7e9adfc0ead83aba054a86a897b01c0a508a refs/tags/v0.5.0
af4f7cace95206873830de6d4cf72d59bb2d3b61 refs/tags/v0.5.1
2a861298da59c45da7e7628b53acc0bb8278582e refs/tags/v0.5.10
4c09cf2b266682253341206978b18d379c77cf87 refs/tags/v0.5.11
b0a2279bcd59ddeef80bec22817ce61af5a7d099 refs/tags/v0.5.12
b3110218fc0c9118fd335d7ff481bc35ad1beaa4 refs/tags/v0.5.13
25bdce73376ee29bdda65959bd929dc74655b4a3 refs/tags/v0.5.14
ef8e68b952ca9d3499e37d9607fc4e44dac8a369 refs/tags/v0.5.15
8c5562edb09722075c8c039ec9040030447b9f40 refs/tags/v0.5.16
84257b2f5865e1963251003c527286125bb549c7 refs/tags/v0.5.2
7aea4b07df314bbf43a4f55b12c764b5141982e2 refs/tags/v0.5.3
6c6bcba650e8805279fffe4427a67051aaa89f9a refs/tags/v0.5.4
afe3e4787f0e3bbfa493c1cf94372016ab52c9a5 refs/tags/v0.5.5
c81db98e3f25c56a808b6c7b3b4df6f4355966dd refs/tags/v0.5.6
2b80abc3ae6b3060e5ea06316529df88e9ed2276 refs/tags/v0.5.7
5760a3a7d0660cd58aa8e99919a71e187da4f785 refs/tags/v0.5.8
b512be79aba5e10cafad60d8b8acdffa4d4e8b94 refs/tags/v0.5.9
392b8632923a624e0bbc6ec3a14c0be088c86538 refs/tags/v0.6.0
654bdd218649d0fb98ef2f74ba681630259e9a20 refs/tags/v0.6.1
693e21423eff56ee6456900cda9812ca7aadb37c refs/tags/v0.6.2
ba97b1a6e38514713c0ec790f3170f79337a4d8c refs/tags/v0.6.3
7a63f0db57814dc4e467972131ce55b4c4aa0c89 refs/tags/v0.6.4
Submodule verify_worktree deleted from e115d2e03f