* Re: [RFC PATCH v3 00/17] Return of smart HTTP
From: Mark Lodato @ 2009-10-16 4:20 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1255577814-14745-1-git-send-email-spearce@spearce.org>
On Wed, Oct 14, 2009 at 11:36 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> This series is still lacking:
>
> * The HTTP protocol documentation
> * Tests for the smart http transport code (existing tests pass)
* Dumb HTTP push support
It would be really nice if git-http-backend supported dumb pushing
over WebDAV. Currently, to support both smart and dumb pushing, one
has to configure Apache in a very awkward and confusing way (if it is
even possible - I'm still trying to figure it out). Without some way
to support older clients, it will be very hard to transition to the
new protocol.
Also, your examples use "DocumentRoot /pub/git", but I think most
people would want to have their main website as the DocumentRoot, have
the URL "/git" serve the repositories through gitweb, and have that
same "/git" URL be `git clone'-able. The Apache configuration for
this is complicated and non-intuitive, so I think an example of this
in the documentation is warranted. The following accomplishes what I
describe, except it does not work with dump HTTP push, and does not
allow anonymous read-only access. (I am currently trying to figure
out how to do both of these things.)
-- 8< --
DocumentRoot /var/www/htdocs
# Rest of httpd config...
<Directory /pub/git>
SetHandler git-http-backend
Action git-http-backend /git-http-backend virtual
</Directory>
# To allow anonymous access (but to disallow pushing), comment out the
following Location block.
<Location /git-http-backend>
AuthName "git"
AuthType Basic
AuthUserFile /etc/apache2/passwd/git.passwd
Require valid-user
</Location>
# Each of the following Aliases should be one line:
AliasMatch ^/git/(.*/(HEAD|info/refs|objects/(info/[^/]*|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))|git-(upload|receive)-pack))$
"/pub/git/$1"
ScriptAlias /git "/var/www/cgi-bin/gitweb.cgi"
ScriptAlias /git-http-backend "/usr/local/libexec/git-core/git-http-backend"
-- >8 --
^ permalink raw reply
* [PATCHv3] gitweb: linkify author/committer names with search
From: Stephen Boyd @ 2009-10-16 4:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Giuseppe Bilotta, Jakub Narebski
In-Reply-To: <1255486344-11891-1-git-send-email-bebarino@gmail.com>
It's nice to search for an author by merely clicking on their name in
gitweb. This is usually faster than selecting the name, copying the
selection, pasting it into the search box, selecting between
author/committer and then hitting enter.
Linkify the avatar icon in log/shortlog view because the icon is directly
adjacent to the name and thus more related. The same is not true
when in commit/tag view where the icon is farther away.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
Changes since v2:
* Add a title to make it not so suprising before you click (Jakub)
Changes since v1:
* CSS hack has been cleaned up to only remove the link border from
avatar icons when actually linked.
* Checking for search capability to avoid generating search links (Wincent)
* Linking of name and email are separate in commit/commitdiff/tag views
gitweb/gitweb.css | 4 ++++
gitweb/gitweb.perl | 40 +++++++++++++++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 8faa94e..50067f2 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -32,6 +32,10 @@ img.avatar {
vertical-align: middle;
}
+a.list img.avatar {
+ border-style: none;
+}
+
div.page_header {
height: 25px;
padding: 8px;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0c71ee8..63e18f4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1625,6 +1625,29 @@ sub git_get_avatar {
}
}
+sub format_search_author {
+ my ($author, $searchtype, $displaytext) = @_;
+ my $have_search = gitweb_check_feature('search');
+
+ if ($have_search) {
+ my $performed = "";
+ if ($searchtype eq 'author') {
+ $performed = "authored";
+ } elsif ($searchtype eq 'committer') {
+ $performed = "committed";
+ }
+
+ return $cgi->a({-href => href(action=>"search", hash=>$hash,
+ searchtext=>$author,
+ searchtype=>$searchtype), class=>"list",
+ title=>"Search for commits $performed by $author"},
+ $displaytext);
+
+ } else {
+ return $displaytext;
+ }
+}
+
# format the author name of the given commit with the given tag
# the author name is chopped and escaped according to the other
# optional parameters (see chop_str).
@@ -1633,8 +1656,10 @@ sub format_author_html {
my $co = shift;
my $author = chop_and_escape_str($co->{'author_name'}, @_);
return "<$tag class=\"author\">" .
- git_get_avatar($co->{'author_email'}, -pad_after => 1) .
- $author . "</$tag>";
+ format_search_author($co->{'author_name'}, "author",
+ git_get_avatar($co->{'author_email'}, -pad_after => 1) .
+ $author) .
+ "</$tag>";
}
# format git diff header line, i.e. "diff --(git|combined|cc) ..."
@@ -3433,10 +3458,11 @@ sub git_print_authorship {
my $co = shift;
my %opts = @_;
my $tag = $opts{-tag} || 'div';
+ my $author = $co->{'author_name'};
my %ad = parse_date($co->{'author_epoch'}, $co->{'author_tz'});
print "<$tag class=\"author_date\">" .
- esc_html($co->{'author_name'}) .
+ format_search_author($author, "author", esc_html($author)) .
" [$ad{'rfc2822'}";
print_local_time(%ad) if ($opts{-localtime});
print "]" . git_get_avatar($co->{'author_email'}, -pad_before => 1)
@@ -3455,8 +3481,12 @@ sub git_print_authorship_rows {
@people = ('author', 'committer') unless @people;
foreach my $who (@people) {
my %wd = parse_date($co->{"${who}_epoch"}, $co->{"${who}_tz"});
- print "<tr><td>$who</td><td>" . esc_html($co->{$who}) . "</td>" .
- "<td rowspan=\"2\">" .
+ print "<tr><td>$who</td><td>" .
+ format_search_author($co->{"${who}_name"}, $who,
+ esc_html($co->{"${who}_name"})) . " " .
+ format_search_author($co->{"${who}_email"}, $who,
+ esc_html("<" . $co->{"${who}_email"} . ">")) .
+ "</td><td rowspan=\"2\">" .
git_get_avatar($co->{"${who}_email"}, -size => 'double') .
"</td></tr>\n" .
"<tr>" .
--
1.6.5.94.gb6c65
^ permalink raw reply related
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Junio C Hamano @ 2009-10-16 3:00 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Nicolas Pitre, Jeff King, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <alpine.DEB.1.00.0910160245310.4985@pacific.mpi-cbg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> In this particular case, I cannot help but notice that commits performed
> on a detached HEAD will get lost _unless_ they are somehow put onto a
> named branch eventually. So the only question is whether you restrict
> flexibility by requiring to name the branch first before committing,
> instead of committing and then naming the branch.
You are forgetting another important case. You may not even want to keep
what you will be committing to the throw-away temporary state.
That is why I liked the proposal by James to introduce a third state
(i.e. not on local branch, but cannot commit) at the conceptual level,
even though as Daniel pointed out and Nico and I concurred later, the
implementation may need to be based on the detached HEAD to avoid "git
fetch" surprises.
You can of course fix it in different ways. The third state could be
implemented by pointing at a non local branch ref with HEAD, and then by
making fetch refuse to update, just like we refuse a push from side to
make the working tree state inconsistent.
Either way, confusion arising from accidental (or unintended) detaching
would be removed for new users, and that won't have to harm people who
need to (because they _are_ used to) be able to work on detached HEAD, no?
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Junio C Hamano @ 2009-10-16 2:56 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Nicolas Pitre, Jeff King, Junio C Hamano, Daniel Barkalow,
Jay Soffian, git
In-Reply-To: <alpine.DEB.1.00.0910160357370.4985@pacific.mpi-cbg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> You are trying to educate the users to use the double-clutch. Rather than
> making the double-clutch obsolete.
I do not quite get your double-clutch rhetoric, in the sense that I do not
think it has anything analogous in the topic of detached HEAD we have been
discussing.
Didn't we discuss possible solutions to make sure that you do not have to
detach HEAD and lose commits by coming back without saving them? I would
consider that corresponds to inventing automatic (iow, making sure that
sightseeing can be done without having to worry about accidentally
committing on that state and later losing them). Obviously, you would
need to cover cases other than we have discussed (e.g. if "rebase -i"
detaches, it needs to allow "commit", "commit --amend", and "reset --soft
HEAD^", but you probably would not want to allow "checkout" to switch to
another branch). Thinking things through so that we can fill in all these
details is a tedious and hard work, but I would say it would be worth it.
In the ideal world, if you do not have to (nor want to) use the detached
HEAD feature, you do not have to.
But that is entirely different from saying "I do not need to use detached
HEAD, I cannot explain it to my users. Let's make it unusable, iow, I give
up". Unfortunately that is the impression I am getting from your whining.
If you have been advocating for something else, and you share the goal of
helping users by e.g. making it unnecessary to worry about accidentally
committing on that state and later losing them, you would need to do a
better job explaining yourself.
> Just recently, I had a user request (a very valid one, mind you) where the
> user does not want to provide a commit message, and wants to just commit
> all the current changes. In that particular case, it is very sensible to
> ask for these things. It is something utterly simple to ask for. Yet, it
> is utterly hard with Git, especially if I have to explain it.
I suspect the above is another example of your needing to do a better job
explaining yourself here, but from "just commit all the changes without
saying message", my knee-jerk reaction is "git commit -a -m 'no message'".
You would need to justify why -m 'no message' does not fit the bill better
than just saying "is very sensible to ask for these things", as I highly
suspect that I misunderstood what "these things" are in your five lines to
come up with that "solution" that you are now going to explain why that is
not what the end user wanted. And in this case, I do not think it is that
me being disconnected from the real world, but that your explanation is
insufficient.
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-16 2:45 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Jeff King, Junio C Hamano, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <alpine.DEB.1.00.0910160357370.4985@pacific.mpi-cbg.de>
On Fri, 16 Oct 2009, Johannes Schindelin wrote:
> Hi,
>
> On Thu, 15 Oct 2009, Nicolas Pitre wrote:
>
> > On Fri, 16 Oct 2009, Johannes Schindelin wrote:
> >
> > > We, the old Gits need to change. Not the many other people.
> > >
> > > Remember: you do not know how exactly the clutch interacts with the 2nd
> > > cylinder of the engine. And you do not _need_ to.
> >
> > Really, the detached HEAD concept can't be _that_ hard.
>
> You are trying to educate the users to use the double-clutch. Rather than
> making the double-clutch obsolete.
> That's what I call "BlameTheWrongThing".
I just can't convince myself to share that point of view. Doesn't mean
that I'm right though, but that's how I see it given the alternative.
> > > Neither should Git users need to.
> >
> > What you're asking for, though, is more comparable to asking old Gits to
> > give up on their clutch and manual gearbox because most American Git
> > users are expecting automatic transmissions. Maybe that's not the case
> > in Germany, but over here automatic transmissions are by far the norm
> > and a manual gearbox can be obtained only in limited cases if at all.
>
> Your point being? You really think Git is already at the stage where it
> has automatic transmission and all you have to do is hit the gas or the
> brake? No, Nico, you are too intelligent to believe that.
No, Git is not at the automatic transmission level, and I _don't_ want
it to, ever. That would not be _my_ choice.
> Besides, Git is not even at the stage of a manual gearbox.
Here I disagree.
> Just recently, I had a user request (a very valid one, mind you) where the
> user does not want to provide a commit message, and wants to just commit
> all the current changes. In that particular case, it is very sensible to
> ask for these things. It is something utterly simple to ask for. Yet, it
> is utterly hard with Git, especially if I have to explain it.
I hope this is a bad example. I just can't imagine how "very sensible"
you may consider messageless commits. I've dealt with them too many
times in my life.
But still, if someone just can't be bothered at all then the
"workaround" is easy: just use '-m.' or any other meaningless character
of your choice. At least _I_ will be able to identify those commits as
being purposely messageless and make a better informed opinion on that
committer instead of blaming it on ignorance.
> Maybe the core Git developers should spend a month explaining the core
> principles of Git to some random software developers, just so all of us
> get an idea just how wrong we are on the account of how intuitive Git is.
Sorry but I don't share that feeling of hopelessness that seems to
affect those random software developers you might have tried to teach
Git to. Well, actually I do have to deal with hopeless software
developers once in a while which are simply total idiots, and they
certainly shine at depicting Git, or any other tool at their disposal
for that matter, as utter crap. But fortunately for me, the few people
to whom I've explained Git so far simply got it in very little time.
In my opinion, the most important concept to explain first is Git
branching. Everything else is kinda secondary. Worked for me pretty
well so far.
Nicolas
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Johannes Schindelin @ 2009-10-16 2:07 UTC (permalink / raw)
To: Nicolas Pitre
Cc: Jeff King, Junio C Hamano, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <alpine.LFD.2.00.0910152118360.20122@xanadu.home>
Hi,
On Thu, 15 Oct 2009, Nicolas Pitre wrote:
> On Fri, 16 Oct 2009, Johannes Schindelin wrote:
>
> > We, the old Gits need to change. Not the many other people.
> >
> > Remember: you do not know how exactly the clutch interacts with the 2nd
> > cylinder of the engine. And you do not _need_ to.
>
> Really, the detached HEAD concept can't be _that_ hard.
You are trying to educate the users to use the double-clutch. Rather than
making the double-clutch obsolete.
That's what I call "BlameTheWrongThing".
> > Neither should Git users need to.
>
> What you're asking for, though, is more comparable to asking old Gits to
> give up on their clutch and manual gearbox because most American Git
> users are expecting automatic transmissions. Maybe that's not the case
> in Germany, but over here automatic transmissions are by far the norm
> and a manual gearbox can be obtained only in limited cases if at all.
Your point being? You really think Git is already at the stage where it
has automatic transmission and all you have to do is hit the gas or the
brake? No, Nico, you are too intelligent to believe that.
Besides, Git is not even at the stage of a manual gearbox.
Just recently, I had a user request (a very valid one, mind you) where the
user does not want to provide a commit message, and wants to just commit
all the current changes. In that particular case, it is very sensible to
ask for these things. It is something utterly simple to ask for. Yet, it
is utterly hard with Git, especially if I have to explain it.
Maybe the core Git developers should spend a month explaining the core
principles of Git to some random software developers, just so all of us
get an idea just how wrong we are on the account of how intuitive Git is.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-16 1:36 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Jeff King, Junio C Hamano, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <alpine.DEB.1.00.0910160256180.4985@pacific.mpi-cbg.de>
On Fri, 16 Oct 2009, Johannes Schindelin wrote:
> We, the old Gits need to change. Not the many other people.
>
> Remember: you do not know how exactly the clutch interacts with the 2nd
> cylinder of the engine. And you do not _need_ to.
Really, the detached HEAD concept can't be _that_ hard. It is not like
if we were asking our users to fully grok the blob/tree/commit hierarchy
and delta compression heuristics to be able to work with Git.
> Neither should Git users need to.
What you're asking for, though, is more comparable to asking old Gits to
give up on their clutch and manual gearbox because most American Git
users are expecting automatic transmissions. Maybe that's not the case
in Germany, but over here automatic transmissions are by far the norm
and a manual gearbox can be obtained only in limited cases if at all.
Nicolas
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Johannes Schindelin @ 2009-10-16 1:04 UTC (permalink / raw)
To: Nicolas Pitre
Cc: Jeff King, Junio C Hamano, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <alpine.LFD.2.00.0910142237010.20122@xanadu.home>
Hi,
On Wed, 14 Oct 2009, Nicolas Pitre wrote:
> On Wed, 14 Oct 2009, Jeff King wrote:
>
> > On Wed, Oct 14, 2009 at 05:56:52PM -0700, Junio C Hamano wrote:
> >
> > > Nicolas Pitre <nico@fluxnic.net> writes:
> > >
> > > > Can't the user confusion be dealt with through some means other than
> > > > making the tool less flexible? I don't mind extra help message to be
> > > > displayed after a headless commit is made for example. But trying to
> > > > make the tool more friendly should perhaps come from better education
> > > > rather than added restrictions.
> > > >
> > > > My thoughts only.
> > >
> > > I actually share that but there apparently are people who have given up on
> > > the education route.
> >
> > I am personally undecided on this issue (my "this is the best option"
> > was the best of "a -f switch to commit, an 'expert' config option', or a
> > session-based option to commit").
> >
> > But we really seem to have reached an impasse with how to proceed with
> > git ui.
> >
> > People like Dscho are fed up with user complaints about parts of git
> > that can be unfriendly to new users. And I can understand that.
>
> People like Dscho have to grow a thicker skin then. There will _always_
> be user complaints regardless of how balanced you try to make a UI.
You are seriously misreading my intentions, then. Or my intelligence.
It is not about growing a thicker skin towards unmerited complaints.
It is about shedding the thick skin when there are merited complaints, and
some people are just too used to the old ways to understand that some of
the complaints have _a lot_ of merit.
It is just like with the olden days when only a precious few could drive
cars, and maintained that it _is_ hard to drive a car, and _not_ everybody
can do it _because_ you will have a breakdown with the car and you _have_
to be able to fix it yourself.
Fast-forward a hundred years.
None of this is true any longer.
None.
Guess what? In these days, we do not need a hundred years. Four is
plenty enough. We have a lot of Git users who do not understand the inner
workings of Git. And why should they need to?
Who are you to say they should?
We, the old Gits need to change. Not the many other people.
Remember: you do not know how exactly the clutch interacts with the 2nd
cylinder of the engine. And you do not _need_ to.
Neither should Git users need to.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Johannes Schindelin @ 2009-10-16 0:53 UTC (permalink / raw)
To: Junio C Hamano
Cc: Nicolas Pitre, Jeff King, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <7viqeha2zv.fsf@alter.siamese.dyndns.org>
Hi,
On Wed, 14 Oct 2009, Junio C Hamano wrote:
> Nicolas Pitre <nico@fluxnic.net> writes:
>
> > Can't the user confusion be dealt with through some means other than
> > making the tool less flexible? I don't mind extra help message to be
> > displayed after a headless commit is made for example. But trying to
> > make the tool more friendly should perhaps come from better education
> > rather than added restrictions.
> >
> > My thoughts only.
>
> I actually share that but there apparently are people who have given up on
> the education route.
At some point, when you try to teach something that people (i.e. more than
one person) do not get easily, you cannot do anything but admit that what
you try to teach is crap. Obviously you did not have that experience.
Maybe you are just more picky than me when it comes to who you try to
teach. But of course, that does not make what you try to teach less crap.
In this particular case, I cannot help but notice that commits performed
on a detached HEAD will get lost _unless_ they are somehow put onto a
named branch eventually. So the only question is whether you restrict
flexibility by requiring to name the branch first before committing,
instead of committing and then naming the branch.
So you are talking about "retaining flexibility" in favor of making the
tool less user-friendly, when all it would take from the few power-users
is to name the branch before committing to it, instead of the other way
round.
You must be kidding me.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Johannes Schindelin @ 2009-10-16 0:43 UTC (permalink / raw)
To: James Pickens
Cc: Junio C Hamano, Jeff King, Nicolas Pitre, Daniel Barkalow,
Jay Soffian, git
In-Reply-To: <885649360910151647v27a15334x63fe3b6f5035dbd2@mail.gmail.com>
Hi,
On Thu, 15 Oct 2009, James Pickens wrote:
> On Thu, Oct 15, 2009 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > Junio C Hamano <gitster@pobox.com> writes:
> >
> >> $ git checkout origin/next ;# ditto
> >> $ git symbolic-ref HEAD
> >> refs/remotes/origin/next
> >
> > Ok, after reading Daniel's message to remind us that "git fetch" after
> > this will get us into trouble, I agree that detaching HEAD is inevitable.
>
> Some people liked the idea, so let's not give up just yet. Here are a few
> things Git could do when a fetch wants to update the currently checked out
> branch:
>
> 1. Refuse the fetch.
> 2. Update the ref, leaving the user with a work tree and index that don't
> match their HEAD.
> 3. Detach the HEAD, then update the ref.
> 4. Update the ref, then check it out.
Everything but 1 and 4 would blatantly violate the law of the Least
Surprise.
And that very much includes what our beloved maintainer proposes.
BTW I appreciate that finally a few users join discussion. It felt
awfully lonely for a while.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-16 0:34 UTC (permalink / raw)
To: James Pickens
Cc: Junio C Hamano, Jeff King, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <885649360910151647v27a15334x63fe3b6f5035dbd2@mail.gmail.com>
On Thu, 15 Oct 2009, James Pickens wrote:
> BTW I'm not convinced this is any better than the current UI... just
> thinking out loud.
I concur with that.
> And I find it more than a little depressing that most
> of these ideas have already been discussed almost 3 years ago (thanks Jeff
> for the pointer).
Rehashing them from time to time is not necessarily a bad idea. Maybe
something better might (or not) turn up this time.
Nicolas
^ permalink raw reply
* Re: cgit suggestion
From: Lars Hjemli @ 2009-10-16 0:13 UTC (permalink / raw)
To: Alexey Nezhdanov; +Cc: git
In-Reply-To: <200909272302.30742.snakeru@gmail.com>
[* Sorry for the late reply *]
On Sun, Sep 27, 2009 at 21:02, Alexey Nezhdanov <snakeru@gmail.com> wrote:
> Here is the diff. It adds feature of downloading 'named' tarball from the tag
> description page.
Thanks, I've applied the patch (slightly modified) to my master branch
and pushed the result to http://hjemli.net/git/cgit.
--
larsh
^ permalink raw reply
* [PATCH] am: allow some defaults to be specified via git-config
From: Sam Vilain @ 2009-10-15 23:50 UTC (permalink / raw)
To: git; +Cc: Nigel McNie, Sam Vilain
Some users prefer in particular '3way' to be the default, let them
specify it via the config file - and some other boolean settings while
we're at it.
Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
---
Documentation/config.txt | 4 ++++
Documentation/git-am.txt | 11 +++++++++--
git-am.sh | 5 +++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index cd17814..82adca5 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -476,6 +476,10 @@ it will be treated as a shell command. For example, defining
executed from the top-level directory of a repository, which may
not necessarily be the current directory.
+am.*::
+ Specify defaults for linkgit:git-am[1]. Currently, the three
+ boolean options, 'sign', 'utf8' and 'keep' may be specified.
+
apply.ignorewhitespace::
When set to 'change', tells 'git-apply' to ignore changes in
whitespace, in the same way as the '--ignore-space-change'
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 67ad5da..c22bca2 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -38,6 +38,7 @@ OPTIONS
-k::
--keep::
Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
+ May be specified via 'am.keep' (see linkgit:git-config[1]).
-c::
--scissors::
@@ -60,7 +61,8 @@ OPTIONS
preferred encoding if it is not UTF-8).
+
This was optional in prior versions of git, but now it is the
-default. You can use `--no-utf8` to override this.
+default. You can use `--no-utf8` to override this, or set
+'am.utf8' to no via linkgit:git-config[1].
--no-utf8::
Pass `-n` flag to 'git-mailinfo' (see
@@ -71,7 +73,12 @@ default. You can use `--no-utf8` to override this.
When the patch does not apply cleanly, fall back on
3-way merge if the patch records the identity of blobs
it is supposed to apply to and we have those blobs
- available locally.
+ available locally. This can be configured via
+ linkgit:git-config[1] using the 'am.3way' option
+
+--no-3way::
+ If 'am.3way' is specified to be true in the configuration file,
+ this switch allows it to be disabled.
--ignore-date::
--ignore-space-change::
diff --git a/git-am.sh b/git-am.sh
index c132f50..a22fa3b 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -294,6 +294,9 @@ git_apply_opt=
committer_date_is_author_date=
ignore_date=
+# apply defaults from config
+eval "$(git config --bool --get-regexp '^am\.(sign|utf8|keep)' | sed 's/^am\.\([a-z0-9]*\) /\1=/;s/true/t/;s/false//')"
+
while test $# != 0
do
case "$1" in
@@ -303,6 +306,8 @@ do
: ;;
-3|--3way)
threeway=t ;;
+ --no-3way)
+ threeway= ;;
-s|--signoff)
sign=t ;;
-u|--utf8)
--
1.6.3.3
^ permalink raw reply related
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: James Pickens @ 2009-10-15 23:47 UTC (permalink / raw)
To: Junio C Hamano
Cc: Jeff King, Nicolas Pitre, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <7vfx9k1faa.fsf@alter.siamese.dyndns.org>
On Thu, Oct 15, 2009 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> $ git checkout origin/next ;# ditto
>> $ git symbolic-ref HEAD
>> refs/remotes/origin/next
>
> Ok, after reading Daniel's message to remind us that "git fetch" after
> this will get us into trouble, I agree that detaching HEAD is inevitable.
Some people liked the idea, so let's not give up just yet. Here are a few
things Git could do when a fetch wants to update the currently checked out
branch:
1. Refuse the fetch.
2. Update the ref, leaving the user with a work tree and index that don't
match their HEAD.
3. Detach the HEAD, then update the ref.
4. Update the ref, then check it out.
Option 1 is ok, as long as the "next step" is not too complicated. It's no
good if the user has to checkout a different branch, then fetch, then
checkout the original branch again.
Option 2 is crap.
Option 3 seems reasonable, but it might be just as scary/confusing to
newbies as the current behavior, so I don't think it should be the default.
Option 4 also seems reasonable, but you run into problems if the user had
changed the index or work tree. In that case Git could do 'checkout
--merge' automatically. This option is also less "pure" since it lets 'git
fetch' modify the index and work tree.
So how about this:
* 'git fetch' refuses the fetch by default.
* 'git fetch --detach' detaches HEAD, then updates the ref
* 'git pull' detaches HEAD, updates the ref, then checks out the new ref
with --merge.
BTW I'm not convinced this is any better than the current UI... just
thinking out loud. And I find it more than a little depressing that most
of these ideas have already been discussed almost 3 years ago (thanks Jeff
for the pointer).
James
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Nicolas Pitre @ 2009-10-15 23:16 UTC (permalink / raw)
To: Junio C Hamano
Cc: Jeff King, James Pickens, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <7vfx9k1faa.fsf@alter.siamese.dyndns.org>
On Thu, 15 Oct 2009, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > $ git checkout origin/next ;# ditto
> > $ git symbolic-ref HEAD
> > refs/remotes/origin/next
>
> Ok, after reading Daniel's message to remind us that "git fetch" after
> this will get us into trouble, I agree that detaching HEAD is inevitable.
Either the fetch should be refused just like a commit would, or HEAD
gets detached automatically in that case. Probably the former would be
less confusing, otherwise the user might expect to see the updated
remote branch after the fetch and not understand that a detached HEAD
remained on the previous remote branch state.
Nicolas
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Thomas Rast @ 2009-10-15 22:56 UTC (permalink / raw)
To: Daniel Barkalow
Cc: Nicolas Pitre, James Pickens, Jeff King, Junio C Hamano,
Jay Soffian, git
In-Reply-To: <alpine.LNX.2.00.0910151517070.32515@iabervon.org>
Daniel Barkalow wrote:
> On Thu, 15 Oct 2009, Nicolas Pitre wrote:
>
> > On Thu, 15 Oct 2009, Daniel Barkalow wrote:
> >
> > > I think the description used in CVS and SVN (and, I think, others) is that
> > > you're not at the HEAD revision.
[...]
> > > * origin/master (not at head)
> > > $ git checkout 123cafe^5; git branch
> > > * 123cafe^5 (not at head)
> >
> > I think this is wrong. Git has multiple heads, and insisting on "not at
> > head" would be extremely confusing.
>
> Maybe "(not at a head)"? Git does have multiple heads, but what's checked
> out isn't one of them, and that's actually the point.
Please don't reuse 'head' (even lowercase) in this context/meaning. I
see enough people coming to IRC who are confused about the fact that
they checked out some old commit, hence HEAD is just that, but they
refer to the *newest* commit on whatever branch they like most as HEAD
because that's what it means in SVN.
Now imagine having to explain to them that their (SVN) 'HEAD' is not
the same as git's 'HEAD', but can rightly be considered the equivalent
of master's 'head'; and that furthermore, you are always at 'HEAD' but
not always at 'head'.
I think in this case '(detached)' would be more consistent with
current terminology, though we may of course try to change it.
(I've tried to consistently use 'tip' in the branch tip meaning,
admittedly without knowing exactly how this intersects with
mercurial's definition of the term.)
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* [PATCH v2 2/5] reflog-walk: refactor the branch@{num} formatting
From: Thomas Rast @ 2009-10-15 22:41 UTC (permalink / raw)
To: Jeff King, Junio C Hamano; +Cc: Jef Driesen, Nanako Shiraishi, git
In-Reply-To: <cover.1255645570.git.trast@student.ethz.ch>
We'll use the same output in an upcoming commit, so refactor its
formatting (which was duplicated anyway) into a separate function.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
reflog-walk.c | 54 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/reflog-walk.c b/reflog-walk.c
index 5623ea6..596bafe 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -241,36 +241,46 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
commit->object.flags &= ~(ADDED | SEEN | SHOWN);
}
-void show_reflog_message(struct reflog_walk_info *info, int oneline,
+void get_reflog_selector(struct strbuf *sb,
+ struct reflog_walk_info *reflog_info,
+ enum date_mode dmode)
+{
+ struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
+ struct reflog_info *info;
+
+ if (!commit_reflog)
+ return;
+
+ strbuf_addf(sb, "%s@{", commit_reflog->reflogs->ref);
+ if (commit_reflog->flag || dmode) {
+ info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
+ strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
+ } else {
+ strbuf_addf(sb, "%d", commit_reflog->reflogs->nr
+ - 2 - commit_reflog->recno);
+ }
+
+ strbuf_addch(sb, '}');
+}
+
+void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
enum date_mode dmode)
{
- if (info && info->last_commit_reflog) {
- struct commit_reflog *commit_reflog = info->last_commit_reflog;
+ if (reflog_info && reflog_info->last_commit_reflog) {
+ struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
struct reflog_info *info;
+ struct strbuf selector = STRBUF_INIT;
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
+ get_reflog_selector(&selector, reflog_info, dmode);
if (oneline) {
- printf("%s@{", commit_reflog->reflogs->ref);
- if (commit_reflog->flag || dmode)
- printf("%s", show_date(info->timestamp,
- info->tz,
- dmode));
- else
- printf("%d", commit_reflog->reflogs->nr
- - 2 - commit_reflog->recno);
- printf("}: %s", info->message);
+ printf("%s: %s", selector.buf, info->message);
}
else {
- printf("Reflog: %s@{", commit_reflog->reflogs->ref);
- if (commit_reflog->flag || dmode)
- printf("%s", show_date(info->timestamp,
- info->tz,
- dmode));
- else
- printf("%d", commit_reflog->reflogs->nr
- - 2 - commit_reflog->recno);
- printf("} (%s)\nReflog message: %s",
- info->email, info->message);
+ printf("Reflog: %s (%s)\nReflog message: %s",
+ selector.buf, info->email, info->message);
}
+
+ strbuf_release(&selector);
}
}
--
1.6.5.18.g9f87a.dirty
^ permalink raw reply related
* [PATCH v2 3/5] Introduce new pretty formats %g[sdD] for reflog information
From: Thomas Rast @ 2009-10-15 22:41 UTC (permalink / raw)
To: Jeff King, Junio C Hamano; +Cc: Jef Driesen, Nanako Shiraishi, git
In-Reply-To: <cover.1255645570.git.trast@student.ethz.ch>
Add three new --pretty=format escapes:
%gD long reflog descriptor (e.g. refs/stash@{0})
%gd short reflog descriptor (e.g. stash@{0})
%gs reflog message
This is achieved by passing down the reflog info, if any, inside the
pretty_print_context struct.
We use the newly refactored get_reflog_selector(), and give it some
extra functionality to extract a shortened ref. The shortening has a
very simple 1-element cache, since it will usually be called with the
same ref every time. Add another helper get_reflog_message() for the
message extraction.
Note that the --format="%h %gD: %gs" tests may not work in real
repositories, as the --pretty formatter doesn't know to leave away the
": " on the last commit in an incomplete (because git-gc removed the
old part) reflog. This equivalence is nevertheless the main goal of
this patch.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Documentation/pretty-formats.txt | 3 +++
commit.h | 1 +
log-tree.c | 1 +
pretty.c | 17 +++++++++++++++++
reflog-walk.c | 37 ++++++++++++++++++++++++++++++++++---
reflog-walk.h | 8 ++++++++
t/t1411-reflog-show.sh | 12 ++++++++++++
7 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 2a845b1..6359272 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -123,6 +123,9 @@ The placeholders are:
- '%s': subject
- '%f': sanitized subject line, suitable for a filename
- '%b': body
+- '%gD': reflog selector, e.g., `refs/stash@{1}`
+- '%gd': shortened reflog selector, e.g., `stash@{1}`
+- '%gs': reflog subject
- '%Cred': switch color to red
- '%Cgreen': switch color to green
- '%Cblue': switch color to blue
diff --git a/commit.h b/commit.h
index 011766d..15cb649 100644
--- a/commit.h
+++ b/commit.h
@@ -70,6 +70,7 @@ struct pretty_print_context
const char *after_subject;
enum date_mode date_mode;
int need_8bit_cte;
+ struct reflog_walk_info *reflog_info;
};
extern int non_ascii(int);
diff --git a/log-tree.c b/log-tree.c
index f57487f..8e782fc 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -409,6 +409,7 @@ void show_log(struct rev_info *opt)
ctx.date_mode = opt->date_mode;
ctx.abbrev = opt->diffopt.abbrev;
ctx.after_subject = extra_headers;
+ ctx.reflog_info = opt->reflog_info;
pretty_print_commit(opt->commit_format, commit, &msgbuf, &ctx);
if (opt->add_signoff)
diff --git a/pretty.c b/pretty.c
index d6d57eb..fc65fca 100644
--- a/pretty.c
+++ b/pretty.c
@@ -7,6 +7,7 @@
#include "mailmap.h"
#include "log-tree.h"
#include "color.h"
+#include "reflog-walk.h"
static char *user_format;
@@ -701,6 +702,22 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
case 'd':
format_decoration(sb, commit);
return 1;
+ case 'g': /* reflog info */
+ switch(placeholder[1]) {
+ case 'd': /* reflog selector */
+ case 'D':
+ if (c->pretty_ctx->reflog_info)
+ get_reflog_selector(sb,
+ c->pretty_ctx->reflog_info,
+ c->pretty_ctx->date_mode,
+ (placeholder[1] == 'd'));
+ return 2;
+ case 's': /* reflog message */
+ if (c->pretty_ctx->reflog_info)
+ get_reflog_message(sb, c->pretty_ctx->reflog_info);
+ return 2;
+ }
+ return 0; /* unknown %g placeholder */
}
/* For the rest we have to parse the commit header. */
diff --git a/reflog-walk.c b/reflog-walk.c
index 596bafe..6c6867b 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -243,15 +243,29 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
void get_reflog_selector(struct strbuf *sb,
struct reflog_walk_info *reflog_info,
- enum date_mode dmode)
+ enum date_mode dmode,
+ int shorten)
{
struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
struct reflog_info *info;
+ static const char *last_ref = NULL;
+ static char *last_short_ref = NULL;
+ const char *printed_ref;
if (!commit_reflog)
return;
- strbuf_addf(sb, "%s@{", commit_reflog->reflogs->ref);
+ if (shorten) {
+ if (last_ref != commit_reflog->reflogs->ref) {
+ free(last_short_ref);
+ last_short_ref = shorten_unambiguous_ref(commit_reflog->reflogs->ref, 0);
+ }
+ printed_ref = last_short_ref;
+ } else {
+ printed_ref = commit_reflog->reflogs->ref;
+ }
+
+ strbuf_addf(sb, "%s@{", printed_ref);
if (commit_reflog->flag || dmode) {
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
strbuf_addstr(sb, show_date(info->timestamp, info->tz, dmode));
@@ -263,6 +277,23 @@ void get_reflog_selector(struct strbuf *sb,
strbuf_addch(sb, '}');
}
+void get_reflog_message(struct strbuf *sb,
+ struct reflog_walk_info *reflog_info)
+{
+ struct commit_reflog *commit_reflog = reflog_info->last_commit_reflog;
+ struct reflog_info *info;
+ size_t len;
+
+ if (!commit_reflog)
+ return;
+
+ info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
+ len = strlen(info->message);
+ if (len > 0)
+ len--; /* strip away trailing newline */
+ strbuf_add(sb, info->message, len);
+}
+
void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
enum date_mode dmode)
{
@@ -272,7 +303,7 @@ void show_reflog_message(struct reflog_walk_info *reflog_info, int oneline,
struct strbuf selector = STRBUF_INIT;
info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
- get_reflog_selector(&selector, reflog_info, dmode);
+ get_reflog_selector(&selector, reflog_info, dmode, 0);
if (oneline) {
printf("%s: %s", selector.buf, info->message);
}
diff --git a/reflog-walk.h b/reflog-walk.h
index 74c9096..7bd2cd4 100644
--- a/reflog-walk.h
+++ b/reflog-walk.h
@@ -3,6 +3,8 @@
#include "cache.h"
+struct reflog_walk_info;
+
extern void init_reflog_walk(struct reflog_walk_info** info);
extern int add_reflog_for_walk(struct reflog_walk_info *info,
struct commit *commit, const char *name);
@@ -10,5 +12,11 @@ extern void fake_reflog_parent(struct reflog_walk_info *info,
struct commit *commit);
extern void show_reflog_message(struct reflog_walk_info *info, int,
enum date_mode);
+extern void get_reflog_message(struct strbuf *sb,
+ struct reflog_walk_info *reflog_info);
+extern void get_reflog_selector(struct strbuf *sb,
+ struct reflog_walk_info *reflog_info,
+ enum date_mode dmode,
+ int shorten);
#endif
diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
index c18ed8e..cb8d0fd 100755
--- a/t/t1411-reflog-show.sh
+++ b/t/t1411-reflog-show.sh
@@ -64,4 +64,16 @@ test_expect_success 'using --date= shows reflog date (oneline)' '
test_cmp expect actual
'
+test_expect_success '--format="%h %gD: %gs" is same as git-reflog' '
+ git reflog >expect &&
+ git log -g --format="%h %gD: %gs" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '--format="%h %gD: %gs" is same as git-reflog (with date)' '
+ git reflog --date=raw >expect &&
+ git log -g --format="%h %gD: %gs" --date=raw >actual &&
+ test_cmp expect actual
+'
+
test_done
--
1.6.5.18.g9f87a.dirty
^ permalink raw reply related
* [PATCH v2 4/5] stash list: use new %g formats instead of sed
From: Thomas Rast @ 2009-10-15 22:41 UTC (permalink / raw)
To: Jeff King, Junio C Hamano; +Cc: Jef Driesen, Nanako Shiraishi, git
In-Reply-To: <cover.1255645570.git.trast@student.ethz.ch>
With the new formats, we can rewrite 'git stash list' in terms of an
appropriate pretty format, instead of hand-editing with sed. This has
the advantage that it obeys the normal settings for git-log, notably
the pager.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
git-stash.sh | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index 4febbbf..f8847c1 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -205,8 +205,7 @@ have_stash () {
list_stash () {
have_stash || return 0
- git log --no-color --pretty=oneline -g "$@" $ref_stash -- |
- sed -n -e 's/^[.0-9a-f]* refs\///p'
+ git log --format="%gd: %gs" -g "$@" $ref_stash --
}
show_stash () {
--
1.6.5.18.g9f87a.dirty
^ permalink raw reply related
* [PATCH v2 1/5] Refactor pretty_print_commit arguments into a struct
From: Thomas Rast @ 2009-10-15 22:41 UTC (permalink / raw)
To: Jeff King, Junio C Hamano; +Cc: Jef Driesen, Nanako Shiraishi, git
In-Reply-To: <cover.1255645570.git.trast@student.ethz.ch>
pretty_print_commit() has a bunch of rarely-used arguments, and
introducing more of them requires yet another update of all the call
sites. Refactor most of them into a struct to make future extensions
easier.
The ones that stay "plain" arguments were chosen on the grounds that
all callers put real arguments there, whereas some callers have 0/NULL
for all arguments that were factored into the struct.
We declare the struct 'const' to ensure none of the callers are bitten
by the changed (no longer call-by-value) semantics.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
builtin-branch.c | 3 ++-
builtin-checkout.c | 3 ++-
builtin-log.c | 3 ++-
builtin-merge.c | 7 +++++--
builtin-rev-list.c | 7 ++++---
builtin-shortlog.c | 9 ++++++---
builtin-show-branch.c | 4 ++--
commit.h | 19 +++++++++++++------
log-tree.c | 20 ++++++++++----------
pretty.c | 27 ++++++++++++++-------------
10 files changed, 60 insertions(+), 42 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index 9f57992..05e876e 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -387,8 +387,9 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
commit = item->commit;
if (commit && !parse_commit(commit)) {
+ struct pretty_print_context ctx = {0};
pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &subject, 0, NULL, NULL, 0, 0);
+ &subject, &ctx);
sub = subject.buf;
}
diff --git a/builtin-checkout.c b/builtin-checkout.c
index d050c37..075a49f 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -302,8 +302,9 @@ static void show_local_changes(struct object *head)
static void describe_detached_head(char *msg, struct commit *commit)
{
struct strbuf sb = STRBUF_INIT;
+ struct pretty_print_context ctx = {0};
parse_commit(commit);
- pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0);
+ pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, &ctx);
fprintf(stderr, "%s %s... %s\n", msg,
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf);
strbuf_release(&sb);
diff --git a/builtin-log.c b/builtin-log.c
index 25e21ed..207a361 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -1304,8 +1304,9 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
if (verbose) {
struct strbuf buf = STRBUF_INIT;
+ struct pretty_print_context ctx = {0};
pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &buf, 0, NULL, NULL, 0, 0);
+ &buf, &ctx);
printf("%c %s %s\n", sign,
sha1_to_hex(commit->object.sha1), buf.buf);
strbuf_release(&buf);
diff --git a/builtin-merge.c b/builtin-merge.c
index b6b8428..c69a305 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -264,6 +264,7 @@ static void squash_message(void)
struct strbuf out = STRBUF_INIT;
struct commit_list *j;
int fd;
+ struct pretty_print_context ctx = {0};
printf("Squash commit -- not updating HEAD\n");
fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
@@ -285,13 +286,15 @@ static void squash_message(void)
if (prepare_revision_walk(&rev))
die("revision walk setup failed");
+ ctx.abbrev = rev.abbrev;
+ ctx.date_mode = rev.date_mode;
+
strbuf_addstr(&out, "Squashed commit of the following:\n");
while ((commit = get_revision(&rev)) != NULL) {
strbuf_addch(&out, '\n');
strbuf_addf(&out, "commit %s\n",
sha1_to_hex(commit->object.sha1));
- pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,
- NULL, NULL, rev.date_mode, 0);
+ pretty_print_commit(rev.commit_format, commit, &out, &ctx);
}
if (write(fd, out.buf, out.len) < 0)
die_errno("Writing SQUASH_MSG");
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 4ba1c12..42cc8d8 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -96,9 +96,10 @@ static void show_commit(struct commit *commit, void *data)
if (revs->verbose_header && commit->buffer) {
struct strbuf buf = STRBUF_INIT;
- pretty_print_commit(revs->commit_format, commit,
- &buf, revs->abbrev, NULL, NULL,
- revs->date_mode, 0);
+ struct pretty_print_context ctx = {0};
+ ctx.abbrev = revs->abbrev;
+ ctx.date_mode = revs->date_mode;
+ pretty_print_commit(revs->commit_format, commit, &buf, &ctx);
if (revs->graph) {
if (buf.len) {
if (revs->commit_format != CMIT_FMT_ONELINE)
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 4d4a3c8..8aa63c7 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -158,9 +158,12 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
sha1_to_hex(commit->object.sha1));
if (log->user_format) {
struct strbuf buf = STRBUF_INIT;
-
- pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
- DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
+ struct pretty_print_context ctx = {0};
+ ctx.abbrev = DEFAULT_ABBREV;
+ ctx.subject = "";
+ ctx.after_subject = "";
+ ctx.date_mode = DATE_NORMAL;
+ pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf, &ctx);
insert_one_record(log, author, buf.buf);
strbuf_release(&buf);
return;
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index be95930..9f13caa 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -293,8 +293,8 @@ static void show_one_commit(struct commit *commit, int no_name)
struct commit_name *name = commit->util;
if (commit->object.parsed) {
- pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &pretty, 0, NULL, NULL, 0, 0);
+ struct pretty_print_context ctx = {0};
+ pretty_print_commit(CMIT_FMT_ONELINE, commit, &pretty, &ctx);
pretty_str = pretty.buf;
}
if (!prefixcmp(pretty_str, "[PATCH] "))
diff --git a/commit.h b/commit.h
index f4fc5c5..011766d 100644
--- a/commit.h
+++ b/commit.h
@@ -63,6 +63,15 @@ enum cmit_fmt {
CMIT_FMT_UNSPECIFIED,
};
+struct pretty_print_context
+{
+ int abbrev;
+ const char *subject;
+ const char *after_subject;
+ enum date_mode date_mode;
+ int need_8bit_cte;
+};
+
extern int non_ascii(int);
extern int has_non_ascii(const char *text);
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
@@ -71,12 +80,10 @@ enum cmit_fmt {
extern void get_commit_format(const char *arg, struct rev_info *);
extern void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb,
- enum date_mode dmode);
-extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,
- struct strbuf *,
- int abbrev, const char *subject,
- const char *after_subject, enum date_mode,
- int need_8bit_cte);
+ const struct pretty_print_context *context);
+extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
+ struct strbuf *sb,
+ const struct pretty_print_context *context);
void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
const char *line, enum date_mode dmode,
const char *encoding);
diff --git a/log-tree.c b/log-tree.c
index f7d54f2..f57487f 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -277,10 +277,9 @@ void show_log(struct rev_info *opt)
struct strbuf msgbuf = STRBUF_INIT;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
- int abbrev = opt->diffopt.abbrev;
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
- const char *subject = NULL, *extra_headers = opt->extra_headers;
- int need_8bit_cte = 0;
+ const char *extra_headers = opt->extra_headers;
+ struct pretty_print_context ctx = {0};
opt->loginfo = NULL;
if (!opt->verbose_header) {
@@ -347,8 +346,8 @@ void show_log(struct rev_info *opt)
*/
if (opt->commit_format == CMIT_FMT_EMAIL) {
- log_write_email_headers(opt, commit, &subject, &extra_headers,
- &need_8bit_cte);
+ log_write_email_headers(opt, commit, &ctx.subject, &extra_headers,
+ &ctx.need_8bit_cte);
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
if (opt->commit_format != CMIT_FMT_ONELINE)
@@ -405,11 +404,12 @@ void show_log(struct rev_info *opt)
/*
* And then the pretty-printed message itself
*/
- if (need_8bit_cte >= 0)
- need_8bit_cte = has_non_ascii(opt->add_signoff);
- pretty_print_commit(opt->commit_format, commit, &msgbuf,
- abbrev, subject, extra_headers, opt->date_mode,
- need_8bit_cte);
+ if (ctx.need_8bit_cte >= 0)
+ ctx.need_8bit_cte = has_non_ascii(opt->add_signoff);
+ ctx.date_mode = opt->date_mode;
+ ctx.abbrev = opt->diffopt.abbrev;
+ ctx.after_subject = extra_headers;
+ pretty_print_commit(opt->commit_format, commit, &msgbuf, &ctx);
if (opt->add_signoff)
append_signoff(&msgbuf, opt->add_signoff);
diff --git a/pretty.c b/pretty.c
index f5983f8..d6d57eb 100644
--- a/pretty.c
+++ b/pretty.c
@@ -442,7 +442,7 @@ struct chunk {
struct format_commit_context {
const struct commit *commit;
- enum date_mode dmode;
+ const struct pretty_print_context *pretty_ctx;
unsigned commit_header_parsed:1;
unsigned commit_message_parsed:1;
@@ -711,11 +711,11 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
case 'a': /* author ... */
return format_person_part(sb, placeholder[1],
msg + c->author.off, c->author.len,
- c->dmode);
+ c->pretty_ctx->date_mode);
case 'c': /* committer ... */
return format_person_part(sb, placeholder[1],
msg + c->committer.off, c->committer.len,
- c->dmode);
+ c->pretty_ctx->date_mode);
case 'e': /* encoding */
strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
return 1;
@@ -741,13 +741,13 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb,
- enum date_mode dmode)
+ const struct pretty_print_context *pretty_ctx)
{
struct format_commit_context context;
memset(&context, 0, sizeof(context));
context.commit = commit;
- context.dmode = dmode;
+ context.pretty_ctx = pretty_ctx;
strbuf_expand(sb, format, format_commit_item, &context);
}
@@ -900,18 +900,18 @@ void pp_remainder(enum cmit_fmt fmt,
}
void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
- struct strbuf *sb, int abbrev,
- const char *subject, const char *after_subject,
- enum date_mode dmode, int need_8bit_cte)
+ struct strbuf *sb,
+ const struct pretty_print_context *context)
{
unsigned long beginning_of_body;
int indent = 4;
const char *msg = commit->buffer;
char *reencoded;
const char *encoding;
+ int need_8bit_cte = context->need_8bit_cte;
if (fmt == CMIT_FMT_USERFORMAT) {
- format_commit_message(commit, user_format, sb, dmode);
+ format_commit_message(commit, user_format, sb, context);
return;
}
@@ -946,8 +946,9 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
}
}
- pp_header(fmt, abbrev, dmode, encoding, commit, &msg, sb);
- if (fmt != CMIT_FMT_ONELINE && !subject) {
+ pp_header(fmt, context->abbrev, context->date_mode, encoding,
+ commit, &msg, sb);
+ if (fmt != CMIT_FMT_ONELINE && !context->subject) {
strbuf_addch(sb, '\n');
}
@@ -956,8 +957,8 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
/* These formats treat the title line specially. */
if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL)
- pp_title_line(fmt, &msg, sb, subject,
- after_subject, encoding, need_8bit_cte);
+ pp_title_line(fmt, &msg, sb, context->subject,
+ context->after_subject, encoding, need_8bit_cte);
beginning_of_body = sb->len;
if (fmt != CMIT_FMT_ONELINE)
--
1.6.5.18.g9f87a.dirty
^ permalink raw reply related
* [PATCH v2 5/5] stash list: drop the default limit of 10 stashes
From: Thomas Rast @ 2009-10-15 22:41 UTC (permalink / raw)
To: Jeff King, Junio C Hamano; +Cc: Jef Driesen, Nanako Shiraishi, git
In-Reply-To: <cover.1255645570.git.trast@student.ethz.ch>
'git stash list' had an undocumented limit of 10 stashes, unless other
git-log arguments were specified. This surprised at least one user,
but possibly served to cut the output below a screenful without using
a pager.
Since the last commit, 'git stash list' will fire up a pager according
to the same rules as the 'git log' it calls, so we can drop the limit.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
git-stash.sh | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/git-stash.sh b/git-stash.sh
index f8847c1..f796c2f 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -382,11 +382,6 @@ test -n "$seen_non_option" || set "save" "$@"
case "$1" in
list)
shift
- if test $# = 0
- then
- set x -n 10
- shift
- fi
list_stash "$@"
;;
show)
--
1.6.5.18.g9f87a.dirty
^ permalink raw reply related
* [PATCH v2 0/5] Pretty formats for reflog data
From: Thomas Rast @ 2009-10-15 22:41 UTC (permalink / raw)
To: Jeff King, Junio C Hamano; +Cc: Jef Driesen, Nanako Shiraishi, git
In-Reply-To: <20091014050645.GD31810@coredump.intra.peff.net>
Jeff King wrote:
> Maybe a better solution would be a "short name" variant for pretty
> format specifiers. We already have %(refname) and %(refname:short) [...]
> The tricky part would be deciding on a syntax. This seems to come up a
> fair bit.
Ok, I settled for %g[dDs] for now to save on letters. I'm saving the
syntax question for a later series while we discuss this one ;-)
I think going for %(...) wouldn't be too bad since we already have
that in for-each-ref, and it can be backwards compatible. So we would
have different sets of short and long specifiers, e.g.
%ae = %(authoremail)
%aE = %(authoremail:mailmap)
We can then pass arguments via some yet-to-be decided syntax, say,
%(body:indent(10)).
Other changes in this version include:
* I followed your struct suggestion, which is the new 1/5.
* Since the shortening can be handled by %gd, the old 5/5 (change from
refs/stash to only stash) is no longer needed.
* I fixed the warning that Junio found (and finally found the right
combination of -W flags, though I cannot compile with -Werror myself
because of *other* warnings...)
I also added tests and docs to the main patch (now 3/5).
Thomas Rast (5):
Refactor pretty_print_commit arguments into a struct
reflog-walk: refactor the branch@{num} formatting
Introduce new pretty formats %g[sdD] for reflog information
stash list: use new %g formats instead of sed
stash list: drop the default limit of 10 stashes
Documentation/pretty-formats.txt | 3 +
builtin-branch.c | 3 +-
builtin-checkout.c | 3 +-
builtin-log.c | 3 +-
builtin-merge.c | 7 ++-
builtin-rev-list.c | 7 ++-
builtin-shortlog.c | 9 +++-
builtin-show-branch.c | 4 +-
commit.h | 20 ++++++---
git-stash.sh | 8 +---
log-tree.c | 21 +++++----
pretty.c | 44 ++++++++++++++------
reflog-walk.c | 85 ++++++++++++++++++++++++++++----------
reflog-walk.h | 8 ++++
t/t1411-reflog-show.sh | 12 +++++
15 files changed, 166 insertions(+), 71 deletions(-)
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Jeff King @ 2009-10-15 22:17 UTC (permalink / raw)
To: Junio C Hamano
Cc: Nicolas Pitre, James Pickens, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <20091015221657.GC13180@coredump.intra.peff.net>
On Thu, Oct 15, 2009 at 06:16:57PM -0400, Jeff King wrote:
> So I will buy that this is somewhat of a new idea. I am still confused
> about what happens with this, though:
>
> $ git checkout origin/next
> $ git fetch ;# updates origin/next
>
> Do we refuse the fetch? Does the user now have a working tree and index
> that doesn't match their HEAD?
OK, nevermind about this, we just crossed emails.
-Peff
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Jeff King @ 2009-10-15 22:16 UTC (permalink / raw)
To: Junio C Hamano
Cc: Nicolas Pitre, James Pickens, Daniel Barkalow, Jay Soffian, git
In-Reply-To: <7v1vl42uid.fsf@alter.siamese.dyndns.org>
On Thu, Oct 15, 2009 at 02:54:18PM -0700, Junio C Hamano wrote:
> Maybe we are reading different messages in the same message.
>
> My understanding of James's suggestion is:
>
> (1) "git checkout $token" makes HEAD point at the refname dwim_ref()
> expands $token to, iff dwim_ref() is happy, and otherwise detaches
> HEAD;
>
> (2) "git commit" (and other things like "git reset HEAD^" that updates
> underlying ref thru updates to HEAD when HEAD is a symref) rejects
> when HEAD points at a ref outside refs/heads/, but works when HEAD
> points at a local branch, or when HEAD is detached.
Right. I thought the idea of "don't complain at checkout time, but
complain at commit" had been considered and rejected. But I guess you
could argue that the difference between this and the original discussion
is that we are going to have _both_ the detached HEAD state and the
"refs/tags/* in HEAD" state, and treat them differently.
I feel like the latter idea was discussed in more detail (I made
reference to it in the latter email I linked to, but I don't think that
was the origin of it), but I can't seem to find any discussion.
So I will buy that this is somewhat of a new idea. I am still confused
about what happens with this, though:
$ git checkout origin/next
$ git fetch ;# updates origin/next
Do we refuse the fetch? Does the user now have a working tree and index
that doesn't match their HEAD?
> This is backward incompatible, and makes what experts are used to do
> slightly cumbersome to spell, i.e.
>
> $ git checkout v1.6.5^0 ;# detaches and can commit
> $ git checkout origin/next^0 ;# ditto
> $ git checkout $(git merge-base master sp/smart-http) ;# ditto
I think it is less cumbersome if we add "git checkout -d v1.6.5" (well,
same number of characters, but a lot less ugly). Assuming that the rest
of it is a good idea.
-Peff
^ permalink raw reply
* Re: [PATCH] Proof-of-concept patch to remember what the detached HEAD was
From: Junio C Hamano @ 2009-10-15 22:08 UTC (permalink / raw)
To: Junio C Hamano
Cc: Jeff King, Nicolas Pitre, James Pickens, Daniel Barkalow,
Jay Soffian, git
In-Reply-To: <7v1vl42uid.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> $ git checkout origin/next ;# ditto
> $ git symbolic-ref HEAD
> refs/remotes/origin/next
Ok, after reading Daniel's message to remind us that "git fetch" after
this will get us into trouble, I agree that detaching HEAD is inevitable.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox