* Re: What's in git.git (stable frozen)
From: Jeff King @ 2008-01-06 4:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v63y8ble8.fsf@gitster.siamese.dyndns.org>
On Sat, Jan 05, 2008 at 02:46:07AM -0800, Junio C Hamano wrote:
> * Jeff's git-add--interactive change to always honor color.diff
> regardless of color.interactive.
>
> I'd probably apply this, along with the patch to redefine
> what color.interactive means. "git am -i" could also learn
> to use colors in the future.
>
> Incidentally I noticed that many of the color.diff.* palette
> options are read by "git-add -i" but never used by the
> script. We might want to fix this while we are at it.
Here is the palette cleanup patch, on top of my others (it should still
be done even if the other patches aren't taken, but backporting it
should be fairly obvious).
-- >8 --
add--interactive: remove unused diff colors
When color support was added, we colored the diffs
ourselves. However, 4af756f3 changed this to simply run
"git diff-files" twice, keeping the colored output
separately.
This makes the internal diff color variables obsolete with
one exception: when splitting hunks, we have to manually
recreate the fragment for each part of the split. Thus we
keep $fraginfo_color around to do that correctly.
Signed-off-by: Jeff King <peff@peff.net>
---
git-add--interactive.perl | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index aaa9b24..5bdcca8 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -6,7 +6,7 @@ use Git;
# Prompt colors:
my ($prompt_color, $header_color, $help_color, $normal_color);
# Diff colors:
-my ($new_color, $old_color, $fraginfo_color, $metainfo_color, $whitespace_color);
+my ($fraginfo_color);
my ($use_color, $diff_use_color);
my $repo = Git->repository();
@@ -27,11 +27,7 @@ if ($use_color) {
# Do we also set diff colors?
$diff_use_color = $repo->get_colorbool('color.diff');
if ($diff_use_color) {
- $new_color = $repo->get_color("color.diff.new", "green");
- $old_color = $repo->get_color("color.diff.old", "red");
$fraginfo_color = $repo->get_color("color.diff.frag", "cyan");
- $metainfo_color = $repo->get_color("color.diff.meta", "bold");
- $whitespace_color = $repo->get_color("color.diff.whitespace", "normal red");
}
sub colored {
--
1.5.4.rc2.1147.gaecdf-dirty
^ permalink raw reply related
* Re: [RFH] On a script for submodules
From: Imran M Yousuf @ 2008-01-06 4:06 UTC (permalink / raw)
To: git
In-Reply-To: <7bfdc29a0801030152t25de6889wc21b9c933f5b9ab9@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2852 bytes --]
Hi All,
I updated the script to do git submodule init and update if not done
already while recursing; fixed some issues and converted it into sh
script from bash. Hopefully by tomorrow I will be email a merge of
this script with git submodule by adding a recurse command in addition
to the ones existing and also add a parameter --init-submodules to the
git-clone command so that when cloning the git submodule init and git
submodule update is done internally.
I would be grateful if you would kindly provide your feedback.
Best regards,
Imran
On Jan 3, 2008 3:52 PM, Imran M Yousuf <imyousuf@gmail.com> wrote:
> Hi all,
>
> Sorry for referring to the blog. I am writing the details here again
> and also attached the script in the email.
>
> I am fairly a new git user; I started working around with GIT on
> Framework development project and I noticed that GIT commands executed
> on the parent module is not propagated to the child modules. In some
> use cases it would be extremely useful (at least for me) to be able to
> be propagate a command from the master module to all its child at all
> depth. I wrote the bash shell script (in the attachment) to simply
> propagate commands from parent to its child. To use this script one
> can simply do the following (I am assuming that the file will have the
> name git-modules and will be an executable in $PATH):
>
> for: git-pull
> do: git-modules pull
>
> for: git-status
> do: git-modules status
>
> for: git-commit -a -m "This is a test commit"
> do: git-modules commit -a -m "This is a test commit"
>
> for: git-checkout master
> do: git-modules checkout master
>
> Basically any git-X command can be simply be done as "git-modules X
> args-as-usual".
>
> It is mainly different from the git-submodule command in its usage. I
> mainly wrote it to propagate commands. It could be extended for
> further usage as well.
>
> I would really appreciate and welcome criticism, feedback and addition
> to the script.
>
> Thank you,
>
> On Jan 3, 2008 3:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> > "Imran M Yousuf" <imyousuf@gmail.com> writes:
> >
> > > ... I would really appreciate if someone would take their time to
> > > suggest me improvements. I would also like to get some feedbacks as
> > > what else could be added here. A brief description can be found in the
> > > following posting.
> >
> > Around here, it is customary to have discussion on-list, not
> > pointing at external web pages and repositories. I would
> > suggest starting by stating what the overall design is and how
> > it meshes with existing git-submodule command and its design.
> >
> >
> >
>
>
>
> --
> Imran M Yousuf
>
--
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: imran@smartitengineering.com
Mobile: +880-1711402557
[-- Attachment #2: git-modules --]
[-- Type: application/octet-stream, Size: 1595 bytes --]
#!/bin/sh
ARGS=1
if [ $# -lt "$ARGS" ]; then
echo Not enough arguments.
echo Example \"\<this script\> status\" for \"git-status\" - git-modules status
exit 65;
fi
initializeSubModule() {
if [ ! -d "$1"/.git ]; then
echo Initializing and updating "$1"
git-submodule init "$1"; git-submodule update "$1"
fi
}
traverseModule() {
current_dir=`pwd`
dir_path="$current_dir:$dir_path"
initializeSubModule "$1"
cd "$1"
echo Working in mod $1 @ `pwd` with $2
eval "$2"
if [ -f .gitmodules ]; then
for mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
traverseModule "$mod_path" "$2"
done
fi
old_dir=$(echo $dir_path | cut -d':' -f1-1)
length_old_dir=`expr "$old_dir" : '.*'`
cd $old_dir
index=$(echo "$length_old_dir+2" | bc)
dir_path=`echo $dir_path $index | awk '{print substr($1, $2)}'`
}
propagate() {
project_home=`pwd`
echo Project Home: $project_home
if [ -d $project_home/.git/ ]; then
git_command=$1
shift
command_arguments=""
for arg in "$@"; do
if [ `expr index "$arg" ' '` -gt 0 ]; then
arg="\"$arg\""
fi
command_arguments="$command_arguments $arg"
done
echo GIT Command git-$git_command with arguments\($#\) "$command_arguments"
main_command="git-$git_command $command_arguments"
eval $main_command
if [ -f .gitmodules ]; then
for mod_path in `grep "path =" .gitmodules | awk '{print $3}'`; do
traverseModule $mod_path "$main_command"
done
fi
else
echo $project_home not a git repo thus exiting
exit
fi
}
propagate "$@"
^ permalink raw reply
* Re: how to use git merge -s subtree?
From: Miklos Vajna @ 2008-01-06 3:45 UTC (permalink / raw)
To: Sean; +Cc: git
In-Reply-To: <BAYC1-PASMTP12374B54BA370A1E1C6E78AE4E0@CEZ.ICE>
[-- Attachment #1: Type: text/plain, Size: 881 bytes --]
On Sat, Jan 05, 2008 at 08:17:40PM -0500, Sean <seanlkml@sympatico.ca> wrote:
> Here's another way that is perhaps a little cleaner:
>
> $ git remote add -f B /path/to/B
> $ git merge -s ours --no-commit B/master
> $ git read-tree --prefix=sub/ -u B/master
> $ git commit -m "subtree merged B"
>
> The first line creates and fetches the remote. The second line initiates a merge, but
> stops before committing it. The third line reads B/master into the subdirectory "sub",
> at which point all that remains is committing the completed merge.
great, thanks. that's more simple than mine, and this is necessary for
the first commit only. the rest (i hope i'm right) can be done using
just by
$ git fetch
$ git merge -s subtree B/master
do you mind if i send a patch to add this to Documentation/howto? i
don't think it's trivial :)
thanks,
- VMiklos
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* Re: What's in git.git (stable frozen)
From: Dan McGee @ 2008-01-06 3:08 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Tsugikazu Shibata, Marco Costalba, Jeff King, Dmitry Potapov
In-Reply-To: <7vy7b364aw.fsf@gitster.siamese.dyndns.org>
On Jan 5, 2008 9:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> >> I've updated the patch a bit as I noticed I completely missed the
> >> user-manual.txt and a handful of other files that weren't named
> >> git-*.txt. The new version is attached (gzipped).
> >
> > The asciidoc.conf change I resurrected from the earlier one but
> > it appears this breaks build with asciidoc 7.1.2 for some reason
> > (I haven't looked into that myself yet, and I won't be for the
> > next 12 hours or so).
>
> Ah, I spoke too fast. I think I need to first do a clean-up
> patch to fix "gitlink::foobar[1]" that should have been spelled
> as "gitlink:foobar[1]" in a few places, and your change is good.
It looks like I still blew it and forgot the changes in asciidoc.conf
in the second patch, sorry about that. Let me know if you need
anything more, although this patch is pretty straightforward (once I
spent 3 hours trying to figure out why it was broken in the first
place and attempting to find a more sane way around it).
-Dan
^ permalink raw reply
* Re: What's in git.git (stable frozen)
From: Junio C Hamano @ 2008-01-06 3:06 UTC (permalink / raw)
To: Dan McGee
Cc: git, Tsugikazu Shibata, Marco Costalba, Jeff King, Dmitry Potapov
In-Reply-To: <7v4pdr7jco.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
>> I've updated the patch a bit as I noticed I completely missed the
>> user-manual.txt and a handful of other files that weren't named
>> git-*.txt. The new version is attached (gzipped).
>
> The asciidoc.conf change I resurrected from the earlier one but
> it appears this breaks build with asciidoc 7.1.2 for some reason
> (I haven't looked into that myself yet, and I won't be for the
> next 12 hours or so).
Ah, I spoke too fast. I think I need to first do a clean-up
patch to fix "gitlink::foobar[1]" that should have been spelled
as "gitlink:foobar[1]" in a few places, and your change is good.
^ permalink raw reply
* Re: What's in git.git (stable frozen)
From: Junio C Hamano @ 2008-01-06 2:56 UTC (permalink / raw)
To: Dan McGee
Cc: git, Tsugikazu Shibata, Marco Costalba, Jeff King, Dmitry Potapov
In-Reply-To: <449c10960801051321g785e45e3v8f7b129bb087e1ca@mail.gmail.com>
"Dan McGee" <dpmcgee@gmail.com> writes:
> On Jan 5, 2008 4:46 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> We are not at -rc3 yet, but we will be soon. What we have
>> accumulated in 'master' are mostly fixes, and the official
>> git-gui 0.9.1 is also included tonight.
>> * Dan McGee's workaround to breakage caused by changes in
>> AsciiDoc 8.2.3.
>>
>> I have to do my usual "before-and-after comparison" with
>> copies of AsciiDoc versions that should not be affected by
>> the breakage, which I did not have time to do so far. But
>> this is probably a must-have before the release.
>
> I've updated the patch a bit as I noticed I completely missed the
> user-manual.txt and a handful of other files that weren't named
> git-*.txt. The new version is attached (gzipped).
The asciidoc.conf change I resurrected from the earlier one but
it appears this breaks build with asciidoc 7.1.2 for some reason
(I haven't looked into that myself yet, and I won't be for the
next 12 hours or so).
^ permalink raw reply
* Re: [PATCH 2/2] filter-branch: work correctly with ambiguous refnames
From: Junio C Hamano @ 2008-01-06 2:53 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Dmitry Potapov, git
In-Reply-To: <alpine.LSU.1.00.0801060154150.10101@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> In any case, from a cursory look I like the 2 patches (except for the
> curly brackets around the single-line "else" clause, but I know your
> opinion about this, so I will not object).
I care more about consistency across codebase than my own
preference [*1*]. I just picked the style the kernel folks seem
to use (see their Documentation/CodingStyle), only because (1)
there seem to be people familiar with it, and (2) I am not
particularly interested myself in wasting time arguing over
which style is superiour. I just had to pick one and that was
the one I happened to have at hand.
And obviously I care more about correctness, so I'd appreciate a
review with non cursory look if you have time.
[Footnote]
*1* I favoring shorter code over consistency between when-true
and when-false clauses. IOW, I do not like having to have {}
around a single statement in else clause when if clause needs {}
around it.
^ permalink raw reply
* Re: how to use git merge -s subtree?
From: Junio C Hamano @ 2008-01-06 2:42 UTC (permalink / raw)
To: David Soria Parra; +Cc: Sean, git
In-Reply-To: <47803CB6.4050102@gmx.net>
David Soria Parra <sn_@gmx.net> writes:
> Well yes the history is preserved, but it's not connected to the
> subdirectory. So you cannot do git-log B/foo.c as git doesnot know where
> to search it as it thinks
> it is in /foo.c not in B/foo.c
The thing is, what you are talking is not about the subtree
merge strategy, but the fundamental philosophy of git. Asking
for "the history of file B/foo.c" does not make any sense, as
git never tracks history of individual files.
I'll point you to one of the most important messages in the
whole archive of the git mailing list.
http://thread.gmane.org/gmane.comp.version-control.git/27/focus=217
^ permalink raw reply
* Re: how to use git merge -s subtree?
From: David Soria Parra @ 2008-01-06 2:28 UTC (permalink / raw)
To: Sean; +Cc: git
In-Reply-To: <BAYC1-PASMTP01FC193EA959D148F19374AE4E0@CEZ.ICE>
Sean wrote:
>
> David,
>
> Yes, the reason to start with the "--no-commit" merge is so that the history
> is properly connected once you do the final commit step. However, I should
> have noted in my original message that none of the steps actually use the
> subtree merge. Instead they simply prepare a repository such that
> future merging can be done with:
>
> $ git merge -s subtree B/master.
>
> Cheers,
> Sean
Well yes the history is preserved, but it's not connected to the
subdirectory. So you cannot do git-log B/foo.c as git doesnot know where
to search it as it thinks
it is in /foo.c not in B/foo.c
Cheers
^ permalink raw reply
* Re: [PATCH] Test "git log --diff-filter"
From: Junio C Hamano @ 2008-01-06 2:26 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, Arjen Laarhoven
In-Reply-To: <200801060033.03672.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> My test checks all --diff-filter filters relevant to git-diff-tree,
> i.e. ADMRCBT, and not only AMD.
Ah, I see. Thanks --- that could have been stated in the log
message. Maybe we would want to add them to existing test
script, instead of adding a whole new one?
> P.S. By the way, it is IMHO a bit strange that --pretty=oneline uses
> newline as a terminator (it means that there is a newline at the end of
> "git log --pretty=oneline), while --pretty="format:%s" uses newline as
> a separator...
Yeah, I tend to agree, although I learned to live with it long
time ago.
^ permalink raw reply
* Re: how to use git merge -s subtree?
From: Sean @ 2008-01-06 2:13 UTC (permalink / raw)
To: David Soria Parra; +Cc: git
In-Reply-To: <flpah7$beg$2@ger.gmane.org>
On Sun, 06 Jan 2008 02:22:47 +0100
David Soria Parra <sn_@gmx.net> wrote:
> > Here's another way that is perhaps a little cleaner:
> >
> > $ git remote add -f B /path/to/B
> > $ git merge -s ours --no-commit B/master
> > $ git read-tree --prefix=sub/ -u B/master
> > $ git commit -m "subtree merged B"
>
> that works perfectly but it doesn't preserve the history, does it?
David,
Yes, the reason to start with the "--no-commit" merge is so that the history
is properly connected once you do the final commit step. However, I should
have noted in my original message that none of the steps actually use the
subtree merge. Instead they simply prepare a repository such that
future merging can be done with:
$ git merge -s subtree B/master.
Cheers,
Sean
^ permalink raw reply
* Re: [PATCH 2/2] filter-branch: work correctly with ambiguous refnames
From: Johannes Schindelin @ 2008-01-06 1:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Dmitry Potapov, git
In-Reply-To: <7vabnk81aw.fsf_-_@gitster.siamese.dyndns.org>
Hi,
On Sat, 5 Jan 2008, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > Junio wrote:
> >
> >> But at that point I would say that exposing the refname dwimming
> >> logic to the scripts could be a much cleaner solution.
> >
> > I considered that when ripping the script from cogito, but it seemed
> > to me at that time that not requiring an up-to-date git for testing
> > the script would be better.
> >
> > Now is a different situation, however, so I agree.
>
> It was already tied to the specific git version when
> git-filter-branch became part of git.git ;-)
Heh. But that was not my intention (at least _before_ it was in git.git's
"master"), so that people could test it.
> I do not use filter-branch myself very often, but I think this
> is worth fixing. The additional --no-flags and sed are to deal
> with something like:
>
> --topo-order master..next
>
> although I do not offhand know if filter-branch would work with
> things like --topo-order and --first-parent.
Frankly, I have no idea, but --topo-order _should_ not matter, whereas
--first-parent _should_ rewrite only commits in the first-parent chain of
the given refs.
In any case, from a cursory look I like the 2 patches (except for the
curly brackets around the single-line "else" clause, but I know your
opinion about this, so I will not object).
Ciao,
Dscho
^ permalink raw reply
* Re: How to bypass the post-commit hook?
From: Pascal Obry @ 2007-12-31 9:50 UTC (permalink / raw)
To: Jan Hudec; +Cc: Ping Yin, Git Mailing List
In-Reply-To: <20071230215008.GB20098@efreet.light.src>
Jan Hudec a écrit :
> By the way, what is your post-commit hook doing anyway? Modifying the work
> tree *after* a commit does not sound like a common thing to do.
Or just trigger a build via a built robot or record a commit information
into an issue tracker...
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
* Re: how to use git merge -s subtree?
From: David Soria Parra @ 2008-01-06 1:22 UTC (permalink / raw)
To: git
In-Reply-To: <BAYC1-PASMTP12374B54BA370A1E1C6E78AE4E0@CEZ.ICE>
> Hi Miklos,
>
> Here's another way that is perhaps a little cleaner:
>
> $ git remote add -f B /path/to/B
> $ git merge -s ours --no-commit B/master
> $ git read-tree --prefix=sub/ -u B/master
> $ git commit -m "subtree merged B"
>
hi sean,
that works perfectly but it doesn't preserve the history, does it?
dsp
^ permalink raw reply
* Re: how to use git merge -s subtree?
From: David Soria Parra @ 2008-01-06 1:20 UTC (permalink / raw)
To: git
In-Reply-To: <20080105230004.GY29972@genesis.frugalware.org>
As said in IRC, subtree is not made for that as far is a understand.
Quite frankly the given workflow doesnot work for me as subtree imports
the things into some directory that it was not supposed to merge it into
(x/z/ instead of B).
dsp
^ permalink raw reply
* Re: how to use git merge -s subtree?
From: Sean @ 2008-01-06 1:17 UTC (permalink / raw)
To: Miklos Vajna; +Cc: git
In-Reply-To: <20080105230004.GY29972@genesis.frugalware.org>
On Sun, 6 Jan 2008 00:00:04 +0100
Miklos Vajna <vmiklos@frugalware.org> wrote:
> i recently noticed that the subtree merge strategy is missing from
> merge-strategies.txt an i tried to first figure out how it works. i got
> it to work, but i'm not 100% sure about i'm using it the way i'm
> supposed to.
>
> here is what i do:
>
> 1) git remote add B /path/to/B.git
> 2) git fetch
> 3) mkdir B
> 4) touch B/.gitignore
> 5) git add B/.gitignore
> 6) git commit -m "add empty B directory"
> 7) git merge -s subtree B/master
>
> and yes, it works pretty well, but is this the right way? or is it
> possible to somehow avoid steps 3..6?
>
Hi Miklos,
Here's another way that is perhaps a little cleaner:
$ git remote add -f B /path/to/B
$ git merge -s ours --no-commit B/master
$ git read-tree --prefix=sub/ -u B/master
$ git commit -m "subtree merged B"
The first line creates and fetches the remote. The second line initiates a merge, but
stops before committing it. The third line reads B/master into the subdirectory "sub",
at which point all that remains is committing the completed merge.
HTH,
Sean
^ permalink raw reply
* [PATCH] Avoid a useless prefix lookup in strbuf_expand()
From: Marco Costalba @ 2008-01-06 0:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List, René Scharfe
[-- Attachment #1: Type: text/plain, Size: 12231 bytes --]
Currently the --prett=format prefix is looked up in a
tight loop in strbuf_expand(), if found is passed as parameter
to format_commit_item() that does another search using a
switch statement to select the proper operation according to
the kind of prefix.
Because the switch statement is already able to discard unknown
matches we don't need the prefix lookup before to call format_commit_item()
This patch removes an useless loop in a very fasth path,
used by, as example, by 'git log' with --pretty=format option
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
To apply on top of "[PATCH] Fix an off by one bug in pretty.c"
I send also as attached file because I thing my mailer will
word wrap this one.
pretty.c | 228 +++++++++++++++++++++++++++++--------------------------------
strbuf.c | 19 ++---
strbuf.h | 4 +-
3 files changed, 118 insertions(+), 133 deletions(-)
diff --git a/pretty.c b/pretty.c
index 3ce5e6f..5132b1f 100644
--- a/pretty.c
+++ b/pretty.c
@@ -282,76 +282,93 @@ static char *logmsg_reencode(const struct
return out;
}
-static void format_person_part(struct strbuf *sb, char part,
- const char *msg, int len)
+static int parse_tz(char *ep, const char *msg, int len) {
+
+ int tz = 0, start = ep - msg + 1;
+
+ for ( ;start < len && isspace(msg[start]); start++)
+ ; /* do nothing */
+
+ if (start + 1 < len) {
+ tz = strtoul(msg + start + 1, NULL, 10);
+ if (msg[start] == '-')
+ tz = -tz;
+ }
+ return tz;
+}
+
+static size_t format_person_part(struct strbuf *sb, char part,
+ const char *msg, int len)
{
- int start, end, tz = 0;
- unsigned long date;
+ int start, end, tz = 0, date_valid;
+ unsigned long date = 0;
char *ep;
- /* parse name */
+ /* advance 'end' to point to name end delimiter */
for (end = 0; end < len && msg[end] != '<'; end++)
; /* do nothing */
- start = end + 1;
- while (end > 0 && isspace(msg[end - 1]))
- end--;
- if (part == 'n') { /* name */
+
+ if (part == 'n') { /* name */
+ while (end > 0 && isspace(msg[end - 1]))
+ end--;
+
strbuf_add(sb, msg, end);
- return;
+ return 2;
}
+ start = ++end; /* save email start delimiter */
- if (start >= len)
- return;
-
- /* parse email */
- for (end = start; end < len && msg[end] != '>'; end++)
+ /* advance 'end' to point to email end delimiter */
+ for ( ; end < len && msg[end] != '>'; end++)
; /* do nothing */
- if (end >= len)
- return;
-
- if (part == 'e') { /* email */
- strbuf_add(sb, msg + start, end - start);
- return;
+ if (part == 'e') { /* email */
+ if (end - start > 0)
+ strbuf_add(sb, msg + start, end - start);
+ return 2;
}
- /* parse date */
+ /* advance 'start' to point to date start delimiter */
for (start = end + 1; start < len && isspace(msg[start]); start++)
; /* do nothing */
- if (start >= len)
- return;
- date = strtoul(msg + start, &ep, 10);
- if (msg + start == ep)
- return;
- if (part == 't') { /* date, UNIX timestamp */
- strbuf_add(sb, msg + start, ep - (msg + start));
- return;
- }
+ date_valid = start < len;
- /* parse tz */
- for (start = ep - msg + 1; start < len && isspace(msg[start]); start++)
- ; /* do nothing */
- if (start + 1 < len) {
- tz = strtoul(msg + start + 1, NULL, 10);
- if (msg[start] == '-')
- tz = -tz;
+ if (date_valid)
+ date = strtoul(msg + start, &ep, 10);
+
+ if (part == 't') { /* date, UNIX timestamp */
+ if (date_valid && msg + start != ep)
+ strbuf_add(sb, msg + start, ep - (msg + start));
+ return 2;
}
switch (part) {
- case 'd': /* date */
- strbuf_addstr(sb, show_date(date, tz, DATE_NORMAL));
- return;
- case 'D': /* date, RFC2822 style */
- strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822));
- return;
- case 'r': /* date, relative */
- strbuf_addstr(sb, show_date(date, tz, DATE_RELATIVE));
- return;
- case 'i': /* date, ISO 8601 */
- strbuf_addstr(sb, show_date(date, tz, DATE_ISO8601));
- return;
+ case 'd': /* date */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_NORMAL));
+ }
+ return 2;
+ case 'D': /* date, RFC2822 style */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822));
+ }
+ return 2;
+ case 'r': /* date, relative */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_RELATIVE));
+ }
+ return 2;
+ case 'i': /* date, ISO 8601 */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_ISO8601));
+ }
+ return 2;
}
+ return 0; /* unknown person part */
}
struct chunk {
@@ -432,8 +449,8 @@ static void parse_commit_header(struct format_
context->commit_header_parsed = 1;
}
-static void format_commit_item(struct strbuf *sb, const char *placeholder,
- void *context)
+static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
+ void *context)
{
struct format_commit_context *c = context;
const struct commit *commit = c->commit;
@@ -443,23 +460,23 @@ static void format_commit_item(struct strbuf *sb,
/* these are independent of the commit */
switch (placeholder[0]) {
case 'C':
- switch (placeholder[3]) {
- case 'd': /* red */
+ if (!prefixcmp(placeholder + 1, "red")) {
strbuf_addstr(sb, "\033[31m");
- return;
- case 'e': /* green */
+ return 4;
+ } else if (!prefixcmp(placeholder + 1, "green")) {
strbuf_addstr(sb, "\033[32m");
- return;
- case 'u': /* blue */
+ return 6;
+ } else if (!prefixcmp(placeholder + 1, "blue")) {
strbuf_addstr(sb, "\033[34m");
- return;
- case 's': /* reset color */
+ return 5;
+ } else if (!prefixcmp(placeholder + 1, "reset")) {
strbuf_addstr(sb, "\033[m");
- return;
- }
+ return 6;
+ } else
+ return 0;
case 'n': /* newline */
strbuf_addch(sb, '\n');
- return;
+ return 1;
}
/* these depend on the commit */
@@ -469,34 +486,34 @@ static void format_commit_item(struct strbuf *sb,
switch (placeholder[0]) {
case 'H': /* commit hash */
strbuf_addstr(sb, sha1_to_hex(commit->object.sha1));
- return;
+ return 1;
case 'h': /* abbreviated commit hash */
if (add_again(sb, &c->abbrev_commit_hash))
- return;
+ return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->object.sha1,
DEFAULT_ABBREV));
c->abbrev_commit_hash.len = sb->len - c->abbrev_commit_hash.off;
- return;
+ return 1;
case 'T': /* tree hash */
strbuf_addstr(sb, sha1_to_hex(commit->tree->object.sha1));
- return;
+ return 1;
case 't': /* abbreviated tree hash */
if (add_again(sb, &c->abbrev_tree_hash))
- return;
+ return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->tree->object.sha1,
DEFAULT_ABBREV));
c->abbrev_tree_hash.len = sb->len - c->abbrev_tree_hash.off;
- return;
+ return 1;
case 'P': /* parent hashes */
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
strbuf_addstr(sb, sha1_to_hex(p->item->object.sha1));
}
- return;
+ return 1;
case 'p': /* abbreviated parent hashes */
if (add_again(sb, &c->abbrev_parent_hashes))
- return;
+ return 1;
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
@@ -505,14 +522,14 @@ static void format_commit_item(struct strbuf
*sb, const char *placeholder,
}
c->abbrev_parent_hashes.len = sb->len -
c->abbrev_parent_hashes.off;
- return;
+ return 1;
case 'm': /* left/right/bottom */
strbuf_addch(sb, (commit->object.flags & BOUNDARY)
? '-'
: (commit->object.flags & SYMMETRIC_LEFT)
? '<'
: '>');
- return;
+ return 1;
}
/* For the rest we have to parse the commit header. */
@@ -520,66 +537,37 @@ static void format_commit_item(struct strbuf *sb,
parse_commit_header(c);
switch (placeholder[0]) {
- case 's':
+ case 's': /* subject */
strbuf_add(sb, msg + c->subject.off, c->subject.len);
- return;
- case 'a':
- format_person_part(sb, placeholder[1],
- msg + c->author.off, c->author.len);
- return;
- case 'c':
- format_person_part(sb, placeholder[1],
- msg + c->committer.off, c->committer.len);
- return;
- case 'e':
+ return 1;
+ case 'a': /* author ... */
+ return format_person_part(sb, placeholder[1],
+ msg + c->author.off,
+ c->author.len);
+
+ case 'c': /* committer ... */
+ return format_person_part(sb, placeholder[1],
+ msg + c->committer.off,
+ c->committer.len);
+
+ case 'e': /* encoding */
strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
- return;
- case 'b':
+ return 1;
+ case 'b': /* body */
strbuf_addstr(sb, msg + c->body_off);
- return;
+ return 1;
}
+ return 0; /* unknown placeholder */
}
void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb)
{
- const char *placeholders[] = {
- "H", /* commit hash */
- "h", /* abbreviated commit hash */
- "T", /* tree hash */
- "t", /* abbreviated tree hash */
- "P", /* parent hashes */
- "p", /* abbreviated parent hashes */
- "an", /* author name */
- "ae", /* author email */
- "ad", /* author date */
- "aD", /* author date, RFC2822 style */
- "ar", /* author date, relative */
- "at", /* author date, UNIX timestamp */
- "ai", /* author date, ISO 8601 */
- "cn", /* committer name */
- "ce", /* committer email */
- "cd", /* committer date */
- "cD", /* committer date, RFC2822 style */
- "cr", /* committer date, relative */
- "ct", /* committer date, UNIX timestamp */
- "ci", /* committer date, ISO 8601 */
- "e", /* encoding */
- "s", /* subject */
- "b", /* body */
- "Cred", /* red */
- "Cgreen", /* green */
- "Cblue", /* blue */
- "Creset", /* reset color */
- "n", /* newline */
- "m", /* left/right/bottom */
- NULL
- };
struct format_commit_context context;
memset(&context, 0, sizeof(context));
context.commit = commit;
- strbuf_expand(sb, format, placeholders, format_commit_item, &context);
+ strbuf_expand(sb, format, format_commit_item, &context);
}
static void pp_header(enum cmit_fmt fmt,
diff --git a/strbuf.c b/strbuf.c
index 5efcfc8..32ab8e5 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -146,11 +146,12 @@ void strbuf_addf(struct strbuf *sb,
strbuf_setlen(sb, sb->len + len);
}
-void strbuf_expand(struct strbuf *sb, const char *format,
- const char **placeholders, expand_fn_t fn, void *context)
+void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn,
+ void *context)
{
for (;;) {
- const char *percent, **p;
+ const char *percent;
+ size_t consumed;
percent = strchrnul(format, '%');
strbuf_add(sb, format, percent - format);
@@ -158,14 +159,10 @@ void strbuf_expand(struct strbuf *sb,
break;
format = percent + 1;
- for (p = placeholders; *p; p++) {
- if (!prefixcmp(format, *p))
- break;
- }
- if (*p) {
- fn(sb, *p, context);
- format += strlen(*p);
- } else
+ consumed = fn(sb, format, context);
+ if (consumed)
+ format += consumed;
+ else
strbuf_addch(sb, '%');
}
}
diff --git a/strbuf.h b/strbuf.h
index 36d61db..faec229 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -103,8 +103,8 @@ static inline void strbuf_addbuf(struct strbuf *sb,
}
extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
-typedef void (*expand_fn_t) (struct strbuf *sb, const char
*placeholder, void *context);
-extern void strbuf_expand(struct strbuf *sb, const char *format,
const char **placeholders, expand_fn_t fn, void *context);
+typedef size_t (*expand_fn_t) (struct strbuf *sb, const char
*placeholder, void *context);
+extern void strbuf_expand(struct strbuf *sb, const char *format,
expand_fn_t fn, void *context);
__attribute__((format(printf,2,3)))
extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
[-- Attachment #2: avoid_prefix_lookup.txt --]
[-- Type: text/plain, Size: 12243 bytes --]
Subject: [PATCH] Avoid a useless prefix lookup in strbuf_expand()
Currently the --prett=format prefix is looked up in a
tight loop in strbuf_expand(), if found is passed as parameter
to format_commit_item() that does another search using a
switch statement to select the proper operation according to
the kind of prefix.
Because the switch statement is already able to discard unknown
matches we don't need the prefix lookup before to call format_commit_item()
This patch removes an useless loop in a very fasth path,
used by, as example, by 'git log' with --pretty=format option
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
To apply on top of "[PATCH] Fix an off by one bug in pretty.c"
pretty.c | 228 +++++++++++++++++++++++++++++--------------------------------
strbuf.c | 19 ++---
strbuf.h | 4 +-
3 files changed, 118 insertions(+), 133 deletions(-)
diff --git a/pretty.c b/pretty.c
index 3ce5e6f..5132b1f 100644
--- a/pretty.c
+++ b/pretty.c
@@ -282,76 +282,93 @@ static char *logmsg_reencode(const struct
return out;
}
-static void format_person_part(struct strbuf *sb, char part,
- const char *msg, int len)
+static int parse_tz(char *ep, const char *msg, int len) {
+
+ int tz = 0, start = ep - msg + 1;
+
+ for ( ;start < len && isspace(msg[start]); start++)
+ ; /* do nothing */
+
+ if (start + 1 < len) {
+ tz = strtoul(msg + start + 1, NULL, 10);
+ if (msg[start] == '-')
+ tz = -tz;
+ }
+ return tz;
+}
+
+static size_t format_person_part(struct strbuf *sb, char part,
+ const char *msg, int len)
{
- int start, end, tz = 0;
- unsigned long date;
+ int start, end, tz = 0, date_valid;
+ unsigned long date = 0;
char *ep;
- /* parse name */
+ /* advance 'end' to point to name end delimiter */
for (end = 0; end < len && msg[end] != '<'; end++)
; /* do nothing */
- start = end + 1;
- while (end > 0 && isspace(msg[end - 1]))
- end--;
- if (part == 'n') { /* name */
+
+ if (part == 'n') { /* name */
+ while (end > 0 && isspace(msg[end - 1]))
+ end--;
+
strbuf_add(sb, msg, end);
- return;
+ return 2;
}
+ start = ++end; /* save email start delimiter */
- if (start >= len)
- return;
-
- /* parse email */
- for (end = start; end < len && msg[end] != '>'; end++)
+ /* advance 'end' to point to email end delimiter */
+ for ( ; end < len && msg[end] != '>'; end++)
; /* do nothing */
- if (end >= len)
- return;
-
- if (part == 'e') { /* email */
- strbuf_add(sb, msg + start, end - start);
- return;
+ if (part == 'e') { /* email */
+ if (end - start > 0)
+ strbuf_add(sb, msg + start, end - start);
+ return 2;
}
- /* parse date */
+ /* advance 'start' to point to date start delimiter */
for (start = end + 1; start < len && isspace(msg[start]); start++)
; /* do nothing */
- if (start >= len)
- return;
- date = strtoul(msg + start, &ep, 10);
- if (msg + start == ep)
- return;
- if (part == 't') { /* date, UNIX timestamp */
- strbuf_add(sb, msg + start, ep - (msg + start));
- return;
- }
+ date_valid = start < len;
- /* parse tz */
- for (start = ep - msg + 1; start < len && isspace(msg[start]); start++)
- ; /* do nothing */
- if (start + 1 < len) {
- tz = strtoul(msg + start + 1, NULL, 10);
- if (msg[start] == '-')
- tz = -tz;
+ if (date_valid)
+ date = strtoul(msg + start, &ep, 10);
+
+ if (part == 't') { /* date, UNIX timestamp */
+ if (date_valid && msg + start != ep)
+ strbuf_add(sb, msg + start, ep - (msg + start));
+ return 2;
}
switch (part) {
- case 'd': /* date */
- strbuf_addstr(sb, show_date(date, tz, DATE_NORMAL));
- return;
- case 'D': /* date, RFC2822 style */
- strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822));
- return;
- case 'r': /* date, relative */
- strbuf_addstr(sb, show_date(date, tz, DATE_RELATIVE));
- return;
- case 'i': /* date, ISO 8601 */
- strbuf_addstr(sb, show_date(date, tz, DATE_ISO8601));
- return;
+ case 'd': /* date */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_NORMAL));
+ }
+ return 2;
+ case 'D': /* date, RFC2822 style */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822));
+ }
+ return 2;
+ case 'r': /* date, relative */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_RELATIVE));
+ }
+ return 2;
+ case 'i': /* date, ISO 8601 */
+ if (date_valid) {
+ tz = parse_tz(ep, msg, len);
+ strbuf_addstr(sb, show_date(date, tz, DATE_ISO8601));
+ }
+ return 2;
}
+ return 0; /* unknown person part */
}
struct chunk {
@@ -432,8 +449,8 @@ static void parse_commit_header(struct format_
context->commit_header_parsed = 1;
}
-static void format_commit_item(struct strbuf *sb, const char *placeholder,
- void *context)
+static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
+ void *context)
{
struct format_commit_context *c = context;
const struct commit *commit = c->commit;
@@ -443,23 +460,23 @@ static void format_commit_item(struct strbuf *sb,
/* these are independent of the commit */
switch (placeholder[0]) {
case 'C':
- switch (placeholder[3]) {
- case 'd': /* red */
+ if (!prefixcmp(placeholder + 1, "red")) {
strbuf_addstr(sb, "\033[31m");
- return;
- case 'e': /* green */
+ return 4;
+ } else if (!prefixcmp(placeholder + 1, "green")) {
strbuf_addstr(sb, "\033[32m");
- return;
- case 'u': /* blue */
+ return 6;
+ } else if (!prefixcmp(placeholder + 1, "blue")) {
strbuf_addstr(sb, "\033[34m");
- return;
- case 's': /* reset color */
+ return 5;
+ } else if (!prefixcmp(placeholder + 1, "reset")) {
strbuf_addstr(sb, "\033[m");
- return;
- }
+ return 6;
+ } else
+ return 0;
case 'n': /* newline */
strbuf_addch(sb, '\n');
- return;
+ return 1;
}
/* these depend on the commit */
@@ -469,34 +486,34 @@ static void format_commit_item(struct strbuf *sb,
switch (placeholder[0]) {
case 'H': /* commit hash */
strbuf_addstr(sb, sha1_to_hex(commit->object.sha1));
- return;
+ return 1;
case 'h': /* abbreviated commit hash */
if (add_again(sb, &c->abbrev_commit_hash))
- return;
+ return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->object.sha1,
DEFAULT_ABBREV));
c->abbrev_commit_hash.len = sb->len - c->abbrev_commit_hash.off;
- return;
+ return 1;
case 'T': /* tree hash */
strbuf_addstr(sb, sha1_to_hex(commit->tree->object.sha1));
- return;
+ return 1;
case 't': /* abbreviated tree hash */
if (add_again(sb, &c->abbrev_tree_hash))
- return;
+ return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->tree->object.sha1,
DEFAULT_ABBREV));
c->abbrev_tree_hash.len = sb->len - c->abbrev_tree_hash.off;
- return;
+ return 1;
case 'P': /* parent hashes */
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
strbuf_addstr(sb, sha1_to_hex(p->item->object.sha1));
}
- return;
+ return 1;
case 'p': /* abbreviated parent hashes */
if (add_again(sb, &c->abbrev_parent_hashes))
- return;
+ return 1;
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
@@ -505,14 +522,14 @@ static void format_commit_item(struct strbuf *sb, const char *placeholder,
}
c->abbrev_parent_hashes.len = sb->len -
c->abbrev_parent_hashes.off;
- return;
+ return 1;
case 'm': /* left/right/bottom */
strbuf_addch(sb, (commit->object.flags & BOUNDARY)
? '-'
: (commit->object.flags & SYMMETRIC_LEFT)
? '<'
: '>');
- return;
+ return 1;
}
/* For the rest we have to parse the commit header. */
@@ -520,66 +537,37 @@ static void format_commit_item(struct strbuf *sb,
parse_commit_header(c);
switch (placeholder[0]) {
- case 's':
+ case 's': /* subject */
strbuf_add(sb, msg + c->subject.off, c->subject.len);
- return;
- case 'a':
- format_person_part(sb, placeholder[1],
- msg + c->author.off, c->author.len);
- return;
- case 'c':
- format_person_part(sb, placeholder[1],
- msg + c->committer.off, c->committer.len);
- return;
- case 'e':
+ return 1;
+ case 'a': /* author ... */
+ return format_person_part(sb, placeholder[1],
+ msg + c->author.off,
+ c->author.len);
+
+ case 'c': /* committer ... */
+ return format_person_part(sb, placeholder[1],
+ msg + c->committer.off,
+ c->committer.len);
+
+ case 'e': /* encoding */
strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
- return;
- case 'b':
+ return 1;
+ case 'b': /* body */
strbuf_addstr(sb, msg + c->body_off);
- return;
+ return 1;
}
+ return 0; /* unknown placeholder */
}
void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb)
{
- const char *placeholders[] = {
- "H", /* commit hash */
- "h", /* abbreviated commit hash */
- "T", /* tree hash */
- "t", /* abbreviated tree hash */
- "P", /* parent hashes */
- "p", /* abbreviated parent hashes */
- "an", /* author name */
- "ae", /* author email */
- "ad", /* author date */
- "aD", /* author date, RFC2822 style */
- "ar", /* author date, relative */
- "at", /* author date, UNIX timestamp */
- "ai", /* author date, ISO 8601 */
- "cn", /* committer name */
- "ce", /* committer email */
- "cd", /* committer date */
- "cD", /* committer date, RFC2822 style */
- "cr", /* committer date, relative */
- "ct", /* committer date, UNIX timestamp */
- "ci", /* committer date, ISO 8601 */
- "e", /* encoding */
- "s", /* subject */
- "b", /* body */
- "Cred", /* red */
- "Cgreen", /* green */
- "Cblue", /* blue */
- "Creset", /* reset color */
- "n", /* newline */
- "m", /* left/right/bottom */
- NULL
- };
struct format_commit_context context;
memset(&context, 0, sizeof(context));
context.commit = commit;
- strbuf_expand(sb, format, placeholders, format_commit_item, &context);
+ strbuf_expand(sb, format, format_commit_item, &context);
}
static void pp_header(enum cmit_fmt fmt,
diff --git a/strbuf.c b/strbuf.c
index 5efcfc8..32ab8e5 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -146,11 +146,12 @@ void strbuf_addf(struct strbuf *sb,
strbuf_setlen(sb, sb->len + len);
}
-void strbuf_expand(struct strbuf *sb, const char *format,
- const char **placeholders, expand_fn_t fn, void *context)
+void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn,
+ void *context)
{
for (;;) {
- const char *percent, **p;
+ const char *percent;
+ size_t consumed;
percent = strchrnul(format, '%');
strbuf_add(sb, format, percent - format);
@@ -158,14 +159,10 @@ void strbuf_expand(struct strbuf *sb,
break;
format = percent + 1;
- for (p = placeholders; *p; p++) {
- if (!prefixcmp(format, *p))
- break;
- }
- if (*p) {
- fn(sb, *p, context);
- format += strlen(*p);
- } else
+ consumed = fn(sb, format, context);
+ if (consumed)
+ format += consumed;
+ else
strbuf_addch(sb, '%');
}
}
diff --git a/strbuf.h b/strbuf.h
index 36d61db..faec229 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -103,8 +103,8 @@ static inline void strbuf_addbuf(struct strbuf *sb,
}
extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
-typedef void (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
-extern void strbuf_expand(struct strbuf *sb, const char *format, const char **placeholders, expand_fn_t fn, void *context);
+typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
+extern void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn, void *context);
__attribute__((format(printf,2,3)))
extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
^ permalink raw reply related
* Re: [PATCH] Test "git log --diff-filter"
From: Jakub Narebski @ 2008-01-05 23:33 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Arjen Laarhoven
In-Reply-To: <7vsl1b7vhb.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
> > Add test to check "git log --diff-filter" works correctly with and
> > without diff generation by git-log; the main purpose of this test is
> > to check if "git log --diff-filter" filters revisions correctly.
> >
> > This is a companion test to commit 0faf2da7e5ee5c2f472d8a7afaf8616101f34e80
> > (Fix "git log --diff-filter" bug) by Arjen Laarhoven.
>
> If you look at the commit, you'd notice that I've added
> necessary test when I accepted the patch from Arjen already ;-).
Sorry for the noise, then.
> Does this new set of tests check something new?
My test checks all --diff-filter filters relevant to git-diff-tree,
i.e. ADMRCBT, and not only AMD.
Also it checks if the diff is shown correctly for --diff-filter=M and
for --diff-filter=M*, but I think this should be a separate test, and
use only git-diff-something, and not git-log.
P.S. By the way, it is IMHO a bit strange that --pretty=oneline uses
newline as a terminator (it means that there is a newline at the end of
"git log --pretty=oneline), while --pretty="format:%s" uses newline as
a separator (meaning that there is no newline at the end) when redirected
to file.
# git log --pretty="format:%s" -B -C -C >current
The 'current' file doesn't end with newline (with --pretty=oneline it
does), when log ends at root commit. Strange.
--
Jakub Narebski
Poland
^ permalink raw reply
* Re: [PATCH] Fix an off by one bug in pretty.c
From: Marco Costalba @ 2008-01-05 23:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List, René Scharfe
In-Reply-To: <e5bfff550801051455i3d589c4q9375aeab0cb6aa47@mail.gmail.com>
On Jan 5, 2008 11:55 PM, Marco Costalba <mcostalba@gmail.com> wrote:
> In case author email is <> then we have the following
> bug in function 'format_person_part'
>
WARNING: Please discard previous patch!
Due to an error I sent the wrong one, the following is the correct one:
------------------- CUT ----------------------------------------------------
In case author email is <> then we have the following
bug in function 'format_person_part'
/* parse name */
for (end = 0; end < len && msg[end] != '<'; end++)
; /* do nothing */
start = end + 1; /* now start points to '>' */
-- cut ---
/* parse email */
for (end = start + 1; end < len && msg[end] != '>'; end++)
And here 'end' is initialized with 'start + 1'
instead of 'start'. This turns out in empty commit
date when git log is used with --pretty=format option.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
feba083ccd11374560e34a755ca03f07e7d45533
pretty.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pretty.c b/pretty.c
index 5b1078b..3ce5e6f 100644
--- a/pretty.c
+++ b/pretty.c
@@ -304,7 +304,7 @@ static void format_person_part
return;
/* parse email */
- for (end = start + 1; end < len && msg[end] != '>'; end++)
+ for (end = start; end < len && msg[end] != '>'; end++)
; /* do nothing */
if (end >= len)
^ permalink raw reply related
* how to use git merge -s subtree?
From: Miklos Vajna @ 2008-01-05 23:00 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 547 bytes --]
hi,
i recently noticed that the subtree merge strategy is missing from
merge-strategies.txt an i tried to first figure out how it works. i got
it to work, but i'm not 100% sure about i'm using it the way i'm
supposed to.
here is what i do:
1) git remote add B /path/to/B.git
2) git fetch
3) mkdir B
4) touch B/.gitignore
5) git add B/.gitignore
6) git commit -m "add empty B directory"
7) git merge -s subtree B/master
and yes, it works pretty well, but is this the right way? or is it
possible to somehow avoid steps 3..6?
thanks,
- VMiklos
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [PATCH] Fix an off by one bug in pretty.c
From: Marco Costalba @ 2008-01-05 22:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
In case author email is <> then we have the following
bug in function 'format_person_part'
/* parse name */
for (end = 0; end < len && msg[end] != '<'; end++)
; /* do nothing */
start = end + 1; /* now start points to '>' */
-- cut ---
/* parse email */
for (end = start + 1; end < len && msg[end] != '>'; end++)
And here 'end' is initialized with 'start + 1'
instead of 'start'. This turns out in empty commit
date when git log is used with --pretty=format option.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
pretty.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pretty.c b/pretty.c
index 5b1078b..0b2f187 100644
--- a/pretty.c
+++ b/pretty.c
@@ -292,7 +292,7 @@ static void format_person_part
/* parse name */
for (end = 0; end < len && msg[end] != '<'; end++)
; /* do nothing */
- start = end + 1;
+ start = end;
while (end > 0 && isspace(msg[end - 1]))
end--;
if (part == 'n') { /* name */
--
1.5.4.rc2.38.gd6da3-dirty
^ permalink raw reply related
* Re: [PATCH] Test "git log --diff-filter"
From: Junio C Hamano @ 2008-01-05 22:34 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, Arjen Laarhoven
In-Reply-To: <1199571622-12953-1-git-send-email-jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Add test to check "git log --diff-filter" works correctly with and
> without diff generation by git-log; the main purpose of this test is
> to check if "git log --diff-filter" filters revisions correctly.
>
> This is a companion test to commit 0faf2da7e5ee5c2f472d8a7afaf8616101f34e80
> (Fix "git log --diff-filter" bug) by Arjen Laarhoven.
If you look at the commit, you'd notice that I've added
necessary test when I accepted the patch from Arjen already ;-).
Does this new set of tests check something new?
^ permalink raw reply
* [PATCH] git-gui/Makefile - Don't convert gg_libdir on Cygwin
From: Mark Levedahl @ 2008-01-05 22:32 UTC (permalink / raw)
To: spearce; +Cc: git, Mark Levedahl
gg_libdir was converted to an absolute Windows path as a remnant of
logic to check for relative / absolute location of libraries, but that
does not work on Cygwin. Converting gg_libdir to a Windows path has the
nasty side-effect that it cannot be prefixed with $DESTDIR, and this
precludes installing to a staging directory. So, don't convert it.
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
(resend, mistyped the git list address)
git-gui/Makefile | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/git-gui/Makefile b/git-gui/Makefile
index c109eab..8eb9e05 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -119,7 +119,6 @@ GITGUI_MACOSXAPP :=
ifeq ($(uname_O),Cygwin)
GITGUI_SCRIPT := `cygpath --windows --absolute "$(GITGUI_SCRIPT)"`
- gg_libdir := $(shell cygpath --windows --absolute "$(gg_libdir)")
else
ifeq ($(exedir),$(gg_libdir))
GITGUI_RELATIVE := 1
--
1.5.4.rc2.50.gcfa92
^ permalink raw reply related
* [PATCH] Documentation/Makefile - honor $DESTDIR for quick-install target
From: Mark Levedahl @ 2008-01-05 22:32 UTC (permalink / raw)
To: gitster; +Cc: git, Mark Levedahl
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
This is an (at least to me) obvious ommission, all other targets
honor DESTDIR.
Documentation/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Documentation/Makefile b/Documentation/Makefile
index c4486d3..c641174 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -224,6 +224,6 @@ install-webdoc : html
sh ./install-webdoc.sh $(WEBDOC_DEST)
quick-install:
- sh ./install-doc-quick.sh $(DOC_REF) $(mandir)
+ sh ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
.PHONY: .FORCE-GIT-VERSION-FILE
--
1.5.4.rc2.50.gcfa92
^ permalink raw reply related
* [PATCH] Test "git log --diff-filter"
From: Jakub Narebski @ 2008-01-05 22:20 UTC (permalink / raw)
To: git; +Cc: Arjen Laarhoven, Junio C Hamano, Jakub Narebski
In-Reply-To: <1198580807-18802-1-git-send-email-arjen@yaph.org>
Add test to check "git log --diff-filter" works correctly with and
without diff generation by git-log; the main purpose of this test is
to check if "git log --diff-filter" filters revisions correctly.
This is a companion test to commit 0faf2da7e5ee5c2f472d8a7afaf8616101f34e80
(Fix "git log --diff-filter" bug) by Arjen Laarhoven.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Junio C Hamano wrote:
> Thanks. Some tests?
So there it is...
First, either I don't understand what referred to commit was supposed
to fix, or my test is wrong, or the patch doesn't fix the bug.
Second, I have a few questions about the test itself. I'm not that
sure about it's name: t/README tells us to use 4 as a first digit of
test number for testing diff commands, and 8 for commands concerning
forensics. "git log --diff-filter" is a forensics concerning diff
output. Second digit is for command itself: 0 is used for diff, 2 for
log, so perhaps the test should be named t/t4203-log-diff-filter.sh
The style of writing test is not very consistent across git test
suite. I think that the 'setup' step style is all right, and only
perhas the style of those two-liner tests could be changed.
I use "git diff --exit-code expected current" instead of "diff" or
"cmp" utilities; should all (new) test use this... well of course
except ones testing diff output itself?
t/t4025-diff-filter.sh | 240 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 240 insertions(+), 0 deletions(-)
create mode 100755 t/t4025-diff-filter.sh
diff --git a/t/t4025-diff-filter.sh b/t/t4025-diff-filter.sh
new file mode 100755
index 0000000..3113786
--- /dev/null
+++ b/t/t4025-diff-filter.sh
@@ -0,0 +1,240 @@
+#!/bin/sh
+
+test_description='git log --diff-filter option
+
+Test --diff-filter option with git-log with and without diff output,
+checking both diff output filtering and revision list filtering.
+'
+
+. ./test-lib.sh
+. ../diff-lib.sh ;# test-lib chdir's into trash
+
+# ----------------------------------------------------------------------
+
+test_expect_success setup '
+
+ rm -f foo &&
+ cat ../../COPYING >foo &&
+ git add foo &&
+ git commit -a -m "1st commit: A" &&
+
+ cp foo bar &&
+ git add bar &&
+ git commit -a -m "2nd commit: C" &&
+
+ git rm foo &&
+ git commit -a -m "3rd commit: D" &&
+
+ echo "First added line" >> bar &&
+ git commit -a -m "4th commit: M" &&
+
+ git mv bar foo &&
+ git commit -a -m "5th commit: R" &&
+
+ rm -f foo &&
+ cat ../../Makefile >foo &&
+ git commit -a -m "6th commit: B" &&
+
+ rm -f bar &&
+ echo "bar" > bar &&
+ git add bar &&
+ echo "Second added line" >> foo &&
+ git commit -a -m "7th commit: AM"
+
+ rm -f bar &&
+ ln -s foo bar &&
+ git commit -a -m "8th commit: T"
+
+'
+
+# ----------------------------------------------------------------------
+
+cat >expected <<\EOF
+7th commit: AM
+:000000 100644 0000000000000000000000000000000000000000 5716ca5987cbf97d6bb54920bea6adde242d87e6 A bar
+
+1st commit: A
+:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=A' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=A >current &&
+ compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+3rd commit: D
+:100644 000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0000000000000000000000000000000000000000 D foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=D' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=D >current &&
+ compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+7th commit: AM
+:100644 100644 21c80e6bf73163b9770cba5331cd48172fa6d43e a892bacce2a80efc14eef1c316e827575a96e5c9 M foo
+
+4th commit: M
+:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 915b225a6c9984e645a8061e05002f8cbd2ce46c M bar
+EOF
+
+test_expect_success 'git log --raw --diff-filter=M' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=M >current &&
+ compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+5th commit: R
+:100644 100644 915b225a6c9984e645a8061e05002f8cbd2ce46c 915b225a6c9984e645a8061e05002f8cbd2ce46c R100 bar foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=R' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=R >current &&
+ compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+2nd commit: C
+:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 foo bar
+EOF
+
+test_expect_success 'git log --raw --diff-filter=C' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=C >current &&
+ compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+6th commit: B
+:100644 100644 915b225a6c9984e645a8061e05002f8cbd2ce46c 21c80e6bf73163b9770cba5331cd48172fa6d43e M098 foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=B' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=B >current &&
+ compare_diff_raw expected current
+'
+
+
+cat >expected <<\EOF
+8th commit: T
+:100644 120000 5716ca5987cbf97d6bb54920bea6adde242d87e6 19102815663d23f8b75a47e7a01965dcdc96468c T bar
+EOF
+
+test_expect_success 'git log --raw --diff-filter=T' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=T >current &&
+ compare_diff_raw expected current
+'
+
+cat >expected <<\EOF
+7th commit: AM
+:000000 100644 0000000000000000000000000000000000000000 5716ca5987cbf97d6bb54920bea6adde242d87e6 A bar
+:100644 100644 21c80e6bf73163b9770cba5331cd48172fa6d43e a892bacce2a80efc14eef1c316e827575a96e5c9 M foo
+
+1st commit: A
+:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 A foo
+EOF
+
+test_expect_success 'git log --raw --diff-filter=A*' '
+ git log --raw --no-abbrev --pretty=format:%s -B -C -C --diff-filter=A* >current &&
+ compare_diff_raw expected current
+'
+
+# ----------------------------------------------------------------------
+
+cat >expected <<\EOF
+8th commit: T
+7th commit: AM
+6th commit: B
+5th commit: R
+4th commit: M
+3rd commit: D
+2nd commit: C
+1st commit: A
+EOF
+
+test_expect_success 'git log (no filter)' '
+ git log --pretty=format:%s -B -C -C >current &&
+ git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+7th commit: AM
+1st commit: A
+EOF
+
+test_expect_success 'git log --diff-filter=A' '
+ git log --pretty=format:%s -B -C -C --diff-filter=A >current &&
+ git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+3rd commit: D
+EOF
+
+test_expect_success 'git log --diff-filter=D' '
+ git log --pretty=format:%s -B -C -C --diff-filter=D >current &&
+ git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+7th commit: AM
+4th commit: M
+EOF
+
+test_expect_success 'git log --diff-filter=M' '
+ git log --pretty=format:%s -B -C -C --diff-filter=M >current &&
+ git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+5th commit: R
+EOF
+
+test_expect_success 'git log --diff-filter=R' '
+ git log --pretty=format:%s -B -C -C --diff-filter=R >current &&
+ git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+2nd commit: C
+EOF
+
+test_expect_success 'git log --diff-filter=C' '
+ git log --pretty=format:%s -B -C -C --diff-filter=C >current &&
+ git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+6th commit: B
+EOF
+
+test_expect_success 'git log --diff-filter=B' '
+ git log --pretty=format:%s -B -C -C --diff-filter=A >current &&
+ git diff --exit-code expected current
+'
+
+
+cat >expected <<\EOF
+8th commit: T
+EOF
+
+test_expect_success 'git log --diff-filter=T' '
+ git log --pretty=format:%s -B -C -C --diff-filter=T >current &&
+ git diff --exit-code expected current
+'
+
+# ----------------------------------------------------------------------
+
+test_done
--
1.5.3.7
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox