aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2025-07-12 20:11:40 -0300
committerDavid Bremner <david@tethera.net>2025-08-11 09:52:10 -0300
commitcca2c869e4a26b4bb8b0b43c6034c4ec6f0b69d2 (patch)
treea6dd575fd995127a4583999f0e2e48ee6da0fb66
parent448c8ca81a3ca9f5c7d2cc20671bb81d7a551f67 (diff)
cli/git-remote: add check for missing messages
In cases where a given 'export' both adds and deletes messages, we may not know what messages are actually missing until the end of processing. We thus do single pass of all remaining message-ids, and report any that are still missing at the end of the "export" operation.
-rw-r--r--git-remote-notmuch.c33
-rwxr-xr-xtest/T860-git-remote.sh1
2 files changed, 32 insertions, 2 deletions
diff --git a/git-remote-notmuch.c b/git-remote-notmuch.c
index c5c46b1f..74c6d702 100644
--- a/git-remote-notmuch.c
+++ b/git-remote-notmuch.c
@@ -460,8 +460,39 @@ purge_database (notmuch_database_t *notmuch, GHashTable *msg_state)
}
static void
-check_missing (unused (notmuch_database_t *notmuch), unused (GHashTable *mid_state))
+check_missing (notmuch_database_t *notmuch, GHashTable *mid_state)
{
+ notmuch_status_t status;
+ notmuch_bool_t strict;
+ gpointer key, value;
+
+ GHashTableIter iter;
+ int count = 0;
+
+ status = notmuch_config_get_bool (notmuch,
+ NOTMUCH_CONFIG_GIT_FAIL_ON_MISSING,
+ &strict);
+ if (print_status_database ("config_get_bool", notmuch, status))
+ exit (EXIT_FAILURE);
+
+ g_hash_table_iter_init (&iter, mid_state);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ if (GPOINTER_TO_INT (value) != MSG_STATE_MISSING)
+ continue;
+
+ fprintf (stderr, "%c: missing mid %s\n", strict ? 'E' : 'W', (const char *) key);
+ flog ("%c: missing mid %s\n", strict ? 'E' : 'W', (const char *) key);
+ count++;
+ }
+
+ if (count > 0) {
+ if (strict) {
+ fprintf (stderr, "E: %d missing messages\n", count);
+ exit (1);
+ } else {
+ flog ("I: ignoring missing messages\n");
+ }
+ }
}
static void
diff --git a/test/T860-git-remote.sh b/test/T860-git-remote.sh
index fa52c2b7..2b826c88 100755
--- a/test/T860-git-remote.sh
+++ b/test/T860-git-remote.sh
@@ -303,7 +303,6 @@ restore_state
backup_state
test_begin_subtest 'by default, missing messages are an error during export'
-test_subtest_known_broken
sed s/4EFC743A.3060609@april.org/missing-message@example.com/ < export.in > missing.in
test_expect_code 1 "run_helper < missing.in"
restore_state