summaryrefslogtreecommitdiff
path: root/imap-send.c
AgeCommit message (Collapse)Author
2008-05-14Provide git_config with a callback-data parameterJohannes Schindelin
git_config() only had a function parameter, but no callback data parameter. This assumes that all callback functions only modify global variables. With this patch, every callback gets a void * parameter, and it is hoped that this will help the libification effort. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-23Don't force imap.host to be set when imap.tunnel is setJeff King
The documentation for git-imap-send suggests a tunnel setting such as Tunnel = "ssh -q user@server.com /usr/bin/imapd ./Maildir 2> /dev/null" which works wonderfully and doesn't require a username, password or port setting. However, git-imap-send currently requires that the imap.host variable be set in the config even when it was unused. This patch changes imap-send to only require that the imap.host setting is set if imap.tunnel is not set. Otherwise, server.host is set to "tunnel" for reporting purposes. Acked-by: Andy Parkins <andyparkins@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-26imap-send: properly error out if imap.host is not set in configGerrit Pape
If no imap host is specified in the git config, git imap-send used to try to lookup a null pointer through gethostbyname(), causing a segfault. Since setting the imap.host variable is mandatory, imap-send now properly fails with an explanatory error message. The problem has been reported by picca through http://bugs.debian.org/472632 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-22Avoid unnecessary "if-before-free" tests.Jim Meyering
This change removes all obvious useless if-before-free tests. E.g., it replaces code like this: if (some_expression) free (some_expression); with the now-equivalent: free (some_expression); It is equivalent not just because POSIX has required free(NULL) to work for a long time, but simply because it has worked for so long that no reasonable porting target fails the test. Here's some evidence from nearly 1.5 years ago: http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html FYI, the change below was prepared by running the following: git ls-files -z | xargs -0 \ perl -0x3b -pi -e \ 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+(free\s*\(\s*\1\s*\))/$2/s' Note however, that it doesn't handle brace-enclosed blocks like "if (x) { free (x); }". But that's ok, since there were none like that in git sources. Beware: if you do use the above snippet, note that it can produce syntactically invalid C code. That happens when the affected "if"-statement has a matching "else". E.g., it would transform this if (x) free (x); else foo (); into this: free (x); else foo (); There were none of those here, either. If you're interested in automating detection of the useless tests, you might like the useless-if-before-free script in gnulib: [it *does* detect brace-enclosed free statements, and has a --name=S option to make it detect free-like functions with different names] http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=build-aux/useless-if-before-free Addendum: Remove one more (in imap-send.c), spotted by Jean-Luc Herren <jlh@gmx.ch>. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-11imap-send.c: guard config parser from value=NULLJunio C Hamano
None of the configuration variables this expects is boolean. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-29strbuf change: be sure ->buf is never ever NULL.Pierre Habouzit
For that purpose, the ->buf is always initialized with a char * buf living in the strbuf module. It is made a char * so that we can sloppily accept things that perform: sb->buf[0] = '\0', and because you can't pass "" as an initializer for ->buf without making gcc unhappy for very good reasons. strbuf_init/_detach/_grow have been fixed to trust ->alloc and not ->buf anymore. as a consequence strbuf_detach is _mandatory_ to detach a buffer, copying ->buf isn't an option anymore, if ->buf is going to escape from the scope, and eventually be free'd. API changes: * strbuf_setlen now always works, so just make strbuf_reset a convenience macro. * strbuf_detatch takes a size_t* optional argument (meaning it can be NULL) to copy the buffer's len, as it was needed for this refactor to make the code more readable, and working like the callers. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-21nfv?asprintf are broken without va_copy, workaround them.Pierre Habouzit
* drop nfasprintf. * move nfvasprintf into imap-send.c back, and let it work on a 8k buffer, and die() in case of overflow. It should be enough for imap commands, if someone cares about imap-send, he's welcomed to fix it properly. * replace nfvasprintf use in merge-recursive with a copy of the strbuf_addf logic, it's one place, we'll live with it. To ease the change, output_buffer string list is replaced with a strbuf ;) * rework trace.c to call vsnprintf itself. It's used to format strerror()s and git command names, it should never be more than a few octets long, let it work on a 8k static buffer with vsnprintf or die loudly. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
2007-09-19Use xmemdupz() in many places.Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-17Now that cache.h needs strbuf.h, remove useless includes.Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-10Use strbufs to in read_message (imap-send.c), custom buffer--.Pierre Habouzit
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-07War on whitespaceJunio C Hamano
This uses "git-apply --whitespace=strip" to fix whitespace errors that have crept in to our source files over time. There are a few files that need to have trailing whitespaces (most notably, test vectors). The results still passes the test, and build result in Documentation/ area is unchanged. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-05-16Ensure return value from xread() is always stored into an ssize_tJohan Herland
This patch fixes all calls to xread() where the return value is not stored into an ssize_t. The patch should not have any effect whatsoever, other than putting better/more appropriate type names on variables. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-21prefixcmp(): fix-up leftover strncmp().Junio C Hamano
There were instances of strncmp() that were formatted improperly (e.g. whitespace around parameter before closing parenthesis) that caused the earlier mechanical conversion step to miss them. This step cleans them up. Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-08short i/o: fix calls to write to use xwrite or write_in_fullAndy Whitcroft
We have a number of badly checked write() calls. Often we are expecting write() to write exactly the size we requested or fail, this fails to handle interrupts or short writes. Switch to using the new write_in_full(). Otherwise we at a minimum need to check for EINTR and EAGAIN, where this is appropriate use xwrite(). Note, the changes to config handling are much larger and handled in the next patch in the sequence. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-08short i/o: fix calls to read to use xread or read_in_fullAndy Whitcroft
We have a number of badly checked read() calls. Often we are expecting read() to read exactly the size we requested or fail, this fails to handle interrupts or short reads. Add a read_in_full() providing those semantics. Otherwise we at a minimum need to check for EINTR and EAGAIN, where this is appropriate use xread(). Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-22Rename imap-send's internal info/warn functions.Shawn O. Pearce
Because I am about to introduce a global warn() function (much like the global error function) this global declaration would conflict with the one supplied by imap-send. Further since imap-send's warn function output depends on its Quiet setting we cannot simply remove its internal definition and use the forthcoming global one. So refactor warn() -> imap_warn() and info() -> imap_info() (the latter was done just to be consistent in naming). Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-20simplify inclusion of system header files.Junio C Hamano
This is a mechanical clean-up of the way *.c files include system header files. (1) sources under compat/, platform sha-1 implementations, and xdelta code are exempt from the following rules; (2) the first #include must be "git-compat-util.h" or one of our own header file that includes it first (e.g. config.h, builtin.h, pkt-line.h); (3) system headers that are included in "git-compat-util.h" need not be included in individual C source files. (4) "git-compat-util.h" does not have to include subsystem specific header files (e.g. expat.h). Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-31Use memmove instead of memcpy for overlapping areasEdgar Toernig
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-18git-imap-send: Strip smtp From_ header from imap message.v1.4.3Markus Amsler
Cyrus imap refuses messages with a 'From ' Header. [jc: Mike McCormack says this is fine with Courier as well.] Signed-off-by: Markus Amsler <markus.amsler@oribi.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-02Trace into a file or an open fd and refactor tracing code.Christian Couder
If GIT_TRACE is set to an absolute path (starting with a '/' character), we interpret this as a file path and we trace into it. Also if GIT_TRACE is set to an integer value greater than 1 and lower than 10, we interpret this as an open fd value and we trace into it. Note that this behavior is not compatible with the previous one. We also trace whole messages using one write(2) call to make sure messages from processes do net get mixed up in the middle. This patch makes it possible to get trace information when running "make test". Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-02Replace uses of strdup with xstrdup.Shawn Pearce
Like xmalloc and xrealloc xstrdup dies with a useful message if the native strdup() implementation returns NULL rather than a valid pointer. I just tried to use xstrdup in new code and found it to be missing. However I expected it to be present as xmalloc and xrealloc are already commonly used throughout the code. [jc: removed the part that deals with last_XXX, which I am finding more and more dubious these days.] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-28Make some strings constTimo Hirvonen
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-19Change types used in bitfields to be `int's.Florian Forster
According to ANSI C99 bitfields are only defined for `signed int' and `unsigned int'. This patch corrects the bitfield in the `msg_data_t' type from `imap-send.c'. Signed-off-by: Florian Forster <octo@verplant.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-08check for error return from fork()Paul T Darga
Trivial fixup for fork() callsites which do not check for errors. Signed-off-by: Paul T Darga <pdarga@umich.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-05Avoid a crash if realloc returns a different pointer.Mike McCormack
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-05Avoid a divide by zero if there's no messages to send.Mike McCormack
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-02Fix sparse warnings about usage of 0 instead of NULLRene Scharfe
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-16fix imap-send for OSXRandal L. Schwartz
This patch works... I've been using it to stay current. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-12imap-send: Add missing #include for macosxJohannes Schindelin
There is a compile error without that. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-11imap-send: cleanup execl() call to use NULL sentinel instead of 0Marco Roeland
Some versions of gcc check that calls to the exec() family have the proper sentinel for variadic calls. This should be (char *) NULL according to the man page. Although for all other purposes the 0 is equivalent, gcc nevertheless does emit a warning for 0 and not for NULL. This also makes the usage consistent throughout git. The whitespace in function calls throughout imap-send.c has its own style, so I left it that way. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-11Add git-imap-send, derived from isync 1.0.1.Mike McCormack
git-imap-send drops a patch series generated by git-format-patch into an IMAP folder. This allows patch submitters to send patches through their own mail program. git-imap-send uses the following values from the GIT repository configuration: The target IMAP folder: [imap] Folder = "INBOX.Drafts" A command to open an ssh tunnel to the imap mail server. [imap] Tunnel = "ssh -q user@imap.server.com /usr/bin/imapd ./Maildir 2> /dev/null" [imap] Host = imap.server.com User = bob Password = pwd Port = 143