This includes a bunch of whitespace cleanup (enough that the interdiff
is a bit boring/noisy) and
id:[email protected], as well as
being rebased on master.

Here is said boring interdiff

diff --git a/lib/message-property.cc b/lib/message-property.cc
index 4fa6cac..0b13cac 100644
--- a/lib/message-property.cc
+++ b/lib/message-property.cc
@@ -86,16 +86,23 @@ notmuch_message_remove_property (notmuch_message_t 
*message, const char *key, co
 }
 
 notmuch_status_t
-notmuch_message_remove_all_properties (notmuch_message_t *message)
+notmuch_message_remove_all_properties (notmuch_message_t *message, const char 
*key)
 {
     notmuch_status_t status;
+    const char * term_prefix;
+
     status = _notmuch_database_ensure_writable (_notmuch_message_database 
(message));
     if (status)
        return status;
 
     _notmuch_message_invalidate_metadata (message, "property");
+    if (key)
+       term_prefix = talloc_asprintf (message, "%s%s=", _find_prefix 
("property"), key);
+    else
+       term_prefix = _find_prefix ("property");
+
     /* XXX better error reporting ? */
-    _notmuch_message_remove_terms (message, _find_prefix ("property"));
+    _notmuch_message_remove_terms (message, term_prefix);
 
     return NOTMUCH_STATUS_SUCCESS;
 }
diff --git a/lib/notmuch.h b/lib/notmuch.h
index f6bad67..e03a05d 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1711,6 +1711,9 @@ notmuch_message_remove_property (notmuch_message_t 
*message, const char *key, co
 /**
  * Remove all (key,value) pairs from the given message.
  *
+ * @param[in,out] message  message to operate on.
+ * @param[in]     key      key to delete properties for. If NULL, delete
+ *                        properties for all keys
  * @returns
  * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
  *   read-only mode so message cannot be modified.
@@ -1718,7 +1721,7 @@ notmuch_message_remove_property (notmuch_message_t 
*message, const char *key, co
  *
  */
 notmuch_status_t
-notmuch_message_remove_all_properties (notmuch_message_t *message);
+notmuch_message_remove_all_properties (notmuch_message_t *message, const char 
*key);
 
 /**
  * Opaque message property iterator
diff --git a/notmuch-dump.c b/notmuch-dump.c
index ec82660..e7965ce 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -80,11 +80,11 @@ print_dump_header (gzFile output, int output_format, int 
include)
        sep = ",";
     }
     if (include & DUMP_INCLUDE_PROPERTIES) {
-       gzprintf (output, "%sproperties",sep);
+       gzprintf (output, "%sproperties", sep);
        sep = ",";
     }
     if (include & DUMP_INCLUDE_TAGS) {
-       gzprintf (output, "%sproperties",sep);
+       gzprintf (output, "%sproperties", sep);
     }
     gzputs (output, "\n");
 }
@@ -106,38 +106,38 @@ dump_properties_message (void *ctx,
        return 0;
     }
 
-   for (list = notmuch_message_get_properties (message, "", FALSE);
-       notmuch_message_properties_valid (list); 
notmuch_message_properties_move_to_next (list)) {
-       const char *key, *val;
-
-       if (first) {
-          if (hex_encode (ctx, message_id, buffer_p, size_p) != HEX_SUCCESS) {
-              fprintf (stderr, "Error: failed to hex-encode message-id %s\n", 
message_id);
-              return 1;
-          }
-          gzprintf (output, "#= %s", *buffer_p);
-          first = FALSE;
-       }
-
-       key = notmuch_message_properties_key (list);
-       val = notmuch_message_properties_value (list);
-
-       if (hex_encode (ctx, key, buffer_p, size_p) != HEX_SUCCESS) {
-          fprintf (stderr, "Error: failed to hex-encode key %s\n", key);
-          return 1;
-       }
-       gzprintf (output, " %s", *buffer_p);
-
-       if (hex_encode (ctx, val, buffer_p, size_p) != HEX_SUCCESS) {
-          fprintf (stderr, "Error: failed to hex-encode value %s\n", val);
-          return 1;
-       }
-       gzprintf (output, "=%s", *buffer_p);
-}
-   notmuch_message_properties_destroy (list);
+    for (list = notmuch_message_get_properties (message, "", FALSE);
+        notmuch_message_properties_valid (list); 
notmuch_message_properties_move_to_next (list)) {
+       const char *key, *val;
+
+       if (first) {
+           if (hex_encode (ctx, message_id, buffer_p, size_p) != HEX_SUCCESS) {
+               fprintf (stderr, "Error: failed to hex-encode message-id %s\n", 
message_id);
+               return 1;
+           }
+           gzprintf (output, "#= %s", *buffer_p);
+           first = FALSE;
+       }
+
+       key = notmuch_message_properties_key (list);
+       val = notmuch_message_properties_value (list);
+
+       if (hex_encode (ctx, key, buffer_p, size_p) != HEX_SUCCESS) {
+           fprintf (stderr, "Error: failed to hex-encode key %s\n", key);
+           return 1;
+       }
+       gzprintf (output, " %s", *buffer_p);
+
+       if (hex_encode (ctx, val, buffer_p, size_p) != HEX_SUCCESS) {
+           fprintf (stderr, "Error: failed to hex-encode value %s\n", val);
+           return 1;
+       }
+       gzprintf (output, "=%s", *buffer_p);
+    }
+    notmuch_message_properties_destroy (list);
 
-   if (!first)
-       gzprintf (output, "\n", *buffer_p);
+    if (! first)
+       gzprintf (output, "\n", *buffer_p);
 
     return 0;
 }
diff --git a/notmuch-restore.c b/notmuch-restore.c
index d2ada61..4b3690f 100644
--- a/notmuch-restore.c
+++ b/notmuch-restore.c
@@ -69,7 +69,7 @@ process_properties_line (notmuch_database_t *notmuch, const 
char* line)
     const char *delim = " \t\n";
     int ret = EXIT_FAILURE;
 
-    void *local = talloc_new(NULL);
+    void *local = talloc_new (NULL);
 
     id_p = strtok_len_c (line, delim, &id_len);
     id = talloc_strndup (local, id_p, id_len);
@@ -97,7 +97,7 @@ process_properties_line (notmuch_database_t *notmuch, const 
char* line)
        }
 
        key = talloc_strndup (local, tok, off);
-       value = talloc_strndup (local, tok+off+1, tok_len - off - 1);
+       value = talloc_strndup (local, tok + off + 1, tok_len - off - 1);
 
        if (hex_decode_inplace (key) != HEX_SUCCESS) {
            fprintf (stderr, "hex decoding failure on key %s\n", key);
@@ -111,13 +111,13 @@ process_properties_line (notmuch_database_t *notmuch, 
const char* line)
 
        if (print_status_database ("notmuch restore", notmuch,
                                   notmuch_message_add_property (message, key, 
value)))
-       goto DONE;
+           goto DONE;
 
     }
 
     ret = EXIT_SUCCESS;
 
- DONE:
+  DONE:
     talloc_free (local);
     return ret;
 }
@@ -341,7 +341,7 @@ notmuch_restore_command (notmuch_config_t *config, int 
argc, char *argv[])
                goto DONE;
        }
        if ((include & DUMP_INCLUDE_PROPERTIES) && line_len >= 2 && line[0] == 
'#' && line[1] == '=') {
-           ret = process_properties_line(notmuch, line+2);
+           ret = process_properties_line (notmuch, line + 2);
            if (ret)
                goto DONE;
        }
@@ -380,7 +380,7 @@ notmuch_restore_command (notmuch_config_t *config, int 
argc, char *argv[])
        line_ctx = talloc_new (config);
 
        if ((include & DUMP_INCLUDE_PROPERTIES) && line_len >= 2 && line[0] == 
'#' && line[1] == '=') {
-           ret = process_properties_line(notmuch, line+2);
+           ret = process_properties_line (notmuch, line + 2);
            if (ret)
                goto DONE;
        }
@@ -423,7 +423,7 @@ notmuch_restore_command (notmuch_config_t *config, int 
argc, char *argv[])
            break;
 
     }  while (! (ret = gz_getline (line_ctx, &line, &line_len, input)));
-    
+
 
     /* EOF is normal loop termination condition, UTIL_SUCCESS is
      * impossible here */
@@ -435,14 +435,14 @@ notmuch_restore_command (notmuch_config_t *config, int 
argc, char *argv[])
        ret = EXIT_FAILURE;
     }
 
-    /* currently this should not be after DONE: since we don't 
+    /* currently this should not be after DONE: since we don't
      * know if the xregcomp was reached
      */
 
     if (input_format == DUMP_FORMAT_SUP)
        regfree (&regex);
 
- DONE:
+  DONE:
     if (line_ctx != NULL)
        talloc_free (line_ctx);
 


_______________________________________________
notmuch mailing list
[email protected]
https://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to