Git development
 help / color / mirror / Atom feed
* Re: [PATCH] Create USE_ST_TIMESPEC and turn it on for Darwin
From: Brian Gernhardt @ 2009-03-08 21:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git List
In-Reply-To: <7vhc23kaay.fsf@gitster.siamese.dyndns.org>


On Mar 8, 2009, at 4:51 PM, Junio C Hamano wrote:

> I think this patch moves things in the right direction, but there are
> other uses of "st_[cm]tim.tv_nsec" that do not use the  
> ST_[CM]TIME_NSEC
> macro.
>
> $ git grep -n -e 'st_[cm]tim\.' --cached -- '*.[ch]'
> builtin-fetch-pack.c:810:				|| st.st_mtim.tv_nsec != mtime.nsec
> git-compat-util.h:396:#define ST_CTIME_NSEC(st) ((unsigned int) 
> ((st).st_ctim.tv_nsec))
> git-compat-util.h:397:#define ST_MTIME_NSEC(st) ((unsigned int) 
> ((st).st_mtim.tv_nsec))
> read-cache.c:207:	if (ce->ce_mtime.nsec != (unsigned int)st- 
> >st_mtim.tv_nsec)
> read-cache.c:209:	if (trust_ctime && ce->ce_ctime.nsec != (unsigned  
> int)st->st_ctim.tv_nsec)

Interesting.  I couldn't use git-grep due to other problems, but  
thought any other tim/timespec issues would have stopped my  
compilation.  Looking at the code, this is because everything other  
than the #defines in git-compat-util.h are surrounded by USE_NSEC  
which is not defined on my machine.

However, I noticed another breakage entirely.  Namely, that USE_NSEC  
is not defined anywhere.  There's a comment in the Makefile that says  
"define USE_NSEC below", but there is no code that checks for USE_NSEC  
and sets the appropriate compiler switch.  Trivial patch to follow.

> Probably we should apply the following patch as a fix, and then  
> apply your
> enhancement to support st_[cm]timespec systems?

Your patch looks sane to me.

~~ Brian

^ permalink raw reply

* [PATCH] Makefile: Set compiler switch for USE_NSEC
From: Brian Gernhardt @ 2009-03-08 21:22 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano
In-Reply-To: <70A401B0-C10D-4B4D-9DCC-D0968CE5EAF7@silverinsanity.com>

The comments indicated that setting a Makefile variable USE_NSEC would
enable the code for sub-second [cm]times.  However, the Makefile
variable was never turned into a compiler switch so the code was never
enabled.  This patch allows USE_NSEC to be noticed by the compiler.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
---
 Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 4bdaad7..b96c2b3 100644
--- a/Makefile
+++ b/Makefile
@@ -929,6 +929,9 @@ endif
 ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
 	BASIC_CFLAGS += -DNO_ST_BLOCKS_IN_STRUCT_STAT
 endif
+ifdef USE_NSEC
+	BASIC_CFLAGS += -DUSE_NSEC
+endif
 ifdef USE_ST_TIMESPEC
 	BASIC_CFLAGS += -DUSE_ST_TIMESPEC
 endif
-- 
1.6.2.222.g01cbd

^ permalink raw reply related

* Re: Git for Windows 1.6.2-preview20090308
From: Christian MICHON @ 2009-03-08 21:30 UTC (permalink / raw)
  To: Johannes.Schindelin; +Cc: git, msysgit
In-Reply-To: <alpine.DEB.1.00.0903080132470.10279@pacific.mpi-cbg.de>


On Sun, Mar 8, 2009 at 3:10 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi,
>
> I just released a new version of Git for Windows (TAFKA WinGit).  It is
> basically Git 1.6.2 plus a few patches.  Please find the installer here:
>
>        http://msysgit.googlecode.com/
>

I noticed the PS1 change too :)

Something is wrong with vim-7.2 apparently: syntax highlighting is not
working apparently.

I'll look at what could be wrong right now.

-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

^ permalink raw reply

* Re: [msysGit] Re: Git for Windows 1.6.2-preview20090308
From: Janos Laube @ 2009-03-08 21:36 UTC (permalink / raw)
  To: christian.michon; +Cc: Johannes.Schindelin, git, msysgit
In-Reply-To: <46d6db660903081430m35da0d2eoc97377dfec54b1b5@mail.gmail.com>

> I'll look at what could be wrong right now.

as vim says, the syntax files in /share/vim/vim72/syntax are missing,
i.e. not included with the installer package :-)

^ permalink raw reply

* Re: Git for Windows 1.6.2-preview20090308
From: Christian MICHON @ 2009-03-08 21:39 UTC (permalink / raw)
  To: Janos Laube; +Cc: Johannes.Schindelin, git, msysgit
In-Reply-To: <9d6091530903081436k20591bdbu69cd73ed2f1c98b5@mail.gmail.com>


On Sun, Mar 8, 2009 at 10:36 PM, Janos Laube <janos.dev@gmail.com> wrote:
>> I'll look at what could be wrong right now.
>
> as vim says, the syntax files in /share/vim/vim72/syntax are missing,
> i.e. not included with the installer package :-)
>

there are a few actually, but somehow it's not working. I need to find
out what happened, as I actually provided a git repo to vim-7.2 (I
also need to update this repo).

-- 
Christian
--
http://detaolb.sourceforge.net/, a linux distribution for Qemu with Git inside !

^ permalink raw reply

* Re: [PATCH/RFD] builtin-revert.c: release index lock when cherry-picking an empty commit
From: Junio C Hamano @ 2009-03-08 21:53 UTC (permalink / raw)
  To: Chris Johnsen; +Cc: git, Miklos Vajna
In-Reply-To: <B0CBEE84-0F46-4AF2-86B1-C80BADAEF4E5@pobox.com>

Chris Johnsen <chris_johnsen@pobox.com> writes:

> My confusion was that I took "usually a mistake" to refer to the case
> where the user meant to commit content changes but forgot to first
> stage any changed content. But your clarification shows that "usually
> a mistake" really means that making any empty commit, intentional or
> not, is (considered to be) a fundamental misuse of SCM machinery.

The empty commits in your example a few messages ago are used as "piss in
the snow" marking.  If you did not have tags (and commit notes), it may be
the only workaround to say "here is an interesting point", but even then
such a workaround can only be made while the commit is at the tip, and be
made useful only by forcing all the other commits on the branch be on top
of that "piss in the snow" commit, so it is a flawed workaround.

Suppose you have this history.

 ---A---B---C

You found that the point C is interesting in some way, so you mark it:

 ---A---B---C---P

But somebody else may have developed on top of C bypassing P

              D---E---F
             /
 ---A---B---C---P

What would you do in such a case?  You cannot leave P dangling, as that
would mean P will not participate in future rebases (and you do not want
to rebase P on top of F because C is the point that is interesting to you,
not F).  Do you merge F and P only to make P not dangling?  What does such
a merge mean?

Worse yet, if you stared from the original history with three commits, how
would you mark that B is interesting?

          P   D---E---F
         /   /
 ---A---B---C


The facility git and other SCM offer you to leave such mark (possibly
after the fact) is to use tags.

So in your particular "piss in the snow" usage, I would agree that such an
empty commit is a misuse.

I am not however claiming that all uses of an empty commit are fundamental
misuses here, though.  Somebody else may have other valid uses.

^ permalink raw reply

* Re: [EGIT PATCH] Show diff when double-clicking on file in commit dialog
From: Robin Rosenberg @ 2009-03-08 21:59 UTC (permalink / raw)
  To: Robin Stocker; +Cc: Shawn O. Pearce, git
In-Reply-To: <49B4260D.6070501@nibor.org>

söndag 08 mars 2009 21:09:49 skrev Robin Stocker <robin@nibor.org>:
> It only compares the index version to the working tree version for now.
> So if the file was already added to the index, the diff is empty. What
> it should show is the diff that will be in the commit.
> 
> Signed-off-by: Robin Stocker <robin@nibor.org>
> ---
> 
> Hi,
> 
> An essential feature I miss in EGit at the moment (apart from the
> synchronize view [1]) is seeing what changes one is about to commit. In
> the Subclipse SVN plugin one can double-click a file in the commit
> dialog and the diff is shown.
Hi, Robin. I miss that too!

> This patch is a first step for adding this to EGit. It only compares the
> index version to the working tree version as I couldn't figure out an
> easy way to get the HEAD version.
You can look at how GitDocument does it.

> 
> It's more a proof of concept than a final patch. What do you think?

I've started on an version with the diff integrated into the same dialog, for
some reasons it's not done yet, but we might takes this meanwhile unless
I complete the dialog real quick, as this is really useful, provided we compare
with HEAD.

-- robin

^ permalink raw reply

* git-grep Bus Error
From: Brian Gernhardt @ 2009-03-08 23:27 UTC (permalink / raw)
  To: Git List

The --color display code in git-grep is giving me a bus error in  
show_line at line 492:

>                         printf("%.*s%s%.*s%s",
>                                match.rm_so, bol,
>                                opt->color_match,
>                                match.rm_eo - match.rm_so, bol +  
> match.rm_so,
>                                GIT_COLOR_RESET);

The first problem is that %.*s does not appear to do on OS X what the  
author thinks it does.  A precision of 0 for %s is listed in "man  
printf" as printing the entire string.

To fix that, I changed it to the following:

> 			if( match.rm_so > 0 )
> 				printf( "%.*s", match.rm_so, bol );
> 			if( match.rm_eo > match.rm_so )
> 				printf("%s%.*s%s",
> 					   opt->color_match,
> 					   match.rm_eo - match.rm_so, bol + match.rm_so,
> 					   GIT_COLOR_RESET);

This code does not fail, but instead gives lines like the following  
(showing the raw color codes):

.gitignore:\033[31m\033[1m(nugit

GIT_COLOR_RESET is apparently being ignored, and I don't know why.

Adding a line to check the values of rm_so, rm_eo, and the difference  
between the two gives:

> 			printf( "%d %d %d",
> 				  match.rm_so, match.rm_eo,
> 				  match.rm_eo - match.rm_so );

.gitignore:0 0 3\033[31m\033[1m(nugit
.mailmap:23 0 26(null)\033[31m\033[1m(nugit-shortlog to fix a few  
botched name translations-shortlog to fix a few botched name  
translations

And now I'm baffled.  Apparently my computer thinks 0 - 0 == 3 and 0 -  
23 == 26.

Can I get some help?

~~ Brian

^ permalink raw reply

* Re: git-grep Bus Error
From: Sam Hocevar @ 2009-03-08 23:41 UTC (permalink / raw)
  To: Git List
In-Reply-To: <C36B091A-ABE9-4C74-9E59-4EBD50E3B9F5@gernhardtsoftware.com>

On Sun, Mar 08, 2009, Brian Gernhardt wrote:

> >			printf( "%d %d %d",
> >				  match.rm_so, match.rm_eo,
> >				  match.rm_eo - match.rm_so );
> 
> .gitignore:0 0 3\033[31m\033[1m(nugit
> .mailmap:23 0 26(null)\033[31m\033[1m(nugit-shortlog to fix a few  
> botched name translations-shortlog to fix a few botched name  
> translations
> 
> And now I'm baffled.  Apparently my computer thinks 0 - 0 == 3 and 0 -  
> 23 == 26.

   rm_so and rm_eo are ints on Linux but off_t's on Darwin, hence
probably int64_t's here. You should cast the arguments.

-- 
Sam.

^ permalink raw reply

* Re: [GSoC] Google Summer of Code 2009 - new ideas
From: Jakub Narebski @ 2009-03-08 23:59 UTC (permalink / raw)
  To: Tay Ray Chuan; +Cc: git, Shawn Pearce
In-Reply-To: <be6fef0d0903061856s21fdb4c4q9d52957dade96e94@mail.gmail.com>

On Sat, 7 Mar 2009, Tay Ray Chuan wrote:
> On 3/7/09, Jakub Narebski <jnareb@gmail.com> wrote:

> > == Single credentials ==
> >
> > Currently if you don't save your username and password in plain-text
> > `.netrc` file (for HTTP transport), or avoid need for interactive
> > credentials using public key / private key pair (for SSH), you need to
> > repeat credentials many times during single git-fetch or git-clone
> > command.  The goal is to reuse existing connections if possible, so the
> > whole transaction occurs using single connection and single
> > credentials; if that is not possible cache credentials (in secure way)
> > so user need to provide username and password at most once.
> >
> > '''Goal:''' git-fetch and git-clone over HTTPS and git://
> >             requiring providing username and password at most once
> > '''Language:''' C (perhaps also shell script)
> 
> Perhaps you might want to look at this:
> 
> http://marc.info/?l=git&m=123599968929476&w=4

Thank you for the link.

> At that time, I was thinking more of removing git's reliance on curl's
> multi interface so that it could use older versions of libcurl. But,
> on this point, Daniel convinced me otherwise. In fact, it doesn't make
> sense if you could have a up-to-date git, but not an up-to-date curl.
> 
> I didn't really get a reply on my point of "minimized credential
> prompting", though, and I think this GSoC proposal kinda gives support
> to it.
> 
> From a learning standpoint, I don't think this project would be too
> challenging, nor can it sustain for a whole summer -- the basic
> strategy to allow non-curl multi usage (ie. single connections) would
> be to "fork" the current http slot methods and make them
> non-curl_multi, then finding and replacing instances of them
> throughout the code base.

I was thinking more about caching credentials by git rather than forcing
to use single connection.  Additionally you are solving the problem for
the HTTP(S) transport; admittedly for SSH there is much better solution
of using public/private keys, instead of asking for password.

I guess you are right and "minimized credential prompting" (aka "single
credentials") is too small a project for Google Summer of Code...
I won't add it to SoC2009Ideas page.
 
> I already have a patch series that does that, plus a --persistent
> option for push. I'm fairly sure that it takes place on a single
> connection (I'm relying on my firewall log though I'm doubting it's
> reliability on this issue).

-- 
Jakub Narebski
Poland

^ permalink raw reply

* Re: git-grep Bus Error
From: Junio C Hamano @ 2009-03-09  0:29 UTC (permalink / raw)
  To: Brian Gernhardt; +Cc: Git List
In-Reply-To: <C36B091A-ABE9-4C74-9E59-4EBD50E3B9F5@gernhardtsoftware.com>

Brian Gernhardt <brian@gernhardtsoftware.com> writes:

> The --color display code in git-grep is giving me a bus error in
> show_line at line 492:
>
>>                         printf("%.*s%s%.*s%s",
>>                                match.rm_so, bol,
>>                                opt->color_match,
>>                                match.rm_eo - match.rm_so, bol +
>> match.rm_so,
>>                                GIT_COLOR_RESET);
>
> The first problem is that %.*s does not appear to do on OS X what the
> author thinks it does.

Hmm, that means that printf on OSX does not dohat the POSIX thinks it
ought to.

    http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html

says that "a negative precision is taken as if the precision were
omitted"; it does not say "a negative or zero" here.

Which is a bit sad, because we would need to apply a workaround like
yours.  We shouldn't have to.

> To fix that, I changed it to the following:
>
>> 			if( match.rm_so > 0 )
>> 				printf( "%.*s", match.rm_so, bol );
>> 			if( match.rm_eo > match.rm_so )
>> 				printf("%s%.*s%s",
>> 					   opt->color_match,
>> 					   match.rm_eo - match.rm_so, bol + match.rm_so,
>> 					   GIT_COLOR_RESET);

> This code does not fail, but instead gives lines like the following
> (showing the raw color codes):
>
> .gitignore:\033[31m\033[1m(nugit

Hmm, that is strange.  Your above change issues color_match and COLOR_RESET
only when you have something between rm_eo and rm_so.  I do not see
anything between "ESC [ 31 m" and "ESC [ m" above, and you have an extra "1"
between "ESC [" and terminating "m" in the reset sequence.

^ permalink raw reply

* Re: git-grep Bus Error
From: Brian Gernhardt @ 2009-03-09  0:58 UTC (permalink / raw)
  To: Sam Hocevar; +Cc: Git List
In-Reply-To: <20090308234141.GJ12880@zoy.org>


On Mar 8, 2009, at 7:41 PM, Sam Hocevar wrote:

> On Sun, Mar 08, 2009, Brian Gernhardt wrote:
>
>>> 			printf( "%d %d %d",
>>> 				  match.rm_so, match.rm_eo,
>>> 				  match.rm_eo - match.rm_so );
>>
>> .gitignore:0 0 3\033[31m\033[1m(nugit
>> .mailmap:23 0 26(null)\033[31m\033[1m(nugit-shortlog to fix a few
>> botched name translations-shortlog to fix a few botched name
>> translations
>>
>> And now I'm baffled.  Apparently my computer thinks 0 - 0 == 3 and  
>> 0 -
>> 23 == 26.
>
>   rm_so and rm_eo are ints on Linux but off_t's on Darwin, hence
> probably int64_t's here. You should cast the arguments.


And that explains the warnings about the parameters to printf not  
being integers.  I was looking at compat/regex/regex.h and was confused.

Adding a cast to int on all of the format specifiers solves my  
problems.  Thank you.

~~ Brian

^ permalink raw reply

* [PATCH 0/2] Move push logic to transport.c
From: Daniel Barkalow @ 2009-03-09  1:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Currently, send_pack() does the work of figuring out what the refspecs 
mean before pushing (with the help of functions from remote.c), updating 
local state afterwards, and reporting what it did.

Transports other than the native protocol use the same logic for the first 
of these, and don't do the other two at all. In order to be able to share 
more code and make it easier to be consist, move the logic to 
transport_push. This is also more similar to how fetch is organized, 
although fetch puts most of the logic in builtin-fetch, which isn't really 
feasible until all of the transports are converted to the new functions, 
and may be less convenient anyway.

This series only goes as far as adding a new "push_refs" method to struct 
transport and using it for the git native transport. It doesn't convert 
http-push or the rsync transports, largely because I don't have test 
setups for rsync or webdav to make sure that they're still working.

It also leaves copies of matching, updating, and reporting code in 
builtin-send-pack, but these are only used for "git send-pack", and are 
not used in the code paths for "git push". Hopefully, we can deprecate the 
protocol-specific command at some point in favor of just using "git push".

This is on top of next for Jay's patch to make get_local_heads() common.

Daniel Barkalow (2):
  Use a common function to get the pretty name of refs
  Move push matching and reporting logic into transport.c

 builtin-fetch.c     |    6 +-
 builtin-send-pack.c |  153 +++++++++++++--------------
 refs.c              |   10 ++
 refs.h              |    2 +
 send-pack.h         |    6 +-
 transport.c         |  283 +++++++++++++++++++++++++++++++++++++++++++++++----
 transport.h         |    3 +-
 7 files changed, 356 insertions(+), 107 deletions(-)

^ permalink raw reply

* [PATCH 1/2] Use a common function to get the pretty name of refs
From: Daniel Barkalow @ 2009-03-09  1:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

The result should be consistent between fetch and push, so we ought to
use the same code in both cases, even though it's short.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
 builtin-fetch.c     |    6 +-----
 builtin-send-pack.c |   10 ----------
 refs.c              |   10 ++++++++++
 refs.h              |    2 ++
 4 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/builtin-fetch.c b/builtin-fetch.c
index 1e4a3d9..f3bdeda 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -197,11 +197,7 @@ static int update_local_ref(struct ref *ref,
 	struct commit *current = NULL, *updated;
 	enum object_type type;
 	struct branch *current_branch = branch_get(NULL);
-	const char *pretty_ref = ref->name + (
-		!prefixcmp(ref->name, "refs/heads/") ? 11 :
-		!prefixcmp(ref->name, "refs/tags/") ? 10 :
-		!prefixcmp(ref->name, "refs/remotes/") ? 13 :
-		0);
+	const char *pretty_ref = prettify_ref(ref);
 
 	*display = 0;
 	type = sha1_object_info(ref->new_sha1, NULL);
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 9072905..43b89ec 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -172,16 +172,6 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
 	}
 }
 
-static const char *prettify_ref(const struct ref *ref)
-{
-	const char *name = ref->name;
-	return name + (
-		!prefixcmp(name, "refs/heads/") ? 11 :
-		!prefixcmp(name, "refs/tags/") ? 10 :
-		!prefixcmp(name, "refs/remotes/") ? 13 :
-		0);
-}
-
 #define SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
 
 static void print_ref_status(char flag, const char *summary, struct ref *to, struct ref *from, const char *msg)
diff --git a/refs.c b/refs.c
index b2a37e1..8f968b5 100644
--- a/refs.c
+++ b/refs.c
@@ -736,6 +736,16 @@ int check_ref_format(const char *ref)
 	}
 }
 
+const char *prettify_ref(const struct ref *ref)
+{
+	const char *name = ref->name;
+	return name + (
+		!prefixcmp(name, "refs/heads/") ? 11 :
+		!prefixcmp(name, "refs/tags/") ? 10 :
+		!prefixcmp(name, "refs/remotes/") ? 13 :
+		0);
+}
+
 const char *ref_rev_parse_rules[] = {
 	"%.*s",
 	"refs/%.*s",
diff --git a/refs.h b/refs.h
index 29bdcec..68c2d16 100644
--- a/refs.h
+++ b/refs.h
@@ -79,6 +79,8 @@ extern int for_each_reflog(each_ref_fn, void *);
 #define CHECK_REF_FORMAT_WILDCARD (-3)
 extern int check_ref_format(const char *target);
 
+extern const char *prettify_ref(const struct ref *ref);
+
 /** rename ref, return 0 on success **/
 extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);
 
-- 
1.6.1.286.gd33a4.dirty

^ permalink raw reply related

* [PATCH 2/2] Move push matching and reporting logic into transport.c
From: Daniel Barkalow @ 2009-03-09  1:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

For native-protocol pushes (and other protocols as they are converted
to the new method), this moves the refspec match, tracking update, and
report message out of send-pack() and into transport_push(), where it
can be shared completely with other protocols. This also makes fetch
and push more similar in terms of what code is in what file.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
 builtin-send-pack.c |  143 +++++++++++++-------------
 send-pack.h         |    6 +-
 transport.c         |  283 +++++++++++++++++++++++++++++++++++++++++++++++----
 transport.h         |    3 +-
 4 files changed, 343 insertions(+), 92 deletions(-)

diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 43b89ec..91c3651 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -11,7 +11,6 @@ static const char send_pack_usage[] =
 "  --all and explicit <ref> specification are mutually exclusive.";
 
 static struct send_pack_args args = {
-	/* .receivepack = */ "git-receive-pack",
 };
 
 static int feed_object(const unsigned char *sha1, int fd, int negative)
@@ -31,7 +30,7 @@ static int feed_object(const unsigned char *sha1, int fd, int negative)
 /*
  * Make a pack stream and spit it out into file descriptor fd
  */
-static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *extra)
+static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *extra, struct send_pack_args *args)
 {
 	/*
 	 * The child becomes pack-objects --revs; we feed
@@ -49,7 +48,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
 	struct child_process po;
 	int i;
 
-	if (args.use_thin_pack)
+	if (args->use_thin_pack)
 		argv[4] = "--thin";
 	memset(&po, 0, sizeof(po));
 	po.argv = argv;
@@ -83,8 +82,6 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
 	return 0;
 }
 
-static struct ref *remote_refs, **remote_tail;
-
 static int receive_status(int in, struct ref *refs)
 {
 	struct ref *hint;
@@ -300,27 +297,19 @@ static int refs_pushed(struct ref *ref)
 	return 0;
 }
 
-static int do_send_pack(int in, int out, struct remote *remote, const char *dest, int nr_refspec, const char **refspec)
+int send_pack(struct send_pack_args *args,
+	      int fd[], struct child_process *conn,
+	      struct ref *remote_refs,
+	      struct extra_have_objects *extra_have)
 {
-	struct ref *ref, *local_refs;
+	int in = fd[0];
+	int out = fd[1];
+	struct ref *ref;
 	int new_refs;
 	int ask_for_status_report = 0;
 	int allow_deleting_refs = 0;
 	int expect_status_report = 0;
-	int flags = MATCH_REFS_NONE;
 	int ret;
-	struct extra_have_objects extra_have;
-
-	memset(&extra_have, 0, sizeof(extra_have));
-	if (args.send_all)
-		flags |= MATCH_REFS_ALL;
-	if (args.send_mirror)
-		flags |= MATCH_REFS_MIRROR;
-
-	/* No funny business with the matcher */
-	remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL,
-				       &extra_have);
-	local_refs = get_local_heads();
 
 	/* Does the other end support the reporting? */
 	if (server_supports("report-status"))
@@ -328,19 +317,9 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 	if (server_supports("delete-refs"))
 		allow_deleting_refs = 1;
 
-	/* match them up */
-	if (!remote_tail)
-		remote_tail = &remote_refs;
-	if (match_refs(local_refs, remote_refs, &remote_tail,
-		       nr_refspec, refspec, flags)) {
-		close(out);
-		return -1;
-	}
-
 	if (!remote_refs) {
 		fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
 			"Perhaps you should specify a branch such as 'master'.\n");
-		close(out);
 		return 0;
 	}
 
@@ -352,7 +331,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 
 		if (ref->peer_ref)
 			hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
-		else if (!args.send_mirror)
+		else if (!args->send_mirror)
 			continue;
 
 		ref->deletion = is_null_sha1(ref->new_sha1);
@@ -391,7 +370,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 		    (!has_sha1_file(ref->old_sha1)
 		      || !ref_newer(ref->new_sha1, ref->old_sha1));
 
-		if (ref->nonfastforward && !ref->force && !args.force_update) {
+		if (ref->nonfastforward && !ref->force && !args->force_update) {
 			ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
 			continue;
 		}
@@ -399,7 +378,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 		if (!ref->deletion)
 			new_refs++;
 
-		if (!args.dry_run) {
+		if (!args->dry_run) {
 			char *old_hex = sha1_to_hex(ref->old_sha1);
 			char *new_hex = sha1_to_hex(ref->new_sha1);
 
@@ -420,27 +399,19 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
 	}
 
 	packet_flush(out);
-	if (new_refs && !args.dry_run) {
-		if (pack_objects(out, remote_refs, &extra_have) < 0)
+	if (new_refs && !args->dry_run) {
+		if (pack_objects(out, remote_refs, extra_have, args) < 0) {
+			for (ref = remote_refs; ref; ref = ref->next)
+				ref->status = REF_STATUS_NONE;
 			return -1;
+		}
 	}
-	else
-		close(out);
 
 	if (expect_status_report)
 		ret = receive_status(in, remote_refs);
 	else
 		ret = 0;
 
-	print_push_status(dest, remote_refs);
-
-	if (!args.dry_run && remote) {
-		for (ref = remote_refs; ref; ref = ref->next)
-			update_tracking_ref(remote, ref);
-	}
-
-	if (!refs_pushed(remote_refs))
-		fprintf(stderr, "Everything up-to-date\n");
 	if (ret < 0)
 		return ret;
 	for (ref = remote_refs; ref; ref = ref->next) {
@@ -489,11 +460,19 @@ static void verify_remote_names(int nr_heads, const char **heads)
 
 int cmd_send_pack(int argc, const char **argv, const char *prefix)
 {
-	int i, nr_heads = 0;
-	const char **heads = NULL;
+	int i, nr_refspecs = 0;
+	const char **refspecs = NULL;
 	const char *remote_name = NULL;
 	struct remote *remote = NULL;
 	const char *dest = NULL;
+	int fd[2];
+	struct child_process *conn;
+	struct extra_have_objects extra_have;
+	struct ref *remote_refs, **remote_tail, *local_refs;
+	int ret;
+	int send_all = 0;
+	const char *receivepack = "git-receive-pack";
+	int flags;
 
 	argv++;
 	for (i = 1; i < argc; i++, argv++) {
@@ -501,11 +480,11 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 
 		if (*arg == '-') {
 			if (!prefixcmp(arg, "--receive-pack=")) {
-				args.receivepack = arg + 15;
+				receivepack = arg + 15;
 				continue;
 			}
 			if (!prefixcmp(arg, "--exec=")) {
-				args.receivepack = arg + 7;
+				receivepack = arg + 7;
 				continue;
 			}
 			if (!prefixcmp(arg, "--remote=")) {
@@ -513,7 +492,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 				continue;
 			}
 			if (!strcmp(arg, "--all")) {
-				args.send_all = 1;
+				send_all = 1;
 				continue;
 			}
 			if (!strcmp(arg, "--dry-run")) {
@@ -542,8 +521,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 			dest = arg;
 			continue;
 		}
-		heads = (const char **) argv;
-		nr_heads = argc - i;
+		refspecs = (const char **) argv;
+		nr_refspecs = argc - i;
 		break;
 	}
 	if (!dest)
@@ -552,8 +531,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 	 * --all and --mirror are incompatible; neither makes sense
 	 * with any refspecs.
 	 */
-	if ((heads && (args.send_all || args.send_mirror)) ||
-					(args.send_all && args.send_mirror))
+	if ((refspecs && (send_all || args.send_mirror)) ||
+	    (send_all && args.send_mirror))
 		usage(send_pack_usage);
 
 	if (remote_name) {
@@ -564,24 +543,50 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	return send_pack(&args, dest, remote, nr_heads, heads);
-}
+	conn = git_connect(fd, dest, receivepack, args.verbose ? CONNECT_VERBOSE : 0);
 
-int send_pack(struct send_pack_args *my_args,
-	      const char *dest, struct remote *remote,
-	      int nr_heads, const char **heads)
-{
-	int fd[2], ret;
-	struct child_process *conn;
+	memset(&extra_have, 0, sizeof(extra_have));
+
+	get_remote_heads(fd[0], &remote_refs, 0, NULL, REF_NORMAL,
+			 &extra_have);
+
+	verify_remote_names(nr_refspecs, refspecs);
+
+	local_refs = get_local_heads();
 
-	memcpy(&args, my_args, sizeof(args));
+	flags = MATCH_REFS_NONE;
+
+	if (send_all)
+		flags |= MATCH_REFS_ALL;
+	if (args.send_mirror)
+		flags |= MATCH_REFS_MIRROR;
+
+	/* match them up */
+	remote_tail = &remote_refs;
+	while (*remote_tail)
+		remote_tail = &((*remote_tail)->next);
+	if (match_refs(local_refs, remote_refs, &remote_tail,
+		       nr_refspecs, refspecs, flags)) {
+		return -1;
+	}
 
-	verify_remote_names(nr_heads, heads);
+	ret = send_pack(&args, fd, conn, remote_refs, &extra_have);
 
-	conn = git_connect(fd, dest, args.receivepack, args.verbose ? CONNECT_VERBOSE : 0);
-	ret = do_send_pack(fd[0], fd[1], remote, dest, nr_heads, heads);
+	close(fd[1]);
 	close(fd[0]);
-	/* do_send_pack always closes fd[1] */
+
 	ret |= finish_connect(conn);
-	return !!ret;
+
+	print_push_status(dest, remote_refs);
+
+	if (!args.dry_run && remote) {
+		struct ref *ref;
+		for (ref = remote_refs; ref; ref = ref->next)
+			update_tracking_ref(remote, ref);
+	}
+
+	if (!ret && !refs_pushed(remote_refs))
+		fprintf(stderr, "Everything up-to-date\n");
+
+	return ret;
 }
diff --git a/send-pack.h b/send-pack.h
index 8ff1dc3..83d76c7 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -2,9 +2,7 @@
 #define SEND_PACK_H
 
 struct send_pack_args {
-	const char *receivepack;
 	unsigned verbose:1,
-		send_all:1,
 		send_mirror:1,
 		force_update:1,
 		use_thin_pack:1,
@@ -12,7 +10,7 @@ struct send_pack_args {
 };
 
 int send_pack(struct send_pack_args *args,
-	      const char *dest, struct remote *remote,
-	      int nr_heads, const char **heads);
+	      int fd[], struct child_process *conn,
+	      struct ref *remote_refs, struct extra_have_objects *extra_have);
 
 #endif
diff --git a/transport.c b/transport.c
index 9ad4a16..73bb9b5 100644
--- a/transport.c
+++ b/transport.c
@@ -138,7 +138,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
 	}
 }
 
-static struct ref *get_refs_via_rsync(struct transport *transport)
+static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
 {
 	struct strbuf buf = STRBUF_INIT, temp_dir = STRBUF_INIT;
 	struct ref dummy, *tail = &dummy;
@@ -146,6 +146,9 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
 	const char *args[5];
 	int temp_dir_len;
 
+	if (for_push)
+		return NULL;
+
 	/* copy the refs to the temporary directory */
 
 	strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
@@ -422,7 +425,7 @@ static int curl_transport_push(struct transport *transport, int refspec_nr, cons
 	return !!err;
 }
 
-static struct ref *get_refs_via_curl(struct transport *transport)
+static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
 {
 	struct strbuf buffer = STRBUF_INIT;
 	char *data, *start, *mid;
@@ -439,6 +442,9 @@ static struct ref *get_refs_via_curl(struct transport *transport)
 
 	struct walker *walker;
 
+	if (for_push)
+		return NULL;
+
 	if (!transport->data)
 		transport->data = get_http_walker(transport->url,
 						transport->remote);
@@ -525,12 +531,15 @@ struct bundle_transport_data {
 	struct bundle_header header;
 };
 
-static struct ref *get_refs_from_bundle(struct transport *transport)
+static struct ref *get_refs_from_bundle(struct transport *transport, int for_push)
 {
 	struct bundle_transport_data *data = transport->data;
 	struct ref *result = NULL;
 	int i;
 
+	if (for_push)
+		return NULL;
+
 	if (data->fd > 0)
 		close(data->fd);
 	data->fd = read_bundle_header(transport->url, &data->header);
@@ -571,6 +580,7 @@ struct git_transport_data {
 	int fd[2];
 	const char *uploadpack;
 	const char *receivepack;
+	struct extra_have_objects extra_have;
 };
 
 static int set_git_option(struct transport *connection,
@@ -602,20 +612,23 @@ static int set_git_option(struct transport *connection,
 	return 1;
 }
 
-static int connect_setup(struct transport *transport)
+static int connect_setup(struct transport *transport, int for_push, int verbose)
 {
 	struct git_transport_data *data = transport->data;
-	data->conn = git_connect(data->fd, transport->url, data->uploadpack, 0);
+	data->conn = git_connect(data->fd, transport->url,
+				 for_push ? data->receivepack : data->uploadpack,
+				 verbose ? CONNECT_VERBOSE : 0);
 	return 0;
 }
 
-static struct ref *get_refs_via_connect(struct transport *transport)
+static struct ref *get_refs_via_connect(struct transport *transport, int for_push)
 {
 	struct git_transport_data *data = transport->data;
 	struct ref *refs;
 
-	connect_setup(transport);
-	get_remote_heads(data->fd[0], &refs, 0, NULL, 0, NULL);
+	connect_setup(transport, for_push, 0);
+	get_remote_heads(data->fd[0], &refs, 0, NULL,
+			 for_push ? REF_NORMAL : 0, &data->extra_have);
 
 	return refs;
 }
@@ -647,7 +660,7 @@ static int fetch_refs_via_pack(struct transport *transport,
 		origh[i] = heads[i] = xstrdup(to_fetch[i]->name);
 
 	if (!data->conn) {
-		connect_setup(transport);
+		connect_setup(transport, 0, 0);
 		get_remote_heads(data->fd[0], &refs_tmp, 0, NULL, 0, NULL);
 	}
 
@@ -670,20 +683,216 @@ static int fetch_refs_via_pack(struct transport *transport,
 	return (refs ? 0 : -1);
 }
 
-static int git_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags)
+static int refs_pushed(struct ref *ref)
+{
+	for (; ref; ref = ref->next) {
+		switch(ref->status) {
+		case REF_STATUS_NONE:
+		case REF_STATUS_UPTODATE:
+			break;
+		default:
+			return 1;
+		}
+	}
+	return 0;
+}
+
+static void update_tracking_ref(struct remote *remote, struct ref *ref, int verbose)
+{
+	struct refspec rs;
+
+	if (ref->status != REF_STATUS_OK && ref->status != REF_STATUS_UPTODATE)
+		return;
+
+	rs.src = ref->name;
+	rs.dst = NULL;
+
+	if (!remote_find_tracking(remote, &rs)) {
+		if (verbose)
+			fprintf(stderr, "updating local tracking ref '%s'\n", rs.dst);
+		if (ref->deletion) {
+			delete_ref(rs.dst, NULL, 0);
+		} else
+			update_ref("update by push", rs.dst,
+					ref->new_sha1, NULL, 0, 0);
+		free(rs.dst);
+	}
+}
+
+#define SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
+
+static void print_ref_status(char flag, const char *summary, struct ref *to, struct ref *from, const char *msg)
+{
+	fprintf(stderr, " %c %-*s ", flag, SUMMARY_WIDTH, summary);
+	if (from)
+		fprintf(stderr, "%s -> %s", prettify_ref(from), prettify_ref(to));
+	else
+		fputs(prettify_ref(to), stderr);
+	if (msg) {
+		fputs(" (", stderr);
+		fputs(msg, stderr);
+		fputc(')', stderr);
+	}
+	fputc('\n', stderr);
+}
+
+static const char *status_abbrev(unsigned char sha1[20])
+{
+	return find_unique_abbrev(sha1, DEFAULT_ABBREV);
+}
+
+static void print_ok_ref_status(struct ref *ref)
+{
+	if (ref->deletion)
+		print_ref_status('-', "[deleted]", ref, NULL, NULL);
+	else if (is_null_sha1(ref->old_sha1))
+		print_ref_status('*',
+			(!prefixcmp(ref->name, "refs/tags/") ? "[new tag]" :
+			  "[new branch]"),
+			ref, ref->peer_ref, NULL);
+	else {
+		char quickref[84];
+		char type;
+		const char *msg;
+
+		strcpy(quickref, status_abbrev(ref->old_sha1));
+		if (ref->nonfastforward) {
+			strcat(quickref, "...");
+			type = '+';
+			msg = "forced update";
+		} else {
+			strcat(quickref, "..");
+			type = ' ';
+			msg = NULL;
+		}
+		strcat(quickref, status_abbrev(ref->new_sha1));
+
+		print_ref_status(type, quickref, ref, ref->peer_ref, msg);
+	}
+}
+
+static int print_one_push_status(struct ref *ref, const char *dest, int count)
+{
+	if (!count)
+		fprintf(stderr, "To %s\n", dest);
+
+	switch(ref->status) {
+	case REF_STATUS_NONE:
+		print_ref_status('X', "[no match]", ref, NULL, NULL);
+		break;
+	case REF_STATUS_REJECT_NODELETE:
+		print_ref_status('!', "[rejected]", ref, NULL,
+				"remote does not support deleting refs");
+		break;
+	case REF_STATUS_UPTODATE:
+		print_ref_status('=', "[up to date]", ref,
+				ref->peer_ref, NULL);
+		break;
+	case REF_STATUS_REJECT_NONFASTFORWARD:
+		print_ref_status('!', "[rejected]", ref, ref->peer_ref,
+				"non-fast forward");
+		break;
+	case REF_STATUS_REMOTE_REJECT:
+		print_ref_status('!', "[remote rejected]", ref,
+				ref->deletion ? NULL : ref->peer_ref,
+				ref->remote_status);
+		break;
+	case REF_STATUS_EXPECTING_REPORT:
+		print_ref_status('!', "[remote failure]", ref,
+				ref->deletion ? NULL : ref->peer_ref,
+				"remote failed to report status");
+		break;
+	case REF_STATUS_OK:
+		print_ok_ref_status(ref);
+		break;
+	}
+
+	return 1;
+}
+
+static void print_push_status(const char *dest, struct ref *refs, int verbose)
+{
+	struct ref *ref;
+	int n = 0;
+
+	if (verbose) {
+		for (ref = refs; ref; ref = ref->next)
+			if (ref->status == REF_STATUS_UPTODATE)
+				n += print_one_push_status(ref, dest, n);
+	}
+
+	for (ref = refs; ref; ref = ref->next)
+		if (ref->status == REF_STATUS_OK)
+			n += print_one_push_status(ref, dest, n);
+
+	for (ref = refs; ref; ref = ref->next) {
+		if (ref->status != REF_STATUS_NONE &&
+		    ref->status != REF_STATUS_UPTODATE &&
+		    ref->status != REF_STATUS_OK)
+			n += print_one_push_status(ref, dest, n);
+	}
+}
+
+static void verify_remote_names(int nr_heads, const char **heads)
+{
+	int i;
+
+	for (i = 0; i < nr_heads; i++) {
+		const char *local = heads[i];
+		const char *remote = strrchr(heads[i], ':');
+
+		if (*local == '+')
+			local++;
+
+		/* A matching refspec is okay.  */
+		if (remote == local && remote[1] == '\0')
+			continue;
+
+		remote = remote ? (remote + 1) : local;
+		switch (check_ref_format(remote)) {
+		case 0: /* ok */
+		case CHECK_REF_FORMAT_ONELEVEL:
+			/* ok but a single level -- that is fine for
+			 * a match pattern.
+			 */
+		case CHECK_REF_FORMAT_WILDCARD:
+			/* ok but ends with a pattern-match character */
+			continue;
+		}
+		die("remote part of refspec is not a valid name in %s",
+		    heads[i]);
+	}
+}
+
+static int git_transport_push(struct transport *transport, struct ref *remote_refs, int flags)
 {
 	struct git_transport_data *data = transport->data;
 	struct send_pack_args args;
+	int ret;
+
+	if (!data->conn) {
+		struct ref *tmp_refs;
+		connect_setup(transport, 1, 0);
+
+		get_remote_heads(data->fd[0], &tmp_refs, 0, NULL, REF_NORMAL,
+				 NULL);
+	}
 
-	args.receivepack = data->receivepack;
-	args.send_all = !!(flags & TRANSPORT_PUSH_ALL);
 	args.send_mirror = !!(flags & TRANSPORT_PUSH_MIRROR);
 	args.force_update = !!(flags & TRANSPORT_PUSH_FORCE);
 	args.use_thin_pack = data->thin;
 	args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);
 	args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
 
-	return send_pack(&args, transport->url, transport->remote, refspec_nr, refspec);
+	ret = send_pack(&args, data->fd, data->conn, remote_refs,
+			&data->extra_have);
+
+	close(data->fd[1]);
+	close(data->fd[0]);
+	ret |= finish_connect(data->conn);
+	data->conn = NULL;
+
+	return ret;
 }
 
 static int disconnect_git(struct transport *transport)
@@ -753,7 +962,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
 		ret->set_option = set_git_option;
 		ret->get_refs_list = get_refs_via_connect;
 		ret->fetch = fetch_refs_via_pack;
-		ret->push = git_transport_push;
+		ret->push_refs = git_transport_push;
 		ret->disconnect = disconnect_git;
 
 		data->thin = 1;
@@ -780,15 +989,53 @@ int transport_set_option(struct transport *transport,
 int transport_push(struct transport *transport,
 		   int refspec_nr, const char **refspec, int flags)
 {
-	if (!transport->push)
-		return 1;
-	return transport->push(transport, refspec_nr, refspec, flags);
+	verify_remote_names(refspec_nr, refspec);
+
+	if (transport->push)
+		return transport->push(transport, refspec_nr, refspec, flags);
+	if (transport->push_refs) {
+		struct ref *remote_refs =
+			transport->get_refs_list(transport, 1);
+		struct ref **remote_tail;
+		struct ref *local_refs = get_local_heads();
+		int match_flags = MATCH_REFS_NONE;
+		int verbose = flags & TRANSPORT_PUSH_VERBOSE;
+		int ret;
+
+		if (flags & TRANSPORT_PUSH_ALL)
+			match_flags |= MATCH_REFS_ALL;
+		if (flags & TRANSPORT_PUSH_MIRROR)
+			match_flags |= MATCH_REFS_MIRROR;
+
+		remote_tail = &remote_refs;
+		while (*remote_tail)
+			remote_tail = &((*remote_tail)->next);
+		if (match_refs(local_refs, remote_refs, &remote_tail,
+			       refspec_nr, refspec, match_flags)) {
+			return -1;
+		}
+
+		ret = transport->push_refs(transport, remote_refs, flags);
+
+		print_push_status(transport->url, remote_refs, verbose);
+
+		if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
+			struct ref *ref;
+			for (ref = remote_refs; ref; ref = ref->next)
+				update_tracking_ref(transport->remote, ref, verbose);
+		}
+
+		if (!ret && !refs_pushed(remote_refs))
+			fprintf(stderr, "Everything up-to-date\n");
+		return ret;
+	}
+	return 1;
 }
 
 const struct ref *transport_get_remote_refs(struct transport *transport)
 {
 	if (!transport->remote_refs)
-		transport->remote_refs = transport->get_refs_list(transport);
+		transport->remote_refs = transport->get_refs_list(transport, 0);
 	return transport->remote_refs;
 }
 
diff --git a/transport.h b/transport.h
index 6bbc1a8..b1c2252 100644
--- a/transport.h
+++ b/transport.h
@@ -18,8 +18,9 @@ struct transport {
 	int (*set_option)(struct transport *connection, const char *name,
 			  const char *value);
 
-	struct ref *(*get_refs_list)(struct transport *transport);
+	struct ref *(*get_refs_list)(struct transport *transport, int for_push);
 	int (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs);
+	int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
 	int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);
 
 	int (*disconnect)(struct transport *connection);
-- 
1.6.1.286.gd33a4.dirty

^ permalink raw reply related

* Re: git-grep Bus Error
From: Junio C Hamano @ 2009-03-09  1:11 UTC (permalink / raw)
  To: Sam Hocevar; +Cc: Git List, Brian Gernhardt
In-Reply-To: <20090308234141.GJ12880@zoy.org>

Sam Hocevar <sam@zoy.org> writes:

> On Sun, Mar 08, 2009, Brian Gernhardt wrote:
>
>> >			printf( "%d %d %d",
>> >				  match.rm_so, match.rm_eo,
>> >				  match.rm_eo - match.rm_so );
>> 
>> .gitignore:0 0 3\033[31m\033[1m(nugit
>> .mailmap:23 0 26(null)\033[31m\033[1m(nugit-shortlog to fix a few  
>> botched name translations-shortlog to fix a few botched name  
>> translations
>> 
>> And now I'm baffled.  Apparently my computer thinks 0 - 0 == 3 and 0 -  
>> 23 == 26.
>
>    rm_so and rm_eo are ints on Linux but off_t's on Darwin, hence
> probably int64_t's here. You should cast the arguments.

That is a very good point.  In fact, "git grep -n -e 'printf.*%\.\*s'"
reveals that many existing call sites to this form casts the precision
argument explicitly to "int".

Brian, would this patch help?

 grep.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/grep.c b/grep.c
index cace1c8..dcdbd5e 100644
--- a/grep.c
+++ b/grep.c
@@ -490,9 +490,9 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
 		*eol = '\0';
 		while (next_match(opt, bol, eol, ctx, &match, eflags)) {
 			printf("%.*s%s%.*s%s",
-			       match.rm_so, bol,
+			       (int) match.rm_so, bol,
 			       opt->color_match,
-			       match.rm_eo - match.rm_so, bol + match.rm_so,
+			       (int)(match.rm_eo - match.rm_so), bol + match.rm_so,
 			       GIT_COLOR_RESET);
 			bol += match.rm_eo;
 			rest -= match.rm_eo;

^ permalink raw reply related

* [PATCH] grep: make show_line more portable
From: Brian Gernhardt @ 2009-03-09  1:15 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

On OS X the printf specifier "%.0s" outputs the entire string instead
of 0 characters as POSIX states.

In addition, for * width or precision printf expects an integer
argument.  On systems were regoff_t is 64-bit, unexpected results can
occur.

To fix these, use if statements to catch 0 precisions and casts to
convert regoff_t to int.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
---
 grep.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/grep.c b/grep.c
index cace1c8..ec68200 100644
--- a/grep.c
+++ b/grep.c
@@ -489,18 +489,22 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
 
 		*eol = '\0';
 		while (next_match(opt, bol, eol, ctx, &match, eflags)) {
-			printf("%.*s%s%.*s%s",
-			       match.rm_so, bol,
-			       opt->color_match,
-			       match.rm_eo - match.rm_so, bol + match.rm_so,
-			       GIT_COLOR_RESET);
+			if( match.rm_so > 0 )
+				printf( "%.*s", (int) match.rm_so, bol );
+			if( match.rm_eo > match.rm_so )
+				printf("%s%.*s%s",
+					   opt->color_match,
+					  (int) (match.rm_eo - match.rm_so), bol + match.rm_so,
+					   GIT_COLOR_RESET);
 			bol += match.rm_eo;
 			rest -= match.rm_eo;
 			eflags = REG_NOTBOL;
 		}
 		*eol = ch;
 	}
-	printf("%.*s\n", rest, bol);
+	if( rest > 0 )
+		printf("%.*s", rest, bol);
+	printf("\n");
 }
 
 static int grep_buffer_1(struct grep_opt *opt, const char *name,
-- 
1.6.2.222.g01cbd

^ permalink raw reply related

* Re: [GSoC] Google Summer of Code 2009 - new ideas
From: Jakub Narebski @ 2009-03-09  1:18 UTC (permalink / raw)
  To: thestar; +Cc: git
In-Reply-To: <20090309115026.obsvt34miowwcw8w@webmail.fussycoder.id.au>

Please do not trim CC list; at least do not remove git mailing list
from addressees.

On Mon, 9 Mar 2009, thestar@fussycoder.id.au wrote:
> Quoting Jakub Narebski <jnareb@gmail.com>:
> 
> <snip>
> > I was thinking more about caching credentials by git rather than forcing
> > to use single connection.  Additionally you are solving the problem for
> > the HTTP(S) transport; admittedly for SSH there is much better solution
> > of using public/private keys, instead of asking for password.
> 
> What about public/private keys that also have a password?  Isn't that  
> the most recommended way to use ssh?

You use ssh-agent for that (via "ssh-add <private key>"), perhaps with
wrapper around it for example keychain. The "caching" is done by SSH,
no need to duplicate this in git.

-- 
Jakub Narebski
Poland

^ permalink raw reply

* Re: git-grep Bus Error
From: Junio C Hamano @ 2009-03-09  1:18 UTC (permalink / raw)
  To: Brian Gernhardt; +Cc: Git List, Sam Hocevar
In-Reply-To: <7vtz63ijoz.fsf@gitster.siamese.dyndns.org>

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

> Brian, would this patch help?
>
>  grep.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index cace1c8..dcdbd5e 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -490,9 +490,9 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
>  		*eol = '\0';
>  		while (next_match(opt, bol, eol, ctx, &match, eflags)) {
>  			printf("%.*s%s%.*s%s",
> -			       match.rm_so, bol,
> +			       (int) match.rm_so, bol,
>  			       opt->color_match,
> -			       match.rm_eo - match.rm_so, bol + match.rm_so,
> +			       (int)(match.rm_eo - match.rm_so), bol + match.rm_so,
>  			       GIT_COLOR_RESET);
>  			bol += match.rm_eo;
>  			rest -= match.rm_eo;

I looked at all the hits from

    $ git grep -n -e 'printf.*%\.\*s' --and --not -e '(int)'

The above should be the only two places that need fixing.

^ permalink raw reply

* Re: git-grep Bus Error
From: Brian Gernhardt @ 2009-03-09  1:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sam Hocevar, Git List
In-Reply-To: <7vtz63ijoz.fsf@gitster.siamese.dyndns.org>


On Mar 8, 2009, at 9:11 PM, Junio C Hamano wrote:

> Sam Hocevar <sam@zoy.org> writes:
>
>>   rm_so and rm_eo are ints on Linux but off_t's on Darwin, hence
>> probably int64_t's here. You should cast the arguments.
>
> That is a very good point.  In fact, "git grep -n -e 'printf.*%\.\*s'"
> reveals that many existing call sites to this form casts the precision
> argument explicitly to "int".
>
> Brian, would this patch help?

Yes, except that the code also depends on printf("%.*s", 0, str)  
working properly.  I just sent a patch which checks for zero width and  
performs the casts.

~~ Brian

^ permalink raw reply

* [PATCH] grep: cast printf %.*s "precision" argument explicitly to int
From: Junio C Hamano @ 2009-03-09  1:24 UTC (permalink / raw)
  To: Brian Gernhardt; +Cc: Git List, Sam Hocevar
In-Reply-To: <7vtz63ijoz.fsf@gitster.siamese.dyndns.org>

On some systems, regoff_t that is the type of rm_so/rm_eo members are
wider than int; %.*s precision specifier expects an int, so use an explicit
cast.

A breakage reported on Darwin by Brian Gernhardt should be fixed with
this patch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

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

 > Brian, would this patch help?

 A resend with a commit log message.

 grep.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/grep.c b/grep.c
index cace1c8..be99b34 100644
--- a/grep.c
+++ b/grep.c
@@ -490,9 +490,9 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
 		*eol = '\0';
 		while (next_match(opt, bol, eol, ctx, &match, eflags)) {
 			printf("%.*s%s%.*s%s",
-			       match.rm_so, bol,
+			       (int)match.rm_so, bol,
 			       opt->color_match,
-			       match.rm_eo - match.rm_so, bol + match.rm_so,
+			       (int)(match.rm_eo - match.rm_so), bol + match.rm_so,
 			       GIT_COLOR_RESET);
 			bol += match.rm_eo;
 			rest -= match.rm_eo;
-- 
1.6.2.206.g5bda76

^ permalink raw reply related

* Re: [PATCH] grep: make show_line more portable
From: Junio C Hamano @ 2009-03-09  1:35 UTC (permalink / raw)
  To: Brian Gernhardt; +Cc: Git List
In-Reply-To: <1236561326-1231-1-git-send-email-benji@silverinsanity.com>

Brian Gernhardt <benji@silverinsanity.com> writes:

> On OS X the printf specifier "%.0s" outputs the entire string instead
> of 0 characters as POSIX states.
>
> In addition, for * width or precision printf expects an integer
> argument.  On systems were regoff_t is 64-bit, unexpected results can
> occur.

I would prefer to see these two issues solved as separate issues.

Specifically, I'd like to know if the patch from me to you a few message
ago solves the issue.

If you still need a "some implementations of printf is broken with respect
to 0 precision" workaround on top of that patch, we would want to add it
separately, but it may have to cover not just this printf(), as I am not
convinced this is the only place that lets (integer) 0 passed to the
"%.*s" format.  That patch needs to be written after a separate auditing
of output from "git grep -n -e 'printf.*%\.\*s'", which I do not think
happened yet (at least I haven't done that, and I somehow do not think you
have yet either).

^ permalink raw reply

* [ANNOUNCE] TortoiseGit 0.4.2.0 release
From: Frank Li @ 2009-03-09  1:38 UTC (permalink / raw)
  To: tortoisegit-dev, tortoisegit-users, git, tortoisegit-announce

TortoiseGit Shell can not appear at explore context menu because miss
install ATL library at v0.4.1.0.
I am sorry for such critial problem happen.

This release is for quick fix this issue.

Version 0.4.2.0 version(external)
	*Fix Shell menu disappear because ATL library have not installed.
	*Fix Commit Dialog and Log Dialog default column is wrong
	*Fix some dialog can't show after resize and close and open again
	*Fix ProgressDlg Sometime thread is dead blocked.

Version 0.4.1.0 version(external)
        *Fixed x64 build of TortoiseProc crashed due to received
unexpected messages
	*Fix tag to head when *force* check box checked
	*Add Git document to help

Version 0.4.0.0 version(internal)
Features:
	*Full Overlay Icon Support.
	 Show "Conflict, ignore file, untracked file, modified, Add, staged"
icon according to file status.

	*Rebase Support.
         Support "Pick" "Sqaush" "Edit" and "Skip" commit when rebase branch.
         Support abort.
 	
	*Combine Multi-commits to one commit.
	 Combine continous commits to one commit. The limition is the only
single line(no merge point) above combined commit.

	*Cherry Pick multi commits.
	 User can use multi commits at log dialog and then choose cherry pick
these. Cherry Pick dialog guide you finish whole work.
         Support "Pick" "Squash" "Edit" and "Skip" commits.
	
	*First x64 version.

	*Support version "browse" at switch, export, new branch/tag and merge dialogs.

	*Add context menu item "Revert" at Commit dialog File List.

	*Show bold font for HEAD at log dialog.
	
	*Add "Whole Project" checkbox at commit dialog

	*First Version Help Document.

Bug Fix:
	*Fix issue 36, Push not working if no remote branch is specified
	*Default UnCheck untrack file at commit dialog
	*Issue 40:  Commit from subfolder shows unversioned files in parent
	*Fix diff problem when filenames have embedded spaces
	*Fix Issue 24,45, Commit results not in window with scroll bars
	*Fix for win2k context menu icons
	*Fix Issue 46, The about window title still displays TortoiseSVN
	*Fix Issue 37, When the file name contains Chinese char, Diff doesn't work.
	*Fix Issue 28, "Add" status icon overlay is not correct.

^ permalink raw reply

* Generalised bisection
From: Ealdwulf Wuffinga @ 2009-03-09  1:40 UTC (permalink / raw)
  To: Git List; +Cc: John Tapsell, Ingo Molnar, Christian Couder

[whoops, mail server does not like html. trying again...]

Hi,

I have developed a generalised bisection algorithm, for the case where
a bug is intermittent. The code may be found at
git://github.com/Ealdwulf/bbchop.git. It should be considered
experimental.

This should cover the use cases requested by Ingo
(http://article.gmane.org/gmane.comp.version-control.git/108565) and
John  (http://article.gmane.org/gmane.comp.version-control.git/112280),
although it does not work in the same way as your proposed solutions -
it is intended to be more general, working when the bug is not
almost-deterministic. It is based on Bayesian Search Theory
(http://en.wikipedia.org/wiki/Bayesian_search_theory, although that
description is a bit simplistic) which is usually used to find
submarines, or people lost on mountains.

To try it out, you need python and mpmath (from
http://code.google.com/p/mpmath/ or your distribution).
Once your have obtained the source, you can immediately run BBChop/source/bbchop
which is the main driver program.

It is not currently integrated into git, although doing so should only
involve minor scriptery.

The simplest way to try it out to is run it in manual mode:


>   bbchop -l 10 -c 0.9

This means, search in a linear history of 10 revisions, numbered 0 to
9, until bbchop thinks it has found
the faulty location with probability at least 0.9. It will start
asking questions:

] Most likely location is 0 (probability 0.100000).
] Please test at location 3.
] Target detected at 3? Y/N/S(kip)

Eventually the search will terminate and BBChop will print out its
conclusion, with evidence, eg:

] Search complete.  Most likely location is 3 (probability 0.919614).
] Number of tests at 3: 3 of which 1 detected
] Number of tests at parents of 3:
]         At 2, 5 of which 0 detected

More information canbe found in the readme file.

Feel free to reply with any comments, questions, etc. If anyone tries
it out on a real bug, please let me know how it goes.

regards,

Ealdwulf

^ permalink raw reply

* Re: git-grep Bus Error
From: Brian Gernhardt @ 2009-03-09  1:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Sam Hocevar, Git List
In-Reply-To: <7vtz63ijoz.fsf@gitster.siamese.dyndns.org>


On Mar 8, 2009, at 9:11 PM, Junio C Hamano wrote:

> Brian, would this patch help?
>
> grep.c |    4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/grep.c b/grep.c
> index cace1c8..dcdbd5e 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -490,9 +490,9 @@ static void show_line(struct grep_opt *opt, char  
> *bol, char *eol,
> 		*eol = '\0';
> 		while (next_match(opt, bol, eol, ctx, &match, eflags)) {
> 			printf("%.*s%s%.*s%s",
> -			       match.rm_so, bol,
> +			       (int) match.rm_so, bol,
> 			       opt->color_match,
> -			       match.rm_eo - match.rm_so, bol + match.rm_so,
> +			       (int)(match.rm_eo - match.rm_so), bol + match.rm_so,
> 			       GIT_COLOR_RESET);
> 			bol += match.rm_eo;
> 			rest -= match.rm_eo;

Apparently so.  Despite the fact that match.rm_so is 0 at times,  
"%.*s" works properly so the other half of the patch isn't needed.  Odd.

~~ B

^ 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