* Re: "Not currently on any branch"
From: Clemens Buchacher @ 2009-10-04 7:22 UTC (permalink / raw)
To: Tim; +Cc: git
In-Reply-To: <loom.20091002T215942-663@post.gmane.org>
On Fri, Oct 02, 2009 at 08:08:52PM +0000, Tim wrote:
> I have some code in a git repo that is "Not currently on any branch". Now,
> there's the master branch and another branch 'ui-integration' that I'm
> using in this project. I don't know how the project got into this headless
> state, but I need to be using the 'ui-integration' branch.
It can happen either by explicitly detaching HEAD using "git checkout
<commit>", or if you used rebase and it is still in progress.
Clemens
^ permalink raw reply
* Re: [PATCH] Add the utterly important 'mispel' command
From: Jeff King @ 2009-10-04 6:52 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, spearce, gitster
In-Reply-To: <alpine.DEB.1.00.0910040040180.4985@pacific.mpi-cbg.de>
On Sun, Oct 04, 2009 at 12:41:55AM +0200, Johannes Schindelin wrote:
> --- a/builtin.h
> +++ b/builtin.h
> @@ -12,6 +12,7 @@ extern const char git_more_info_string[];
>
> extern void list_common_cmds_help(void);
> extern const char *help_unknown_cmd(const char *cmd);
> +const char *help_mispeld_comd(const char *cmd);
> extern void prune_packed_objects(int);
> extern int read_line_with_nul(char *buf, int size, FILE *file);
> extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
Hmph. This hunk doesn't apply to Shawn's master, and your blob sha1 is
not in my repository for a 3-way merge. ;P
Also, I think there is a bug:
$ git mispel show-branc
error: You probably meant show-index
Or is it intentional for it to throw the user off track?
Let this be a lesson, kids: don't drink and code.
-Peff
^ permalink raw reply
* Re: Interim maintainer tree
From: Jeff King @ 2009-10-04 6:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, git
In-Reply-To: <7viqevu1zt.fsf@alter.siamese.dyndns.org>
On Sat, Oct 03, 2009 at 11:06:30PM -0700, Junio C Hamano wrote:
> Thanks, both.
>
> I've fetched, but haven't fully examined "log ..spearce/*" nor "log ..peff/*"
> yet.
>
> I noticed that some topics in 'pu' have been rebased (not complaining, but
> just making sure I am not hallucinating).
>
> Do you have preferences/suggestions as to how to proceed? Should I just
> take the tips over at this point, or do you have some more patches you
> were polishing but haven't pushed out that I should wait for?
For my stuff, I think you can just take over my tips. I was just
collecting and polishing topics, while Shawn was doing integration. For
topics I have, please use my versions rather than applying from the
list; many of them have extra fixes squashed in, acked-by's collected
from the list, etc.
Here's a brief status report on what's in my tree:
proposed-master
One-off patches that I think should go straight to master.
ef/mscv-noreturn
This is the latest round and I think should be ready for at least
'next' (maybe even 'master' as it is really about the build and not
about functionality).
ef/msys-imap
This is from an RFC which has generated some comments. He should be
posting another round soon. 'pu' at best.
fc/mutt-alias
Latest round that addressed comments. Ready for 'next' if not
'master'.
jn/gitweb-patch
After some comments with Jakub, I think the code is right but he
promised a re-roll with more in the commit message.
mr/gitweb-snapshot
This is probably the pu rewind you saw. He posted a v5 of his
series. I didn't look at it closely, but Jakub ack'd it.
tf/doc-pt-br
Minor translation update, ack'd by somebody who can read it. :)
Ready for 'master'.
There are a few patches floating on the list that I haven't picked up or
looked too closely at yet. Just so we don't drop anything, they are:
- curl http auth tweak:
http://article.gmane.org/gmane.comp.version-control.git/129455
The author said he didn't really test it, and I haven't set up http
auth to test it with, but probably somebody should do so before
applying. :)
- a new rev-cache from Nick
- silence gcc warning:
http://article.gmane.org/gmane.comp.version-control.git/129485
The warning is overly cautious, I think, but it is a dubious enough
construct that it is probably worth fixing.
- enable openssl on msvc
http://article.gmane.org/gmane.comp.version-control.msysgit/7238
This goes on top of ef/msys-imap, but I think that will be getting a
re-roll.
-Peff
^ permalink raw reply
* Re: Interim maintainer tree
From: Junio C Hamano @ 2009-10-04 6:06 UTC (permalink / raw)
To: Shawn O. Pearce, Jeff King; +Cc: git
In-Reply-To: <20090925160504.GW14660@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Junio is on vaction for the next week. In his absence Peff and I
> are trying to keep up with current patches in my fork:
>
> git://repo.or.cz/git/spearce.git
> http://repo.or.cz/r/git/spearce.git
>
> Right now the tree matches Junio's last push, I'll try to pick up
> the patches since then and push later today.
Thanks, both.
I've fetched, but haven't fully examined "log ..spearce/*" nor "log ..peff/*"
yet.
I noticed that some topics in 'pu' have been rebased (not complaining, but
just making sure I am not hallucinating).
Do you have preferences/suggestions as to how to proceed? Should I just
take the tips over at this point, or do you have some more patches you
were polishing but haven't pushed out that I should wait for?
^ permalink raw reply
* [PATCH] Add the utterly important 'mispel' command
From: Johannes Schindelin @ 2009-10-03 22:41 UTC (permalink / raw)
To: git; +Cc: spearce, peff, gitster
If you do not remember how to mispel a command, you need some help.
Provide it.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: A Large Angry SCM <gitzilla@gmail.com>
Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Acked-By: <paisleyklm@gmail.com>
---
Please apply.
Makefile | 1 +
builtin-mispel.c | 11 +++++++++++
builtin.h | 2 ++
git.c | 1 +
help.c | 31 +++++++++++++++++++++++++++++++
5 files changed, 46 insertions(+), 0 deletions(-)
create mode 100644 builtin-mispel.c
diff --git a/Makefile b/Makefile
index 690ac55..0b48b3b 100644
--- a/Makefile
+++ b/Makefile
@@ -610,6 +610,7 @@ BUILTIN_OBJS += builtin-merge-file.o
BUILTIN_OBJS += builtin-merge-ours.o
BUILTIN_OBJS += builtin-merge-recursive.o
BUILTIN_OBJS += builtin-mktree.o
+BUILTIN_OBJS += builtin-mispel.o
BUILTIN_OBJS += builtin-mv.o
BUILTIN_OBJS += builtin-name-rev.o
BUILTIN_OBJS += builtin-pack-objects.o
diff --git a/builtin-mispel.c b/builtin-mispel.c
new file mode 100644
index 0000000..e685f91
--- /dev/null
+++ b/builtin-mispel.c
@@ -0,0 +1,11 @@
+#include "cache.h"
+#include "builtin.h"
+
+int cmd_mispel(int argc, const char **argv, const char *prefix)
+{
+ if (argc < 2)
+ die ("What command do you want to mispel?");
+ error("You probably meant %s", help_mispeld_comd(argv[1]));
+ return 0;
+
+}
diff --git a/builtin.h b/builtin.h
index 20427d2..2973d90 100644
--- a/builtin.h
+++ b/builtin.h
@@ -12,6 +12,7 @@ extern const char git_more_info_string[];
extern void list_common_cmds_help(void);
extern const char *help_unknown_cmd(const char *cmd);
+const char *help_mispeld_comd(const char *cmd);
extern void prune_packed_objects(int);
extern int read_line_with_nul(char *buf, int size, FILE *file);
extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
@@ -73,6 +74,7 @@ extern int cmd_merge_ours(int argc, const char **argv, const char *prefix);
extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
extern int cmd_merge_recursive(int argc, const char **argv, const char *prefix);
extern int cmd_mktree(int argc, const char **argv, const char *prefix);
+extern int cmd_mispel(int argc, const char **argv, const char *prefix);
extern int cmd_mv(int argc, const char **argv, const char *prefix);
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 807d875..2caca54 100644
--- a/git.c
+++ b/git.c
@@ -327,6 +327,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "mktree", cmd_mktree, RUN_SETUP },
+ { "mispel", cmd_mispel },
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
diff --git a/help.c b/help.c
index 6c46d8b..97f0f22 100644
--- a/help.c
+++ b/help.c
@@ -296,6 +296,37 @@ static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
old->names = NULL;
}
+const char *help_mispeld_comd(const char *cmd)
+{
+ struct cmdnames main_cmds, other_cmds;
+ int i;
+
+ memset(&main_cmds, 0, sizeof(main_cmds));
+ memset(&other_cmds, 0, sizeof(main_cmds));
+ git_config(git_unknown_cmd_config, NULL);
+
+ load_command_list("git-", &main_cmds, &other_cmds);
+
+ add_cmd_list(&main_cmds, &aliases);
+ add_cmd_list(&main_cmds, &other_cmds);
+ qsort(main_cmds.names, main_cmds.cnt,
+ sizeof(main_cmds.names), cmdname_compare);
+ uniq(&main_cmds);
+
+ /* This reuses cmdname->len for similarity index */
+ for (i = 0; i < main_cmds.cnt; ++i)
+ main_cmds.names[i]->len =
+ levenshtein(cmd, main_cmds.names[i]->name, 0, 2, 1, 4);
+
+ qsort(main_cmds.names, main_cmds.cnt,
+ sizeof(*main_cmds.names), levenshtein_compare);
+
+ if (main_cmds.cnt< 2)
+ die ("Uh oh. Your system reports no Git commands at all.");
+
+ return main_cmds.names[1]->name;
+}
+
const char *help_unknown_cmd(const char *cmd)
{
int i, n, best_similarity = 0;
--
1.6.4.msysgit.0.1.g2dcf.dirty
^ permalink raw reply related
* Re: [PATCH/RFC 1/7] imap-send: use separate read and write fds
From: Johannes Sixt @ 2009-10-03 21:34 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: msysgit, Jeff King, git
In-Reply-To: <40aa078e0910031144r735a6fdq25efc1e57a1d4c33@mail.gmail.com>
On Samstag, 3. Oktober 2009, Erik Faye-Lund wrote:
> - It needs some additional patching to get tunnelling support working
> on Windows, because we can't exec "/bin/sh" there. Changing it to
> "c:\\msysgit\\bin\\sh.exe" makes tunneling work for me, but isn't
> exactly portable across installations.
It should be fine to just exec "sh" (without a path).
-- Hannes
^ permalink raw reply
* Re: [PATCH/RFC 5/7] imap-send: provide fall-back random-source
From: Jeff King @ 2009-10-03 20:52 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: msysgit, git, mike
In-Reply-To: <20091003204317.GB9058@sigill.intra.peff.net>
On Sat, Oct 03, 2009 at 04:43:17PM -0400, Jeff King wrote:
> The other confusing bit is that the code carefully tracks the "uid"
> (deep within the call chain it munges cb.ctx, which is a pointer to uid)
> which is assigned to the newly created message by the server. This could
> be used by a client to later refer to the same message unambiguously.
> But we never do that, and just throw away the uid value that the server
> gives us. Again, I suspect this is a holdover from isync wanting to do
> repeated synchronization (and it looks like this x-tuid stuff may be
> about working around servers which don't support certain uid
> operations).
>
> So that could probably be ripped out, too, with no ill effect.
And here is a patch (on top of the earlier one) to do that.
Even more can be ripped out from the lower levels, too, I'm not sure if
it is worth it. Ripping out the arc4 code is worthwhile, because it
solves a portability problem. Ripping out more isn't really helping us
much. Less code makes it easier to read, but given our lack of tests and
my relatively small knowledge of this code, it is entirely possible I am
introducing new bugs.
---
imap-send.c | 25 ++++++-------------------
1 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index d60a0bd..8da7a94 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1149,7 +1149,7 @@ static int imap_make_flags(int flags, char *buf)
return d;
}
-static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)
+static int imap_store_msg(struct store *gctx, struct msg_data *data)
{
struct imap_store *ctx = (struct imap_store *)gctx;
struct imap *imap = ctx->imap;
@@ -1171,26 +1171,14 @@ static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)
}
flagstr[d] = 0;
- if (!uid) {
- box = gctx->conf->trash;
- prefix = ctx->prefix;
- cb.create = 1;
- if (ctx->trashnc)
- imap->caps = imap->rcaps & ~(1 << LITERALPLUS);
- } else {
- box = gctx->name;
- prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
- cb.create = 0;
- }
- cb.ctx = uid;
+ box = gctx->name;
+ prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
+ cb.create = 0;
ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" %s", prefix, box, flagstr);
imap->caps = imap->rcaps;
if (ret != DRV_OK)
return ret;
- if (!uid)
- ctx->trashnc = 0;
- else
- gctx->count++;
+ gctx->count++;
return DRV_OK;
}
@@ -1366,7 +1354,6 @@ int main(int argc, char **argv)
{
struct msg_data all_msgs, msg;
struct store *ctx = NULL;
- int uid = 0;
int ofs = 0;
int r;
int total, n = 0;
@@ -1420,7 +1407,7 @@ int main(int argc, char **argv)
break;
if (server.use_html)
wrap_in_html(&msg);
- r = imap_store_msg(ctx, &msg, &uid);
+ r = imap_store_msg(ctx, &msg);
if (r != DRV_OK)
break;
n++;
^ permalink raw reply related
* Re: [PATCH/RFC 5/7] imap-send: provide fall-back random-source
From: Jeff King @ 2009-10-03 20:43 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: msysgit, git, mike
In-Reply-To: <40aa078e0910031145l2849697ftd2da2f5aaa28d957@mail.gmail.com>
On Sat, Oct 03, 2009 at 11:45:55AM -0700, Erik Faye-Lund wrote:
> I tried to trace this a little bit, but I got lost a bit in the
> callback-stuff. However, it looks to me like it might get sent to the
> server: it gets injected into cb.data in imap_store_msg(), and in
> v_issue_imap_cmd() it gets sent to the server if the LITERALPLUS
> capability is supported. I might be wrong though, as I find this code
> quite confusing.
It does get stored on the server either way (LITERALPLUS is just an imap
server extension that gives us different options for how we send). The
code actually munges an extra "X-TUID" rfc822 header into your message,
which has a randomly generated value. But we never _use_ the value for
anything. I think it is just inherited via cut-and-paste from the
original isync, which I guess actually does use it for synchronization.
The patch below rips it (and the arc4 code) out completely. It still
works in my simple test case, but I am not really an imap-send user, so
caveat emptor.
The other confusing bit is that the code carefully tracks the "uid"
(deep within the call chain it munges cb.ctx, which is a pointer to uid)
which is assigned to the newly created message by the server. This could
be used by a client to later refer to the same message unambiguously.
But we never do that, and just throw away the uid value that the server
gives us. Again, I suspect this is a holdover from isync wanting to do
repeated synchronization (and it looks like this x-tuid stuff may be
about working around servers which don't support certain uid
operations).
So that could probably be ripped out, too, with no ill effect.
That's just from looking at the code for a few minutes. I would not be
surprised if there is more useless cruft, nor would I be surprised to
find that I am totally wrong about something above.
Anyway, here is the patch to rip out the arc4 stuff. It has a very
pleasant diff-stat. :)
---
imap-send.c | 130 ++--------------------------------------------------------
1 files changed, 5 insertions(+), 125 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 3847fd1..d60a0bd 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -123,9 +123,6 @@ static int nfvasprintf(char **strp, const char *fmt, va_list ap)
return len;
}
-static void arc4_init(void);
-static unsigned char arc4_getbyte(void);
-
struct imap_server_conf {
char *name;
char *tunnel;
@@ -489,52 +486,6 @@ static int nfsnprintf(char *buf, int blen, const char *fmt, ...)
return ret;
}
-static struct {
- unsigned char i, j, s[256];
-} rs;
-
-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 (read_in_full(fd, dat, 128) != 128) {
- fprintf(stderr, "Fatal: cannot read random number source.\n");
- exit(3);
- }
- close(fd);
-
- for (i = 0; i < 256; i++)
- rs.s[i] = i;
- for (i = j = 0; i < 256; i++) {
- si = rs.s[i];
- j += si + dat[i & 127];
- rs.s[i] = rs.s[j];
- rs.s[j] = si;
- }
- rs.i = rs.j = 0;
-
- for (i = 0; i < 256; i++)
- arc4_getbyte();
-}
-
-static unsigned char arc4_getbyte(void)
-{
- unsigned char si, sj;
-
- rs.i++;
- si = rs.s[rs.i];
- rs.j += si;
- sj = rs.s[rs.j];
- rs.s[rs.i] = sj;
- rs.s[rs.j] = si;
- return rs.s[(si + sj) & 0xff];
-}
-
static struct imap_cmd *v_issue_imap_cmd(struct imap_store *ctx,
struct imap_cmd_cb *cb,
const char *fmt, va_list ap)
@@ -1198,88 +1149,20 @@ static int imap_make_flags(int flags, char *buf)
return d;
}
-#define TUIDL 8
-
static int imap_store_msg(struct store *gctx, struct msg_data *data, int *uid)
{
struct imap_store *ctx = (struct imap_store *)gctx;
struct imap *imap = ctx->imap;
struct imap_cmd_cb cb;
- char *fmap, *buf;
const char *prefix, *box;
- int ret, i, j, d, len, extra, nocr;
- int start, sbreak = 0, ebreak = 0;
- char flagstr[128], tuid[TUIDL * 2 + 1];
+ int ret, d;
+ char flagstr[128];
memset(&cb, 0, sizeof(cb));
- fmap = data->data;
- len = data->len;
- nocr = !data->crlf;
- extra = 0, i = 0;
- if (!CAP(UIDPLUS) && uid) {
- nloop:
- start = i;
- while (i < len)
- if (fmap[i++] == '\n') {
- extra += nocr;
- if (i - 2 + nocr == start) {
- sbreak = ebreak = i - 2 + nocr;
- goto mktid;
- }
- if (!memcmp(fmap + start, "X-TUID: ", 8)) {
- extra -= (ebreak = i) - (sbreak = start) + nocr;
- goto mktid;
- }
- goto nloop;
- }
- /* invalid message */
- free(fmap);
- return DRV_MSG_BAD;
- mktid:
- for (j = 0; j < TUIDL; j++)
- sprintf(tuid + j * 2, "%02x", arc4_getbyte());
- extra += 8 + TUIDL * 2 + 2;
- }
- if (nocr)
- for (; i < len; i++)
- if (fmap[i] == '\n')
- extra++;
-
- cb.dlen = len + extra;
- buf = cb.data = xmalloc(cb.dlen);
- i = 0;
- if (!CAP(UIDPLUS) && uid) {
- if (nocr) {
- for (; i < sbreak; i++)
- if (fmap[i] == '\n') {
- *buf++ = '\r';
- *buf++ = '\n';
- } else
- *buf++ = fmap[i];
- } else {
- memcpy(buf, fmap, sbreak);
- buf += sbreak;
- }
- memcpy(buf, "X-TUID: ", 8);
- buf += 8;
- memcpy(buf, tuid, TUIDL * 2);
- buf += TUIDL * 2;
- *buf++ = '\r';
- *buf++ = '\n';
- i = ebreak;
- }
- if (nocr) {
- for (; i < len; i++)
- if (fmap[i] == '\n') {
- *buf++ = '\r';
- *buf++ = '\n';
- } else
- *buf++ = fmap[i];
- } else
- memcpy(buf, fmap + i, len - i);
-
- free(fmap);
+ cb.dlen = data->len;
+ cb.data = xmalloc(cb.dlen);
+ memcpy(cb.data, data->data, data->len);
d = 0;
if (data->flags) {
@@ -1491,9 +1374,6 @@ int main(int argc, char **argv)
git_extract_argv0_path(argv[0]);
- /* init the random number generator */
- arc4_init();
-
setup_git_directory_gently(&nongit_ok);
git_config(git_imap_config, NULL);
^ permalink raw reply related
* Re: [PATCH/RFC 1/7] imap-send: use separate read and write fds
From: Jeff King @ 2009-10-03 20:34 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: msysgit, git
In-Reply-To: <40aa078e0910031144r735a6fdq25efc1e57a1d4c33@mail.gmail.com>
On Sat, Oct 03, 2009 at 11:44:50AM -0700, Erik Faye-Lund wrote:
> Yeah, this is about Windows portability.
>
> I'll add something like "This is a patch that enables us to use the
> run-command API, which is supported on Windows." to the commit-message
> in the next round. Is that enough?
Yeah, that would be fine. I was just left scratching my head wondering
what subtle portability difference the two descriptors could have. But
if it really is just a cleanup for the next patch, that's OK; just say
so.
-Peff
^ permalink raw reply
* Re: MSVC build broken (on cygwin)
From: Marius Storm-Olsen @ 2009-10-03 20:29 UTC (permalink / raw)
To: Ramsay Jones; +Cc: Alex Riesen, GIT Mailing-list, Shawn O. Pearce
In-Reply-To: <4AC7AEB9.3030404@ramsay1.demon.co.uk>
Ramsay Jones said the following on 03.10.2009 22:06:
> Marius Storm-Olsen wrote:
>> So, something like this maybe, in git-compat-util.h:
>>
>> #if defined(__MINGW32__) || defined(_MSC_VER)
>> # defined API_WIN32
>> # defined OS_WINDOWS
>> #elif defined(__CYGWIN__)
>> # defined API_POSIX
>> # defined OS_WINDOWS
>> #else
>> # defined API_POSIX
>> #endif
>
> This is a much better idea.
OK, I'll write up a patch, tomorrow or Monday.
...
> So, I think something like this in git-compat-util.h:
>
> #if defined(_WIN32) && !defined(__CYGWIN__)
> # define WIN32_API
> # define WIN32_LEAN_AND_MEAN
> # include <winsock2.h>
> # include <windows.h>
> #endif
I agree with this one. Send a patch, and I'll ack.
> and replace all #if(n)def WIN32|_WIN32 with #if(n)def WIN32_API.
Ok, I might look into that too then.
> The only use of the <windows.h> header by cygwin can be moved
> into compat/cygwin.c. (I don't much like cygwin using the
> Win32 API anyway!)
I don't have Cygwin installed, so I won't touch this one.
>> So, then we can use #ifdef API_WIN32 when using the Win32 API is the
>> only option/preferred for MinGW or MSVC; and use #ifdef OS_WINDOWS
>> when there are things that affect all the Windows builds.
>>
>> Opinions?
>
> see above. I don't think OS_WINDOWS is necessary.
Well, it was mostly intended where we'd have code/algorithms which are
platform specific, and not really compiler specific; such as the *stat()
optimizations. They could probably be joined into an OS_WINDOWS section,
with a POSIX_API hunk for the Cygwin fallbacks.
Not really important though. Hopefully there won't be too much platform
specific stuff anyways.
--
.marius
^ permalink raw reply
* Re: [PATCH] MSVC: Enable OpenSSL, and translate -lcrypto
From: Erik Faye-Lund @ 2009-10-03 20:17 UTC (permalink / raw)
To: Marius Storm-Olsen; +Cc: git, msysgit
In-Reply-To: <4AC7AF58.1090603@gmail.com>
On Sat, Oct 3, 2009 at 1:08 PM, Marius Storm-Olsen
<marius@storm-olsen.com> wrote:
>> Didn't my 7/7 already do this hunk?
>
> Not for MSVC. It has it's own section above the MinGW part. Besides, the
> -lcrypto 'translation' is critical for it to link.
Ahh, thanks for the clarification :)
--
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656
^ permalink raw reply
* Re: MSVC build broken (on cygwin)
From: Ramsay Jones @ 2009-10-03 19:36 UTC (permalink / raw)
To: Marius Storm-Olsen; +Cc: GIT Mailing-list, Shawn O. Pearce
In-Reply-To: <4AC5B4AE.5070307@gmail.com>
Marius Storm-Olsen wrote:
> ...
> Clone the git://repo.or.cz/msvcgit.git, and run the
> setup_32bit_env.cmd script in there, and you should have everything
> you need to both compile and link Git with MSVC.
>
Hmm, I'm trying to avoid YASORD (Yet Another Set Of Redundant
Dependencies ;-) On my laptop, I currently have 4 zlib installations,
5 openssl installations, 3 iconv's ...
As I said earlier (see below), I'm not so interested in getting the
msvc build to work for me, rather than understand why it works for you,
since it should not work!
Having said that, I *may* try to get it working on my cygwin
installation. However, I'm much more likely to make some changes to
the build/Makefile to allow the dependent libraries to be installed
in different locations :) There is nothing wrong with my zlib at
C:\zlib.
>> Anyway, the point is *not* to get the msvc build to work for me; rather
>> it is to understand why the build *works* for you. ;-)
>
> First of all, thanks for the thorough report! :)
You're welcome.
> Second, I just recompiled, and it magically works for me. Why is a
> good question, since I also think it shouldn't at this point. The
Oh, you *really* don't want "magic" to be the answer... :P
> So, obviously, some magic in there is making it work for me. I have a
> hard time locating the magic in question though. :-/
Which shell are you using? MSYS-bash?
Which make are you using? MSYS-GNU?
Which Perl are you using? ActiveState? MSYS?
I'm using cygwin 1.5.22, along with the cygwin versions of
bash 3.2, GNU make 3.81, perl 5.8.7
I noticed that the clink.pl script was not returning the correct exit
code to the Makefile, which is why I ended up snipping 940 lines of
output from the earlier #error demonstration; the Makefile does not
notice when the compile exits with an error.
In order to fix this issue for me, I made the following change:
-- >8 --
diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
index 0ffd59f..3e4e501 100644
--- a/compat/vcbuild/scripts/clink.pl
+++ b/compat/vcbuild/scripts/clink.pl
@@ -45,4 +45,18 @@ if ($is_linking) {
push(@args, @cflags);
}
#printf("**** @args\n");
-exit system(@args);
+
+system(@args);
+
+if ($? == -1) {
+ print "clink.pl: failed to execute: $!\n";
+ exit 1;
+}
+elsif ($? & 127) {
+ printf "clink.pl: child died with signal %d%s\n",
+ ($? & 127), ($? & 128) ? ', coredump.' : '.';
+ exit 1;
+}
+
+exit $? >> 8;
+
-- >8 --
See "perldoc -f system" for more explanation of the above. This is
how it works on unix and unix-alike systems, so this may not work
too well on (say) ActiveState Perl; Dunno. Also, according to this
documentation, the form of the call to system() should result in a
call to an exec function, rather than using a shell; this may or
may not be true on other platforms.
Having fixed that problem, I modified clink.pl again so that it
would run args.exe rather than cl.exe; this allowed me to see,
using: make -> perl -> "system()" -> args.exe, just what will be
passed to the compiler.
Just in case you can't guess, create args.exe from:
$ cat -n args.c
1 #include <stdio.h>
2
3 int main(int argc, char *argv[])
4 {
5 int i;
6
7 for (i=0; i< argc; i++) {
8 printf("argv[%d] = '%s'\n", i, argv[i]);
9 }
10 exit(1);
11 }
12
$
and put it somewhere in your path (~/bin for me).
$ make MSVC=1
GIT_VERSION = 1.6.5.rc1.38.gb4f27.dirty
* new build flags or prefix
CC fast-import.o
argv[0] = 'args'
argv[1] = '-Fofast-import.o'
argv[2] = '-c'
argv[3] = '-nologo'
argv[4] = 'fast-import.c'
argv[5] = '-I.'
argv[6] = '-I../zlib'
argv[7] = '-Icompat/vcbuild'
argv[8] = '-Icompat/vcbuild/include'
argv[9] = '-DWIN32-D_CONSOLE'
[...snipped...]
argv[56] = '-Icompat/regex'
make: *** [fast-import.o] Error 1
Perhaps you could try a similar exercise?
Hmm, do you have any funny environment variables set which msvc is
picking up?
Oh, what about the CL variable?
> That being said, does adding the space between the defines fix the
> MSVC compilation using Cygwin's GNU Make? It's none-the-less a correct
> patch, so you get an ack from me. Thanks!
>
> Acked-by: Marius Storm-Olsen <mstormo@gmail.com>
>
Thanks!
ATB,
Ramsay Jones
^ permalink raw reply related
* Re: MSVC build broken (on cygwin)
From: Ramsay Jones @ 2009-10-03 20:06 UTC (permalink / raw)
To: Marius Storm-Olsen; +Cc: Alex Riesen, GIT Mailing-list, Shawn O. Pearce
In-Reply-To: <4AC5BEA6.5000102@gmail.com>
Marius Storm-Olsen wrote:
> Apparently, nothing is broken in neither Cygwin, MinGW or MSVC after
> Ramsays whitespace fix, but I'm sure it might get hairy later, if/when
> we get more Windows contributions. Keeping the guards right could get
> tricky.
>
Right! Thus my earlier nervousness. :P
> So, something like this maybe, in git-compat-util.h:
>
> #if defined(__MINGW32__) || defined(_MSC_VER)
> # defined API_WIN32
> # defined OS_WINDOWS
> #elif defined(__CYGWIN__)
> # defined API_POSIX
> # defined OS_WINDOWS
> #else
> # defined API_POSIX
> #endif
>
This is a much better idea.
Note that I also have Digital-Mars C/C++ 8.50, Open Watcom C/C++ 1.8
and lcc 4.2 installed. So, lets add to our previous tests:
Digital-Mars:
$ dmc hello.c
link hello,,,user32+kernel32/noi;
$ ./hello.exe
_WIN32
WIN32
Hello world
$
$ dmc -DIW_H hello.c
link hello,,,user32+kernel32/noi;
$ ./hello.exe
_WIN32
WIN32
Hello world
$
$ dmc -DWIN32-D_CONSOLE hello.c
Command line error: bad -D switch, need '=' after macro name--- errorlevel 1
$
Open Watcom:
$ wcl386 hello.c
[...compiler output snipped...]
$ ./hello.exe
_WIN32
Hello world
$
$ wcl386 -DIW_H hello.c
[...compiler output snipped...]
$ ./hello.exe
_WIN32
Hello world
$
$ wcl386 -DWIN32-D_CONSOLE hello.c
Open Watcom C/C++32 Compile and Link Utility Version 1.8
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
wcc386 hello.c -DWIN32 -D_CONSOLE
Open Watcom C32 Optimizing Compiler Version 1.8
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
hello.c: 25 lines, included 757, 0 warnings, 0 errors
Code size: 52
wlink @__wcl__.lnk
Open Watcom Linker Version 1.8
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
loading object files
searching libraries
creating a Windows NT character-mode executable
$ ./hello.exe
_WIN32
WIN32
Hello world
$
[Note: I didn't snip the compiler output here so that you could see that
the Watcom driver program had "fixed" the malformed -Define and passed
it as two separate parameters to the compiler proper!]
Also note that Open Watcom is currently being ported to Linux, I *think*
Digital-Mars already has a Linux version and lcc does have a Linux
version. However, I think it's reasonably safe to assume we won't see a
Linux version of msvc.
So, I think something like this in git-compat-util.h:
#if defined(_WIN32) && !defined(__CYGWIN__)
# define WIN32_API
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h>
# include <windows.h>
#endif
and replace all #if(n)def WIN32|_WIN32 with #if(n)def WIN32_API.
The only use of the <windows.h> header by cygwin can be moved
into compat/cygwin.c. (I don't much like cygwin using the
Win32 API anyway!)
> So, then we can use #ifdef API_WIN32 when using the Win32 API is the
> only option/preferred for MinGW or MSVC; and use #ifdef OS_WINDOWS
> when there are things that affect all the Windows builds.
>
> Opinions?
see above. I don't think OS_WINDOWS is necessary.
Anyway, *something* like this would be an improvement.
ATB,
Ramsay Jones
^ permalink raw reply
* Re: [PATCH] MSVC: Enable OpenSSL, and translate -lcrypto
From: Marius Storm-Olsen @ 2009-10-03 20:08 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: git, msysgit
In-Reply-To: <40aa078e0910031305u38cfaf4aua72d4c7af2a470b2@mail.gmail.com>
Erik Faye-Lund said the following on 03.10.2009 22:05:
> On Sat, Oct 3, 2009 at 1:00 PM, Marius Storm-Olsen <mstormo@gmail.com> wrote:
>> This patch was actually sent using the MSVC
>> git-imap-send.exe to my GMail account.
>> D:\msvc\git>cat
>> 0001-MSVC-Enable-OpenSSL-and-translate-lcrypto.patch |
>> git-imap-send.exe
>> Resolving imap.gmail.com... ok
>> Connecting to 74.125.79.109:993... ok
>> Logging in...
>> sending 1 message
>> 100% (1/1) done
>> :)
>
> Awesome :)
Yup, only sad to see that GMail dropped the In-reply-to when sending :-/
>> diff --git a/Makefile b/Makefile
>> index 8818f0f..c4b91d8 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -881,7 +881,6 @@ ifdef MSVC
>> GIT_VERSION := $(GIT_VERSION).MSVC
>> pathsep = ;
>> NO_PREAD = YesPlease
>> - NO_OPENSSL = YesPlease
>> NO_LIBGEN_H = YesPlease
>> NO_SYMLINK_HEAD = YesPlease
>> NO_IPV6 = YesPlease
>
> Didn't my 7/7 already do this hunk?
Not for MSVC. It has it's own section above the MinGW part. Besides, the
-lcrypto 'translation' is critical for it to link.
--
.marius
^ permalink raw reply
* Re: [PATCH] MSVC: Enable OpenSSL, and translate -lcrypto
From: Erik Faye-Lund @ 2009-10-03 20:05 UTC (permalink / raw)
To: Marius Storm-Olsen; +Cc: git, msysgit
In-Reply-To: <18cd41840910031300i32c74b15t74eb9eee23ff8469@mail.gmail.com>
On Sat, Oct 3, 2009 at 1:00 PM, Marius Storm-Olsen <mstormo@gmail.com> wrote:
> This patch was actually sent using the MSVC
> git-imap-send.exe to my GMail account.
> D:\msvc\git>cat
> 0001-MSVC-Enable-OpenSSL-and-translate-lcrypto.patch |
> git-imap-send.exe
> Resolving imap.gmail.com... ok
> Connecting to 74.125.79.109:993... ok
> Logging in...
> sending 1 message
> 100% (1/1) done
> :)
Awesome :)
> diff --git a/Makefile b/Makefile
> index 8818f0f..c4b91d8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -881,7 +881,6 @@ ifdef MSVC
> GIT_VERSION := $(GIT_VERSION).MSVC
> pathsep = ;
> NO_PREAD = YesPlease
> - NO_OPENSSL = YesPlease
> NO_LIBGEN_H = YesPlease
> NO_SYMLINK_HEAD = YesPlease
> NO_IPV6 = YesPlease
Didn't my 7/7 already do this hunk?
--
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656
^ permalink raw reply
* [PATCH] MSVC: Enable OpenSSL, and translate -lcrypto
From: Marius Storm-Olsen @ 2009-10-03 20:00 UTC (permalink / raw)
To: git; +Cc: kusmabite, msysgit
We don't use crypto, but rather require libeay32 and
ssleay32. handle it in both the Makefile msvc linker
script, and the buildsystem generator.
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
Requires Erik Faye-Lund's MinGW patches for imap-send
ontop of git.git master.
This patch was actually sent using the MSVC
git-imap-send.exe to my GMail account.
D:\msvc\git>cat
0001-MSVC-Enable-OpenSSL-and-translate-lcrypto.patch |
git-imap-send.exe
Resolving imap.gmail.com... ok
Connecting to 74.125.79.109:993... ok
Logging in...
sending 1 message
100% (1/1) done
:)
Makefile | 1 -
compat/vcbuild/scripts/clink.pl | 3 +++
contrib/buildsystems/engine.pl | 3 +++
3 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 8818f0f..c4b91d8 100644
--- a/Makefile
+++ b/Makefile
@@ -881,7 +881,6 @@ ifdef MSVC
GIT_VERSION := $(GIT_VERSION).MSVC
pathsep = ;
NO_PREAD = YesPlease
- NO_OPENSSL = YesPlease
NO_LIBGEN_H = YesPlease
NO_SYMLINK_HEAD = YesPlease
NO_IPV6 = YesPlease
diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
index 0ffd59f..fce1e24 100644
--- a/compat/vcbuild/scripts/clink.pl
+++ b/compat/vcbuild/scripts/clink.pl
@@ -29,6 +29,9 @@ while (@ARGV) {
push(@args, "zlib.lib");
} elsif ("$arg" eq "-liconv") {
push(@args, "iconv.lib");
+ } elsif ("$arg" eq "-lcrypto") {
+ push(@args, "libeay32.lib");
+ push(@args, "ssleay32.lib");
} elsif ("$arg" =~ /^-L/ && "$arg" ne "-LTCG") {
$arg =~ s/^-L/-LIBPATH:/;
push(@args, $arg);
diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
index 20bd061..d506717 100644
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -315,6 +315,9 @@ sub handleLinkLine
$appout = shift @parts;
} elsif ("$part" eq "-lz") {
push(@libs, "zlib.lib");
+ } elsif ("$part" eq "-lcrypto") {
+ push(@libs, "libeay32.lib");
+ push(@libs, "ssleay32.lib");
} elsif ($part =~ /^-/) {
push(@lflags, $part);
} elsif ($part =~ /\.(a|lib)$/) {
--
1.6.3.msysgit.0.18.gef407
^ permalink raw reply related
* Re: [PATCH/RFC 5/7] imap-send: provide fall-back random-source
From: Erik Faye-Lund @ 2009-10-03 18:59 UTC (permalink / raw)
To: Jeff King; +Cc: msysgit, git
In-Reply-To: <40aa078e0910031145l2849697ftd2da2f5aaa28d957@mail.gmail.com>
On Sat, Oct 3, 2009 at 11:45 AM, Erik Faye-Lund
<kusmabite@googlemail.com> wrote:
> I CC'ed Mike McCormack, who initially added imap-send (including the
> arc4 code), as he *might* have more insight on this. It's a long-shot
> though, considering that this appears to be code adapted around 3.5
> years ago.
OK, it seems the e-mail address he used for the commit isn't valid any
more, and I can't easily find another address for him. So I guess
we're out of luck on that front.
--
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656
^ permalink raw reply
* Re: [PATCH/RFC 5/7] imap-send: provide fall-back random-source
From: Erik Faye-Lund @ 2009-10-03 18:45 UTC (permalink / raw)
To: Jeff King; +Cc: msysgit, git, mike
In-Reply-To: <20091003095811.GB17873@coredump.intra.peff.net>
On Sat, Oct 3, 2009 at 2:58 AM, Jeff King <peff@peff.net> wrote:
>
> Hmm. It looks like this arc4 RNG is used just for generating a unique
> "X-TUID" header. Which seems to be used in isync (from which imap-send
> is derived) to be to avoid duplicates in synchronization. But imap-send
> doesn't actually use it for anything, as it just blindly pushes the
> messages.
>
> In other words, should all of this TUID code (and the arc4 code) simply
> be ripped out?
Possibly. I must admit that I didn't dig far on this one - I just
added some randomness, and saw that things worked for me.
I tried to trace this a little bit, but I got lost a bit in the
callback-stuff. However, it looks to me like it might get sent to the
server: it gets injected into cb.data in imap_store_msg(), and in
v_issue_imap_cmd() it gets sent to the server if the LITERALPLUS
capability is supported. I might be wrong though, as I find this code
quite confusing.
I CC'ed Mike McCormack, who initially added imap-send (including the
arc4 code), as he *might* have more insight on this. It's a long-shot
though, considering that this appears to be code adapted around 3.5
years ago.
--
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656
^ permalink raw reply
* Re: [PATCH/RFC 1/7] imap-send: use separate read and write fds
From: Erik Faye-Lund @ 2009-10-03 18:44 UTC (permalink / raw)
To: Jeff King; +Cc: msysgit, git
In-Reply-To: <20091003094049.GA17873@coredump.intra.peff.net>
On Sat, Oct 3, 2009 at 2:40 AM, Jeff King <peff@peff.net> wrote:
> On Sat, Oct 03, 2009 at 12:39:39AM +0000, Erik Faye-Lund wrote:
>
>> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
>
> Why? Given its presence in this series, I can only assume it has to do
> with windows portability, but it would be helpful to give a little bit
> of the reasoning in the commit message.
>
> -Peff
>
Yeah, this is about Windows portability.
I'll add something like "This is a patch that enables us to use the
run-command API, which is supported on Windows." to the commit-message
in the next round. Is that enough?
I also guess I should have made a cover letter for this series, making
it apparent to reviewers that:
- This patch series is about supporting imap-send on Windows
- It needs some additional patching to get tunnelling support working
on Windows, because we can't exec "/bin/sh" there. Changing it to
"c:\\msysgit\\bin\\sh.exe" makes tunneling work for me, but isn't
exactly portable across installations.
I'll write one up for the next round.
--
Erik "kusma" Faye-Lund
kusmabite@gmail.com
(+47) 986 59 656
^ permalink raw reply
* [PATCH 5/6] This assertion is valid for both loose and packed objects
From: Hervé Cauwelier @ 2009-10-03 18:10 UTC (permalink / raw)
To: git; +Cc: Hervé Cauwelier
In-Reply-To: <1254593401-18801-5-git-send-email-herve@itaapy.com>
Signed-off-by: Hervé Cauwelier <herve@itaapy.com>
---
src/odb.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/odb.c b/src/odb.c
index bc26cf7..dd3c142 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1149,11 +1149,10 @@ void git_odb_close(git_odb *db)
free(db);
}
-int git_odb_read(
- git_obj *out,
- git_odb *db,
- const git_oid *id)
+int git_odb_read(git_obj *out, git_odb *db, const git_oid *id)
{
+ assert(out && db && id);
+
attempt:
if (!git_odb__read_packed(out, db, id))
return GIT_SUCCESS;
@@ -1171,8 +1170,6 @@ int git_odb__read_loose(git_obj *out, git_odb *db, const git_oid *id)
char file[GIT_PATH_MAX];
gitfo_buf obj = GITFO_BUF_INIT;
- assert(out && db && id);
-
out->data = NULL;
out->len = 0;
out->type = GIT_OBJ_BAD;
--
1.6.4.4
^ permalink raw reply related
* [PATCH 6/6] Read an object from a pack file
From: Hervé Cauwelier @ 2009-10-03 18:10 UTC (permalink / raw)
To: git; +Cc: Hervé Cauwelier
In-Reply-To: <1254593401-18801-6-git-send-email-herve@itaapy.com>
Signed-off-by: Hervé Cauwelier <herve@itaapy.com>
---
src/odb.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/odb.c b/src/odb.c
index dd3c142..a712d71 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1263,13 +1263,16 @@ static int read_packed(git_obj *out, git_pack *p, const git_oid *id)
if (pack_openidx(p))
return GIT_ERROR;
+ if (pack_openpack(p)) {
+ pack_decidx(p);
+ return GIT_ERROR;
+ }
res = p->idx_search(&pos, p, id);
pack_decidx(p);
+ assert(pos < p->pack_map.len);
- if (!res) {
- /* TODO unpack object at pos */
- res = GIT_ERROR;
- }
+ if (res == GIT_SUCCESS)
+ return inflate_pack_obj(out, p, pos);
return res;
}
--
1.6.4.4
^ permalink raw reply related
* [PATCH 3/6] Allow zlib to read a pack buffer longer than the actual data
From: Hervé Cauwelier @ 2009-10-03 18:09 UTC (permalink / raw)
To: git; +Cc: Hervé Cauwelier
In-Reply-To: <1254593401-18801-3-git-send-email-herve@itaapy.com>
As we don't know where the compressed data end, only the size of the
uncompressed data.
Signed-off-by: Hervé Cauwelier <herve@itaapy.com>
---
src/odb.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/odb.c b/src/odb.c
index 3cfc932..89ee1f2 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -432,7 +432,7 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen)
inflateEnd(&zs);
- if ((status != Z_STREAM_END) || (zs.avail_in != 0))
+ if (status != Z_STREAM_END)
return GIT_ERROR;
if (zs.total_out != outlen)
--
1.6.4.4
^ permalink raw reply related
* [PATCH 4/6] Inflate an object from a pack file
From: Hervé Cauwelier @ 2009-10-03 18:09 UTC (permalink / raw)
To: git; +Cc: Hervé Cauwelier
In-Reply-To: <1254593401-18801-4-git-send-email-herve@itaapy.com>
Support delta objects too.
Signed-off-by: Hervé Cauwelier <herve@itaapy.com>
---
src/odb.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 68 insertions(+), 1 deletions(-)
diff --git a/src/odb.c b/src/odb.c
index 89ee1f2..bc26cf7 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -28,6 +28,7 @@
#include "git/zlib.h"
#include "fileops.h"
#include "hash.h"
+#include "delta-apply.h"
#include "odb.h"
#define GIT_PACK_NAME_MAX (5 + 40 + 1)
@@ -232,7 +233,7 @@ static int is_zlib_compressed_data(unsigned char *data)
unsigned int w;
w = ((unsigned int)(data[0]) << 8) + data[1];
- return data[0] == 0x78 && !(w %31);
+ return data[0] == 0x78 && !(w % 31);
}
static size_t get_binary_object_header(obj_hdr *hdr, gitfo_buf *obj)
@@ -1192,6 +1193,72 @@ int git_odb__read_loose(git_obj *out, git_odb *db, const git_oid *id)
return GIT_SUCCESS;
}
+static int inflate_pack_obj(git_obj *out, git_pack *p, off_t offset)
+{
+ obj_hdr hdr;
+ gitfo_buf buf;
+ size_t used;
+ void *data;
+ git_obj base;
+
+ /* Cast the map to a gitfo_buf */
+ buf.data = (unsigned char *)p->pack_map.data + offset;
+ buf.len = p->pack_map.len - offset;
+
+ /*
+ * Read the object header, which is an (uncompressed)
+ * binary encoding of the object type and size.
+ */
+ if (!(used = get_binary_object_header(&hdr, &buf)))
+ return GIT_ERROR;
+
+ /*
+ * Read the object data as a zlib compressed data
+ */
+ buf.data += used;
+ buf.len -= used;
+ assert(is_zlib_compressed_data(buf.data));
+
+ if (!(data = git__malloc(hdr.size + 1)))
+ return GIT_ERROR;
+ if (inflate_buffer(buf.data, buf.len, data, hdr.size))
+ goto inflate_fail;
+
+ switch (hdr.type) {
+ case GIT_OBJ_COMMIT:
+ case GIT_OBJ_TREE:
+ case GIT_OBJ_BLOB:
+ case GIT_OBJ_TAG:
+ out->data = data;
+ out->len = hdr.size;
+ out->type = hdr.type;
+ return GIT_SUCCESS;
+ case GIT_OBJ_OFS_DELTA:
+ offset -= hdr.base_offset;
+ if (inflate_pack_obj(&base, p, offset))
+ goto inflate_fail;
+ if (git__delta_apply(out, base.data, base.len, data, hdr.size))
+ goto inflate_fail;
+ out->type = base.type;
+ return GIT_SUCCESS;
+ case GIT_OBJ_REF_DELTA:
+ if (p->idx_search(&offset, p, &hdr.base_name))
+ goto inflate_fail;
+ if (inflate_pack_obj(&base, p, offset))
+ goto inflate_fail;
+ if (git__delta_apply(out, base.data, base.len, data, hdr.size))
+ goto inflate_fail;
+ out->type = base.type;
+ return GIT_SUCCESS;
+ default:
+ goto inflate_fail;
+ }
+
+inflate_fail:
+ free(data);
+ return GIT_ERROR;
+}
+
static int read_packed(git_obj *out, git_pack *p, const git_oid *id)
{
off_t pos;
--
1.6.4.4
^ permalink raw reply related
* [PATCH 2/6] Read the base offset or name of delta objects
From: Hervé Cauwelier @ 2009-10-03 18:09 UTC (permalink / raw)
To: git; +Cc: Hervé Cauwelier
In-Reply-To: <1254593401-18801-2-git-send-email-herve@itaapy.com>
Signed-off-by: Hervé Cauwelier <herve@itaapy.com>
---
src/cc-compat.h | 3 +++
src/odb.c | 28 ++++++++++++++++++++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/cc-compat.h b/src/cc-compat.h
index 8997caa..8dd6774 100644
--- a/src/cc-compat.h
+++ b/src/cc-compat.h
@@ -30,6 +30,9 @@
# define GIT_TYPEOF(x)
#endif
+#define bitsizeof(x) (CHAR_BIT * sizeof(x))
+#define MSB(x, bits) ((x) & GIT_TYPEOF(x)(~0ULL << (bitsizeof(x) - (bits))))
+
/*
* Does our compiler/platform support the C99 <inttypes.h> and
* <stdint.h> header files. (C99 requires that <inttypes.h>
diff --git a/src/odb.c b/src/odb.c
index a562a19..3cfc932 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -97,8 +97,10 @@ struct git_odb {
};
typedef struct { /* object header data */
- git_otype type; /* object type */
- size_t size; /* object size */
+ git_otype type; /* object type */
+ size_t size; /* object size */
+ off_t base_offset; /* delta base offset (GIT_OBJ_OFS_DELTA) */
+ git_oid base_name; /* delta base name (GIT_OBJ_REF_DELTA) */
} obj_hdr;
static struct {
@@ -238,6 +240,7 @@ static size_t get_binary_object_header(obj_hdr *hdr, gitfo_buf *obj)
unsigned char c;
unsigned char *data = obj->data;
size_t shift, size, used = 0;
+ off_t base_offset;
if (obj->len == 0)
return 0;
@@ -258,6 +261,27 @@ static size_t get_binary_object_header(obj_hdr *hdr, gitfo_buf *obj)
}
hdr->size = size;
+ hdr->base_offset = 0;
+ hdr->base_name.id[0] = '\0';
+
+ if (hdr->type == GIT_OBJ_OFS_DELTA) {
+ c = data[used++];
+ base_offset = c & 127;
+ while (c & 128) {
+ base_offset++;
+ if (!base_offset || MSB(base_offset, 7))
+ return 0; /* overflow */
+ c = data[used++];
+ base_offset = (base_offset << 7) + (c & 127);
+ }
+ assert(base_offset > 0);
+ hdr->base_offset = base_offset;
+ }
+ else if (hdr->type == GIT_OBJ_REF_DELTA) {
+ git_oid_mkraw(&hdr->base_name, data + used);
+ used += 20;
+ }
+
return used;
}
--
1.6.4.4
^ permalink raw reply related
* [PATCH 1/6] Open the pack file and keep a map on it.
From: Hervé Cauwelier @ 2009-10-03 18:09 UTC (permalink / raw)
To: git; +Cc: Hervé Cauwelier
In-Reply-To: <1254593401-18801-1-git-send-email-herve@itaapy.com>
On the same model than the idx file.
Signed-off-by: Hervé Cauwelier <herve@itaapy.com>
---
src/odb.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/odb.h | 5 ++-
2 files changed, 68 insertions(+), 4 deletions(-)
diff --git a/src/odb.c b/src/odb.c
index 6d646a4..a562a19 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -64,6 +64,10 @@ struct git_pack {
/** Name of the pack file(s), without extension ("pack-abc"). */
char pack_name[GIT_PACK_NAME_MAX];
+
+ /** The .pack file, mapped into memory. */
+ git_file pack_fd;
+ git_map pack_map;
};
typedef struct git_pack git_pack;
@@ -782,7 +786,7 @@ static int pack_openidx(git_pack *p)
goto invalid_fail;
data = p->idx_map.data;
- if (decode32(&data[0]) == PACK_TOC) {
+ if (decode32(&data[0]) == IDX_TOC) {
switch (decode32(&data[1])) {
case 2:
if (pack_openidx_v2(p))
@@ -809,6 +813,59 @@ unlock_fail:
return GIT_ERROR;
}
+static int pack_openpack_map(git_pack *p)
+{
+ char pb[GIT_PATH_MAX];
+ off_t len;
+
+ if (git__fmt(pb, sizeof(pb), "%s/pack/%s.pack",
+ p->db->objects_dir,
+ p->pack_name) < 0)
+ return GIT_ERROR;
+
+ if ((p->pack_fd = gitfo_open(pb, O_RDONLY)) < 0)
+ return GIT_ERROR;
+
+ if ((len = gitfo_size(p->pack_fd)) < 0
+ || !git__is_sizet(len)
+ || gitfo_map_ro(&p->pack_map, p->pack_fd, 0, (size_t)len)) {
+ gitfo_close(p->pack_fd);
+ return GIT_ERROR;
+ }
+
+ return GIT_SUCCESS;
+}
+
+static int pack_openpack(git_pack *p)
+{
+ gitlck_lock(&p->lock);
+ if (p->invalid)
+ goto unlock_fail;
+ if (p->pack_fd < 0) {
+ uint32_t *data;
+
+ if (pack_openpack_map(p))
+ goto invalid_fail;
+ data = p->pack_map.data;
+
+ if (decode32(&data[0]) != PACK_TOC)
+ goto unmap_fail;
+ }
+ gitlck_unlock(&p->lock);
+ return GIT_SUCCESS;
+
+unmap_fail:
+ gitfo_free_map(&p->pack_map);
+
+invalid_fail:
+ p->invalid = 1;
+ p->pack_fd = -1;
+
+unlock_fail:
+ gitlck_unlock(&p->lock);
+ return GIT_ERROR;
+}
+
static void pack_decidx(git_pack *p)
{
gitlck_lock(&p->lock);
@@ -830,6 +887,11 @@ static void pack_dec(git_pack *p)
gitfo_close(p->idx_fd);
free(p->im_fanout);
}
+ if (p->pack_fd >= 0) {
+ gitfo_free_map(&p->pack_map);
+ gitfo_close(p->pack_fd);
+ p->pack_fd = -1;
+ }
gitlck_free(&p->lock);
free(p);
@@ -861,6 +923,7 @@ static git_pack *alloc_pack(const char *pack_name)
gitlck_init(&p->lock);
strcpy(p->pack_name, pack_name);
p->refcnt = 1;
+ p->pack_fd = -1;
return p;
}
@@ -895,7 +958,7 @@ static int scan_one_pack(void *state, char *name)
r->next = *ret;
*ret = r;
- return 0;
+ return GIT_SUCCESS;
}
static git_packlist* scan_packs(git_odb *db)
diff --git a/src/odb.h b/src/odb.h
index 2f205b2..0311d78 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -11,9 +11,10 @@
* uint32_t *fanout = ... the file data at offset 0 ...
* ntohl(fanout[0]) < ntohl(fanout[1])
*
- * The value chosen here for PACK_TOC is such that the above
+ * The value chosen here for IDX_TOC is such that the above
* cannot be true for an idx v1 file.
*/
-#define PACK_TOC 0xff744f63 /* -1tOc */
+#define IDX_TOC 0xff744f63 /* -1tOc */
+#define PACK_TOC 0x5041434b /* PACK */
#endif
--
1.6.4.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox