Git development
 help / color / mirror / Atom feed
* Re: [PATCH] better git-submodule status output
From: Sylvain Joyeux @ 2008-07-07  6:21 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Junio C Hamano, Lars Hjemli, Ping Yin, Mark Levedahl, git
In-Reply-To: <alpine.DEB.1.00.0807061821340.7342@eeepc-johanness>

> IOW the mail body should look like the output of format-patch, optionally 
> some comments between "--" and the diffstat.
> 
> Write a patch for SubmittingPatches.
I shall do that :)

> > > Not yet.  Will test/comment when the spurious "fetch" is fixed.
> >
> > I thought that the only thing that 'fetch' does is update FETCH_HEAD.
> 
> Uhoh.  'fetch' fetches.  Which means it does not only update something.

Yes, it fetches objects (admittedly, it updates something on the current
partition), but AFAIK does not change the state of the repository. So I thought
that it could be considered as a no-op from the repo point of view. The idea
behind the 'fetch' thing was to get the latest objects from the repository,
therefore being able to know the relationship between the currently committed
submodule state 

> There are three states that are interesting:
> 
> - the committed submodule state:
> 
>   You get this in the superproject by "git ls-tree HEAD -- <dir>"
> 
> - the local HEAD of the submodule:
> 
>   (cd "<dir>" && git rev-parse --verify HEAD)
> 
> - the HEAD of the default branch of the upstream repository of the 
>   submodule:
> 
>   (cd "<dir>" && git ls-remote origin HEAD)
>   NOTE: this does not have to do _anything_ with the submodule: you can 
>   easily have two independent branches (see "html" and "next" in git.git), 
>   and the submodule is free to be pinned to whatever commit is available
>   in the upstream repository.
>
>   It is even possible that it is pinned to a commit that is only reachable 
>   from a tag, not from a branch.
Then when you initialize your submodules it will be unable to fetch the commit
object, isn't it ? Since git-submodule clones origin/HEAD, the submodule state
committed in the repository must be reachable from origin/HEAD.

Or the third interesting state is not "the default branch of the upstream
repository of the submodule", i.e.  origin/HEAD, but the
most-probably-interesting-branch, i.e. the branch configured in .git/config as
being fetched for the current branch of the local submodule HEAD.

That is the point of this patch. It make clear, *for all registered submodules*,
what is the current relationship between the current submodule state committed
in the repository and the current submodule HEAD. The "fetch" is there to take
into account the fact that the submodule state may not yet be available locally.

Best,
--
Sylvain

^ permalink raw reply

* Re: [FIXED PATCH] Make rebase save ORIG_HEAD if changing current branch
From: Junio C Hamano @ 2008-07-07  6:28 UTC (permalink / raw)
  To: Brian Gernhardt; +Cc: Git List
In-Reply-To: <803A3528-2451-4C5D-A48D-5E0C37B8E90E@silverinsanity.com>

Brian Gernhardt <benji@silverinsanity.com> writes:

> My final thought is that the rational ORIG_HEAD and when we set it is
> not clearly documented anywhere.  But I am currently out of time to
> work on git, so that patch won't be coming from me soon.

The idea behind ORIG_HEAD is to have an anchoring point before an
operation that moves your HEAD in a drastic way.  Think if it as a
poor-man's reflog -- in fact it predates reflog.

That is why reset saves away the HEAD before it does its thing, so that
you can easily say "Oops, I did not mean it -- reset ORIG_HEAD" to flip
back to the previous state.  Both a fast-forward merge and a real merge
can be undone by resetting back to ORIG_HEAD.

So in that sense:

 (1) ORIG_HEAD is not strictly necessary these days, because we have
     reflogs;

 (2) Even then, it is handy and useful, and we could add ORIG_HEAD to more
     commands such as "git am" and "git rebase".

^ permalink raw reply

* Re: RFC: grafts generalised
From: Andreas Ericsson @ 2008-07-07  6:28 UTC (permalink / raw)
  To: Stephen R. van den Berg; +Cc: Michael J Gruber, git
In-Reply-To: <20080702174255.GB16235@cuci.nl>

Stephen R. van den Berg wrote:
> Michael J Gruber wrote:
>> Maybe the upcoming git-sequencer could be the appropriate place? It 
>> tries to achieve just that: edit history by specifying a list of 
>> commands. The currently planned set of commands would need to be 
> 
> That's the problem.  Like git filter-branch, git sequencer needs you to
> parameterise the changes, which, in my case, is hardly possible, since
> the changes are randomlike.
> Also, having to run the sequencer to dig 20000 commits into the past,
> then change something, then come back up and rewrite all following
> history and relations (parents/tags/merges) will take a sizeable amount
> of time.  I need something that can be changed at will, then viewed with
> gitk a second later.
> 

A second later might be too much, but for the case where you need to
add a patch in the middle (which I suspect is the most timeconsuming
and tricky part at the moment), you might want to use a temporary
branch checked out where you need to apply the patch, apply the patch
and then rebase the rest of the history onto that new commit. Rebase
is fairly quick (although not a one-second thing for 20k commits), so
you'll get the time down quite a bit, I imagine.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply

* Re: [PATCH] fix "git-submodule add a/b/c/repository"
From: Sylvain Joyeux @ 2008-07-07  6:34 UTC (permalink / raw)
  To: Mark Levedahl; +Cc: Junio C Hamano, Lars Hjemli, Ping Yin, git
In-Reply-To: <48711782.6090609@gmail.com>

On Sun, Jul 06, 2008 at 03:05:38PM -0400, Mark Levedahl wrote:
> Sylvain Joyeux wrote:
>>  	git submodule add init dir0/dir1/init
>>     Would clone dir0/dir1/init at ./init and add ./init as a submodule. 
>> This is
>> actually what the current git-submodule (wrongly) does.
>>
>> Sylvain
>>   
> ...after some prep work...
>
> >git submodule add init dir0/dir1/init
> Adding existing repo at 'dir0/dir1/init' to the index
>
> So, what's the problem?

Redo the prep work, the clone and now

git submodule add dir0/dir1/init

(i.e. don't expect dir0/dir1/init to be the clone of ./init, that was just a
shortcut for the test. Expect it to be a clone of "something, somewhere")

[~/tmp/test]% git-submodule add dir0/dir1/init
Initialize init/.git
Initialized empty Git repository in /home/doudou/tmp/test/init/.git/

[~/tmp/test]% git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   .gitmodules
#       new file:   init
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       dir0/

What it is supposed to do (according to the documentation) is register
dir0/dir1/init as the submodule, not clone it and register init/.

Sylvain

^ permalink raw reply

* Re: [FIXED PATCH] Make rebase save ORIG_HEAD if changing current branch
From: Junio C Hamano @ 2008-07-07  6:48 UTC (permalink / raw)
  To: Brian Gernhardt; +Cc: Git List
In-Reply-To: <7vbq1a8ay3.fsf@gitster.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> writes:

> Brian Gernhardt <benji@silverinsanity.com> writes:
>
>> My final thought is that the rational ORIG_HEAD and when we set it is
>> not clearly documented anywhere.  But I am currently out of time to
>> work on git, so that patch won't be coming from me soon.
>
> The idea behind ORIG_HEAD is to have an anchoring point before an
> operation that moves your HEAD in a drastic way.  Think if it as a
> poor-man's reflog -- in fact it predates reflog.
>
> That is why reset saves away the HEAD before it does its thing, so that
> you can easily say "Oops, I did not mean it -- reset ORIG_HEAD" to flip
> back to the previous state.  Both a fast-forward merge and a real merge
> can be undone by resetting back to ORIG_HEAD.
>
> So in that sense:
>
>  (1) ORIG_HEAD is not strictly necessary these days, because we have
>      reflogs;
>
>  (2) Even then, it is handy and useful, and we could add ORIG_HEAD to more
>      commands such as "git am" and "git rebase".

Perhaps something like this for "git am" (only minimally tested).

-- >8 --
am: record ORIG_HEAD so that we can quickly undo a large series

This teaches "git-am" to record the commit before it starts its work in
ORIG_HEAD, so that application of a large series can be undone by
resetting to it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-am.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index 2c517ed..818b4e5 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -242,6 +242,7 @@ else
 	else
 		: >"$dotest/applying"
 	fi
+	git update-ref ORIG_HEAD HEAD
 fi
 
 case "$resolved" in

^ permalink raw reply related

* Re: [PATCH v2] git daemon: avoid calling syslog() from a signal handler
From: Stephen R. van den Berg @ 2008-07-07  6:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, Brian Foster, git
In-Reply-To: <7vmykua2et.fsf@gitster.siamese.dyndns.org>

Junio C Hamano wrote:
>Another thing we might want to consider to make this logic much more
>simpler would be to move everything out of child_handler(), except the
>write() whose sole purpose is to allow us break out of the poll().

As a general rule, keep the work done in a signal handler down to the
bare minimum (like setting an integer flag, and perhaps unblocking the
main thread through a write to this signallingpipe).
-- 
Sincerely,
           Stephen R. van den Berg.

A truly wise man never plays leapfrog with a unicorn.

^ permalink raw reply

* Re: RFC: grafts generalised
From: Stephen R. van den Berg @ 2008-07-07  6:59 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: Michael J Gruber, git
In-Reply-To: <4871B7A0.1090604@op5.se>

Andreas Ericsson wrote:
>Stephen R. van den Berg wrote:
>>of time.  I need something that can be changed at will, then viewed with
>>gitk a second later.

>A second later might be too much, but for the case where you need to
>add a patch in the middle (which I suspect is the most timeconsuming
>and tricky part at the moment), you might want to use a temporary
>branch checked out where you need to apply the patch, apply the patch
>and then rebase the rest of the history onto that new commit. Rebase
>is fairly quick (although not a one-second thing for 20k commits), so
>you'll get the time down quite a bit, I imagine.

Not really.
Rebase does two things:
a. Apply every patch/commit again, which takes too long for 20k commits.
b. Mess up carefully grafted parent/merge relationships.

Rebase is only suitable for short linear strands of commits.
The history I'm dealing with is neither short, nor linear.
-- 
Sincerely,
           Stephen R. van den Berg.

A truly wise man never plays leapfrog with a unicorn.

^ permalink raw reply

* Re* [FIXED PATCH] Make rebase save ORIG_HEAD if changing current branch
From: Junio C Hamano @ 2008-07-07  7:16 UTC (permalink / raw)
  To: Nanako Shiraishi; +Cc: Brian Gernhardt, Git List
In-Reply-To: <20080707151401.6117@nanako3.lavabit.com>

Nanako Shiraishi <nanako3@lavabit.com> writes:

> Quoting Junio C Hamano <gitster@pobox.com>:
> ...
>> Having said that, thanks to updates to git-rebase, rebased_branch@{1} has
>> useful information these days, so I do not see much practical upside, even
>> though I _will_ apply this patch, just for the sake of consistency.
>
> Are you really aiming for consistency, Junio?
>
> Doesn't this make the behavior of the command inconsistent between
> "git-rebase" and "git-rebase -m"?

Hmm, it makes "rebase -i" different, too.  Luckily, I haven't pushed
anything out, so I can rewind and all I lose is just a few dozens of
minutes.

The one from Brian has another serious issue.  That patch does not allow
you to refer to ORIG_HEAD during conflict resolution, which is quite
different from how "merge" lets you use ORIG_HEAD.  We need to set
ORIG_HEAD upfront if we want to tell user that ORIG_HEAD can be reliably
used across workflows the same way to name where we were before.

When we correctly update "rebase" to do this, because one codepath of it
uses "am" as its backend, we cannot use the patch I sent out earlier.  We
probably need to do something like this (minimally tested).

-- >8 --
Teach "am" and "rebase" to mark the original position with ORIG_HEAD

"merge" and "reset" leave the original point in history in ORIG_HEAD,
which makes it easy to go back to where you were before you inflict a
major damage to your history and realize that you do not like the result
at all.  These days with reflog, we technically do not need to use
ORIG_HEAD, but it is a handy way nevertheless.

This teaches "am" and "rebase" (all forms --- the vanilla one that uses
"am" as its backend, "-m" variant that cherry-picks, and "--interactive")
to do the same.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-am.sh                  |    1 +
 git-rebase--interactive.sh |    1 +
 git-rebase.sh              |    2 +-
 3 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index 2c517ed..fe53608 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -241,6 +241,7 @@ else
 		: >"$dotest/rebasing"
 	else
 		: >"$dotest/applying"
+		git update-ref ORIG_HEAD HEAD
 	fi
 fi
 
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index a64d9d5..02d7e3c 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -549,6 +549,7 @@ EOF
 		has_action "$TODO" ||
 			die_abort "Nothing to do"
 
+		git update-ref ORIG_HEAD $HEAD
 		output git checkout $ONTO && do_rest
 		;;
 	esac
diff --git a/git-rebase.sh b/git-rebase.sh
index e2d85ee..2597d77 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -378,7 +378,7 @@ fi
 echo "First, rewinding head to replay your work on top of it..."
 git checkout "$onto^0" >/dev/null 2>&1 ||
 	die "could not detach HEAD"
-# git reset --hard "$onto^0"
+git update-ref ORIG_HEAD $branch
 
 # If the $onto is a proper descendant of the tip of the branch, then
 # we just fast forwarded.

^ permalink raw reply related

* [PATCH 1/3] git-imap-send: Allow the program to be run from subdirectories of a git tree.
From: Rob Shearman @ 2008-07-07  8:05 UTC (permalink / raw)
  To: git

Call setup_git_directory_gently to allow git-imap-send to be used from
subdirectories of a git tree.
---
 imap-send.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index 1ec1310..89a1532 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1296,6 +1296,7 @@ main(int argc, char **argv)
 	/* init the random number generator */
 	arc4_init();

+	setup_git_directory_gently( NULL );
 	git_config(git_imap_config, NULL);

 	if (!imap_folder) {
-- 
1.5.6.GIT

^ permalink raw reply related

* [PATCH 2/3] git-imap-send: Add support for SSL.
From: Rob Shearman @ 2008-07-07  8:05 UTC (permalink / raw)
  To: git

Allow SSL to be used when a imaps:// URL is used for the host name.

Also, automatically use TLS when not using imaps:// by using the IMAP
STARTTLS command, if the server supports it.

Tested with Courier and Gimap IMAP servers.
---
 Documentation/git-imap-send.txt |    5 +-
 Makefile                        |    4 +-
 imap-send.c                     |  166 +++++++++++++++++++++++++++++++++++----
 3 files changed, 157 insertions(+), 18 deletions(-)

diff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt
index b3d8da3..e4a5873 100644
--- a/Documentation/git-imap-send.txt
+++ b/Documentation/git-imap-send.txt
@@ -37,10 +37,11 @@ configuration file (shown with examples):
     Tunnel = "ssh -q user@server.com /usr/bin/imapd ./Maildir 2> /dev/null"

 [imap]
-    Host = imap.server.com
+    Host = imaps://imap.example.com
     User = bob
     Pass = pwd
-    Port = 143
+    Port = 993
+    sslverify = false
 ..........................


diff --git a/Makefile b/Makefile
index bddd1a7..d9265f7 100644
--- a/Makefile
+++ b/Makefile
@@ -1193,7 +1193,9 @@ endif
 git-%$X: %.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)

-git-imap-send$X: imap-send.o $(LIB_FILE)
+git-imap-send$X: imap-send.o $(GITLIBS)
+	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
+		$(LIBS) $(OPENSSL_LINK) $(OPENSSL_LIBSSL)

 http.o http-walker.o http-push.o transport.o: http.h

diff --git a/imap-send.c b/imap-send.c
index 89a1532..d138726 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -23,6 +23,12 @@
  */

 #include "cache.h"
+#ifdef NO_OPENSSL
+typedef void *SSL;
+#else
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+#endif

 typedef struct store_conf {
 	char *name;
@@ -129,6 +135,8 @@ typedef struct imap_server_conf {
 	int port;
 	char *user;
 	char *pass;
+	int use_ssl;
+	int ssl_verify;
 } imap_server_conf_t;

 typedef struct imap_store_conf {
@@ -148,6 +156,7 @@ typedef struct _list {

 typedef struct {
 	int fd;
+	SSL *ssl;
 } Socket_t;

 typedef struct {
@@ -201,6 +210,7 @@ enum CAPABILITY {
 	UIDPLUS,
 	LITERALPLUS,
 	NAMESPACE,
+	STARTTLS,
 };

 static const char *cap_list[] = {
@@ -208,6 +218,7 @@ static const char *cap_list[] = {
 	"UIDPLUS",
 	"LITERAL+",
 	"NAMESPACE",
+	"STARTTLS",
 };

 #define RESP_OK    0
@@ -225,19 +236,101 @@ static const char *Flags[] = {
 	"Deleted",
 };

+#ifndef NO_OPENSSL
+static void ssl_socket_perror(const char *func)
+{
+	fprintf(stderr, "%s: %s\n", func, ERR_error_string(ERR_get_error(), 0));
+}
+#endif
+
 static void
 socket_perror( const char *func, Socket_t *sock, int ret )
 {
-	if (ret < 0)
-		perror( func );
+#ifndef NO_OPENSSL
+	if (sock->ssl) {
+		int sslerr = SSL_get_error(sock->ssl, ret);
+		switch (sslerr) {
+		case SSL_ERROR_NONE:
+			break;
+		case SSL_ERROR_SYSCALL:
+			perror("SSL_connect");
+			break;
+		default:
+			ssl_socket_perror("SSL_connect");
+			break;
+		}
+	} else
+#endif
+	{
+		if (ret < 0)
+			perror(func);
+		else
+			fprintf(stderr, "%s: unexpected EOF\n", func);
+	}
+}
+
+static int ssl_socket_connect(Socket_t *sock, int use_tls_only, int verify)
+{
+#ifdef NO_OPENSSL
+	fprintf(stderr, "SSL requested but SSL support not compiled in\n");
+	return -1;
+#else
+	SSL_METHOD *meth;
+	SSL_CTX *ctx;
+	int ret;
+
+	SSL_library_init();
+	SSL_load_error_strings();
+
+	if (use_tls_only)
+		meth = TLSv1_method();
 	else
-		fprintf( stderr, "%s: unexpected EOF\n", func );
+		meth = SSLv23_method();
+
+	if (!meth) {
+		ssl_socket_perror("SSLv23_method");
+		return -1;
+	}
+
+	ctx = SSL_CTX_new(meth);
+
+	if (verify)
+		SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);
+
+	if (!SSL_CTX_set_default_verify_paths(ctx)) {
+		ssl_socket_perror("SSL_CTX_set_default_verify_paths");
+		return -1;
+	}
+	sock->ssl = SSL_new(ctx);
+	if (!sock->ssl) {
+		ssl_socket_perror("SSL_new");
+		return -1;
+	}
+	if (!SSL_set_fd(sock->ssl, sock->fd)) {
+		ssl_socket_perror("SSL_set_fd");
+		return -1;
+	}
+
+	ret = SSL_connect(sock->ssl);
+	if (ret <= 0) {
+		socket_perror("SSL_connect", sock, ret);
+		return -1;
+	}
+
+	return 0;
+#endif
 }

 static int
 socket_read( Socket_t *sock, char *buf, int len )
 {
-	ssize_t n = xread( sock->fd, buf, len );
+	ssize_t n;
+#ifndef NO_OPENSSL
+	if (sock->ssl)
+		n = SSL_read(sock->ssl, buf, len);
+	else
+#endif
+		n = xread( sock->fd, buf, len );
 	if (n <= 0) {
 		socket_perror( "read", sock, n );
 		close( sock->fd );
@@ -249,7 +342,13 @@ socket_read( Socket_t *sock, char *buf, int len )
 static int
 socket_write( Socket_t *sock, const char *buf, int len )
 {
-	int n = write_in_full( sock->fd, buf, len );
+	int n;
+#ifndef NO_OPENSSL
+	if (sock->ssl)
+		n = SSL_write(sock->ssl, buf, len);
+	else
+#endif
+		n = write_in_full( sock->fd, buf, len );
 	if (n != len) {
 		socket_perror( "write", sock, n );
 		close( sock->fd );
@@ -258,6 +357,17 @@ socket_write( Socket_t *sock, const char *buf, int len )
 	return n;
 }

+static void socket_shutdown(Socket_t *sock)
+{
+#ifndef NO_OPENSSL
+	if (sock->ssl) {
+		SSL_shutdown(sock->ssl);
+		SSL_free(sock->ssl);
+	}
+#endif
+	close(sock->fd);
+}
+
 /* simple line buffering */
 static int
 buffer_gets( buffer_t * b, char **s )
@@ -875,7 +985,7 @@ imap_close_server( imap_store_t *ictx )

 	if (imap->buf.sock.fd != -1) {
 		imap_exec( ictx, NULL, "LOGOUT" );
-		close( imap->buf.sock.fd );
+		socket_shutdown( &imap->buf.sock );
 	}
 	free_list( imap->ns_personal );
 	free_list( imap->ns_other );
@@ -906,6 +1016,7 @@ imap_open_store( imap_server_conf_t *srvc )

 	ctx->imap = imap = xcalloc( sizeof(*imap), 1 );
 	imap->buf.sock.fd = -1;
+	imap->buf.sock.ssl = NULL;
 	imap->in_progress_append = &imap->in_progress;

 	/* open connection to IMAP server */
@@ -958,10 +1069,15 @@ imap_open_store( imap_server_conf_t *srvc )
 			perror( "connect" );
 			goto bail;
 		}
-		imap_info( "ok\n" );
-
+		
 		imap->buf.sock.fd = s;

+		if (srvc->use_ssl &&
+		    ssl_socket_connect(&imap->buf.sock, 0, srvc->ssl_verify)) {
+			close(s);
+			goto bail;
+		}
+		imap_info( "ok\n" );
 	}

 	/* read the greeting string */
@@ -986,7 +1102,18 @@ imap_open_store( imap_server_conf_t *srvc )
 		goto bail;

 	if (!preauth) {
-
+#ifndef NO_OPENSSL
+		if (!srvc->use_ssl && CAP(STARTTLS)) {
+			if (imap_exec(ctx, 0, "STARTTLS") != RESP_OK)
+				goto bail;
+			if (ssl_socket_connect(&imap->buf.sock, 1,
+					       srvc->ssl_verify))
+				goto bail;
+			/* capabilities may have changed, so get the new capabilities */
+			if (imap_exec(ctx, 0, "CAPABILITY") != RESP_OK)
+				goto bail;
+		}
+#endif
 		imap_info ("Logging in...\n");
 		if (!srvc->user) {
 			fprintf( stderr, "Skipping server %s, no user\n", srvc->host );
@@ -1014,7 +1141,9 @@ imap_open_store( imap_server_conf_t *srvc )
 			fprintf( stderr, "Skipping account %s@%s, server forbids LOGIN\n",
srvc->user, srvc->host );
 			goto bail;
 		}
-		imap_warn( "*** IMAP Warning *** Password is being sent in the clear\n" );
+		if (!imap->buf.sock.ssl)
+			imap_warn( "*** IMAP Warning *** Password is being "
+				   "sent in the clear\n" );
 		if (imap_exec( ctx, NULL, "LOGIN \"%s\" \"%s\"", srvc->user,
srvc->pass ) != RESP_OK) {
 			fprintf( stderr, "IMAP error: LOGIN failed\n" );
 			goto bail;
@@ -1242,6 +1371,8 @@ static imap_server_conf_t server =
 	0,	/* port */
 	NULL,	/* user */
 	NULL,	/* pass */
+	0,   	/* use_ssl */
+	1,   	/* ssl_verify */
 };

 static char *imap_folder;
@@ -1262,11 +1393,11 @@ git_imap_config(const char *key, const char
*val, void *cb)
 	if (!strcmp( "folder", key )) {
 		imap_folder = xstrdup( val );
 	} else if (!strcmp( "host", key )) {
-		{
-			if (!prefixcmp(val, "imap:"))
-				val += 5;
-			if (!server.port)
-				server.port = 143;
+		if (!prefixcmp(val, "imap:"))
+			val += 5;
+		else if (!prefixcmp(val, "imaps:")) {
+			val += 6;
+			server.use_ssl = 1;
 		}
 		if (!prefixcmp(val, "//"))
 			val += 2;
@@ -1280,6 +1411,8 @@ git_imap_config(const char *key, const char
*val, void *cb)
 		server.port = git_config_int( key, val );
 	else if (!strcmp( "tunnel", key ))
 		server.tunnel = xstrdup( val );
+	else if (!strcmp( "ssl_verify", key ))
+		server.ssl_verify = git_config_bool( key, val );
 	return 0;
 }

@@ -1299,6 +1432,9 @@ main(int argc, char **argv)
 	setup_git_directory_gently( NULL );
 	git_config(git_imap_config, NULL);

+	if (!server.port)
+		server.port = server.use_ssl ? 993 : 143;
+
 	if (!imap_folder) {
 		fprintf( stderr, "no imap store specified\n" );
 		return 1;
-- 
1.5.6.GIT

^ permalink raw reply related

* [PATCH 3/3] imap-send.c: Clean up coding style to better match the rest of the git codebase.
From: Rob Shearman @ 2008-07-07  8:05 UTC (permalink / raw)
  To: git

---
 imap-send.c |  631 ++++++++++++++++++++++++++++-------------------------------
 1 files changed, 301 insertions(+), 330 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index d138726..59ef4eb 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -102,14 +102,14 @@ typedef struct {

 static int Verbose, Quiet;

-static void imap_info( const char *, ... );
-static void imap_warn( const char *, ... );
+static void imap_info(const char *, ...);
+static void imap_warn(const char *, ...);

-static char *next_arg( char ** );
+static char *next_arg(char **);

-static void free_generic_messages( message_t * );
+static void free_generic_messages(message_t *);

-static int nfsnprintf( char *buf, int blen, const char *fmt, ... );
+static int nfsnprintf(char *buf, int blen, const char *fmt, ...);

 static int nfvasprintf(char **strp, const char *fmt, va_list ap)
 {
@@ -125,8 +125,8 @@ static int nfvasprintf(char **strp, const char
*fmt, va_list ap)
 	return len;
 }

-static void arc4_init( void );
-static unsigned char arc4_getbyte( void );
+static void arc4_init(void);
+static unsigned char arc4_getbyte(void);

 typedef struct imap_server_conf {
 	char *name;
@@ -187,8 +187,8 @@ typedef struct imap_store {
 } imap_store_t;

 struct imap_cmd_cb {
-	int (*cont)( imap_store_t *ctx, struct imap_cmd *cmd, const char *prompt );
-	void (*done)( imap_store_t *ctx, struct imap_cmd *cmd, int response);
+	int (*cont)(imap_store_t *ctx, struct imap_cmd *cmd, const char *prompt);
+	void (*done)(imap_store_t *ctx, struct imap_cmd *cmd, int response);
 	void *ctx;
 	char *data;
 	int dlen;
@@ -225,7 +225,7 @@ static const char *cap_list[] = {
 #define RESP_NO    1
 #define RESP_BAD   2

-static int get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd );
+static int get_cmd_result(imap_store_t *ctx, struct imap_cmd *tcmd);


 static const char *Flags[] = {
@@ -243,8 +243,7 @@ static void ssl_socket_perror(const char *func)
 }
 #endif

-static void
-socket_perror( const char *func, Socket_t *sock, int ret )
+static void socket_perror(const char *func, Socket_t *sock, int ret)
 {
 #ifndef NO_OPENSSL
 	if (sock->ssl) {
@@ -321,8 +320,7 @@ static int ssl_socket_connect(Socket_t *sock, int
use_tls_only, int verify)
 #endif
 }

-static int
-socket_read( Socket_t *sock, char *buf, int len )
+static int socket_read(Socket_t *sock, char *buf, int len)
 {
 	ssize_t n;
 #ifndef NO_OPENSSL
@@ -330,17 +328,16 @@ socket_read( Socket_t *sock, char *buf, int len )
 		n = SSL_read(sock->ssl, buf, len);
 	else
 #endif
-		n = xread( sock->fd, buf, len );
+		n = xread(sock->fd, buf, len);
 	if (n <= 0) {
-		socket_perror( "read", sock, n );
-		close( sock->fd );
+		socket_perror("read", sock, n);
+		close(sock->fd);
 		sock->fd = -1;
 	}
 	return n;
 }

-static int
-socket_write( Socket_t *sock, const char *buf, int len )
+static int socket_write(Socket_t *sock, const char *buf, int len)
 {
 	int n;
 #ifndef NO_OPENSSL
@@ -348,10 +345,10 @@ socket_write( Socket_t *sock, const char *buf, int len )
 		n = SSL_write(sock->ssl, buf, len);
 	else
 #endif
-		n = write_in_full( sock->fd, buf, len );
+		n = write_in_full(sock->fd, buf, len);
 	if (n != len) {
-		socket_perror( "write", sock, n );
-		close( sock->fd );
+		socket_perror("write", sock, n);
+		close(sock->fd);
 		sock->fd = -1;
 	}
 	return n;
@@ -369,8 +366,7 @@ static void socket_shutdown(Socket_t *sock)
 }

 /* simple line buffering */
-static int
-buffer_gets( buffer_t * b, char **s )
+static int buffer_gets(buffer_t * b, char **s)
 {
 	int n;
 	int start = b->offset;
@@ -384,7 +380,7 @@ buffer_gets( buffer_t * b, char **s )
 				/* shift down used bytes */
 				*s = b->buf;

-				assert( start <= b->bytes );
+				assert(start <= b->bytes);
 				n = b->bytes - start;

 				if (n)
@@ -394,8 +390,8 @@ buffer_gets( buffer_t * b, char **s )
 				start = 0;
 			}

-			n = socket_read( &b->sock, b->buf + b->bytes,
-					 sizeof(b->buf) - b->bytes );
+			n = socket_read(&b->sock, b->buf + b->bytes,
+					 sizeof(b->buf) - b->bytes);

 			if (n <= 0)
 				return -1;
@@ -404,12 +400,12 @@ buffer_gets( buffer_t * b, char **s )
 		}

 		if (b->buf[b->offset] == '\r') {
-			assert( b->offset + 1 < b->bytes );
+			assert(b->offset + 1 < b->bytes);
 			if (b->buf[b->offset + 1] == '\n') {
 				b->buf[b->offset] = 0;  /* terminate the string */
 				b->offset += 2; /* next line */
 				if (Verbose)
-					puts( *s );
+					puts(*s);
 				return 0;
 			}
 		}
@@ -419,39 +415,36 @@ buffer_gets( buffer_t * b, char **s )
 	/* not reached */
 }

-static void
-imap_info( const char *msg, ... )
+static void imap_info(const char *msg, ...)
 {
 	va_list va;

 	if (!Quiet) {
-		va_start( va, msg );
-		vprintf( msg, va );
-		va_end( va );
-		fflush( stdout );
+		va_start(va, msg);
+		vprintf(msg, va);
+		va_end(va);
+		fflush(stdout);
 	}
 }

-static void
-imap_warn( const char *msg, ... )
+static void imap_warn(const char *msg, ...)
 {
 	va_list va;

 	if (Quiet < 2) {
-		va_start( va, msg );
-		vfprintf( stderr, msg, va );
-		va_end( va );
+		va_start(va, msg);
+		vfprintf(stderr, msg, va);
+		va_end(va);
 	}
 }

-static char *
-next_arg( char **s )
+static char *next_arg(char **s)
 {
 	char *ret;

 	if (!s || !*s)
 		return NULL;
-	while (isspace( (unsigned char) **s ))
+	while (isspace((unsigned char) **s))
 		(*s)++;
 	if (!**s) {
 		*s = NULL;
@@ -460,10 +453,10 @@ next_arg( char **s )
 	if (**s == '"') {
 		++*s;
 		ret = *s;
-		*s = strchr( *s, '"' );
+		*s = strchr(*s, '"');
 	} else {
 		ret = *s;
-		while (**s && !isspace( (unsigned char) **s ))
+		while (**s && !isspace((unsigned char) **s))
 			(*s)++;
 	}
 	if (*s) {
@@ -475,27 +468,25 @@ next_arg( char **s )
 	return ret;
 }

-static void
-free_generic_messages( message_t *msgs )
+static void free_generic_messages(message_t *msgs)
 {
 	message_t *tmsg;

 	for (; msgs; msgs = tmsg) {
 		tmsg = msgs->next;
-		free( msgs );
+		free(msgs);
 	}
 }

-static int
-nfsnprintf( char *buf, int blen, const char *fmt, ... )
+static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
 {
 	int ret;
 	va_list va;

-	va_start( va, fmt );
-	if (blen <= 0 || (unsigned)(ret = vsnprintf( buf, blen, fmt, va ))
>= (unsigned)blen)
-		die( "Fatal: buffer too small. Please report a bug.\n");
-	va_end( va );
+	va_start(va, fmt);
+	if (blen <= 0 || (unsigned)(ret = vsnprintf(buf, blen, fmt, va)) >=
(unsigned)blen)
+		die("Fatal: buffer too small. Please report a bug.\n");
+	va_end(va);
 	return ret;
 }

@@ -503,21 +494,20 @@ static struct {
 	unsigned char i, j, s[256];
 } rs;

-static void
-arc4_init( void )
+static void arc4_init(void)
 {
 	int i, fd;
 	unsigned char j, si, dat[128];

-	if ((fd = open( "/dev/urandom", O_RDONLY )) < 0 && (fd = open(
"/dev/random", O_RDONLY )) < 0) {
-		fprintf( stderr, "Fatal: no random number source available.\n" );
-		exit( 3 );
+	if ((fd = open("/dev/urandom", O_RDONLY)) < 0 && (fd =
open("/dev/random", O_RDONLY)) < 0) {
+		fprintf(stderr, "Fatal: no random number source available.\n");
+		exit(3);
 	}
-	if (read_in_full( fd, dat, 128 ) != 128) {
-		fprintf( stderr, "Fatal: cannot read random number source.\n" );
-		exit( 3 );
+	if (read_in_full(fd, dat, 128) != 128) {
+		fprintf(stderr, "Fatal: cannot read random number source.\n");
+		exit(3);
 	}
-	close( fd );
+	close(fd);

 	for (i = 0; i < 256; i++)
 		rs.s[i] = i;
@@ -533,8 +523,7 @@ arc4_init( void )
 		arc4_getbyte();
 }

-static unsigned char
-arc4_getbyte( void )
+static unsigned char arc4_getbyte(void)
 {
 	unsigned char si, sj;

@@ -547,54 +536,54 @@ arc4_getbyte( void )
 	return rs.s[(si + sj) & 0xff];
 }

-static struct imap_cmd *
-v_issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb,
-		  const char *fmt, va_list ap )
+static struct imap_cmd *v_issue_imap_cmd(imap_store_t *ctx,
+					 struct imap_cmd_cb *cb,
+					 const char *fmt, va_list ap)
 {
 	imap_t *imap = ctx->imap;
 	struct imap_cmd *cmd;
 	int n, bufl;
 	char buf[1024];

-	cmd = xmalloc( sizeof(struct imap_cmd) );
-	nfvasprintf( &cmd->cmd, fmt, ap );
+	cmd = xmalloc(sizeof(struct imap_cmd));
+	nfvasprintf(&cmd->cmd, fmt, ap);
 	cmd->tag = ++imap->nexttag;

 	if (cb)
 		cmd->cb = *cb;
 	else
-		memset( &cmd->cb, 0, sizeof(cmd->cb) );
+		memset(&cmd->cb, 0, sizeof(cmd->cb));

 	while (imap->literal_pending)
-		get_cmd_result( ctx, NULL );
+		get_cmd_result(ctx, NULL);

-	bufl = nfsnprintf( buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ?
+	bufl = nfsnprintf(buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ?
 			   "%d %s{%d+}\r\n" : "%d %s{%d}\r\n" : "%d %s\r\n",
-			   cmd->tag, cmd->cmd, cmd->cb.dlen );
+			   cmd->tag, cmd->cmd, cmd->cb.dlen);
 	if (Verbose) {
 		if (imap->num_in_progress)
-			printf( "(%d in progress) ", imap->num_in_progress );
-		if (memcmp( cmd->cmd, "LOGIN", 5 ))
-			printf( ">>> %s", buf );
+			printf("(%d in progress) ", imap->num_in_progress);
+		if (memcmp(cmd->cmd, "LOGIN", 5))
+			printf(">>> %s", buf);
 		else
-			printf( ">>> %d LOGIN <user> <pass>\n", cmd->tag );
+			printf(">>> %d LOGIN <user> <pass>\n", cmd->tag);
 	}
-	if (socket_write( &imap->buf.sock, buf, bufl ) != bufl) {
-		free( cmd->cmd );
-		free( cmd );
+	if (socket_write(&imap->buf.sock, buf, bufl) != bufl) {
+		free(cmd->cmd);
+		free(cmd);
 		if (cb)
-			free( cb->data );
+			free(cb->data);
 		return NULL;
 	}
 	if (cmd->cb.data) {
 		if (CAP(LITERALPLUS)) {
-			n = socket_write( &imap->buf.sock, cmd->cb.data, cmd->cb.dlen );
-			free( cmd->cb.data );
+			n = socket_write(&imap->buf.sock, cmd->cb.data, cmd->cb.dlen);
+			free(cmd->cb.data);
 			if (n != cmd->cb.dlen ||
-			    (n = socket_write( &imap->buf.sock, "\r\n", 2 )) != 2)
+			    (n = socket_write(&imap->buf.sock, "\r\n", 2)) != 2)
 			{
-				free( cmd->cmd );
-				free( cmd );
+				free(cmd->cmd);
+				free(cmd);
 				return NULL;
 			}
 			cmd->cb.data = NULL;
@@ -609,109 +598,106 @@ v_issue_imap_cmd( imap_store_t *ctx, struct
imap_cmd_cb *cb,
 	return cmd;
 }

-static struct imap_cmd *
-issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb, const char
*fmt, ... )
+static struct imap_cmd *issue_imap_cmd(imap_store_t *ctx,
+				       struct imap_cmd_cb *cb,
+				       const char *fmt, ...)
 {
 	struct imap_cmd *ret;
 	va_list ap;

-	va_start( ap, fmt );
-	ret = v_issue_imap_cmd( ctx, cb, fmt, ap );
-	va_end( ap );
+	va_start(ap, fmt);
+	ret = v_issue_imap_cmd(ctx, cb, fmt, ap);
+	va_end(ap);
 	return ret;
 }

-static int
-imap_exec( imap_store_t *ctx, struct imap_cmd_cb *cb, const char *fmt, ... )
+static int imap_exec(imap_store_t *ctx, struct imap_cmd_cb *cb,
+		     const char *fmt, ...)
 {
 	va_list ap;
 	struct imap_cmd *cmdp;

-	va_start( ap, fmt );
-	cmdp = v_issue_imap_cmd( ctx, cb, fmt, ap );
-	va_end( ap );
+	va_start(ap, fmt);
+	cmdp = v_issue_imap_cmd(ctx, cb, fmt, ap);
+	va_end(ap);
 	if (!cmdp)
 		return RESP_BAD;

-	return get_cmd_result( ctx, cmdp );
+	return get_cmd_result(ctx, cmdp);
 }

-static int
-imap_exec_m( imap_store_t *ctx, struct imap_cmd_cb *cb, const char *fmt, ... )
+static int imap_exec_m(imap_store_t *ctx, struct imap_cmd_cb *cb,
+		       const char *fmt, ...)
 {
 	va_list ap;
 	struct imap_cmd *cmdp;

-	va_start( ap, fmt );
-	cmdp = v_issue_imap_cmd( ctx, cb, fmt, ap );
-	va_end( ap );
+	va_start(ap, fmt);
+	cmdp = v_issue_imap_cmd(ctx, cb, fmt, ap);
+	va_end(ap);
 	if (!cmdp)
 		return DRV_STORE_BAD;

-	switch (get_cmd_result( ctx, cmdp )) {
+	switch (get_cmd_result(ctx, cmdp)) {
 	case RESP_BAD: return DRV_STORE_BAD;
 	case RESP_NO: return DRV_MSG_BAD;
 	default: return DRV_OK;
 	}
 }

-static int
-is_atom( list_t *list )
+static int is_atom(list_t *list)
 {
 	return list && list->val && list->val != NIL && list->val != LIST;
 }

-static int
-is_list( list_t *list )
+static int is_list(list_t *list)
 {
 	return list && list->val == LIST;
 }

-static void
-free_list( list_t *list )
+static void free_list(list_t *list)
 {
 	list_t *tmp;

 	for (; list; list = tmp) {
 		tmp = list->next;
-		if (is_list( list ))
-			free_list( list->child );
-		else if (is_atom( list ))
-			free( list->val );
-		free( list );
+		if (is_list(list))
+			free_list(list->child);
+		else if (is_atom(list))
+			free(list->val);
+		free(list);
 	}
 }

-static int
-parse_imap_list_l( imap_t *imap, char **sp, list_t **curp, int level )
+static int parse_imap_list_l(imap_t *imap, char **sp, list_t **curp, int level)
 {
 	list_t *cur;
 	char *s = *sp, *p;
 	int n, bytes;

 	for (;;) {
-		while (isspace( (unsigned char)*s ))
+		while (isspace((unsigned char)*s))
 			s++;
 		if (level && *s == ')') {
 			s++;
 			break;
 		}
-		*curp = cur = xmalloc( sizeof(*cur) );
+		*curp = cur = xmalloc(sizeof(*cur));
 		curp = &cur->next;
 		cur->val = NULL; /* for clean bail */
 		if (*s == '(') {
 			/* sublist */
 			s++;
 			cur->val = LIST;
-			if (parse_imap_list_l( imap, &s, &cur->child, level + 1 ))
+			if (parse_imap_list_l(imap, &s, &cur->child, level + 1))
 				goto bail;
 		} else if (imap && *s == '{') {
 			/* literal */
-			bytes = cur->len = strtol( s + 1, &s, 10 );
+			bytes = cur->len = strtol(s + 1, &s, 10);
 			if (*s != '}')
 				goto bail;

-			s = cur->val = xmalloc( cur->len );
+			s = cur->val = xmalloc(cur->len);

 			/* dump whats left over in the input buffer */
 			n = imap->buf.bytes - imap->buf.offset;
@@ -720,7 +706,7 @@ parse_imap_list_l( imap_t *imap, char **sp, list_t
**curp, int level )
 				/* the entire message fit in the buffer */
 				n = bytes;

-			memcpy( s, imap->buf.buf + imap->buf.offset, n );
+			memcpy(s, imap->buf.buf + imap->buf.offset, n);
 			s += n;
 			bytes -= n;

@@ -729,13 +715,13 @@ parse_imap_list_l( imap_t *imap, char **sp,
list_t **curp, int level )

 			/* now read the rest of the message */
 			while (bytes > 0) {
-				if ((n = socket_read (&imap->buf.sock, s, bytes)) <= 0)
+				if ((n = socket_read(&imap->buf.sock, s, bytes)) <= 0)
 					goto bail;
 				s += n;
 				bytes -= n;
 			}

-			if (buffer_gets( &imap->buf, &s ))
+			if (buffer_gets(&imap->buf, &s))
 				goto bail;
 		} else if (*s == '"') {
 			/* quoted string */
@@ -750,11 +736,11 @@ parse_imap_list_l( imap_t *imap, char **sp,
list_t **curp, int level )
 		} else {
 			/* atom */
 			p = s;
-			for (; *s && !isspace( (unsigned char)*s ); s++)
+			for (; *s && !isspace((unsigned char)*s); s++)
 				if (level && *s == ')')
 					break;
 			cur->len = s - p;
-			if (cur->len == 3 && !memcmp ("NIL", p, 3)) {
+			if (cur->len == 3 && !memcmp("NIL", p, 3)) {
 				cur->val = NIL;
 			} else {
 				cur->val = xmemdupz(p, cur->len);
@@ -775,39 +761,36 @@ parse_imap_list_l( imap_t *imap, char **sp,
list_t **curp, int level )
 	return -1;
 }

-static list_t *
-parse_imap_list( imap_t *imap, char **sp )
+static list_t *parse_imap_list(imap_t *imap, char **sp)
 {
 	list_t *head;

-	if (!parse_imap_list_l( imap, sp, &head, 0 ))
+	if (!parse_imap_list_l(imap, sp, &head, 0))
 		return head;
-	free_list( head );
+	free_list(head);
 	return NULL;
 }

-static list_t *
-parse_list( char **sp )
+static list_t *parse_list(char **sp)
 {
-	return parse_imap_list( NULL, sp );
+	return parse_imap_list(NULL, sp);
 }

-static void
-parse_capability( imap_t *imap, char *cmd )
+static void parse_capability(imap_t *imap, char *cmd)
 {
 	char *arg;
 	unsigned i;

 	imap->caps = 0x80000000;
-	while ((arg = next_arg( &cmd )))
+	while ((arg = next_arg(&cmd)))
 		for (i = 0; i < ARRAY_SIZE(cap_list); i++)
-			if (!strcmp( cap_list[i], arg ))
+			if (!strcmp(cap_list[i], arg))
 				imap->caps |= 1 << i;
 	imap->rcaps = imap->caps;
 }

-static int
-parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
+static int parse_response_code(imap_store_t *ctx, struct imap_cmd_cb *cb,
+			       char *s)
 {
 	imap_t *imap = ctx->imap;
 	char *arg, *p;
@@ -815,43 +798,42 @@ parse_response_code( imap_store_t *ctx, struct
imap_cmd_cb *cb, char *s )
 	if (*s != '[')
 		return RESP_OK;		/* no response code */
 	s++;
-	if (!(p = strchr( s, ']' ))) {
-		fprintf( stderr, "IMAP error: malformed response code\n" );
+	if (!(p = strchr(s, ']'))) {
+		fprintf(stderr, "IMAP error: malformed response code\n");
 		return RESP_BAD;
 	}
 	*p++ = 0;
-	arg = next_arg( &s );
-	if (!strcmp( "UIDVALIDITY", arg )) {
-		if (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg ))) {
-			fprintf( stderr, "IMAP error: malformed UIDVALIDITY status\n" );
+	arg = next_arg(&s);
+	if (!strcmp("UIDVALIDITY", arg)) {
+		if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg))) {
+			fprintf(stderr, "IMAP error: malformed UIDVALIDITY status\n");
 			return RESP_BAD;
 		}
-	} else if (!strcmp( "UIDNEXT", arg )) {
-		if (!(arg = next_arg( &s )) || !(imap->uidnext = atoi( arg ))) {
-			fprintf( stderr, "IMAP error: malformed NEXTUID status\n" );
+	} else if (!strcmp("UIDNEXT", arg)) {
+		if (!(arg = next_arg(&s)) || !(imap->uidnext = atoi(arg))) {
+			fprintf(stderr, "IMAP error: malformed NEXTUID status\n");
 			return RESP_BAD;
 		}
-	} else if (!strcmp( "CAPABILITY", arg )) {
-		parse_capability( imap, s );
-	} else if (!strcmp( "ALERT", arg )) {
+	} else if (!strcmp("CAPABILITY", arg)) {
+		parse_capability(imap, s);
+	} else if (!strcmp("ALERT", arg)) {
 		/* RFC2060 says that these messages MUST be displayed
 		 * to the user
 		 */
-		for (; isspace( (unsigned char)*p ); p++);
-		fprintf( stderr, "*** IMAP ALERT *** %s\n", p );
-	} else if (cb && cb->ctx && !strcmp( "APPENDUID", arg )) {
-		if (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg )) ||
-		    !(arg = next_arg( &s )) || !(*(int *)cb->ctx = atoi( arg )))
+		for (; isspace((unsigned char)*p); p++);
+		fprintf(stderr, "*** IMAP ALERT *** %s\n", p);
+	} else if (cb && cb->ctx && !strcmp("APPENDUID", arg)) {
+		if (!(arg = next_arg(&s)) || !(ctx->gen.uidvalidity = atoi(arg)) ||
+		    !(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg)))
 		{
-			fprintf( stderr, "IMAP error: malformed APPENDUID status\n" );
+			fprintf(stderr, "IMAP error: malformed APPENDUID status\n");
 			return RESP_BAD;
 		}
 	}
 	return RESP_OK;
 }

-static int
-get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
+static int get_cmd_result(imap_store_t *ctx, struct imap_cmd *tcmd)
 {
 	imap_t *imap = ctx->imap;
 	struct imap_cmd *cmdp, **pcmdp, *ncmdp;
@@ -859,38 +841,38 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
 	int n, resp, resp2, tag;

 	for (;;) {
-		if (buffer_gets( &imap->buf, &cmd ))
+		if (buffer_gets(&imap->buf, &cmd))
 			return RESP_BAD;

-		arg = next_arg( &cmd );
+		arg = next_arg(&cmd);
 		if (*arg == '*') {
-			arg = next_arg( &cmd );
+			arg = next_arg(&cmd);
 			if (!arg) {
-				fprintf( stderr, "IMAP error: unable to parse untagged response\n" );
+				fprintf(stderr, "IMAP error: unable to parse untagged response\n");
 				return RESP_BAD;
 			}

-			if (!strcmp( "NAMESPACE", arg )) {
-				imap->ns_personal = parse_list( &cmd );
-				imap->ns_other = parse_list( &cmd );
-				imap->ns_shared = parse_list( &cmd );
-			} else if (!strcmp( "OK", arg ) || !strcmp( "BAD", arg ) ||
-				   !strcmp( "NO", arg ) || !strcmp( "BYE", arg )) {
-				if ((resp = parse_response_code( ctx, NULL, cmd )) != RESP_OK)
+			if (!strcmp("NAMESPACE", arg)) {
+				imap->ns_personal = parse_list(&cmd);
+				imap->ns_other = parse_list(&cmd);
+				imap->ns_shared = parse_list(&cmd);
+			} else if (!strcmp("OK", arg) || !strcmp("BAD", arg) ||
+				   !strcmp("NO", arg) || !strcmp("BYE", arg)) {
+				if ((resp = parse_response_code(ctx, NULL, cmd)) != RESP_OK)
 					return resp;
-			} else if (!strcmp( "CAPABILITY", arg ))
-				parse_capability( imap, cmd );
-			else if ((arg1 = next_arg( &cmd ))) {
-				if (!strcmp( "EXISTS", arg1 ))
-					ctx->gen.count = atoi( arg );
-				else if (!strcmp( "RECENT", arg1 ))
-					ctx->gen.recent = atoi( arg );
+			} else if (!strcmp("CAPABILITY", arg))
+				parse_capability(imap, cmd);
+			else if ((arg1 = next_arg(&cmd))) {
+				if (!strcmp("EXISTS", arg1))
+					ctx->gen.count = atoi(arg);
+				else if (!strcmp("RECENT", arg1))
+					ctx->gen.recent = atoi(arg);
 			} else {
-				fprintf( stderr, "IMAP error: unable to parse untagged response\n" );
+				fprintf(stderr, "IMAP error: unable to parse untagged response\n");
 				return RESP_BAD;
 			}
 		} else if (!imap->in_progress) {
-			fprintf( stderr, "IMAP error: unexpected reply: %s %s\n", arg, cmd
? cmd : "" );
+			fprintf(stderr, "IMAP error: unexpected reply: %s %s\n", arg, cmd
? cmd : "");
 			return RESP_BAD;
 		} else if (*arg == '+') {
 			/* This can happen only with the last command underway, as
@@ -898,30 +880,30 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
 			cmdp = (struct imap_cmd *)((char *)imap->in_progress_append -
 			       offsetof(struct imap_cmd, next));
 			if (cmdp->cb.data) {
-				n = socket_write( &imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen );
-				free( cmdp->cb.data );
+				n = socket_write(&imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen);
+				free(cmdp->cb.data);
 				cmdp->cb.data = NULL;
 				if (n != (int)cmdp->cb.dlen)
 					return RESP_BAD;
 			} else if (cmdp->cb.cont) {
-				if (cmdp->cb.cont( ctx, cmdp, cmd ))
+				if (cmdp->cb.cont(ctx, cmdp, cmd))
 					return RESP_BAD;
 			} else {
-				fprintf( stderr, "IMAP error: unexpected command continuation request\n" );
+				fprintf(stderr, "IMAP error: unexpected command continuation request\n");
 				return RESP_BAD;
 			}
-			if (socket_write( &imap->buf.sock, "\r\n", 2 ) != 2)
+			if (socket_write(&imap->buf.sock, "\r\n", 2) != 2)
 				return RESP_BAD;
 			if (!cmdp->cb.cont)
 				imap->literal_pending = 0;
 			if (!tcmd)
 				return DRV_OK;
 		} else {
-			tag = atoi( arg );
+			tag = atoi(arg);
 			for (pcmdp = &imap->in_progress; (cmdp = *pcmdp); pcmdp = &cmdp->next)
 				if (cmdp->tag == tag)
 					goto gottag;
-			fprintf( stderr, "IMAP error: unexpected tag %s\n", arg );
+			fprintf(stderr, "IMAP error: unexpected tag %s\n", arg);
 			return RESP_BAD;
 		  gottag:
 			if (!(*pcmdp = cmdp->next))
@@ -929,26 +911,26 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
 			imap->num_in_progress--;
 			if (cmdp->cb.cont || cmdp->cb.data)
 				imap->literal_pending = 0;
-			arg = next_arg( &cmd );
-			if (!strcmp( "OK", arg ))
+			arg = next_arg(&cmd);
+			if (!strcmp("OK", arg))
 				resp = DRV_OK;
 			else {
-				if (!strcmp( "NO", arg )) {
-					if (cmdp->cb.create && cmd && (cmdp->cb.trycreate || !memcmp(
cmd, "[TRYCREATE]", 11 ))) { /* SELECT, APPEND or UID COPY */
-						p = strchr( cmdp->cmd, '"' );
-						if (!issue_imap_cmd( ctx, NULL, "CREATE \"%.*s\"", strchr( p +
1, '"' ) - p + 1, p )) {
+				if (!strcmp("NO", arg)) {
+					if (cmdp->cb.create && cmd && (cmdp->cb.trycreate ||
!memcmp(cmd, "[TRYCREATE]", 11))) { /* SELECT, APPEND or UID COPY */
+						p = strchr(cmdp->cmd, '"');
+						if (!issue_imap_cmd(ctx, NULL, "CREATE \"%.*s\"", strchr(p + 1,
'"') - p + 1, p)) {
 							resp = RESP_BAD;
 							goto normal;
 						}
 						/* not waiting here violates the spec, but a server that does not
 						   grok this nonetheless violates it too. */
 						cmdp->cb.create = 0;
-						if (!(ncmdp = issue_imap_cmd( ctx, &cmdp->cb, "%s", cmdp->cmd ))) {
+						if (!(ncmdp = issue_imap_cmd(ctx, &cmdp->cb, "%s", cmdp->cmd))) {
 							resp = RESP_BAD;
 							goto normal;
 						}
-						free( cmdp->cmd );
-						free( cmdp );
+						free(cmdp->cmd);
+						free(cmdp);
 						if (!tcmd)
 							return 0;	/* ignored */
 						if (cmdp == tcmd)
@@ -956,21 +938,21 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
 						continue;
 					}
 					resp = RESP_NO;
-				} else /*if (!strcmp( "BAD", arg ))*/
+				} else /*if (!strcmp("BAD", arg))*/
 					resp = RESP_BAD;
-				fprintf( stderr, "IMAP command '%s' returned response (%s) - %s\n",
-					 memcmp (cmdp->cmd, "LOGIN", 5) ?
+				fprintf(stderr, "IMAP command '%s' returned response (%s) - %s\n",
+					 memcmp(cmdp->cmd, "LOGIN", 5) ?
 							cmdp->cmd : "LOGIN <user> <pass>",
 							arg, cmd ? cmd : "");
 			}
-			if ((resp2 = parse_response_code( ctx, &cmdp->cb, cmd )) > resp)
+			if ((resp2 = parse_response_code(ctx, &cmdp->cb, cmd)) > resp)
 				resp = resp2;
 		  normal:
 			if (cmdp->cb.done)
-				cmdp->cb.done( ctx, cmdp, resp );
-			free( cmdp->cb.data );
-			free( cmdp->cmd );
-			free( cmdp );
+				cmdp->cb.done(ctx, cmdp, resp);
+			free(cmdp->cb.data);
+			free(cmdp->cmd);
+			free(cmdp);
 			if (!tcmd || tcmd == cmdp)
 				return resp;
 		}
@@ -978,31 +960,28 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
 	/* not reached */
 }

-static void
-imap_close_server( imap_store_t *ictx )
+static void imap_close_server(imap_store_t *ictx)
 {
 	imap_t *imap = ictx->imap;

 	if (imap->buf.sock.fd != -1) {
-		imap_exec( ictx, NULL, "LOGOUT" );
-		socket_shutdown( &imap->buf.sock );
+		imap_exec(ictx, NULL, "LOGOUT");
+		socket_shutdown(&imap->buf.sock);
 	}
-	free_list( imap->ns_personal );
-	free_list( imap->ns_other );
-	free_list( imap->ns_shared );
-	free( imap );
+	free_list(imap->ns_personal);
+	free_list(imap->ns_other);
+	free_list(imap->ns_shared);
+	free(imap);
 }

-static void
-imap_close_store( store_t *ctx )
+static void imap_close_store(store_t *ctx)
 {
-	imap_close_server( (imap_store_t *)ctx );
-	free_generic_messages( ctx->msgs );
-	free( ctx );
+	imap_close_server((imap_store_t *)ctx);
+	free_generic_messages(ctx->msgs);
+	free(ctx);
 }

-static store_t *
-imap_open_store( imap_server_conf_t *srvc )
+static store_t *imap_open_store(imap_server_conf_t *srvc)
 {
 	imap_store_t *ctx;
 	imap_t *imap;
@@ -1012,9 +991,9 @@ imap_open_store( imap_server_conf_t *srvc )
 	int s, a[2], preauth;
 	pid_t pid;

-	ctx = xcalloc( sizeof(*ctx), 1 );
+	ctx = xcalloc(sizeof(*ctx), 1);

-	ctx->imap = imap = xcalloc( sizeof(*imap), 1 );
+	ctx->imap = imap = xcalloc(sizeof(*imap), 1);
 	imap->buf.sock.fd = -1;
 	imap->buf.sock.ssl = NULL;
 	imap->in_progress_append = &imap->in_progress;
@@ -1022,51 +1001,51 @@ imap_open_store( imap_server_conf_t *srvc )
 	/* open connection to IMAP server */

 	if (srvc->tunnel) {
-		imap_info( "Starting tunnel '%s'... ", srvc->tunnel );
+		imap_info("Starting tunnel '%s'... ", srvc->tunnel);

-		if (socketpair( PF_UNIX, SOCK_STREAM, 0, a )) {
-			perror( "socketpair" );
-			exit( 1 );
+		if (socketpair(PF_UNIX, SOCK_STREAM, 0, a)) {
+			perror("socketpair");
+			exit(1);
 		}

 		pid = fork();
 		if (pid < 0)
-			_exit( 127 );
+			_exit(127);
 		if (!pid) {
-			if (dup2( a[0], 0 ) == -1 || dup2( a[0], 1 ) == -1)
-				_exit( 127 );
-			close( a[0] );
-			close( a[1] );
-			execl( "/bin/sh", "sh", "-c", srvc->tunnel, NULL );
-			_exit( 127 );
+			if (dup2(a[0], 0) == -1 || dup2(a[0], 1) == -1)
+				_exit(127);
+			close(a[0]);
+			close(a[1]);
+			execl("/bin/sh", "sh", "-c", srvc->tunnel, NULL);
+			_exit(127);
 		}

-		close (a[0]);
+		close(a[0]);

 		imap->buf.sock.fd = a[1];

-		imap_info( "ok\n" );
+		imap_info("ok\n");
 	} else {
-		memset( &addr, 0, sizeof(addr) );
-		addr.sin_port = htons( srvc->port );
+		memset(&addr, 0, sizeof(addr));
+		addr.sin_port = htons(srvc->port);
 		addr.sin_family = AF_INET;

-		imap_info( "Resolving %s... ", srvc->host );
-		he = gethostbyname( srvc->host );
+		imap_info("Resolving %s... ", srvc->host);
+		he = gethostbyname(srvc->host);
 		if (!he) {
-			perror( "gethostbyname" );
+			perror("gethostbyname");
 			goto bail;
 		}
-		imap_info( "ok\n" );
+		imap_info("ok\n");

 		addr.sin_addr.s_addr = *((int *) he->h_addr_list[0]);

-		s = socket( PF_INET, SOCK_STREAM, 0 );
+		s = socket(PF_INET, SOCK_STREAM, 0);

-		imap_info( "Connecting to %s:%hu... ", inet_ntoa( addr.sin_addr ),
ntohs( addr.sin_port ) );
-		if (connect( s, (struct sockaddr *)&addr, sizeof(addr) )) {
-			close( s );
-			perror( "connect" );
+		imap_info("Connecting to %s:%hu... ", inet_ntoa(addr.sin_addr),
ntohs(addr.sin_port));
+		if (connect(s, (struct sockaddr *)&addr, sizeof(addr))) {
+			close(s);
+			perror("connect");
 			goto bail;
 		}
 		
@@ -1077,28 +1056,28 @@ imap_open_store( imap_server_conf_t *srvc )
 			close(s);
 			goto bail;
 		}
-		imap_info( "ok\n" );
+		imap_info("ok\n");
 	}

 	/* read the greeting string */
-	if (buffer_gets( &imap->buf, &rsp )) {
-		fprintf( stderr, "IMAP error: no greeting response\n" );
+	if (buffer_gets(&imap->buf, &rsp)) {
+		fprintf(stderr, "IMAP error: no greeting response\n");
 		goto bail;
 	}
-	arg = next_arg( &rsp );
-	if (!arg || *arg != '*' || (arg = next_arg( &rsp )) == NULL) {
-		fprintf( stderr, "IMAP error: invalid greeting response\n" );
+	arg = next_arg(&rsp);
+	if (!arg || *arg != '*' || (arg = next_arg(&rsp)) == NULL) {
+		fprintf(stderr, "IMAP error: invalid greeting response\n");
 		goto bail;
 	}
 	preauth = 0;
-	if (!strcmp( "PREAUTH", arg ))
+	if (!strcmp("PREAUTH", arg))
 		preauth = 1;
-	else if (strcmp( "OK", arg ) != 0) {
-		fprintf( stderr, "IMAP error: unknown greeting response\n" );
+	else if (strcmp("OK", arg) != 0) {
+		fprintf(stderr, "IMAP error: unknown greeting response\n");
 		goto bail;
 	}
-	parse_response_code( ctx, NULL, rsp );
-	if (!imap->caps && imap_exec( ctx, NULL, "CAPABILITY" ) != RESP_OK)
+	parse_response_code(ctx, NULL, rsp);
+	if (!imap->caps && imap_exec(ctx, NULL, "CAPABILITY") != RESP_OK)
 		goto bail;

 	if (!preauth) {
@@ -1114,38 +1093,38 @@ imap_open_store( imap_server_conf_t *srvc )
 				goto bail;
 		}
 #endif
-		imap_info ("Logging in...\n");
+		imap_info("Logging in...\n");
 		if (!srvc->user) {
-			fprintf( stderr, "Skipping server %s, no user\n", srvc->host );
+			fprintf(stderr, "Skipping server %s, no user\n", srvc->host);
 			goto bail;
 		}
 		if (!srvc->pass) {
 			char prompt[80];
-			sprintf( prompt, "Password (%s@%s): ", srvc->user, srvc->host );
-			arg = getpass( prompt );
+			sprintf(prompt, "Password (%s@%s): ", srvc->user, srvc->host);
+			arg = getpass(prompt);
 			if (!arg) {
-				perror( "getpass" );
-				exit( 1 );
+				perror("getpass");
+				exit(1);
 			}
 			if (!*arg) {
-				fprintf( stderr, "Skipping account %s@%s, no password\n",
srvc->user, srvc->host );
+				fprintf(stderr, "Skipping account %s@%s, no password\n",
srvc->user, srvc->host);
 				goto bail;
 			}
 			/*
 			 * getpass() returns a pointer to a static buffer.  make a copy
 			 * for long term storage.
 			 */
-			srvc->pass = xstrdup( arg );
+			srvc->pass = xstrdup(arg);
 		}
 		if (CAP(NOLOGIN)) {
-			fprintf( stderr, "Skipping account %s@%s, server forbids LOGIN\n",
srvc->user, srvc->host );
+			fprintf(stderr, "Skipping account %s@%s, server forbids LOGIN\n",
srvc->user, srvc->host);
 			goto bail;
 		}
 		if (!imap->buf.sock.ssl)
 			imap_warn( "*** IMAP Warning *** Password is being "
 				   "sent in the clear\n" );
-		if (imap_exec( ctx, NULL, "LOGIN \"%s\" \"%s\"", srvc->user,
srvc->pass ) != RESP_OK) {
-			fprintf( stderr, "IMAP error: LOGIN failed\n" );
+		if (imap_exec(ctx, NULL, "LOGIN \"%s\" \"%s\"", srvc->user,
srvc->pass) != RESP_OK) {
+			fprintf(stderr, "IMAP error: LOGIN failed\n");
 			goto bail;
 		}
 	} /* !preauth */
@@ -1155,12 +1134,11 @@ imap_open_store( imap_server_conf_t *srvc )
 	return (store_t *)ctx;

   bail:
-	imap_close_store( &ctx->gen );
+	imap_close_store(&ctx->gen);
 	return NULL;
 }

-static int
-imap_make_flags( int flags, char *buf )
+static int imap_make_flags(int flags, char *buf)
 {
 	const char *s;
 	unsigned i, d;
@@ -1179,8 +1157,7 @@ imap_make_flags( int flags, char *buf )

 #define TUIDL 8

-static int
-imap_store_msg( store_t *gctx, msg_data_t *data, int *uid )
+static int imap_store_msg(store_t *gctx, msg_data_t *data, int *uid)
 {
 	imap_store_t *ctx = (imap_store_t *)gctx;
 	imap_t *imap = ctx->imap;
@@ -1191,7 +1168,7 @@ imap_store_msg( store_t *gctx, msg_data_t *data,
int *uid )
 	int start, sbreak = 0, ebreak = 0;
 	char flagstr[128], tuid[TUIDL * 2 + 1];

-	memset( &cb, 0, sizeof(cb) );
+	memset(&cb, 0, sizeof(cb));

 	fmap = data->data;
 	len = data->len;
@@ -1207,18 +1184,18 @@ imap_store_msg( store_t *gctx, msg_data_t
*data, int *uid )
 					sbreak = ebreak = i - 2 + nocr;
 					goto mktid;
 				}
-				if (!memcmp( fmap + start, "X-TUID: ", 8 )) {
+				if (!memcmp(fmap + start, "X-TUID: ", 8)) {
 					extra -= (ebreak = i) - (sbreak = start) + nocr;
 					goto mktid;
 				}
 				goto nloop;
 			}
 		/* invalid message */
-		free( fmap );
+		free(fmap);
 		return DRV_MSG_BAD;
 	 mktid:
 		for (j = 0; j < TUIDL; j++)
-			sprintf( tuid + j * 2, "%02x", arc4_getbyte() );
+			sprintf(tuid + j * 2, "%02x", arc4_getbyte());
 		extra += 8 + TUIDL * 2 + 2;
 	}
 	if (nocr)
@@ -1227,7 +1204,7 @@ imap_store_msg( store_t *gctx, msg_data_t *data,
int *uid )
 				extra++;

 	cb.dlen = len + extra;
-	buf = cb.data = xmalloc( cb.dlen );
+	buf = cb.data = xmalloc(cb.dlen);
 	i = 0;
 	if (!CAP(UIDPLUS) && uid) {
 		if (nocr) {
@@ -1238,12 +1215,12 @@ imap_store_msg( store_t *gctx, msg_data_t
*data, int *uid )
 				} else
 					*buf++ = fmap[i];
 		} else {
-			memcpy( buf, fmap, sbreak );
+			memcpy(buf, fmap, sbreak);
 			buf += sbreak;
 		}
-		memcpy( buf, "X-TUID: ", 8 );
+		memcpy(buf, "X-TUID: ", 8);
 		buf += 8;
-		memcpy( buf, tuid, TUIDL * 2 );
+		memcpy(buf, tuid, TUIDL * 2);
 		buf += TUIDL * 2;
 		*buf++ = '\r';
 		*buf++ = '\n';
@@ -1257,13 +1234,13 @@ imap_store_msg( store_t *gctx, msg_data_t
*data, int *uid )
 			} else
 				*buf++ = fmap[i];
 	} else
-		memcpy( buf, fmap + i, len - i );
+		memcpy(buf, fmap + i, len - i);

-	free( fmap );
+	free(fmap);

 	d = 0;
 	if (data->flags) {
-		d = imap_make_flags( data->flags, flagstr );
+		d = imap_make_flags(data->flags, flagstr);
 		flagstr[d++] = ' ';
 	}
 	flagstr[d] = 0;
@@ -1276,11 +1253,11 @@ imap_store_msg( store_t *gctx, msg_data_t
*data, int *uid )
 			imap->caps = imap->rcaps & ~(1 << LITERALPLUS);
 	} else {
 		box = gctx->name;
-		prefix = !strcmp( box, "INBOX" ) ? "" : ctx->prefix;
+		prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
 		cb.create = 0;
 	}
 	cb.ctx = uid;
-	ret = imap_exec_m( ctx, &cb, "APPEND \"%s%s\" %s", prefix, box, flagstr );
+	ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" %s", prefix, box, flagstr);
 	imap->caps = imap->rcaps;
 	if (ret != DRV_OK)
 		return ret;
@@ -1294,8 +1271,7 @@ imap_store_msg( store_t *gctx, msg_data_t *data,
int *uid )

 #define CHUNKSIZE 0x1000

-static int
-read_message( FILE *f, msg_data_t *msg )
+static int read_message(FILE *f, msg_data_t *msg)
 {
 	struct strbuf buf;

@@ -1312,8 +1288,7 @@ read_message( FILE *f, msg_data_t *msg )
 	return msg->len;
 }

-static int
-count_messages( msg_data_t *msg )
+static int count_messages(msg_data_t *msg)
 {
 	int count = 0;
 	char *p = msg->data;
@@ -1323,7 +1298,7 @@ count_messages( msg_data_t *msg )
 			count++;
 			p += 5;
 		}
-		p = strstr( p+5, "\nFrom ");
+		p = strstr(p+5, "\nFrom ");
 		if (!p)
 			break;
 		p++;
@@ -1331,22 +1306,21 @@ count_messages( msg_data_t *msg )
 	return count;
 }

-static int
-split_msg( msg_data_t *all_msgs, msg_data_t *msg, int *ofs )
+static int split_msg(msg_data_t *all_msgs, msg_data_t *msg, int *ofs)
 {
 	char *p, *data;

-	memset( msg, 0, sizeof *msg );
+	memset(msg, 0, sizeof *msg);
 	if (*ofs >= all_msgs->len)
 		return 0;

-	data = &all_msgs->data[ *ofs ];
+	data = &all_msgs->data[*ofs];
 	msg->len = all_msgs->len - *ofs;

 	if (msg->len < 5 || prefixcmp(data, "From "))
 		return 0;

-	p = strchr( data, '\n' );
+	p = strchr(data, '\n');
 	if (p) {
 		p = &p[1];
 		msg->len -= p-data;
@@ -1354,7 +1328,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t
*msg, int *ofs )
 		data = p;
 	}

-	p = strstr( data, "\nFrom " );
+	p = strstr(data, "\nFrom ");
 	if (p)
 		msg->len = &p[1] - data;

@@ -1363,8 +1337,7 @@ split_msg( msg_data_t *all_msgs, msg_data_t
*msg, int *ofs )
 	return 1;
 }

-static imap_server_conf_t server =
-{
+static imap_server_conf_t server = {
 	NULL,	/* name */
 	NULL,	/* tunnel */
 	NULL,	/* host */
@@ -1377,12 +1350,11 @@ static imap_server_conf_t server =

 static char *imap_folder;

-static int
-git_imap_config(const char *key, const char *val, void *cb)
+static int git_imap_config(const char *key, const char *val, void *cb)
 {
 	char imap_key[] = "imap.";

-	if (strncmp( key, imap_key, sizeof imap_key - 1 ))
+	if (strncmp(key, imap_key, sizeof imap_key - 1))
 		return 0;

 	if (!val)
@@ -1390,9 +1362,9 @@ git_imap_config(const char *key, const char
*val, void *cb)

 	key += sizeof imap_key - 1;

-	if (!strcmp( "folder", key )) {
-		imap_folder = xstrdup( val );
-	} else if (!strcmp( "host", key )) {
+	if (!strcmp("folder", key)) {
+		imap_folder = xstrdup(val);
+	} else if (!strcmp("host", key)) {
 		if (!prefixcmp(val, "imap:"))
 			val += 5;
 		else if (!prefixcmp(val, "imaps:")) {
@@ -1401,23 +1373,22 @@ git_imap_config(const char *key, const char
*val, void *cb)
 		}
 		if (!prefixcmp(val, "//"))
 			val += 2;
-		server.host = xstrdup( val );
+		server.host = xstrdup(val);
 	}
-	else if (!strcmp( "user", key ))
-		server.user = xstrdup( val );
-	else if (!strcmp( "pass", key ))
-		server.pass = xstrdup( val );
-	else if (!strcmp( "port", key ))
-		server.port = git_config_int( key, val );
-	else if (!strcmp( "tunnel", key ))
-		server.tunnel = xstrdup( val );
-	else if (!strcmp( "ssl_verify", key ))
-		server.ssl_verify = git_config_bool( key, val );
+	else if (!strcmp("user", key))
+		server.user = xstrdup(val);
+	else if (!strcmp("pass", key))
+		server.pass = xstrdup(val);
+	else if (!strcmp("port", key))
+		server.port = git_config_int(key, val);
+	else if (!strcmp("tunnel", key))
+		server.tunnel = xstrdup(val);
+	else if (!strcmp("sslverify", key))
+		server.ssl_verify = git_config_bool(key, val);
 	return 0;
 }

-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	msg_data_t all_msgs, msg;
 	store_t *ctx = NULL;
@@ -1429,57 +1400,57 @@ main(int argc, char **argv)
 	/* init the random number generator */
 	arc4_init();

-	setup_git_directory_gently( NULL );
+	setup_git_directory_gently(NULL);
 	git_config(git_imap_config, NULL);

 	if (!server.port)
 		server.port = server.use_ssl ? 993 : 143;

 	if (!imap_folder) {
-		fprintf( stderr, "no imap store specified\n" );
+		fprintf(stderr, "no imap store specified\n");
 		return 1;
 	}
 	if (!server.host) {
 		if (!server.tunnel) {
-			fprintf( stderr, "no imap host specified\n" );
+			fprintf(stderr, "no imap host specified\n");
 			return 1;
 		}
 		server.host = "tunnel";
 	}

 	/* read the messages */
-	if (!read_message( stdin, &all_msgs )) {
+	if (!read_message(stdin, &all_msgs)) {
 		fprintf(stderr,"nothing to send\n");
 		return 1;
 	}

-	total = count_messages( &all_msgs );
+	total = count_messages(&all_msgs);
 	if (!total) {
 		fprintf(stderr,"no messages to send\n");
 		return 1;
 	}

 	/* write it to the imap server */
-	ctx = imap_open_store( &server );
+	ctx = imap_open_store(&server);
 	if (!ctx) {
-		fprintf( stderr,"failed to open store\n");
+		fprintf(stderr,"failed to open store\n");
 		return 1;
 	}

-	fprintf( stderr, "sending %d message%s\n", total, (total!=1)?"s":"" );
+	fprintf(stderr, "sending %d message%s\n", total, (total!=1)?"s":"");
 	ctx->name = imap_folder;
 	while (1) {
 		unsigned percent = n * 100 / total;
-		fprintf( stderr, "%4u%% (%d/%d) done\r", percent, n, total );
-		if (!split_msg( &all_msgs, &msg, &ofs ))
+		fprintf(stderr, "%4u%% (%d/%d) done\r", percent, n, total);
+		if (!split_msg(&all_msgs, &msg, &ofs))
 			break;
-		r = imap_store_msg( ctx, &msg, &uid );
+		r = imap_store_msg(ctx, &msg, &uid);
 		if (r != DRV_OK) break;
 		n++;
 	}
-	fprintf( stderr,"\n" );
+	fprintf(stderr, "\n");

-	imap_close_store( ctx );
+	imap_close_store(ctx);

 	return 0;
 }
-- 
1.5.6.GIT

^ permalink raw reply related

* Re: [PATCH 3/3] imap-send.c: Clean up coding style to better match the rest of the git codebase.
From: Junio C Hamano @ 2008-07-07  8:49 UTC (permalink / raw)
  To: Rob Shearman; +Cc: git
In-Reply-To: <1096648c0807070105s2b4ea1d9t2ab1eb17e891e3e8@mail.gmail.com>

These patches seem to have been linewrapped severely.  I _could_ fix them
up and apply, but the last one being about whitespace and style fixes, I'd
rather not.

^ permalink raw reply

* Re: [PATCH/rfc] git-svn.perl: workaround assertions in svn library 1.5.0
From: Eric Wong @ 2008-07-07  9:06 UTC (permalink / raw)
  To: Gerrit Pape, Junio C Hamano; +Cc: git
In-Reply-To: <20080706192850.32547.qmail@4480698c45f1ed.315fe32.mid.smarden.org>

Gerrit Pape <pape@smarden.org> wrote:
> With subversion 1.5.0 (C and perl libraries) the git-svn selftest
> t9101-git-svn-props.sh fails at test 25 and 26.  The following commands
> cause assertions in the svn library
> 
>  $ cd deeply
>  $ git-svn propget svn:ignore .
>  perl: /build/buildd/subversion-1.5.0dfsg1/subversion/libsvn_ra/ra_loader.c:674: svn_ra_get_dir: Assertion `*path != '/'' failed.
>  Aborted
> 
>  $ git-svn propget svn:ignore ..
>  perl: /build/buildd/subversion-1.5.0dfsg1/subversion/libsvn_subr/path.c:120: svn_path_join: Assertion `is_canonical(component, clen)' failed.
> 
> With this commit, git-svn makes sure the path doesn't start with a
> slash, and is not a dot, working around these assertions.
> 
> The breakage was reported by Lucas Nussbaum through
>  http://bugs.debian.org/489108
> 
> Signed-off-by: Gerrit Pape <pape@smarden.org>

Thanks Gerrit,

This works with svn 1.4.3 here

Acked-by: Eric Wong <normalperson@yhbt.net>

> ---
>  git-svn.perl |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> I ran into this on Debian/unstable.  With svn 1.5.0 the selftest fails
> without the patch, with svn 1.4.6 it succeeds with and without the
> patch.  I'm not familar with the svn interfaces, not sure whether this
> is a regression in subversion, or a bug in git-svn.
> 
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index f789a6e..a366c89 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -643,6 +643,8 @@ sub canonicalize_path {
>  	$path =~ s#/[^/]+/\.\.##g;
>  	$path =~ s#/$##g;
>  	$path =~ s#^\./## if $dot_slash_added;
> +	$path =~ s#^/##;
> +	$path =~ s#^\.$##;
>  	return $path;
>  }
>  
> -- 
> 1.5.6

^ permalink raw reply

* Re: git-svn sucks when it should not
From: Eric Wong @ 2008-07-07  9:44 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0807070135450.7342@eeepc-johanness>

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi Eric,

Hi Johannes,

> I have the pleasure of needing to work with a subversion project where 
> parts of the webserver are password restricted.
> 
> In particular, I cannot access the parent directory, and one of 
> the branches is protected, too.
> 
> Maybe you remember me describing that problem on IRC a few weeks ago: yes, 
> it is still persistent.
> 
> Now, I thought that I know my way around Perl, at least a little bit, but 
> while git-svn barfed on the repository, I... uhm, well, you probably get 
> the idea.
> 
> The funny part is this: when I say "git svn clone $URL/trunk", or the same 
> with the absolute paths to the single tags, instead of "git svn clone -s 
> $URL", git-svn does the correct thing.  It works, importing the stuff as 
> "git-svn".

Noted, -s/--stdlayout doesn't work well with access-restricted
repositories.  I remember leaving the minimize_url() stuff out of the
non--stdlayout code path so git-svn could at least have a way of working
with restricted repositories.

> So I tried to just edit out by hand the branches section, so that the 
> password-protected branch would not be a problem.
> 
> The result was surprising: git svn fetch exited with success, but it 
> did... absolutely nothing.
> 
> After a lot of frustrating hours, which were not at all helped by 
> brilliant variable names such as "r" and "gsv", I now know this: the log 
> contains paths that do not have a prefix "trunk", but "<dir>/trunk", 
> where "<dir>" is the last directory of the URL.

$r should always revision number ('r' is pretty common in the svn
command-line client in referring to revision numbers).  $gsv is just
a $gs vector (like 'argv') with multiple Git::SVN objects.

On the other hand, your comments about some of the other code being
gross is completely valid...

> Changing git-svn's URL to the parent of <dir> is a no-go, since that is -- 
> as I mentioned above -- password protected.
> 
> Yes, in a perfect world I could just force the admin to change that, but 
> no, this is not a perfect world, so do not even try to suggest that if 
> you want to help.

In a perfect world, everybody would be using git and we wouldn't have to
deal with SVN :)

I highly doubt I'd ask you to get an admin to give you access, so please
don't suggest that's something I would ask of you.  I always try to stay
as under-the-radar as possible as far as dealing with admins go and
avoid ever mentioning git-svn to them.

Closed repositories suck, yes, and I've had the fortune (and misfortune
to some users such as yourself) to have never had work with anything
less than full read access.

> Changing the fetch line to "<dir>/trunk:refs/remotes/trunk" does not work 
> either, since git-svn cleverly checks $URL/<dir>/<dir>/trunk/.
> 
> I then tried to hack match_globs() and match_paths() to add that extra 
> prefix to the patterns, so that that extra prefix + trunk would be 
> matched and edited out.  This happened to work out alright.
> 
> But I tried for several hours to get in a proper solution which does not 
> throw up on the tags, and I have to conclude that this piece of code is 
> not hackable by anybody else but you.

I've actually been afraid to touch the globbing/paths stuff myself.  I
got it working for common repository types ~18 months ago and have been
afraid to look at it ever since, so I definitely feel your pain.

git-svn works alright for most repositories people come across, but
yes, it has trouble with less-common, restricted ones.

Does it do some brain-damaged things?  Yes, and those things should get
fixed.  But nowadays I'm much busier with other projects and working
with SVN/SVN bindings was a traumatic experience for me, and (possibly
as a result) the git-svn code scares me, too.

A first step to making the git-svn code more accessible would be
to split out the individual packages into smaller, more manageable
files.  The second would be documenting more of the internal data
structures that it uses (including the ones SVN returns).

Rewriting the paths/globbing code from scratch would probably be
the next step...

> So I stand defeated by your program.  Thank you.
> 
> My ugly, ugly workaround that is however easy, easy, is a shell script 
> that uses curl to find out what refs are new, and clones each ref 
> individually, then pushes all the results together into one repository.
> 
> Should not have been _that_ hard,
> Dscho

It might be helpful to publish your script so other people can see/use it.

dcommit, multi-init/fetch (precursor to clone --stdlayout) were all
prototyped as shell scripts using git-svn commands before they were
integrated into the main program.

-- 
Eric Wong

^ permalink raw reply

* Re: [FIXED PATCH] Make rebase save ORIG_HEAD if changing current branch
From: Theodore Tso @ 2008-07-07 11:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Brian Gernhardt, Git List
In-Reply-To: <7vbq1a8ay3.fsf@gitster.siamese.dyndns.org>

On Sun, Jul 06, 2008 at 11:28:36PM -0700, Junio C Hamano wrote:
> The idea behind ORIG_HEAD is to have an anchoring point before an
> operation that moves your HEAD in a drastic way.  Think if it as a
> poor-man's reflog -- in fact it predates reflog.
> 
> That is why reset saves away the HEAD before it does its thing, so that
> you can easily say "Oops, I did not mean it -- reset ORIG_HEAD" to flip
> back to the previous state.  Both a fast-forward merge and a real merge
> can be undone by resetting back to ORIG_HEAD.
> 
> So in that sense:
> 
>  (1) ORIG_HEAD is not strictly necessary these days, because we have
>      reflogs;

True, but (and please correct me if I'm wrong) ORIG_HEAD will always
be pointing out HEAD before the user typed pretty much any git
porcelein command (which saves HEAD into ORIG_HEAD), but with reflogs,
it you have to paw through multiple HEAD@{n} to find the 'n' which
corresponds to state before executing the git plumbing command, since
multiple git plumbing commands could have updated the HEAD's reflog,
right?

One of the things that's been on my 'twoud be nice list is having an
option to "git reflog show" which prints the timestamp associated with
each reflog entry, since tools like guilt tend to create quite a few
reflog entries, and looking at the time stamps is one of the easier
ways to disentangle it.  For now what I tend to do is expand my
terminal window so it's super wide, and then look at the raw
.git/logs/HEAD file directly.

						- Ted

^ permalink raw reply

* Re: [FIXED PATCH] Make rebase save ORIG_HEAD if changing current branch
From: Jakub Narebski @ 2008-07-07 11:42 UTC (permalink / raw)
  To: Theodore Tso; +Cc: Junio C Hamano, Brian Gernhardt, Git List
In-Reply-To: <20080707111803.GF31490@mit.edu>

Theodore Tso <tytso@MIT.EDU> writes:

> On Sun, Jul 06, 2008 at 11:28:36PM -0700, Junio C Hamano wrote:
> > The idea behind ORIG_HEAD is to have an anchoring point before an
> > operation that moves your HEAD in a drastic way.  Think if it as a
> > poor-man's reflog -- in fact it predates reflog.
> > 
> > That is why reset saves away the HEAD before it does its thing, so that
> > you can easily say "Oops, I did not mean it -- reset ORIG_HEAD" to flip
> > back to the previous state.  Both a fast-forward merge and a real merge
> > can be undone by resetting back to ORIG_HEAD.
> > 
> > So in that sense:
> > 
> >  (1) ORIG_HEAD is not strictly necessary these days, because we have
> >      reflogs;
> 
> True, but (and please correct me if I'm wrong) ORIG_HEAD will always
> be pointing out HEAD before the user typed pretty much any git
> porcelein command (which saves HEAD into ORIG_HEAD), but with reflogs,
> it you have to paw through multiple HEAD@{n} to find the 'n' which
> corresponds to state before executing the git plumbing command, since
> multiple git plumbing commands could have updated the HEAD's reflog,
> right?

You can always use _branch_ reflog, either in the <branch>@{1} form,
or in @{1} shortcut form.  @{1} should be equovalent to ORIG_HEAD
even for rebase.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply

* Re: git-svn sucks when it should not
From: Johannes Schindelin @ 2008-07-07 11:49 UTC (permalink / raw)
  To: Eric Wong; +Cc: git
In-Reply-To: <20080707094438.GA5964@untitled>

Hi,

On Mon, 7 Jul 2008, Eric Wong wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > [...] a shell script that uses curl to find out what refs are new, and 
> > clones each ref individually, then pushes all the results together 
> > into one repository.
> 
> It might be helpful to publish your script so other people can see/use 
> it.

-- snipsnap --
#!/bin/sh

# This script looks for the config variable svn-manual.url, and if it
# is set, will traverse the url and its subdirectories with curl, and
# install different svn-remotes for all found refs.
#
# It heavily relies on curl being able to screen-scrape the directories,
# in other words, it wants an HTTP on the other side that has directory
# listings enabled.
#
# The quick and dirty heuristics to find out what makes a ref is that
# a ref's subdirectory contains files, while a subdirectory containing
# only subdirectories is supposed to contain refs (or subdirectories
# of refs).

list_contains_files () {
	while test $# -gt 0
	do
		case "$1" in
		*/) ;;
		*) echo "$1";;
		esac
		shift
	done
}

svn_manually_fetch_one_dir () {
	contents="$(curl --silent -k "$1"/ |
		sed -n "s/.*a href=\"\([^\"]*\).*/\1/p" |
		grep -ve '^\.\./$' -e '^http:' -e '^/')"
	test -z "$contents" && return
	test -z "$(list_contains_files $contents)" || {
		test -z "$(git config svn-remote."$2".url)" && {
			git config svn-remote."$2".url "$1" &&
			git config svn-remote."$2".fetch :"$2" ||
			return
		}
		git svn fetch -R "$2"
		return
	}
	for dir in $contents
	do
		dir=${dir%%/}
		svn_manually_fetch_one_dir "$1/$dir" "$2/$dir" || break
	done
}

svn_fetch_semi_manually () {
	url="$(git config svn-manual.url)"
	test -z "$url" && return 1
	svn_manually_fetch_one_dir "$url" refs/remotes
}

svn_fetch_semi_manually || git svn fetch

^ permalink raw reply

* Re: [PATCH 3/3] imap-send.c: Clean up coding style to better match the rest of the git codebase.
From: Rob Shearman @ 2008-07-07 12:17 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vfxqm5ba2.fsf@gitster.siamese.dyndns.org>

2008/7/7 Junio C Hamano <gitster@pobox.com>:
> These patches seem to have been linewrapped severely.  I _could_ fix them
> up and apply, but the last one being about whitespace and style fixes, I'd
> rather not.

2008/6/22 Junio C Hamano <gitster@pobox.com>:
> Next time please do _not_ attach *.diff but follow the style of patch
> submission other people do (see recent patch from Linus for example).

How do you propose I fix this? I attached the patch last time to avoid
the problem of line wrapping.

-- 
Rob Shearman

^ permalink raw reply

* Re: [PATCH 3/3] imap-send.c: Clean up coding style to better match the rest of the git codebase.
From: Jakub Narebski @ 2008-07-07 12:40 UTC (permalink / raw)
  To: Rob Shearman; +Cc: Junio C Hamano, git
In-Reply-To: <1096648c0807070517o8f22f0cs4d25103675bd635d@mail.gmail.com>

"Rob Shearman" <robertshearman@gmail.com> writes:

> 2008/7/7 Junio C Hamano <gitster@pobox.com>:
> > These patches seem to have been linewrapped severely.  I _could_ fix them
> > up and apply, but the last one being about whitespace and style fixes, I'd
> > rather not.
> 
> 2008/6/22 Junio C Hamano <gitster@pobox.com>:
> > Next time please do _not_ attach *.diff but follow the style of patch
> > submission other people do (see recent patch from Linus for example).
> 
> How do you propose I fix this? I attached the patch last time to avoid
> the problem of line wrapping.

If possible to turn of linewrapping, or use either git-send-email
(I think you can send patches also via Gmail) or git-imap-send,
then preferred solution is to have patch inline.

If it is not possible, then attach the patch, but preferrably
 1) with text/plain mimetype (.txt extension instead of .patch or
    .diff could be required for that)

 2) 8bit (preferred) or quoted-printable (if 8bit is not possible)
    transfer encoding (base64 is terrible waste of space); text/plain
    should chose quoted-printable at worst

 3) use "inline" attachement (select 'suggest to display attachement'
    or something like that), so it is possible to select attachement
    and hit reply.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

^ permalink raw reply

* [PATCH] builtin-rerere: fix conflict markers parsing
From: Olivier Marin @ 2008-07-07 12:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git

From: Olivier Marin <dkr@freesurf.fr>

When a conflicting file contains a line that begin with "=======", rerere
failed to parse conflict markers. This result to a wrong preimage file and
an unexpected error for the user.

This patch enforce parsing rules so that markers match in the right order
and update tests to match the above fix.

Signed-off-by: Olivier Marin <dkr@freesurf.fr>
---

 This happend to me with a conflict in Documentation/git-remote.txt.

 The bug seems to have always been there but nobody noticed probably because
 before a1b32fdc3d1d05395f186bfa06e92174519dab8d parsing errors were ignored
 and (I think) it does not affect the way git rerere works.

 builtin-rerere.c  |    7 ++++---
 t/t4200-rerere.sh |   26 ++++++++++++++++++++------
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/builtin-rerere.c b/builtin-rerere.c
index 839b26e..e618862 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -112,11 +112,12 @@ static int handle_file(const char *path,
 	strbuf_init(&one, 0);
 	strbuf_init(&two,  0);
 	while (fgets(buf, sizeof(buf), f)) {
-		if (!prefixcmp(buf, "<<<<<<< "))
+		if (hunk == 0 && !prefixcmp(buf, "<<<<<<< "))
 			hunk = 1;
-		else if (!prefixcmp(buf, "======="))
+		else if (hunk == 1 && !prefixcmp(buf, "=======") &&
+			 isspace(buf[7]))
 			hunk = 2;
-		else if (!prefixcmp(buf, ">>>>>>> ")) {
+		else if (hunk == 2 && !prefixcmp(buf, ">>>>>>> ")) {
 			if (strbuf_cmp(&one, &two) > 0)
 				strbuf_swap(&one, &two);
 			hunk_no++;
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index a64727d..cf10557 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -9,6 +9,8 @@ test_description='git rerere
 . ./test-lib.sh
 
 cat > a1 << EOF
+Some title
+==========
 Whether 'tis nobler in the mind to suffer
 The slings and arrows of outrageous fortune,
 Or to take arms against a sea of troubles,
@@ -24,6 +26,8 @@ git commit -q -a -m initial
 
 git checkout -b first
 cat >> a1 << EOF
+Some title
+==========
 To die, to sleep;
 To sleep: perchance to dream: ay, there's the rub;
 For in that sleep of death what dreams may come
@@ -35,7 +39,7 @@ git commit -q -a -m first
 
 git checkout -b second master
 git show first:a1 |
-sed -e 's/To die, t/To die! T/' > a1
+sed -e 's/To die, t/To die! T/' -e 's/Some title/Some Title/' > a1
 echo "* END *" >>a1
 git commit -q -a -m second
 
@@ -55,14 +59,14 @@ test_expect_success 'conflicting merge' '
 
 sha1=$(sed -e 's/	.*//' .git/rr-cache/MERGE_RR)
 rr=.git/rr-cache/$sha1
-test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
+test_expect_success 'recorded preimage' "grep ^=======$ $rr/preimage"
 
 test_expect_success 'rerere.enabled works, too' '
 	rm -rf .git/rr-cache &&
 	git config rerere.enabled true &&
 	git reset --hard &&
 	! git merge first &&
-	grep ======= $rr/preimage
+	grep ^=======$ $rr/preimage
 '
 
 test_expect_success 'no postimage or thisimage yet' \
@@ -71,7 +75,7 @@ test_expect_success 'no postimage or thisimage yet' \
 test_expect_success 'preimage has right number of lines' '
 
 	cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
-	test $cnt = 9
+	test $cnt = 13
 
 '
 
@@ -80,13 +84,23 @@ git show first:a1 > a1
 cat > expect << EOF
 --- a/a1
 +++ b/a1
-@@ -6,17 +6,9 @@
+@@ -1,4 +1,4 @@
+-Some Title
++Some title
+ ==========
+ Whether 'tis nobler in the mind to suffer
+ The slings and arrows of outrageous fortune,
+@@ -8,21 +8,11 @@
  The heart-ache and the thousand natural shocks
  That flesh is heir to, 'tis a consummation
  Devoutly to be wish'd.
 -<<<<<<<
+-Some Title
+-==========
 -To die! To sleep;
 -=======
+ Some title
+ ==========
  To die, to sleep;
 ->>>>>>>
  To sleep: perchance to dream: ay, there's the rub;
@@ -124,7 +138,7 @@ test_expect_success 'another conflicting merge' '
 '
 
 git show first:a1 | sed 's/To die: t/To die! T/' > expect
-test_expect_success 'rerere kicked in' "! grep ======= a1"
+test_expect_success 'rerere kicked in' "! grep ^=======$ a1"
 
 test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
 
-- 
1.5.6.2.346.gddd7f

^ permalink raw reply related

* Test breakage [Re: [ANNOUNCE] GIT 1.5.6.2]
From: Michael J Gruber @ 2008-07-07 12:44 UTC (permalink / raw)
  To: git
In-Reply-To: <7vy74fo9t4.fsf@gitster.siamese.dyndns.org>

Junio C Hamano venit, vidit, dixit 06.07.2008 07:34:
> The latest maintenance release GIT 1.5.6.2 are available at the usual
> places:
...

On Kubuntu 7.10 (not my choice, this is at work...), "make test" gives:

*** t9600-cvsimport.sh ***
*   ok 1: setup cvsroot
*   ok 2: setup a cvs module
*   ok 3: import a trivial module
*   ok 4: pack refs
*   ok 5: update cvs module
* FAIL 6: update git module


                 cd module-git &&
                 git cvsimport -a -z 0 module &&
                 git merge origin &&
                 cd .. &&
                 test_cmp module-cvs/o_fortuna module-git/o_fortuna


*   ok 7: update cvs module
*   ok 8: cvsimport.module config works
*   ok 9: import from a CVS working tree
* failed 1 among 9 test(s)

On the second (and subsequent) run, "make test" succeeds. I tried again 
with a fresh copy from the tarball, same effect: failure on 1, success 
on 2 and following.

This is with LANG=de_DE.UTF-8, whereas with LANG=C the tests succeed the 
first time already. Are tests supposed to be done in C locale only? Do 
they reuse data from a previous test run? I didn't notice this with 1.5.6.1.

Michael

^ permalink raw reply

* Re: [PATCH] builtin-rerere: fix conflict markers parsing
From: Johannes Schindelin @ 2008-07-07 13:02 UTC (permalink / raw)
  To: Olivier Marin; +Cc: Junio C Hamano, git
In-Reply-To: <1215434568-30456-1-git-send-email-dkr+ml.git@free.fr>

Hi,

On Mon, 7 Jul 2008, Olivier Marin wrote:

> From: Olivier Marin <dkr@freesurf.fr>
> 
> When a conflicting file contains a line that begin with "=======", rerere
> failed to parse conflict markers. This result to a wrong preimage file and
> an unexpected error for the user.
> 
> This patch enforce parsing rules so that markers match in the right order
> and update tests to match the above fix.

So what about

	<<<<<<< This hunk contains =====
	anythin
	=======

	Hello
	=======
	somethin else
	>>>>>>> problem!


If you fix it, I think you should do it properly, and analyze the index.

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH] git-mailinfo may corrupt patch headers on attached files
From: Don Zickus @ 2008-07-07 13:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, torvalds
In-Reply-To: <7v1w269sp9.fsf@gitster.siamese.dyndns.org>

On Sun, Jul 06, 2008 at 10:19:46PM -0700, Junio C Hamano wrote:
> The point you inserted strlen() above, however, is one of the places that
> line[] has patch text and can have NUL in it, so strlen() there would
> break the earlier fix.
> 
> Here is the minimum replacement patch, still not handling embedded NULs
> anywhere in the structural part of the message, that should work.  Sane
> MUAs should quote embedded NULs in the original contents with QP or BASE64
> to protect them from handle_boundary() and other functions, and after
> decoding, these embedded NULs will be kept by decode_transfer_encoding(),
> so I think this would work Ok in practice.
> 
> I tested this with both Linus's test message and it does not break t5100.

Good thing for test cases. :-)  Thanks for the explanation.

ACK

Cheers,
Don

^ permalink raw reply

* [PATCH] run_command(): respect GIT_TRACE
From: Johannes Schindelin @ 2008-07-07 13:41 UTC (permalink / raw)
  To: git, gitster


When GIT_TRACE is set, the user is most likely wanting to see an external
command that is about to be executed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 run-command.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/run-command.c b/run-command.c
index 2ce8c2b..6e29fdf 100644
--- a/run-command.c
+++ b/run-command.c
@@ -65,6 +65,8 @@ int start_command(struct child_process *cmd)
 		cmd->err = fderr[0];
 	}
 
+	trace_argv_printf(cmd->argv, "trace: run_command:");
+
 #ifndef __MINGW32__
 	cmd->pid = fork();
 	if (!cmd->pid) {
-- 
1.5.6.2.402.g95b5ab.dirty

^ permalink raw reply related

* Re: [PATCH] INSTALL: Update section about git-frotz form.
From: Miklos Vajna @ 2008-07-07 13:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git
In-Reply-To: <7vhcb2a1hj.fsf@gitster.siamese.dyndns.org>

[-- Attachment #1: Type: text/plain, Size: 645 bytes --]

On Sun, Jul 06, 2008 at 07:10:00PM -0700, Junio C Hamano <gitster@pobox.com> wrote:
> The mention of 1997 was correct when it was made, and I think it still is
> true to some extent (http://savannah.gnu.org/forum/forum.php?forum_id=5189
> says it has not been actively maintained for quite some time), but I think
> it is no longer relevant to us whether many users use gnuit or moved away
> to graphical file managers because of its name change.
> 
> The only people possibly affected are people who has older version of
> gnuit that has been called git, so how about shortening the section even
> further like:

Thanks, I like it.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox