Git fork

imap-send: enable specifying the folder using the command line

Some users may very often want to imap-send messages to a folder
other than the default set in the config. Add a command line
argument for the same.

While at it, fix minor mark-up inconsistencies in the existing
documentation text.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Aditya Garg and committed by
Junio C Hamano
3168514e ea8681e3

+23 -7
+4 -2
Documentation/config/imap.adoc
··· 1 1 imap.folder:: 2 2 The folder to drop the mails into, which is typically the Drafts 3 - folder. For example: "INBOX.Drafts", "INBOX/Drafts" or 4 - "[Gmail]/Drafts". Required. 3 + folder. For example: `INBOX.Drafts`, `INBOX/Drafts` or 4 + `[Gmail]/Drafts`. The IMAP folder to interact with MUST be specified; 5 + the value of this configuration variable is used as the fallback 6 + default value when the `--folder` option is not given. 5 7 6 8 imap.tunnel:: 7 9 Command used to set up a tunnel to the IMAP server through which
+11 -4
Documentation/git-imap-send.adoc
··· 9 9 SYNOPSIS 10 10 -------- 11 11 [verse] 12 - 'git imap-send' [-v] [-q] [--[no-]curl] 12 + 'git imap-send' [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>] 13 13 14 14 15 15 DESCRIPTION 16 16 ----------- 17 - This command uploads a mailbox generated with 'git format-patch' 17 + This command uploads a mailbox generated with `git format-patch` 18 18 into an IMAP drafts folder. This allows patches to be sent as 19 19 other email is when using mail clients that cannot read mailbox 20 20 files directly. The command also works with any general mailbox 21 - in which emails have the fields "From", "Date", and "Subject" in 21 + in which emails have the fields `From`, `Date`, and `Subject` in 22 22 that order. 23 23 24 24 Typical usage is something like: 25 25 26 - git format-patch --signoff --stdout --attach origin | git imap-send 26 + ------ 27 + $ git format-patch --signoff --stdout --attach origin | git imap-send 28 + ------ 27 29 28 30 29 31 OPTIONS ··· 36 38 -q:: 37 39 --quiet:: 38 40 Be quiet. 41 + 42 + -f <folder>:: 43 + --folder=<folder>:: 44 + Specify the folder in which the emails have to saved. 45 + For example: `--folder=[Gmail]/Drafts` or `-f INBOX/Drafts`. 39 46 40 47 --curl:: 41 48 Use libcurl to communicate with the IMAP server, unless tunneling
+8 -1
imap-send.c
··· 46 46 47 47 static int verbosity; 48 48 static int use_curl = USE_CURL_DEFAULT; 49 + static char *opt_folder; 49 50 50 - static const char * const imap_send_usage[] = { "git imap-send [-v] [-q] [--[no-]curl] < <mbox>", NULL }; 51 + static const char * const imap_send_usage[] = { "git imap-send [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>] < <mbox>", NULL }; 51 52 52 53 static struct option imap_send_options[] = { 53 54 OPT__VERBOSITY(&verbosity), 54 55 OPT_BOOL(0, "curl", &use_curl, "use libcurl to communicate with the IMAP server"), 56 + OPT_STRING('f', "folder", &opt_folder, "folder", "specify the IMAP folder"), 55 57 OPT_END() 56 58 }; 57 59 ··· 1721 1723 git_config(git_imap_config, &server); 1722 1724 1723 1725 argc = parse_options(argc, (const char **)argv, "", imap_send_options, imap_send_usage, 0); 1726 + 1727 + if (opt_folder) { 1728 + free(server.folder); 1729 + server.folder = xstrdup(opt_folder); 1730 + } 1724 1731 1725 1732 if (argc) 1726 1733 usage_with_options(imap_send_usage, imap_send_options);