Git development
 help / color / mirror / Atom feed
* Re: [PATCH] Allow selection of different cleanup modes for commit messages
From: Junio C Hamano @ 2007-12-21 21:43 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Linus Torvalds, git
In-Reply-To: <20071221173521.GA3494@steel.home>

Alex Riesen <raa.lkml@gmail.com> writes:

> The patch is on top of my previos patches. Junio, if you wish, I can
> squash and resend.

That would be a sane thing to do.

^ permalink raw reply

* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
From: Gustaf Hendeby @ 2007-12-21 21:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: luciano, git

Sorry Junio for the double, but I didn't mean to cut the CCs on this one.

On 2007-12-21 18:02, Junio C Hamano wrote:
> Gustaf Hendeby <hendeby@isy.liu.se> writes:
> 
>> Junio, even if this is technically not a bug fix, it would be nice to
>> get this fix into the 1.5.4 so that the usage of $EDITOR becomes more
>> consistent throughout git.
> 
> I can buy that, but at least a single line comment in front of that
> system() explaining why this is safe to do so would be beneficial.  I
> suspect that somebody would propose moving $compse_filename inside
> $GIT_DIR, now people realized $compose_filename is currently "./.msg.$$",
> and $GIT_DIR could be anything.  Quotemeta would probably be better as the
> code you are touching won't be affected by a future change to the value of
> that constant defined far away in the source.

Moving that file makes sense, I'll have a look at that, and do that as
well when I fix this patch.  After a first look at it though, I was
surprised to learn that git send-email actually wont work outside a
repository.  Ok, I can't really see any workflow where git send-email is
called from outside a git repository, but at the same time I don't see
why is should not be possible.  Are there any special reason for this?

Thanks,
	Gustaf

^ permalink raw reply

* Re: [PATCH] git-describe: Add a --match option to limit considered tags.
From: Pierre Habouzit @ 2007-12-21 21:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v7ij87x5u.fsf@gitster.siamese.dyndns.org>

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

On Fri, Dec 21, 2007 at 05:52:29PM +0000, Junio C Hamano wrote:
> Does it work with "describe --contains" as well?

  I think so, the idea here is that I give prio "0" to tags that don't
match, which unless you pass --all (which basically conflicts with
--match <foo> anyways) means that those are not added to the list of
tags that are considered. So I don't see why it would fail with
--contains.

  That's a patch we "need" at work because we have a repository with
different products that share a _lot_ of code (and we're not confident
with submodules yet to switch) and we use git-describe to embed the
exact version of the code that was shipped to a client. Though it sucks
when the last tag shows another product name :)

  I'd also like to use it in some scripts of mine for debian packaging
where I have quite a lot of private tags and only want to describe tags
that match 'debian-sid*'

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

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

^ permalink raw reply

* Re: [PATCH] git-tag: fix -l switch handling regression.
From: Pierre Habouzit @ 2007-12-21 21:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vd4t0atzo.fsf@gitster.siamese.dyndns.org>

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

On Fri, Dec 21, 2007 at 04:32:43PM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
> 
> > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> > ---
> >
> > It seems that you didnt took that patch either, that IMHO gives a better
> > semantics to git tag -l than yours, while keeping backward
> > compatibility.
> 
> I thought this depended on some other changes.  As is, doesn't
> it break the t7004 test?

  Well there are tests that test:

  git tag -n xxx -l ...

  or

  git tag -n "" -l ...

  but I think we agreed those test nothing legitimate, and that the
tests have to be removed. SO yes it hides another patch to cleanse t7004
from the broken tests.
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

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

^ permalink raw reply

* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
From: Junio C Hamano @ 2007-12-21 21:17 UTC (permalink / raw)
  To: Gustaf Hendeby; +Cc: Jeff King, luciano, git, gitster
In-Reply-To: <476C2B2E.1080801@isy.liu.se>

Gustaf Hendeby <hendeby@isy.liu.se> writes:

> On 2007-12-21 20:23, Jeff King wrote:
> 
>> I am fine with using the shell. Though keep in mind that the two
>> solutions will behave differently with
>> 
>>   EDITOR='foo; bar'
>> 
>> That is, system("$editor $message") will actually invoke the shell,
>> whereas system(split(/ /, $editor), $message) will _just_ split on
>> whitespace. We should do whatever is consistent with the rest of the git
>> commands (off the top of my head, I don't know).

Personally, I think EDITOR='foo; bar' is a user shooting his
foot off which we do not care about.

> A quick look at the proposed solution to the similar problem with git
> commit, using code now in git tag, it seems it uses a split like
> solution, though taking " and ' quoting into consideration.

I think the easiest to read and compatible way is:

	system('sh', '-c', '$0 $@', $editor, $filename)

^ permalink raw reply

* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
From: Gustaf Hendeby @ 2007-12-21 21:07 UTC (permalink / raw)
  To: Jeff King; +Cc: luciano, git, gitster
In-Reply-To: <20071221192359.GA10660@coredump.intra.peff.net>

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

On 2007-12-21 20:23, Jeff King wrote:
> On Fri, Dec 21, 2007 at 04:23:11PM +0100, Gustaf Hendeby wrote:
> 
>>> If you are going to do it that way, I suspect you want to quotemeta
>>> $compose_filename.
>> Generally that would be true, but is that really necessary when I know
>> $compose_filename is defined as:
>>
>> my $compose_filename = ".msg.$$";
> 
> I know; it is just easier to see that it is correct with the quotemeta
> (and correct in the face of somebody changing the message later).
Point taken!

> 
>> Or, should I take it that you prefer the version using split?  I didn't
>> really feel good about the possibility of splitting paths with spaces
>> that came with that one though.
> 
> I am fine with using the shell. Though keep in mind that the two
> solutions will behave differently with
> 
>   EDITOR='foo; bar'
> 
> That is, system("$editor $message") will actually invoke the shell,
> whereas system(split(/ /, $editor), $message) will _just_ split on
> whitespace. We should do whatever is consistent with the rest of the git
> commands (off the top of my head, I don't know).

A quick look at the proposed solution to the similar problem with git
commit, using code now in git tag, it seems it uses a split like
solution, though taking " and ' quoting into consideration.  On the top
of my head I can't come up with any other commands using $EDITOR.  I'll
try to find some time the next couple of days to make a reasonable
equivalent solution here.

Thanks,
	Gustaf

[-- Attachment #2: hendeby.vcf --]
[-- Type: text/x-vcard, Size: 378 bytes --]

begin:vcard
fn:Gustaf Hendeby
n:Hendeby;Gustaf
org;quoted-printable:Link=C3=B6ping University;Department of Electrical Engineering
adr;quoted-printable:;;;Link=C3=B6ping;;SE-581 83;Sweden
email;internet:hendeby@isy.liu.se
title:PhD Student
tel;work:+46 (0)13 282226
tel;fax:+46 (0)13 282622
x-mozilla-html:FALSE
url:http://www.control.isy.liu.se/~hendeby
version:2.1
end:vcard


^ permalink raw reply

* Re: cvs -> git tools?
From: Pascal Obry @ 2007-12-21 20:46 UTC (permalink / raw)
  To: Gonzalo Garramuño; +Cc: git
In-Reply-To: <476C1D9E.4060700@advancedsl.com.ar>

Gonzalo,

> I was wondering if there were any tools to keep a mirror repository of
> CVS as a git repository.

I'm no expert on this, maybe cvsimport. I'll let other answer.

http://www.kernel.org/pub/software/scm/git/docs/git-cvsimport.html

> As a second question...
> 
> Are there any good websites that can host a git repository?  Something
> equivalent to sourceforge but for git.

Savannah support Git.

There is also http://repo.or.cz

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595

^ permalink raw reply

* cvs -> git tools?
From: Gonzalo Garramuño @ 2007-12-21 20:10 UTC (permalink / raw)
  To: git


I was wondering if there were any tools to keep a mirror repository of 
CVS as a git repository.

Basically, I would like to mirror a CVS repository (that I don't 
control) as a git "main" branch.  This CVS repository is live and 
expected to remain so.

I would then work on another git branch and would do merges from the 
main branch to mine as I see fit to develop some stuff.

Is there anything like that?   Basically, I'm looking for the equivalent 
of Tailor for Mercurial.

---

As a second question...

Are there any good websites that can host a git repository?  Something 
equivalent to sourceforge but for git.



-- 
Gonzalo Garramuño
ggarra@advancedsl.com.ar

AMD4400 - ASUS48N-E
GeForce7300GT
Xubuntu Gutsy

^ permalink raw reply

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
From: Nguyen Thai Ngoc Duy @ 2007-12-21 20:15 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Johannes Schindelin, Dana How, Linus Torvalds, Alex Riesen,
	Jakub Narebski, git
In-Reply-To: <7vbq8k7x91.fsf@gitster.siamese.dyndns.org>

On Dec 22, 2007 12:50 AM, Junio C Hamano <gitster@pobox.com> wrote:
> "Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:
>
> >> Note that this patch does not handle "../", and neither do I plan to.
> >
> > Junio's rc1 announcement got me to read this. It would be indeed
> > useful as I usually work in deep subdirs. However, from my user
> > perspective, the right approach is to make <treeish>:path always be
> > relative to current directory. If you want absolute path, use
> > <treeish>:/path. More intuitive but it breaks current behavior.
>
> I do not know if you followed the discussion thread, but the
> <treeish>:relative-path has been shown to be broken semantics,
> so even if it may be "intuitive", it is intuitive only to people
> who do not understand the brokenness.  Please read the one that
> Dscho talks about windows drive letter and Linus agrees that is
> a good analogy.
>
> It might be possible to do <commit>:relative and apply that only
> to direct user input, but I do not think it is worth the
> compatibility and complexity hassle.

Argh! I missed that thread. Will shut up now :-X Thanks for the pointer.
-- 
Duy

^ permalink raw reply

* Failed binary detection.
From: David Brown @ 2007-12-21 19:50 UTC (permalink / raw)
  To: Git

A coworker has a branch with some large binary files (video test streams).
Git doesn't seem to be detecting this file is binary, and is causing things
that try to generate diffs to fail.

Specifically, he is unable to rebase his branch, getting an error:

.dotest/patch:3241:LD   := ld
fatal: corrupt patch at line 84682
Patch failed at 0001.

Line 84682 is in the middle of what appear to be the binary contents of the
large media file, with pluses inserted after newline.

Any advice on where to look or possibly how to fix this?

I was able to work around the problem by cherry picking the change instead
of using rebase.  git-format-patch generates a patch that is corrupt in the
same way, which fails with 'git-am'.

Thanks,
Dave

^ permalink raw reply

* Re: [PATCH] Make "git stash" configurable
From: Junio C Hamano @ 2007-12-21 19:48 UTC (permalink / raw)
  To: Steven Grimm
  Cc: しらいしななこ, git
In-Reply-To: <2AB285BD-DA6E-49D1-B664-B1A8B552DD76@midwinter.com>

Steven Grimm <koreth@midwinter.com> writes:

> On Dec 21, 2007, at 2:22 AM, しらいしななこ wrote:
>
>> "git stash" without argument originally created an unnamed
>> stash, but some people felt this can be confusing to new
>> users.  This introduces per-user config variable stash.quick to
>> control this behavior.
>
> This whole thing smells of indecision to me.

If you want to force me to decide, you know what the decision it
would be.  Here are the guiding principles and decisions based
on them.

 (1) A tool should be optimized for people who know what it does
     and how to use it.

     While forbidding "git stash" without argument and forcing
     people who want to have a quick stash to type "git stash
     save" may appear not to be adding too many keystrokes, it
     actually is a regression.  Because "git stash save" without
     arguments make a much less descriptive stash than the
     current quickie "git stash", doing so slows them down by
     forcing them to think of what message to give.

     The decision would be to keep "git stash" quickie stash
     creation.  An alternative decision could be to do nothing
     when "git stash" is given, and make "git stash save" (and
     "git stash create") without the actual message to come up
     with a better default message.

 (2) A tool should not change its behaviour too drastically
     depending on who the user is.

     Otherwise it makes it harder for people with mid-level
     experience to teach less experienced people.  The decision
     would be that "stash.quick=ask" and "stash.quick=no" are
     unacceptable.

 (3) A tool should support safety for a mistaken use by who know
     the tool (even they can make mistakes).

     I listed this mostly because we made "git clean" to violate
     principle (2) above.  Even when you know what that command
     does, it is easy to mean "make clean" and type "git clean"
     by mistake.  And "git clean" is very destructive --- there
     is no "oops, I take it back".  This principle has led us to
     introduce clean.requireforce that defaults to true.

     For "git stash", there is no "make stash" or "xyzzy stash"
     that can easily induce mistyping.  Even if it were typed by
     mistake, there is no such destructive "oops, I cannot take
     it back" problem with "git stash", either.  "git stash
     apply" will get you back to where you were.  The decision
     would again be that "stash.quick=no" is unwanted.

 (4) A tool should support safety for clueless people when it is
     reasonable.

     Even though "I did not know what command foo does, so I
     tried running it and it did something unexpected" is a
     silly excuse to rob quickie "git stash" from people who
     know better, we cannot avoid the fact that there are
     clueless people.  I think checking stash.iknowwhatitdoes to
     detect first-time users, and explaining what it does to
     them, may make sense.  And we can take hints from the patch
     that started this thread how to do this.

     The decision here is that I am open to a change that
     implements the one-time safety instruction.

Note that in the above guiding principles, I used "should" in
RFC2119/BCP0014 sense: there may exist valid reasons in
particular circumstances to ignore a particular item, but the
full implications must be understood and carefully weighed
before choosing a different course.

^ permalink raw reply

* Re: msysgit Git-1.5.4-rc1 available
From: Steffen Prohaska @ 2007-12-21 19:25 UTC (permalink / raw)
  To: Git Mailing List, msysGit
In-Reply-To: <0F6939E0-686C-4526-85D1-447C080230A5-wjoc1KHpMeg@public.gmane.org>



On Dec 21, 2007, at 11:05 AM, Steffen Prohaska wrote:

> for download from
>
> http://msysgit.googlecode.com/files/Git-1.5.4-rc1-preview20071221.exe

I recognized that this installer does not contain
all new binaries.

I uploaded a corrected version

    Git-1.5.4-rc1-preview20071221-corrected.exe

which is available from

    http://code.google.com/p/msysgit/downloads

Sorry for the confusion.

	Steffen

^ permalink raw reply

* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
From: Jeff King @ 2007-12-21 19:23 UTC (permalink / raw)
  To: Gustaf Hendeby; +Cc: luciano, git, gitster
In-Reply-To: <476BDA5F.4070306@isy.liu.se>

On Fri, Dec 21, 2007 at 04:23:11PM +0100, Gustaf Hendeby wrote:

> > If you are going to do it that way, I suspect you want to quotemeta
> > $compose_filename.
> Generally that would be true, but is that really necessary when I know
> $compose_filename is defined as:
> 
> my $compose_filename = ".msg.$$";

I know; it is just easier to see that it is correct with the quotemeta
(and correct in the face of somebody changing the message later).

> Or, should I take it that you prefer the version using split?  I didn't
> really feel good about the possibility of splitting paths with spaces
> that came with that one though.

I am fine with using the shell. Though keep in mind that the two
solutions will behave differently with

  EDITOR='foo; bar'

That is, system("$editor $message") will actually invoke the shell,
whereas system(split(/ /, $editor), $message) will _just_ split on
whitespace. We should do whatever is consistent with the rest of the git
commands (off the top of my head, I don't know).

-Peff

^ permalink raw reply

* Re: [PATCH] git-send-email: Add --suppress-all-from option.
From: Joel Becker @ 2007-12-21 19:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: David Brown, git
In-Reply-To: <7vfxxw7xkb.fsf@gitster.siamese.dyndns.org>

On Fri, Dec 21, 2007 at 09:43:48AM -0800, Junio C Hamano wrote:
> The option name feels as if it is somehow affecting From: but
> this is all about recipients.  It needs to be named better.
> 
> Even more importantly, git-send-email has too many places that
> pick up additional recipients.  I doubt --suppress-foo to
> suppress one such source "foo" is sustainable.  We should try to
> clean up the mess, not adding to it.

	Yay, even better that we're going to evaluate the sucker (I was
just complaining about this yesterday to someone, so how apropos that it
comes up on-list).
	First and foremost, I think git-send-email should not default to
anything.  It was quite a surprise, the first time I tried to use it, to
discover I had to add two options to ~/.gitconfig just for sane
behavior.  Never mind that I couldn't suppress the author-cc.  I think
that a naive "git send-email --to bob@bob.com foo.patch" should only go
to bob, period.
	We can then add ways to auto-cc.  I don't mind typing the extra
bits.  Heck, we could even define a --review that does what is currently
the default - cc-everyone-who-might-care-as-we-go-upstream.

Joel

-- 

Life's Little Instruction Book #99

	"Think big thoughts, but relish small pleasures."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker@oracle.com
Phone: (650) 506-8127

^ permalink raw reply

* Re: [PATCH] Make "git stash" configurable
From: Steven Grimm @ 2007-12-21 18:26 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Matthieu Moy,
	しらいしななこ, git
In-Reply-To: <7v3atw7x33.fsf@gitster.siamese.dyndns.org>

On Dec 21, 2007, at 9:54 AM, Junio C Hamano wrote:
> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>> It also makes portable scripts harder. It's easy to write a script
>> that works only if you have the option set ...
>
> In general I'd agree but in this particular case I do not think
> that applies.  Scripts can always say what they want, either
> "stash save" or "stash list".

I bet Matthieu meant that it's easy for someone who runs bare "git  
stash" all the time to forget that there's an option to make that  
command do something different, and to thus code up a local script  
that runs the command as they're used to running it. Such a script  
will work just fine for them but it'll break as soon as they give it  
to someone else who has the option set differently.

-Steve

^ permalink raw reply

* Re: [PATCH] Make "git stash" configurable
From: Junio C Hamano @ 2007-12-21 17:54 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: Steven Grimm,
	しらいしななこ, git
In-Reply-To: <vpq4pec7yb8.fsf@bauges.imag.fr>

Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> Steven Grimm <koreth@midwinter.com> writes:
>
>> Git's command line interface is already confusing enough without
>> adding this kind of variability
>
> It also makes portable scripts harder. It's easy to write a script
> that works only if you have the option set ...

In general I'd agree but in this particular case I do not think
that applies.  Scripts can always say what they want, either
"stash save" or "stash list".

^ permalink raw reply

* Re: [PATCH] git-describe: Add a --match option to limit considered tags.
From: Junio C Hamano @ 2007-12-21 17:52 UTC (permalink / raw)
  To: Pierre Habouzit; +Cc: git
In-Reply-To: <1198253900-31502-1-git-send-email-madcoder@debian.org>

Does it work with "describe --contains" as well?

^ permalink raw reply

* Re: [PATCH v0] sha1_name: grok <revision>:./<relative-path>
From: Junio C Hamano @ 2007-12-21 17:50 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy
  Cc: Johannes Schindelin, Dana How, Linus Torvalds, Alex Riesen,
	Jakub Narebski, git
In-Reply-To: <fcaeb9bf0712210617x2bafa33cp15815a59fc631f45@mail.gmail.com>

"Nguyen Thai Ngoc Duy" <pclouds@gmail.com> writes:

>> Note that this patch does not handle "../", and neither do I plan to.
>
> Junio's rc1 announcement got me to read this. It would be indeed
> useful as I usually work in deep subdirs. However, from my user
> perspective, the right approach is to make <treeish>:path always be
> relative to current directory. If you want absolute path, use
> <treeish>:/path. More intuitive but it breaks current behavior.

I do not know if you followed the discussion thread, but the
<treeish>:relative-path has been shown to be broken semantics,
so even if it may be "intuitive", it is intuitive only to people
who do not understand the brokenness.  Please read the one that
Dscho talks about windows drive letter and Linus agrees that is
a good analogy.

It might be possible to do <commit>:relative and apply that only
to direct user input, but I do not think it is worth the
compatibility and complexity hassle.

^ permalink raw reply

* Re: Linux 2.6.24-rc6
From: Linus Torvalds @ 2007-12-21 17:45 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List
In-Reply-To: <alpine.LFD.0.9999.0712202110350.21557@woody.linux-foundation.org>



On Thu, 20 Dec 2007, Linus Torvalds wrote:
> 
> Both answers are *correct*, though. The particular choice of "insert at 
> line 489, after line 488" is a bit odd, but is because we don't actually 
> search to exactly the beginning of where the differences started, we 
> search in blocks of 1kB and then we go forward to the next newline.

This slightly more involved diff does a better job at this particular 
issue. Whether the complexity is worth it or not, I dunno, but it changes 
the "remove common lines at the end" to do an exact job, which for this 
particular test-case means that the end result of adding a thousand lines 
of 'y' will look like

	[torvalds@woody ~]$ git diff -U0 a b | grep @@
	@@ -0,0 +1,1000 @@

instead - ie it will say that they were added at the very beginning of the 
file rather than added at some arbitrary point in the middle.

Whether this is really worth it, I dunno.

Also, I'm kind of debating with myself whether it would make most sense to 
only do this kind of optimization when (pick arbitrary cut-off here) 
something like more than half of the file is identical at the end. If we 
don't have a noticeable fraction of the file being the same, it may not 
make sense to really bother with this, since it really is meant for just 
things like ChangeLog files etc that have data added at the beginning.

That would make this whole optimization a lot more targeted to the case 
where it really matters and really helps.

I also do have an incling of a really evil way to make xdiff handle the 
case of having multiple lines of context right too, and basically just 
move all of this logic into xdiff itself rather than have this 
interface-level hack, but I'll have to let that idea brew for a while yet. 

			Linus

---
 xdiff-interface.c |   38 ++++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/xdiff-interface.c b/xdiff-interface.c
index 9ee877c..54a53d2 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -109,21 +109,43 @@ int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
  */
 static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx)
 {
-	const int blk = 1024;
+	int blk = 1024;
 	long trimmed = 0, recovered = 0;
 	char *ap = a->ptr + a->size;
 	char *bp = b->ptr + b->size;
 	long smaller = (a->size < b->size) ? a->size : b->size;
 
-	while (blk + trimmed <= smaller && !memcmp(ap - blk, bp - blk, blk)) {
-		trimmed += blk;
-		ap -= blk;
-		bp -= blk;
-	}
+	if (ctx)
+		return;
+
+	do {
+		while (blk + trimmed <= smaller && !memcmp(ap - blk, bp - blk, blk)) {
+			trimmed += blk;
+			ap -= blk;
+			bp -= blk;
+		}
+		blk /= 2;
+	} while (blk);
+
+	/* Did we trim one of them all away? */
+	if (trimmed == smaller) {
+		char *bigger;
+		if (a->size == b->size)
+			return;
+		bigger = a->ptr;
+		if (a->size > b->size)
+			bigger = b->ptr;
+
+		/* Did the other one end in a newline? */
+		if (bigger[trimmed-1] == '\n')
+			goto done;
+	}		
 
-	while (recovered < trimmed && 0 <= ctx)
+	/* Find the next newline */
+	while (recovered < trimmed)
 		if (ap[recovered++] == '\n')
-			ctx--;
+			break;
+done:
 	a->size -= (trimmed - recovered);
 	b->size -= (trimmed - recovered);
 }

^ permalink raw reply related

* Re: [PATCH] git-send-email: Add --suppress-all-from option.
From: Junio C Hamano @ 2007-12-21 17:43 UTC (permalink / raw)
  To: David Brown; +Cc: git
In-Reply-To: <1198216860-487-1-git-send-email-git@davidb.org>

David Brown <git@davidb.org> writes:

> Sometimes, it is useful to be able to send a patch to a third party
> without the author of the patch being copied on the message.

I would agree with the cause, but not necessarily with the
execution.

> +--suppress-all-from, --no-suppress-all-from::
> +        If this is set, do not add the From: address to the cc: list,
> +        even if it is different than the person sending the email.
> +        Default is the value of the 'sendemail.suppressallfrom'
> +        configuration value; if that is unspecified, default to
> +        -no-suppress-all-from.

The option name feels as if it is somehow affecting From: but
this is all about recipients.  It needs to be named better.

Even more importantly, git-send-email has too many places that
pick up additional recipients.  I doubt --suppress-foo to
suppress one such source "foo" is sustainable.  We should try to
clean up the mess, not adding to it.

So let's analyze the current situation first.  It seems that we
currently pick up the list of recipients from the following
places:

 * obviously, --to command line;
 * mbox Cc: header lines;
 * mbox From: header lines;
 * lots-of-email first line
 * $cc_cmd output;
 * Signed-off-by: lines in body;
 * Cc: lines in body;

The --no-signed-off-cc option is about omitting the last two
from the recipients.  We do not have a way to squelch other
sources of extra recipients, hence the need for your patch.

The --suppress-from option is about not giving an extra copy to
the sender.  It is "suppress from-address from the recipient
list", so the option name makes sense.

Your --suppress-all-from, from a cursory read of your patch,
omits only mbox Cc: and From: line recipients -- it is far from
"all", isn't it?  --signed-off-cc defaults to true so you would
need to suppress that at least to call it "all".

A cleaner approach might be:

 - introduce a helper function add_to_recipients that take \@cc,
   $recipient and the "source class".  Make this function
   responsible for not adding the sender to the list
   (i.e. --suppress-from, which is currently checked
   everywhere), and for not adding recipients from specified
   classes of sources, like this:

        sub add_to_recipients {
                my ($cc, $source, $recipient) = @_;
                return 0 if ($suppress_from and $sender eq $recipient);
                return 0 if ($suppressed_recipient_source{$source});
                push @$cc, $recipient;
                return 1;
        }

   Instead of returning 1 unconditionally, it might make sense
   to omit pushing duplicate here and to return 0 when
   $recipient was already in @$cc.

 - adjust the places where "push @cc" happens to use the above
   helper; the existing suppress logic in the callers can and
   should be removed as the add_to_recipients will be
   responsible for it, like this (an example for cc-cmd part):

        if (defined $cc_cmd) {
        open(F, "$cc_cmd $t |")
                or die "(cc-cmd) Could not execute '$cc_cmd'";
        while(<F>) {
                my $c = $_;
                $c =~ s/^\s*//g;
                $c =~ s/\n$//g;
-               next if ($c eq $sender and $suppress_from);
-               push @cc, $c;
+               next if (!add_to_recipients(\@cc, 'cccmd', $c));
                printf("(cc-cmd) Adding cc: %s from: '%s'\n",
                        $c, $cc_cmd) unless $quiet;
        }

 - define a global %suppressed_recipient_source hash to be used
   in add_to_recipients().  The existing --no-signed-off-cc is
   about adding two sources to this hash.

 - make the %suppressed_recipient_source configurable from the
   command line and repository configuration.

As to the "recipient source" classes, I think they can be
categorized as:

 * 'cc', to cover mbox Cc: header, lots-of-email first line, and
    Cc: lines in body;

 * 'sob', to cover Signed-off-by: lines in body;

 * 'cccmd', to cover $cc_cmd output;

Hmm?

^ permalink raw reply

* [PATCH] Allow selection of different cleanup modes for commit messages
From: Alex Riesen @ 2007-12-21 17:35 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, git
In-Reply-To: <alpine.LFD.0.9999.0712201555570.21557@woody.linux-foundation.org>

The modes being default, verbatim, whitespace and strip. The default
mode depends on if the message is being edited and will either strip
whitespace and comments (if editor active) or just strip the
whitespace (for where the message is given explicitely).

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>

---
Linus Torvalds, Fri, Dec 21, 2007 01:03:26 +0100:
> But for the case of actually using the built-in editing capability, we 
> don't have that choice, so I'd argue that regardless, we should make the 
> "--verbatim" switch be a three-way choice between (a) not touching things 
> at all, (b) touching up just whitespace, or (c) doing the full enchilada.
> 
> And if we introduce such a flag, then I think we can make the *default* 
> (in the absense of an explicit flag) be something like
> 
> 	if (no_edit)
> 		default = touch_up_just_whitespace;
> 	else
> 		default = whole_enchilada
> 
> and obviously it could also be a configuration option.

which makes it four-way choice...

> That way, you could always get the existing behaviour with
> 
> 	git commit --verbatim=full-enchilada -F my_message
> 
> (yeah, bad name - I'm not seriously suggesting it be called 
> "full-enchilada", and I'm also not sure the flag should be called 
> "--verbatim" any more if it has choices, it's more likely that we should 
> call it something like "--cleanup={verbatim,whitespace,strip}" or 
> something like that.

"verbatim", "whitespace", "strip", "default".

The patch is on top of my previos patches. Junio, if you wish, I can
squash and resend.

 Documentation/git-commit.txt |   15 ++++++---
 builtin-commit.c             |   69 +++++++++++++++++++++++++++++-------------
 t/t7502-commit.sh            |   28 +++++++++++++++--
 3 files changed, 83 insertions(+), 29 deletions(-)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 862543f..ac2bfd5 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -11,7 +11,7 @@ SYNOPSIS
 'git-commit' [-a | --interactive] [-s] [-v] [-u]
 	   [(-c | -C) <commit> | -F <file> | -m <msg> | --amend]
 	   [--allow-empty] [--no-verify] [-e] [--author <author>]
-	   [--verbatim] [--] [[-i | -o ]<file>...]
+	   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]
 
 DESCRIPTION
 -----------
@@ -95,10 +95,15 @@ OPTIONS
 	from making such a commit.  This option bypasses the safety, and
 	is primarily for use by foreign scm interface scripts.
 
---verbatim::
-	Inhibits stripping of leading and trailing spaces,
-	empty lines and #commentary from the commit message.
-	Implies --allow-empty.
+--cleanup=<mode>::
+	This option sets how the commit message is cleaned up.
+	The  '<mode>' can be one of 'verbatim', 'whitespace', 'strip',
+	and 'default'. The 'default' mode will strip leading and
+	trailing empty lines and #commentary from the commit message
+	only if the message is to be edited. Otherwise only whitespace
+	removed. The 'verbatim' mode wont change message at all,
+	'whitespace' removes just leading/trailing whitespace lines
+	and 'strip' removes both whitespace and commentary.
 
 -e|--edit::
 	The message taken from file with `-F`, command line with
diff --git a/builtin-commit.c b/builtin-commit.c
index eae7661..6f98537 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -47,7 +47,20 @@ static char *logfile, *force_author, *template_file;
 static char *edit_message, *use_message;
 static int all, edit_flag, also, interactive, only, amend, signoff;
 static int quiet, verbose, untracked_files, no_verify, allow_empty;
-static int verbatim_message;
+/*
+ * The default commit message cleanup mode will remove the lines
+ * beginning with # (shell comments) and leading and trailing
+ * whitespaces (empty lines or containing only whitespaces)
+ * if editor is used, and only the whitespaces if the message
+ * is specified explicitly.
+ */
+static enum {
+	CLEANUP_DEFAULT,
+	CLEANUP_NONE,
+	CLEANUP_SPACE,
+	CLEANUP_ALL,
+} cleanup_mode;
+static char *cleanup_arg;
 
 static int no_edit, initial_commit, in_merge;
 const char *only_include_assumed;
@@ -89,7 +102,7 @@ static struct option builtin_commit_options[] = {
 	OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
 	OPT_BOOLEAN(0, "untracked-files", &untracked_files, "show all untracked files"),
 	OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
-	OPT_BOOLEAN(0, "verbatim", &verbatim_message, "do not strip spaces and #comments from message"),
+	OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
 
 	OPT_END()
 };
@@ -348,7 +361,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)
 	if (fp == NULL)
 		die("could not open %s", git_path(commit_editmsg));
 
-	if (!verbatim_message)
+	if (cleanup_mode != CLEANUP_NONE)
 		stripspace(&sb, 0);
 
 	if (signoff) {
@@ -397,21 +410,24 @@ static int prepare_log_message(const char *index_file, const char *prefix)
 		return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
 	}
 
-	if (in_merge && !no_edit)
-		fprintf(fp,
-			"#\n"
-			"# It looks like you may be committing a MERGE.\n"
-			"# If this is not correct, please remove the file\n"
-			"#	%s\n"
-			"# and try again.\n"
-			"#\n",
-			git_path("MERGE_HEAD"));
-
-	if (!verbatim_message)
-		fprintf(fp,
-			"\n"
-			"# Please enter the commit message for your changes.\n"
-			"# (Comment lines starting with '#' will not be included)\n");
+	if (!no_edit) {
+		if (in_merge)
+			fprintf(fp,
+				"#\n"
+				"# It looks like you may be committing a MERGE.\n"
+				"# If this is not correct, please remove the file\n"
+				"#	%s\n"
+				"# and try again.\n"
+				"#\n",
+				git_path("MERGE_HEAD"));
+		if (cleanup_mode != CLEANUP_NONE)
+			fprintf(fp,
+				"\n"
+				"# Please enter the commit message for your changes.\n");
+		if (cleanup_mode == CLEANUP_DEFAULT)
+			fprintf(fp,
+				"# (Comment lines starting with '#' will not be included)\n");
+	}
 	if (only_include_assumed)
 		fprintf(fp, "# %s\n", only_include_assumed);
 
@@ -435,7 +451,7 @@ static int message_is_empty(struct strbuf *sb, int start)
 	const char *nl;
 	int eol, i;
 
-	if (verbatim_message && sb->len)
+	if (cleanup_mode == CLEANUP_NONE && sb->len)
 		return 0;
 
 	/* See if the template is just a prefix of the message. */
@@ -594,6 +610,16 @@ static int parse_and_validate_options(int argc, const char *argv[],
 		only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
 		also = 0;
 	}
+	if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
+		cleanup_mode = CLEANUP_DEFAULT;
+	else if (!strcmp(cleanup_arg, "verbatim"))
+		cleanup_mode = CLEANUP_NONE;
+	else if (!strcmp(cleanup_arg, "whitespace"))
+		cleanup_mode = CLEANUP_SPACE;
+	else if (!strcmp(cleanup_arg, "strip"))
+		cleanup_mode = CLEANUP_ALL;
+	else
+		die("Invalid cleanup mode %s", cleanup_arg);
 
 	if (all && argc > 0)
 		die("Paths with -a does not make sense.");
@@ -820,8 +846,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 	if (p != NULL)
 		strbuf_setlen(&sb, p - sb.buf + 1);
 
-	if (!verbatim_message)
-		stripspace(&sb, !no_edit);
+	if (cleanup_mode != CLEANUP_NONE)
+		stripspace(&sb, cleanup_mode == CLEANUP_DEFAULT ?
+			   !no_edit: cleanup_mode == CLEANUP_ALL);
 	if (sb.len < header_len || message_is_empty(&sb, header_len)) {
 		rollback_index_files();
 		die("no commit message?  aborting commit.");
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index d549728..6219378 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -93,15 +93,37 @@ test_expect_success 'verbatim commit messages' '
 
 	echo >>negative &&
 	{ echo;echo "# text";echo; } >expect &&
-	git commit --verbatim -t expect -a &&
+	git commit --cleanup=verbatim -t expect -a &&
 	git cat-file -p HEAD |sed -e "1,/^\$/d" |head -n 3 >actual &&
 	diff -u expect actual &&
 	echo >>negative &&
-	git commit --verbatim -F expect -a &&
+	git commit --cleanup=verbatim -F expect -a &&
 	git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
 	diff -u expect actual &&
 	echo >>negative &&
-	git commit --verbatim -m "$(cat expect)" -a &&
+	git commit --cleanup=verbatim -m "$(cat expect)" -a &&
+	git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
+	diff -u expect actual
+
+'
+
+test_expect_success 'cleanup only whitespace from commit messages' '
+
+	echo >>negative &&
+	{ echo;echo "# text";echo; } >text &&
+	echo "# text" >expect &&
+	git commit --cleanup=whitespace -F text -a &&
+	git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
+	diff -u expect actual
+
+'
+
+test_expect_success 'cleanup commit messages' '
+
+	echo >>negative &&
+	{ echo;echo "# text";echo sample;echo; } >text &&
+	echo sample >expect &&
+	git commit --cleanup=strip -F text -a &&
 	git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
 	diff -u expect actual
 
-- 
1.5.4.rc1.34.gf21f1

^ permalink raw reply related

* Re: [PATCH] Make "git stash" configurable
From: Matthieu Moy @ 2007-12-21 17:27 UTC (permalink / raw)
  To: Steven Grimm
  Cc: しらいしななこ,
	Junio C Hamano, git
In-Reply-To: <2AB285BD-DA6E-49D1-B664-B1A8B552DD76@midwinter.com>

Steven Grimm <koreth@midwinter.com> writes:

> Git's command line interface is already confusing enough without
> adding this kind of variability

It also makes portable scripts harder. It's easy to write a script
that works only if you have the option set ...

-- 
Matthieu

^ permalink raw reply

* Re: [PATCH] Make "git stash" configurable
From: Steven Grimm @ 2007-12-21 17:23 UTC (permalink / raw)
  To: しらいしななこ
  Cc: Junio C Hamano, git
In-Reply-To: <200712211026.lBLAQWWM014059@mi0.bluebottle.com>

On Dec 21, 2007, at 2:22 AM, しらいしななこ wrote:

> "git stash" without argument originally created an unnamed
> stash, but some people felt this can be confusing to new
> users.  This introduces per-user config variable stash.quick to
> control this behavior.

This whole thing smells of indecision to me. We should figure out a  
behavior we want and go with it. Git's command line interface is  
already confusing enough without adding this kind of variability --  
any new user is going to look at this and say, "Why couldn't they just  
make up their minds?"

My vote is to require "save". We already have an alias mechanism that  
people can use to turn "git stash save" into a two-word command. And I  
say this as someone who runs "git stash" and will have to retrain his  
fingers.

-Steve (who thinks "trying to please everyone at all times" is usually  
a source of bad UI design decisions)

^ permalink raw reply

* Re: [PATCH v2] Make git send-email accept $EDITOR with arguments
From: Junio C Hamano @ 2007-12-21 17:02 UTC (permalink / raw)
  To: Gustaf Hendeby; +Cc: luciano, git, gitster
In-Reply-To: <1198237002-21470-1-git-send-email-hendeby@isy.liu.se>

Gustaf Hendeby <hendeby@isy.liu.se> writes:

> Junio, even if this is technically not a bug fix, it would be nice to
> get this fix into the 1.5.4 so that the usage of $EDITOR becomes more
> consistent throughout git.

I can buy that, but at least a single line comment in front of that
system() explaining why this is safe to do so would be beneficial.  I
suspect that somebody would propose moving $compse_filename inside
$GIT_DIR, now people realized $compose_filename is currently "./.msg.$$",
and $GIT_DIR could be anything.  Quotemeta would probably be better as the
code you are touching won't be affected by a future change to the value of
that constant defined far away in the source.

^ permalink raw reply

* Re: Linux 2.6.24-rc6
From: Junio C Hamano @ 2007-12-21 16:56 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Kyle McMartin, Git Mailing List, Linux Kernel Mailing List
In-Reply-To: <alpine.LFD.0.9999.0712202054350.21557@woody.linux-foundation.org>

Linus Torvalds <torvalds@linux-foundation.org> writes:

> Actually, the code to finding one '\n' is still needed to avoid the 
> (pathological) case of getting a "\No newline", so scrap that one which 
> was too aggressive, and use this (simpler) one instead.
>
> Not that it matters in real life, since nobody uses -U0, and "git blame" 
> won't care. But let's get it right anyway ;)

Actually "blame won't care" is a bit too strong.  It's only we
(you) made it not to care.  It is a different story if the
change to make it not to care was sensible.

The diff text "git blame" will see is affected with the tail
trimming optimization exactly the same way as the optimization
triggered this thread.  With the common tails trimmed, the hunks
match differently from the way they match without trimming (the
gcc changelog testcase has differences between the unoptimized
blame and the tail-trimming one --- your original to put this
logic only in blame and my rewrite to move it in xdiff-interface
produce the same result that is different from the unoptimized
version, although both are 4x faster than the original).

When there are multiple possible matches, any match among them
is a correct match, and a match with a line in a blob is a match
to the blob no matter what line the match is anyway.  The usual
workflow of checking blame to find the commit that introduced
the change and then going to "git show" to view the bigger
picture won't get affected.  But the blamed line numbers will be
different from the unoptimized blame, and it may not match the
expectation of human readers.  It won't match "git show" output
of the blamed commit.

> This whole function has had more bugs than it has lines.

I have to agree.  It started as a brilliant idea but then it was
enhanced (in an attempt to support context) and executed not so
brilliantly.

^ 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