* Problem with cg-merge
From: Marcel Holtmann @ 2005-05-29 15:04 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing List
Hi Petr,
I saw that earlier, but I don't have any idea what's wrong here. If I do
a simple cg-update, I see something like this:
Tree change: cf1f29d97210d0594dcf5b2a734bdb714de6bf24:89a14a5bd2c880095d5c618a102319bb3dc03da9
:100755 100755 ceda2c50fc2c2941daa34a57722df251bf892c38 fea239b99d351502d1acb098abd725557f0af202 M cg-diff
:100755 100755 cc0c17beef75db41da3ad4ef8983bd7e222ac739 5f0bff77eb2110d52892793e5bef104acde7be32 M cg-help
Applying changes...
Fast-forwarding cf1f29d97210d0594dcf5b2a734bdb714de6bf24 -> 89a14a5bd2c880095d5c618a102319bb3dc03da9
on top of cf1f29d97210d0594dcf5b2a734bdb714de6bf24...
patching file cg-diff
patching file cg-help
cg-diff: needs update
cg-help: needs update
This is a little bit odd, because if I call "git-diff-cache HEAD" after
it, I will see that cg-diff and cg-help are modified. After calling
cg-cancel everything looks fine again.
Regards
Marcel
^ permalink raw reply
* Re: change of git-diff-tree and symlinks
From: Jochen Roemling @ 2005-05-29 14:16 UTC (permalink / raw)
To: Kay Sievers; +Cc: Git Mailing List
In-Reply-To: <20050525111711.GA27492@vrfy.org>
Hello Kay,
I'm planning to use cogito/git for tracking development of my (PHP
based) website. Although this is the first time in my life I'm using
something that smells like a SCM, it seems to work great. The only thing
lacking is a working gitweb installation.
I downloaded the gitweb.cgi script from
kernel.org/pub/software/scm/gitweb, but it dates already May 23rd.
In your mail below from May 25 you state that there have been quite some
changes to git-diff-tree:
Kay Sievers wrote:
>Hi,
>I'm catching up with gitweb.cgi to parse the changed output. Works fine
>so far and is really much easier to parse. Here is something that does
>not work anymore. See the difference between:
>
> http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=commit;h=49cedafaf893bfe348eb7598227f1a11ae24bfd6
> http://ehlo.org/~kay/gitweb.cgi?p=linux/hotplug/udev.git;a=commit;h=49cedafaf893bfe348eb7598227f1a11ae24bfd6
>
>On my box is the lates git with the adapted gitweb.cgi. Here is the raw
>output of the old git-diff-tree:
> kay@dhcp-188:~/src/udev> /home/kay/src/cogito/git-diff-tree -r 49cedafaf893bfe348eb7598227f1a11ae24bfd6 17f2b1a7e0d10334af7f9622848788add125dea8
> *120000->100644 blob 2d78258b1a0fe49afabc8c16a352117df5dc338a->2d78258b1a0fe49afabc8c16a352117df5dc338a test/sys/block/cciss!c0d0/device
> *120000->100644 blob 2d78258b1a0fe49afabc8c16a352117df5dc338a->2d78258b1a0fe49afabc8c16a352117df5dc338a test/sys/block/rd!c0d0/device
> *120000->100644 blob 2d78258b1a0fe49afabc8c16a352117df5dc338a->2d78258b1a0fe49afabc8c16a352117df5dc338a test/sys/block/sda/device
> *120000->100644 blob 1c776568bdc9dc750addd0885dded6b008a44460->1c776568bdc9dc750addd0885dded6b008a44460 test/sys/bus/pci/devices/0000:00:09.0
> *120000->100644 blob e000c77614a23ad57fed284bd007ed7c1cb7872e->e000c77614a23ad57fed284bd007ed7c1cb7872e test/sys/bus/pci/devices/0000:00:1e.0
> ...
>
>The new one shows simply nothing.
>Shouldn't it print the mode changes like the old one?
>
>
>
and that might be the reason why I'm getting "nothing" when I'm clicking
on a "commitdiff" link.
After investigating further, I found out that the object type ("blob" in
the example above) is no longer printed by git-diff-tree.
Also there is a new parameter '-p' that allows the output of a patch
directly instead of creating it with the help of temporary files as you
do it in gitweb.
Unfortunately my perl knowledge is really poor and I didn't get it to
work. After I changed the call to git-diff-tree to use the '-p' switch,
I'm getting a "403 Forbidden - Reading diff-tree failed" message, but
the same command on the command line works perfectly well. I don't know
what is wrong there.
Could you please post a downloadable current release of gitweb to
kernel.org that works with the current git? If not, please tell me what
git release is installed at kernel.org so that I can use that branch to
get it to work with gitweb.
And as a last side note it would be helpfull if you could include a
release number in the gitweb footer as you did in the very beginning so
that we know if something changed and there is new stuff to explore...
... keep up the great work!
Jochen
^ permalink raw reply
* Re: [cogito] paged output for cg-diff
From: Petr Baudis @ 2005-05-29 14:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Michal Rokos, git
In-Reply-To: <7vu0kyuhtq.fsf@assigned-by-dhcp.cox.net>
Dear diary, on Fri, May 20, 2005 at 03:50:57PM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> On the other hand, if your user is a "less" user, and if the
> user wants it to honor ANSI "color" escape sequences, it would
> be more helpful to the user if you educate/encourage the user to
> have "LESS=R" in the environment and make that in effect
> everywhere less is used not just in Cogito. Giving that support
> silently just in Cogito at the first thought may seem to be more
> helpful but in reality it is not.
>
> So I would suggest to use the above form without defining your
> own PAGER shell function, and add a tip for "less" users to have
> "LESS=R" in their environment somewhere in the documentation.
Using the $LESS variable didn't occur to me and I like the idea. :-)
I think the most reasonable thing for Cogito will be to set LESS=R$LESS
if the user passed -c to the given command.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply
* Re: [PATCH] cg-log: make -r id:id show the given id instead of nothing
From: Jonas Fonseca @ 2005-05-29 13:07 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20050529121910.GG1036@pasky.ji.cz>
Petr Baudis <pasky@ucw.cz> wrote Sun, May 29, 2005:
> Dear diary, on Fri, May 20, 2005 at 05:04:00PM CEST, I got a letter
> where Jonas Fonseca <fonseca@diku.dk> told me that...
> > If cg-log is passed -r cogito-0.10 -r cogito-0.10 no log entries are
> > shown. This patch make it show the log for the given ID.
> >
> > Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
>
> I don't like such a special case a lot. If you just want to make it
> possible to show up just a single revision by cg-log, what about -R or
> something, so that you don't need to write it twice?
I admit it is a bit weird. The reason for this was to make support for
specifying revisions with something as fuzzy as dates more usable.
Originally I modified commit-id to support it, but I've tried to move
the logic to the new cg-Xnormid to just give an idea. It is suppose to
add support for
$ cg-log -r '2005-05-12':'1 day ago'
but for some reason it seems to only work as expected for commits by
you. That is it works as expected when I specify the dates for
cogito-0.9 and cogito-0.10.
Of course supporting revisions via date specifications can lead to
ambiguity problems when the date contains `HH:MM' because the colon can
confuse -r option parsing. This means that either a new option needs to
be added (-D?) or the rev1:rev2 case has to be handled after all options
has been parsed so that `-r date1 -r date2' can be handled correctly.
Index: cg-Xnormid
===================================================================
--- c8e987e5e4608c1144293cd3f852210d70b572cb/cg-Xnormid (mode:100755)
+++ uncommitted/cg-Xnormid (mode:100755)
@@ -40,6 +40,14 @@
fi
fi
+if [ ${#id} -ne 40 ] || [ ! -f .git/objects/${id:0:2}/${id:2} ]; then
+ reqsecs=$(date --date="$id" +'%s' 2>/dev/null)
+
+ if [ "$reqsecs" ]; then
+ id=$(git-rev-list --min-age=$reqsecs --max-count=1 HEAD)
+ fi
+fi
+
# If we don't have a 40-char ID by now, it's an error
if [ ${#id} -ne 40 ] || [ ! -f .git/objects/${id:0:2}/${id:2} ]; then
echo "Invalid id: $id" >&2
--
Jonas Fonseca
^ permalink raw reply
* Re: -p diff output and the 'Index:' line
From: Thomas Glanzmann @ 2005-05-29 12:36 UTC (permalink / raw)
To: Sean; +Cc: Junio C Hamano, Petr Baudis, git
In-Reply-To: <2788.10.10.10.24.1117353158.squirrel@linux1>
Hello,
I actually use the following bash script to browse the diffs with
what-changed:
(faui03) [~/work/monitor] git-whatchanged -p | cdiff
...
# COLORDEFINITIONS
BLACK="^[[0;30m"
RED="^[[0;31m"
GREEN="^[[0;32m"
YELLO="^[[0;33m"
BLUE="^[[0;34m"
PURPLE="^[[0;35m"
CYAN="^[[0;36m"
WHITE="^[[0;37m"
END="^[[0m"
REVERSE="^[[7m"
cdiff()
{
cat $1 | \
sed -e " \
s/^\(diff-tree\)\(.*\)/\1${RED}\2${END}/; \
s/^+.*/$RED&$END/; \
s/^-.*/$BLUE&$END/; \
s/^@.*/$GREEN&$END/; \
s/^Date.*/$RED&$END/; \
s/^Author.*/$RED&$END/; \
" | less -R -i -p "^diff-tree"
# This would highlight manpages but the last line clashes with cdiff
# --tg 00:52 05-05-26
#s/^[A-Z]\+[A-Z ]\+$/$RED&$END/; \
#s/[A-Z]\+([0-9])/$RED&$END/g; \
# s/\W--\?[0-9a-zA-Z=-]\+/$BLUE&$END/g; \
}
Gruesse,
Thomas
^ permalink raw reply
* Re: [PATCH] cg-log: make -r id:id show the given id instead of nothing
From: Petr Baudis @ 2005-05-29 12:19 UTC (permalink / raw)
To: Jonas Fonseca; +Cc: git
In-Reply-To: <20050520150400.GC27395@diku.dk>
Dear diary, on Fri, May 20, 2005 at 05:04:00PM CEST, I got a letter
where Jonas Fonseca <fonseca@diku.dk> told me that...
> If cg-log is passed -r cogito-0.10 -r cogito-0.10 no log entries are
> shown. This patch make it show the log for the given ID.
>
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
I don't like such a special case a lot. If you just want to make it
possible to show up just a single revision by cg-log, what about -R or
something, so that you don't need to write it twice?
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply
* Re: [COGITO PATCH] fix "cg-Xnormid: command not found" error
From: Petr Baudis @ 2005-05-29 12:06 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: YOSHIFUJI Hideaki / ????????????, git
In-Reply-To: <1117360678.7072.53.camel@pegasus>
Dear diary, on Sun, May 29, 2005 at 11:57:57AM CEST, I got a letter
where Marcel Holtmann <marcel@holtmann.org> told me that...
> I made the same patch, but when I used cg-diff to create the patch, I
> got two extra annoying lines at the top.
>
> commit-id: needs update
> tree-id: needs update
> Index: commit-id
> ===================================================================
> --- c8e987e5e4608c1144293cd3f852210d70b572cb/commit-id (mode:100755)
> +++ uncommitted/commit-id (mode:100755)
>
> I think the "needs update" lines came from "git-update-cache --refresh"
> and we don't really want them there. Should we simply direct the output
> to /dev/null or what?
Oh yes, this is one of the small things I've long meant to fix but never
really got to it. Thanks for reminding me, fixed now. :-)
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply
* Re: -p diff output and the 'Index:' line
From: Petr Baudis @ 2005-05-29 12:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vd5raqy28.fsf@assigned-by-dhcp.cox.net>
Dear diary, on Sun, May 29, 2005 at 09:41:03AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> >>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
>
> PB> What do you think? Would you hate it to show up in the diffs, or are
> PB> you ok with it?
>
> I cannot tell if you are asking about cg-diff or changing the
> built-in diff-* output. The Subject: line suggests you are
> talking about the latter, but if that is the case I have to
> admit that I am not that sympathetic to Index: nor separator.
Yes, I'm talking about the latter.
> Like Linus, I do "/^diff --git .*" in my less sessions, which
> gives a very nice highlighted separator line without wasting a
> single line on the terminal. If any of the readers on the list
> didn't know about this trick (especially the trailing .* part),
> please try it. I'm certain everybody would love it.
When I do just cg-diff to see what I changed I usually do not pipe it to
less, and typing that / stuff seems insane (although /^d.* could give a
good approximation). OTOH I think I'll go for the diff output
colorification (at the Cogito level), so the separator indeed isn't
strictly necessary. I can live without it. :-)
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply
* Re: [COGITO PATCH] fix "cg-Xnormid: command not found" error
From: Marcel Holtmann @ 2005-05-29 9:57 UTC (permalink / raw)
To: YOSHIFUJI Hideaki / 吉藤英明; +Cc: git
In-Reply-To: <20050529.121545.77345008.yoshfuji@linux-ipv6.org>
Hi,
> Call cg-Xnormid with ${COGITO_LIB} to fix "cg-Xnormid: command not found"
> error.
I made the same patch, but when I used cg-diff to create the patch, I
got two extra annoying lines at the top.
commit-id: needs update
tree-id: needs update
Index: commit-id
===================================================================
--- c8e987e5e4608c1144293cd3f852210d70b572cb/commit-id (mode:100755)
+++ uncommitted/commit-id (mode:100755)
I think the "needs update" lines came from "git-update-cache --refresh"
and we don't really want them there. Should we simply direct the output
to /dev/null or what?
Regards
Marcel
^ permalink raw reply
* [PATCH] diff: move diffcore-break before diffcore-rename.
From: Junio C Hamano @ 2005-05-29 9:14 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
In-Reply-To: <7vbr6vrvqf.fsf@assigned-by-dhcp.cox.net>
The order diffcore-break is applied has changed. Earlier it
came fairly late in the diffcore chain, but now it comes before
diffcore-rename, which makes diffcore-break far more useful than
before.
As the new test t4008-diff-break-rewrite demonstrates, if a file
is a complete rewrite, it is broken and then can be subjected to
the usual rename detection. For example, if file0 gets
completely rewritten to make it as if it was rather based on
file1 which disappeared, diff-* -B -M would do the following:
The original change would look like this:
file0 --> file0' (quite different from file0)
file1 --> /dev/null
After diffcore-break, it would become this:
file0 --> /dev/null
/dev/null --> file0'
file1 --> /dev/null
Then diffcore-rename matches them up:
file1 --> file0'
The meaning of the parameter the -B option takes has changed
from the previous one. Earlier it meant the amount of source
materials permitted to remain for the file and still be
considered a rewrite, which meant that the lower the number, the
tighter the detection criteria. This was changed to match the
way the parameters to the -C and the -M options are used, where
larger parameter value means tighter detection criteria. The
parameter for the -B option now means how much new material must
be in the resulting file for the filepair to be considered a
rewrite, and defaults to 99%.
The internal score values are finer grained now. Earlier
maximum of 10000 has been raised to 60000; there is no user
visible changes but there is no reason to waste available bits.
Documentation now mentions the -B option.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Documentation/git-diff-cache.txt | 5 -
Documentation/git-diff-files.txt | 5 -
Documentation/git-diff-tree.txt | 5 -
diff.c | 20 +++-
diffcore-break.c | 101 +++++++++++++----------
diffcore-rename.c | 64 ++++++++++++--
diffcore.h | 13 ++-
t/t4008-diff-break-rewrite.sh | 169 +++++++++++++++++++++++++++++++++++++++
8 files changed, 317 insertions(+), 65 deletions(-)
new file (100755): t/t4008-diff-break-rewrite.sh
diff --git a/Documentation/git-diff-cache.txt b/Documentation/git-diff-cache.txt
--- a/Documentation/git-diff-cache.txt
+++ b/Documentation/git-diff-cache.txt
@@ -9,7 +9,7 @@ git-diff-cache - Compares content and mo
SYNOPSIS
--------
-'git-diff-cache' [-p] [-r] [-z] [-m] [-M] [-R] [-C] [-O<orderfile>] [-S<string>] [--pickaxe-all] [--cached] <tree-ish> [<path>...]
+'git-diff-cache' [-p] [-r] [-z] [-m] [-B] [-M] [-R] [-C] [-O<orderfile>] [-S<string>] [--pickaxe-all] [--cached] <tree-ish> [<path>...]
DESCRIPTION
-----------
@@ -35,6 +35,9 @@ OPTIONS
-z::
\0 line termination on output
+-B::
+ Break complete rewrite changes into pairs of delete and create.
+
-M::
Detect renames.
diff --git a/Documentation/git-diff-files.txt b/Documentation/git-diff-files.txt
--- a/Documentation/git-diff-files.txt
+++ b/Documentation/git-diff-files.txt
@@ -9,7 +9,7 @@ git-diff-files - Compares files in the w
SYNOPSIS
--------
-'git-diff-files' [-p] [-q] [-r] [-z] [-M] [-C] [-R] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<pattern>...]
+'git-diff-files' [-p] [-q] [-r] [-z] [-B] [-M] [-C] [-R] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<pattern>...]
DESCRIPTION
-----------
@@ -29,6 +29,9 @@ OPTIONS
-R::
Output diff in reverse.
+-B::
+ Break complete rewrite changes into pairs of delete and create.
+
-M::
Detect renames.
diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt
--- a/Documentation/git-diff-tree.txt
+++ b/Documentation/git-diff-tree.txt
@@ -9,7 +9,7 @@ git-diff-tree - Compares the content and
SYNOPSIS
--------
-'git-diff-tree' [-p] [-r] [-z] [--stdin] [-M] [-R] [-C] [-O<orderfile>] [-S<string>] [--pickaxe-all] [-m] [-s] [-v] [-t] <tree-ish> <tree-ish> [<pattern>]\*
+'git-diff-tree' [-p] [-r] [-z] [--stdin] [-B] [-M] [-R] [-C] [-O<orderfile>] [-S<string>] [--pickaxe-all] [-m] [-s] [-v] [-t] <tree-ish> <tree-ish> [<pattern>]\*
DESCRIPTION
-----------
@@ -33,6 +33,9 @@ OPTIONS
generate patch (see section on generating patches). For
git-diff-tree, this flag implies '-r' as well.
+-B::
+ Break complete rewrite changes into pairs of delete and create.
+
-M::
Detect renames.
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -609,6 +609,7 @@ struct diff_filepair *diff_queue(struct
dp->two = two;
dp->score = 0;
dp->source_stays = 0;
+ dp->broken_pair = 0;
diff_q(queue, dp);
return dp;
}
@@ -643,6 +644,16 @@ static void diff_flush_raw(struct diff_f
sprintf(status, "%c%03d", p->status,
(int)(0.5 + p->score * 100.0/MAX_SCORE));
break;
+ case 'N': case 'D':
+ two_paths = 0;
+ if (p->score)
+ sprintf(status, "%c%03d", p->status,
+ (int)(0.5 + p->score * 100.0/MAX_SCORE));
+ else {
+ status[0] = p->status;
+ status[1] = 0;
+ }
+ break;
default:
two_paths = 0;
status[0] = p->status;
@@ -799,8 +810,9 @@ void diff_debug_filepair(const struct di
{
diff_debug_filespec(p->one, i, "one");
diff_debug_filespec(p->two, i, "two");
- fprintf(stderr, "score %d, status %c source_stays %d\n",
- p->score, p->status ? : '?', p->source_stays);
+ fprintf(stderr, "score %d, status %c stays %d broken %d\n",
+ p->score, p->status ? : '?',
+ p->source_stays, p->broken_pair);
}
void diff_debug_queue(const char *msg, struct diff_queue_struct *q)
@@ -939,12 +951,12 @@ void diffcore_std(const char **paths,
{
if (paths)
diffcore_pathspec(paths);
+ if (0 <= break_opt)
+ diffcore_break(break_opt);
if (detect_rename)
diffcore_rename(detect_rename, rename_score);
if (pickaxe)
diffcore_pickaxe(pickaxe, pickaxe_opts);
- if (0 <= break_opt)
- diffcore_break(break_opt);
if (orderfile)
diffcore_order(orderfile);
}
diff --git a/diffcore-break.c b/diffcore-break.c
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -9,13 +9,18 @@
static int very_different(struct diff_filespec *src,
struct diff_filespec *dst,
- int max_score)
+ int min_score)
{
/* dst is recorded as a modification of src. Are they so
* different that we are better off recording this as a pair
- * of delete and create? max_score is maximum size that is
- * common between src and dst for the pair to be still considered
- * a change (not delete and create), and typically set to 5-10%.
+ * of delete and create? min_score is the minimum amount of
+ * new material that must exist in the dst and not in src for
+ * the pair to be considered a complete rewrite, and recommended
+ * to be set to a very high value, 99% or so.
+ *
+ * The value we return represents the amount of new material
+ * that is in dst and not in src. We return 0 when we do not
+ * want to get the filepair broken.
*/
void *delta;
unsigned long delta_size, base_size;
@@ -28,15 +33,19 @@ static int very_different(struct diff_fi
delta_size = ((src->size < dst->size) ?
(dst->size - src->size) : (src->size - dst->size));
- base_size = ((src->size < dst->size) ? src->size : dst->size);
+
+ /* Notice that we use max of src and dst as the base size,
+ * unlike rename similarity detection. This is so that we do
+ * not mistake a large addition as a complete rewrite.
+ */
+ base_size = ((src->size < dst->size) ? dst->size : src->size);
/*
- * If delta size is larger than
- * (MAX_SCORE-max_score)/MAX_SCORE * min(src->size, dst->size)
- * then we declare this is too big a change to be a patch.
+ * If file size difference is too big compared to the
+ * base_size, we declare this a complete rewrite.
*/
- if (base_size * (MAX_SCORE-max_score) < delta_size * MAX_SCORE)
- return 1;
+ if (base_size * min_score < delta_size * MAX_SCORE)
+ return MAX_SCORE;
if (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0))
return 0; /* error but caught downstream */
@@ -48,60 +57,68 @@ static int very_different(struct diff_fi
/* A delta that has a lot of literal additions would have
* big delta_size no matter what else it does.
*/
- if (base_size * (MAX_SCORE-max_score) < delta_size * MAX_SCORE)
- return 1;
+ if (base_size * min_score < delta_size * MAX_SCORE)
+ return MAX_SCORE;
/* Estimate the edit size by interpreting delta. */
delta_size = count_delta(delta, delta_size);
free(delta);
if (delta_size == UINT_MAX)
return 0; /* error in delta computation */
- /*
- * So how big is the edit?
- */
- if (base_size * (MAX_SCORE-max_score) < delta_size * MAX_SCORE)
- return 1;
- return 0;
+
+ if (base_size < delta_size)
+ return MAX_SCORE;
+
+ return delta_size * MAX_SCORE / base_size;
}
-void diffcore_break(int max_score)
+void diffcore_break(int min_score)
{
struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
int i;
- if (!max_score)
- max_score = DEFAULT_MAXIMUM_SCORE;
+ if (!min_score)
+ min_score = DEFAULT_BREAK_SCORE;
outq.nr = outq.alloc = 0;
outq.queue = NULL;
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
- /* We deal only with in-place edit of non directory */
+ int score;
+
+ /* We deal only with in-place edit of non directory.
+ * We do not break anything else.
+ */
if (DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two) &&
!S_ISDIR(p->one->mode) && !S_ISDIR(p->two->mode) &&
- !strcmp(p->one->path, p->two->path) &&
- very_different(p->one, p->two, max_score)) {
- /* Split this into delete and create */
- struct diff_filespec *one_pre, *one_post,
- *two_pre, *two_post;
-
- /* deletion of one */
- one_pre = alloc_filespec(p->one->path);
- fill_filespec(one_pre, p->one->sha1, p->one->mode);
- one_post = alloc_filespec(p->one->path);
- diff_queue(&outq, one_pre, one_post);
-
- /* creation of two */
- two_pre = alloc_filespec(p->two->path);
- two_post = alloc_filespec(p->two->path);
- fill_filespec(two_post, p->two->sha1, p->two->mode);
- diff_queue(&outq, two_pre, two_post);
- diff_free_filepair(p);
+ !strcmp(p->one->path, p->two->path)) {
+ score = very_different(p->one, p->two, min_score);
+ if (min_score <= score) {
+ /* Split this into delete and create */
+ struct diff_filespec *null_one, *null_two;
+ struct diff_filepair *dp;
+
+ /* deletion of one */
+ null_one = alloc_filespec(p->one->path);
+ dp = diff_queue(&outq, p->one, null_one);
+ dp->score = score;
+ dp->broken_pair = 1;
+
+ /* creation of two */
+ null_two = alloc_filespec(p->two->path);
+ dp = diff_queue(&outq, null_two, p->two);
+ dp->score = score;
+ dp->broken_pair = 1;
+
+ free(p); /* not diff_free_filepair(), we are
+ * reusing one and two here.
+ */
+ continue;
+ }
}
- else
- diff_q(&outq, p);
+ diff_q(&outq, p);
}
free(q->queue);
*q = outq;
diff --git a/diffcore-rename.c b/diffcore-rename.c
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -232,7 +232,7 @@ void diffcore_rename(int detect_rename,
int num_create, num_src, dst_cnt;
if (!minimum_score)
- minimum_score = DEFAULT_MINIMUM_SCORE;
+ minimum_score = DEFAULT_RENAME_SCORE;
renq.queue = NULL;
renq.nr = renq.alloc = 0;
@@ -311,26 +311,66 @@ void diffcore_rename(int detect_rename,
outq.nr = outq.alloc = 0;
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
- struct diff_rename_dst *dst = locate_rename_dst(p->two, 0);
struct diff_filepair *pair_to_free = NULL;
- if (dst) {
- /* creation */
- if (dst->pair) {
- /* renq has rename/copy to produce
- * this file already, so we do not
- * emit the creation record in the
- * output.
- */
+ if (!DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
+ /*
+ * Creation
+ *
+ * We would output this create record if it has
+ * not been turned into a rename/copy already.
+ */
+ struct diff_rename_dst *dst =
+ locate_rename_dst(p->two, 0);
+ if (dst && dst->pair) {
diff_q(&outq, dst->pair);
pair_to_free = p;
}
else
- /* no matching rename/copy source, so record
- * this as a creation.
+ /* no matching rename/copy source, so
+ * record this as a creation.
*/
diff_q(&outq, p);
}
+ else if (DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two)) {
+ /*
+ * Deletion
+ *
+ * We would output this delete record if:
+ *
+ * (1) this is a broken delete and the counterpart
+ * broken create remains in the output; or
+ * (2) this is not a broken delete, and renq does
+ * not have a rename/copy to create p->two->path.
+ *
+ * Otherwise, the counterpart broken create
+ * has been turned into a rename-edit; or
+ * delete did not have a matching create to
+ * begin with.
+ */
+ if (DIFF_PAIR_BROKEN(p)) {
+ /* broken delete */
+ struct diff_rename_dst *dst =
+ locate_rename_dst(p->one, 0);
+ if (dst && dst->pair)
+ /* counterpart is now rename/copy */
+ pair_to_free = p;
+ }
+ else {
+ for (j = 0; j < renq.nr; j++)
+ if (!strcmp(renq.queue[j]->two->path,
+ p->one->path))
+ break;
+ if (j < renq.nr)
+ /* this path remains */
+ pair_to_free = p;
+ }
+
+ if (pair_to_free)
+ ;
+ else
+ diff_q(&outq, p);
+ }
else if (!diff_unmodified_pair(p))
/* all the usual ones need to be kept */
diff_q(&outq, p);
diff --git a/diffcore.h b/diffcore.h
--- a/diffcore.h
+++ b/diffcore.h
@@ -8,9 +8,9 @@
* (e.g. diffcore-rename, diffcore-pickaxe). Never include this header
* in anything else.
*/
-#define MAX_SCORE 10000
-#define DEFAULT_MINIMUM_SCORE 5000 /* rename/copy similarity minimum */
-#define DEFAULT_MAXIMUM_SCORE 1500 /* similarity maximum for break to happen */
+#define MAX_SCORE 60000
+#define DEFAULT_RENAME_SCORE 30000 /* rename/copy similarity minimum (50%) */
+#define DEFAULT_BREAK_SCORE 59400 /* minimum for break to happen (99%)*/
#define RENAME_DST_MATCHED 01
@@ -43,14 +43,19 @@ struct diff_filepair {
struct diff_filespec *one;
struct diff_filespec *two;
unsigned short int score;
- char source_stays; /* all of R/C are copies */
char status; /* M C R N D U (see Documentation/diff-format.txt) */
+ unsigned source_stays : 1; /* all of R/C are copies */
+ unsigned broken_pair : 1;
};
#define DIFF_PAIR_UNMERGED(p) \
(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
+#define DIFF_PAIR_BROKEN(p) \
+ ( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
+ ((p)->broken_pair != 0) )
+
#define DIFF_PAIR_TYPE_CHANGED(p) \
((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh
new file mode 100755
--- /dev/null
+++ b/t/t4008-diff-break-rewrite.sh
@@ -0,0 +1,169 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Break and then rename
+
+We have two very different files, file0 and file1, registered in a tree.
+
+We update file1 so drastically that it is more similar to file0, and
+then remove file0. With -B, changes to file1 should be broken into
+separate delete and create, resulting in removal of file0, removal of
+original file1 and creation of completely rewritten file1.
+
+Further, with -B and -M together, these three modifications should
+turn into rename-edit of file0 into file1.
+
+Starting from the same two files in the tree, we swap file0 and file1.
+With -B, this should be detected as two complete rewrites, resulting in
+four changes in total.
+
+Further, with -B and -M together, these should turn into two renames.
+'
+. ./test-lib.sh
+
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+sanitize_diff_raw='s/ '"$_x40"' '"$_x40"' \([CDNR]\)[0-9]* / X X \1# /'
+compare_diff_raw () {
+ # When heuristics are improved, the score numbers would change.
+ # Ignore them while comparing.
+ # Also we do not check SHA1 hash generation in this test, which
+ # is a job for t0000-basic.sh
+
+ sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
+ sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
+ diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+}
+
+test_expect_success \
+ setup \
+ 'cat ../../README >file0 &&
+ cat ../../COPYING >file1 &&
+ git-update-cache --add file0 file1 &&
+ tree=$(git-write-tree) &&
+ echo "$tree"'
+
+test_expect_success \
+ 'change file1 with copy-edit of file0 and remove file0' \
+ 'sed -e "s/git/GIT/" file0 >file1 &&
+ rm -f file0 &&
+ git-update-cache --remove file0 file1'
+
+test_expect_success \
+ 'run diff with -B' \
+ 'git-diff-cache -B --cached "$tree" >current'
+
+cat >expected <<\EOF
+:100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D file0
+:100644 000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0000000000000000000000000000000000000000 D100 file1
+:000000 100644 0000000000000000000000000000000000000000 11e331465a89c394dc25c780de230043750c1ec8 N100 file1
+EOF
+
+test_expect_success \
+ 'validate result of -B (#1)' \
+ 'compare_diff_raw current expected'
+
+test_expect_success \
+ 'run diff with -B and -M' \
+ 'git-diff-cache -B -M "$tree" >current'
+
+cat >expected <<\EOF
+:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c R100 file0 file1
+EOF
+
+test_expect_success \
+ 'validate result of -B -M (#2)' \
+ 'compare_diff_raw current expected'
+
+test_expect_success \
+ 'swap file0 and file1' \
+ 'rm -f file0 file1 &&
+ git-read-tree -m $tree &&
+ git-checkout-cache -f -u -a &&
+ mv file0 tmp &&
+ mv file1 file0 &&
+ mv tmp file1 &&
+ git-update-cache file0 file1'
+
+test_expect_success \
+ 'run diff with -B' \
+ 'git-diff-cache -B "$tree" >current'
+
+cat >expected <<\EOF
+:100644 000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 0000000000000000000000000000000000000000 D100 file0
+:000000 100644 0000000000000000000000000000000000000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 N100 file0
+:100644 000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0000000000000000000000000000000000000000 D100 file1
+:000000 100644 0000000000000000000000000000000000000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 N100 file1
+EOF
+
+test_expect_success \
+ 'validate result of -B (#3)' \
+ 'compare_diff_raw current expected'
+
+test_expect_success \
+ 'run diff with -B and -M' \
+ 'git-diff-cache -B -M "$tree" >current'
+
+cat >expected <<\EOF
+:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100 file1 file0
+:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 R100 file0 file1
+EOF
+
+test_expect_success \
+ 'validate result of -B -M (#4)' \
+ 'compare_diff_raw current expected'
+
+test_expect_success \
+ 'make file0 into something completely different' \
+ 'rm -f file0 &&
+ ln -s frotz file0 &&
+ git-update-cache file0 file1'
+
+test_expect_success \
+ 'run diff with -B' \
+ 'git-diff-cache -B "$tree" >current'
+
+cat >expected <<\EOF
+:100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0
+:100644 000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0000000000000000000000000000000000000000 D100 file1
+:000000 100644 0000000000000000000000000000000000000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 N100 file1
+EOF
+
+test_expect_success \
+ 'validate result of -B (#5)' \
+ 'compare_diff_raw current expected'
+
+test_expect_success \
+ 'run diff with -B' \
+ 'git-diff-cache -B -M "$tree" >current'
+
+# This should not mistake file0 as the copy source of new file1
+# due to type differences.
+cat >expected <<\EOF
+:100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0
+:100644 000000 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0000000000000000000000000000000000000000 D100 file1
+:000000 100644 0000000000000000000000000000000000000000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 N100 file1
+EOF
+
+test_expect_success \
+ 'validate result of -B -M (#6)' \
+ 'compare_diff_raw current expected'
+
+test_expect_success \
+ 'run diff with -M' \
+ 'git-diff-cache -M "$tree" >current'
+
+# This should not mistake file0 as the copy source of new file1
+# due to type differences.
+cat >expected <<\EOF
+:100644 120000 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 67be421f88824578857624f7b3dc75e99a8a1481 T file0
+:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 M file1
+EOF
+
+test_expect_success \
+ 'validate result of -M (#7)' \
+ 'compare_diff_raw current expected'
+
+test_done
^ permalink raw reply
* [PATCH] diff: code clean-up.
From: Junio C Hamano @ 2005-05-29 9:10 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
In-Reply-To: <7voeaur4fu.fsf_-_@assigned-by-dhcp.cox.net>
- The previous fix for the "diff-cache -p mode bits problem"
had an unnecessary conditional statement not to use the mode
that came from the calling program when we get 0{40} SHA1.
This was totally unnecessary, since the caller gives the
valid mode bits even when calling us with 0{40} SHA1.
This mistake did not break anything, since the mode bits we
got ourselves were the same one taken from the filesystem,
but it was doing unnecessary work. This has been fixed.
- DIFF_PAIR_RENAME() macro is introduced to distinguish a filepair
that is a rename/copy (the definition of which is src and dst
are different paths, of course). This removes the hack used
in the record_rename_pair() to always put some non-zero value
in the score field.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff.c | 17 +++++++----------
diffcore-rename.c | 2 +-
diffcore.h | 6 +++---
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -429,14 +429,11 @@ static void prepare_temp_file(const char
else
strcpy(temp->hex, sha1_to_hex(one->sha1));
/* even though we borrow the contents from the
- * work tree, we want our mode if we are not told
- * to look at the filesystem.
+ * work tree, we always want our mode. mode is
+ * trustworthy even when !(one->sha1_valid), as
+ * long as DIFF_FILE_VALID(one).
*/
- if (one->sha1_valid)
- sprintf(temp->mode, "%06o", one->mode);
- else
- sprintf(temp->mode, "%06o",
- S_IFREG | ce_permissions(st.st_mode));
+ sprintf(temp->mode, "%06o", one->mode);
}
return;
}
@@ -843,7 +840,7 @@ static void diff_resolve_rename_copy(voi
for (j = 0; j < q->nr; j++) {
pp = q->queue[j];
if (!strcmp(p->one->path, pp->one->path) &&
- pp->score) {
+ DIFF_PAIR_RENAME(pp)) {
/* rename/copy are always valid
* so we do not say DIFF_FILE_VALID()
* on pp->one and pp->two.
@@ -862,7 +859,7 @@ static void diff_resolve_rename_copy(voi
* whose both sides are valid and of the same type, i.e.
* either in-place edit or rename/copy edit.
*/
- else if (p->score) {
+ else if (DIFF_PAIR_RENAME(p)) {
if (p->source_stays) {
p->status = 'C';
continue;
@@ -875,7 +872,7 @@ static void diff_resolve_rename_copy(voi
pp = q->queue[j];
if (strcmp(pp->one->path, p->one->path))
continue; /* not us */
- if (!pp->score)
+ if (!DIFF_PAIR_RENAME(pp))
continue; /* not a rename/copy */
/* pp is a rename/copy from the same source */
p->status = 'C';
diff --git a/diffcore-rename.c b/diffcore-rename.c
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -190,7 +190,7 @@ static void record_rename_pair(struct di
fill_filespec(two, dst->sha1, dst->mode);
dp = diff_queue(renq, one, two);
- dp->score = score ? : 1; /* make sure it is at least 1 */
+ dp->score = score;
dp->source_stays = rename_src[src_index].src_stays;
rename_dst[dst_index].pair = dp;
}
diff --git a/diffcore.h b/diffcore.h
--- a/diffcore.h
+++ b/diffcore.h
@@ -42,15 +42,15 @@ extern void diff_free_filespec_data(stru
struct diff_filepair {
struct diff_filespec *one;
struct diff_filespec *two;
- unsigned short int score; /* only valid when one and two are
- * different paths
- */
+ unsigned short int score;
char source_stays; /* all of R/C are copies */
char status; /* M C R N D U (see Documentation/diff-format.txt) */
};
#define DIFF_PAIR_UNMERGED(p) \
(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
+#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
+
#define DIFF_PAIR_TYPE_CHANGED(p) \
((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
------------------------------------------------
^ permalink raw reply
* Re: ALSA official git repository
From: Jaroslav Kysela @ 2005-05-29 9:06 UTC (permalink / raw)
To: Linus Torvalds; +Cc: LKML, Andrew Morton, Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0505271941250.1757@pnote.perex-int.cz>
On Fri, 27 May 2005, Jaroslav Kysela wrote:
> On Fri, 27 May 2005, Linus Torvalds wrote:
>
> > On Fri, 27 May 2005, Jaroslav Kysela wrote:
> > >
> > > I created new git tree for the ALSA project at:
> > >
> > > rsync://rsync.kernel.org/pub/scm/linux/kernel/git/perex/alsa.git
> >
> > Your scripts(?) to generate these things are a bit strange, since they
> > leave an extra empty line in the commit message, which confuses at least
> > gitweb (ie just look at
> >
> > http://www.kernel.org/git/?p=linux/kernel/git/perex/alsa.git;a=summary
> >
> > and note how the summary thing looks empty).
>
> Okay, sorry for this small bug. I'll recreate the ALSA git tree with
> proper comments again. Also, the author is not correct (should be taken
> from the first Signed-off-by:).
The ALSA git tree is updated with all fixes now. I had an old git version
which inserted this extra line at top of comments.
Also, it seems that there's a delay between master.kernel.org and git web
interface at www.kernel.org (the changes are not on web yet).
Jaroslav
-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs
^ permalink raw reply
* Re: -p diff output and the 'Index:' line
From: Sean @ 2005-05-29 7:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Petr Baudis, git
In-Reply-To: <7vd5raqy28.fsf@assigned-by-dhcp.cox.net>
On Sun, May 29, 2005 3:41 am, Junio C Hamano said:
>>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
>
> PB> What do you think? Would you hate it to show up in the diffs, or are
> PB> you ok with it?
>
> I cannot tell if you are asking about cg-diff or changing the
> built-in diff-* output. The Subject: line suggests you are
> talking about the latter, but if that is the case I have to
> admit that I am not that sympathetic to Index: nor separator.
>
> Like Linus, I do "/^diff --git .*" in my less sessions, which
> gives a very nice highlighted separator line without wasting a
> single line on the terminal. If any of the readers on the list
> didn't know about this trick (especially the trailing .* part),
> please try it. I'm certain everybody would love it.
It's good to know you can wrap this into a shell script too, which saves
you having to type the search string in "less" each time... something
like:
git-diff-tree "$@" | git-diff-helper | less -p "^diff --git .*"
Sean
^ permalink raw reply
* Re: -p diff output and the 'Index:' line
From: Junio C Hamano @ 2005-05-29 7:41 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20050529071520.GC1036@pasky.ji.cz>
>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
PB> What do you think? Would you hate it to show up in the diffs, or are
PB> you ok with it?
I cannot tell if you are asking about cg-diff or changing the
built-in diff-* output. The Subject: line suggests you are
talking about the latter, but if that is the case I have to
admit that I am not that sympathetic to Index: nor separator.
Like Linus, I do "/^diff --git .*" in my less sessions, which
gives a very nice highlighted separator line without wasting a
single line on the terminal. If any of the readers on the list
didn't know about this trick (especially the trailing .* part),
please try it. I'm certain everybody would love it.
^ permalink raw reply
* -p diff output and the 'Index:' line
From: Petr Baudis @ 2005-05-29 7:15 UTC (permalink / raw)
To: git
Hello,
so I've tried how would cg-diff output look like if I used the
git-diff -p argument, and I found that I miss the 'Index:' line.
Actually, what I really miss is the separator ==== line just below, but
it'd probably look weird without the 'Index:' line. I became used to the
separators and they enable me to quickly visually notice the files
boundary, which is more drudging if you have just the 'diff --git' line.
What do you think? Would you hate it to show up in the diffs, or are
you ok with it?
Thanks,
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply
* [PATCH] diff-cache: diff-patch (-p) format fixes.
From: Junio C Hamano @ 2005-05-29 5:23 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
In-Reply-To: <7v3bs6slwl.fsf_-_@assigned-by-dhcp.cox.net>
This fixes two more bugs.
- When diff-cache is run with -R and without --cached, a
stat-dirty but otherwise unmodified file still produced an
empty "diff --git" header (earlier fix was only for the case
without -R).
- When diff-cache is run without --cached, an unmodifed file
that has different mode bits from the tree incorrectly picked
up the mode bits from the filesystem, when it should have
used what was recorded in the tree object.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -183,6 +183,9 @@ void fill_filespec(struct diff_filespec
* Given a name and sha1 pair, if the dircache tells us the file in
* the work tree has that object contents, return true, so that
* prepare_temp_file() does not have to inflate and extract.
+ *
+ * NOTE: this function does not use the mode bits, so diff_filespec
+ * users must be careful about mode handling!
*/
static int work_tree_matches(const char *name, const unsigned char *sha1)
{
@@ -394,6 +397,10 @@ static void prepare_temp_file(const char
if (!one->sha1_valid ||
work_tree_matches(name, one->sha1)) {
+ /* NOTE: we only say the matching file has the same
+ * contents. It may have a different mode, in which
+ * case we should not pick it up from the filesystem!
+ */
struct stat st;
if (lstat(name, &st) < 0) {
if (errno == ENOENT)
@@ -421,8 +428,15 @@ static void prepare_temp_file(const char
strcpy(temp->hex, sha1_to_hex(null_sha1));
else
strcpy(temp->hex, sha1_to_hex(one->sha1));
- sprintf(temp->mode, "%06o",
- S_IFREG |ce_permissions(st.st_mode));
+ /* even though we borrow the contents from the
+ * work tree, we want our mode if we are not told
+ * to look at the filesystem.
+ */
+ if (one->sha1_valid)
+ sprintf(temp->mode, "%06o", one->mode);
+ else
+ sprintf(temp->mode, "%06o",
+ S_IFREG | ce_permissions(st.st_mode));
}
return;
}
@@ -716,9 +730,13 @@ static void diff_flush_patch(struct diff
* need to see if the two are the same and if so not to emit
* anything at all. Avoid is_exact_match() comparison when it
* does not matter.
+ * Notice that "look at the filesystem" can happen on p->one
+ * if we are operating under reverse-diff option.
*/
- if ((DIFF_FILE_VALID(p->two) && !p->two->sha1_valid) &&
- is_exact_match(p->one, p->two))
+ if ( ((DIFF_FILE_VALID(p->one) && !p->one->sha1_valid) ||
+ (DIFF_FILE_VALID(p->two) && !p->two->sha1_valid)) &&
+ is_exact_match(p->one, p->two) &&
+ (p->one->mode == p->two->mode) )
return;
name = p->one->path;
------------------------------------------------
^ permalink raw reply
* [PATCH] Documentation: call "similarity index" just "score".
From: Junio C Hamano @ 2005-05-29 4:21 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
It really is an internal "score" number and will not necessarily
stay "similarity index" forever. Document so that Porcelain can
be prepared to see numbers to follow the status letter.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Documentation/diff-format.txt | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
--- a/Documentation/diff-format.txt
+++ b/Documentation/diff-format.txt
@@ -36,7 +36,7 @@ That is, from the left to the right:
(6) sha1 for "src"; 0{40} if creation or unmerged.
(7) a space.
(8) sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
- (9) status, followed by similarlity index number only for C and R.
+ (9) status, followed by optional "score" number.
(10) a tab or a NUL when '-z' option is used.
(11) path for "src"
(12) a tab or a NUL when '-z' option is used; only exists for C or R.
------------------------------------------------
^ permalink raw reply
* [PATCH] diff-helper: fix R/C score parsing under -z flag.
From: Junio C Hamano @ 2005-05-29 4:20 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
In-Reply-To: <7vr7frrw8x.fsf_-_@assigned-by-dhcp.cox.net>
The score number that follows R/C status letter was parsed but
the parse pointer was not updated, causing the entire line to
become unrecognized. This patch fixes this problem.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff-helper.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/diff-helper.c b/diff-helper.c
--- a/diff-helper.c
+++ b/diff-helper.c
@@ -80,17 +80,16 @@ int main(int ac, const char **av) {
if (!strchr("MCRNDU", status))
break;
two_paths = score = 0;
- if (status == 'R' || status == 'C') {
+ if (status == 'R' || status == 'C')
two_paths = 1;
- sscanf(cp, "%d", &score);
- if (line_termination) {
- cp = strchr(cp,
- inter_name_termination);
- if (!cp)
- break;
- }
- }
+ /* pick up score if exists */
+ if (sscanf(cp, "%d", &score) != 1)
+ score = 0;
+ cp = strchr(cp,
+ inter_name_termination);
+ if (!cp)
+ break;
if (*cp++ != inter_name_termination)
break;
------------------------------------------------
^ permalink raw reply
* [COGITO PATCH] fix "cg-Xnormid: command not found" error
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2005-05-29 3:15 UTC (permalink / raw)
To: git
Call cg-Xnormid with ${COGITO_LIB} to fix "cg-Xnormid: command not found"
error.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Index: commit-id
===================================================================
--- c8e987e5e4608c1144293cd3f852210d70b572cb/commit-id (mode:100755)
+++ uncommitted/commit-id (mode:100755)
@@ -8,7 +8,7 @@
. ${COGITO_LIB}cg-Xlib
id="$1"
-normid=$(cg-Xnormid "$id") || exit 1
+normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1
if [ "$(git-cat-file -t "$normid")" != "commit" ]; then
echo "Invalid commit id: $id" >&2
Index: tree-id
===================================================================
--- c8e987e5e4608c1144293cd3f852210d70b572cb/tree-id (mode:100755)
+++ uncommitted/tree-id (mode:100755)
@@ -6,7 +6,7 @@
# Takes ID of the appropriate commit, defaults to HEAD.
id="$1"
-normid=$(cg-Xnormid "$id") || exit 1
+normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1
type=$(git-cat-file -t "$normid")
if [ "$type" = "commit" ]; then
--
YOSHIFUJI Hideaki @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG-FP : 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
^ permalink raw reply
* Re: [RFC] Removing git-*.html references from manpages
From: Jonas Fonseca @ 2005-05-29 1:52 UTC (permalink / raw)
To: David Greaves; +Cc: git
In-Reply-To: <20050527225850.GA25491@diku.dk>
Jonas Fonseca <fonseca@diku.dk> wrote Sat, May 28, 2005:
> Just a minor issue but still.
Another issue: `--' gets replaced with `—'. The debian cogito
package mentions this. Seems it can be fixed by overwriting the default
replacement rule using the following in asciidoc.conf:
[replacements]
(^|[^-])--($|[^-])=\1--\2
Maybe it can be done smarter.
--
Jonas Fonseca
^ permalink raw reply
* [PATCH Cogito] cg-log: improve parsing -r
From: Jonas Fonseca @ 2005-05-29 1:41 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
Move parsing of the -r option to the option parsing loop so it no longer
needs to be last in the argument list.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
cg-log | 32 +++++++++++++++-----------------
1 files changed, 15 insertions(+), 17 deletions(-)
--- c8e987e5e4608c1144293cd3f852210d70b572cb/cg-log (mode:100755)
+++ uncommitted/cg-log (mode:100755)
@@ -37,7 +37,10 @@
colsignoff=
coldefault=
list_files=
+log_start=
+log_end=
user=
+
while [ "$1" ]; do
# TODO: Parse -r here too.
case "$1" in
@@ -59,6 +62,18 @@
user="${1#-u}"
shift
;;
+ -r)
+ shift
+ if echo "$1" | grep -q ':'; then
+ log_end=$(echo "$1" | cut -d : -f 2)
+ log_start=$(echo "$1" | cut -d : -f 1)
+ elif [ -z "$log_start" ]; then
+ log_start="$1"
+ else
+ log_end="$1"
+ fi
+ shift
+ ;;
*)
break
;;
@@ -93,23 +108,6 @@
echo "$coldefault:"
}
-log_start=
-log_end=
-if [ "$1" = "-r" ]; then
- shift
- log_start="$1"
- shift
- if echo "$log_start" | grep -q ':'; then
- log_end=$(echo "$log_start" | cut -d : -f 2)
- log_start=$(echo "$log_start" | cut -d : -f 1)
- fi
-fi
-if [ "$1" = "-r" ]; then
- shift
- log_end="$1"
- shift
-fi
-
if [ "$log_end" ]; then
id1="$(commit-id $log_start)" || exit 1
id2="$(commit-id $log_end)" || exit 1
--
Jonas Fonseca
^ permalink raw reply
* [PATCH Cogito] Make cg-Xnormid use $_git and $_git_objects
From: Jonas Fonseca @ 2005-05-29 1:00 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
The recently introduced cg-Xnormid accesses .git and .git/objects
directly which is not consistent with the current behavior so source
cg-Xlib to get access to the $_git and $_git_objects variables.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
BTW, both commit-id and tree-id needs to be patched to find the
installed cg-Xnormid.
-normid=$(cg-Xnormid "$id") || exit 1
+normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1
--- c8e987e5e4608c1144293cd3f852210d70b572cb/cg-Xnormid (mode:100755)
+++ uncommitted/cg-Xnormid (mode:100755)
@@ -13,16 +13,18 @@
#
# Takes the ID to normalize and returns the normalized ID.
+. ${COGITO_LIB}cg-Xlib
+
id="$1"
if [ ! "$id" ] || [ "$id" = "this" ] || [ "$id" = "HEAD" ]; then
- read id < .git/HEAD
+ read id < "$_git/HEAD"
-elif [ -r ".git/refs/tags/$id" ]; then
- read id < ".git/refs/tags/$id"
+elif [ -r "$_git/refs/tags/$id" ]; then
+ read id < "$_git/refs/tags/$id"
-elif [ -r ".git/refs/heads/$id" ]; then
- read id < ".git/refs/heads/$id"
+elif [ -r "$_git/refs/heads/$id" ]; then
+ read id < "$_git/refs/heads/$id"
# Short id's must be lower case and at least 4 digits.
elif [[ "$id" == [0-9a-z][0-9a-z][0-9a-z][0-9a-z]* ]]; then
@@ -30,10 +32,10 @@
idpost=${id:2}
# Assign array elements to matching names
- idmatch=(.git/objects/$idpref/$idpost*)
+ idmatch=($_git_objects/$idpref/$idpost*)
if [ ${#idmatch[*]} -eq 1 ] && [ -r "$idmatch" ]; then
- id=$idpref${idmatch#.git/objects/$idpref/}
+ id=$idpref${idmatch#$_git_objects/$idpref/}
elif [ ${#idmatch[*]} -gt 1 ]; then
echo "Ambiguous id: $id" >&2
exit 1
@@ -41,7 +43,7 @@
fi
# If we don't have a 40-char ID by now, it's an error
-if [ ${#id} -ne 40 ] || [ ! -f .git/objects/${id:0:2}/${id:2} ]; then
+if [ ${#id} -ne 40 ] || [ ! -f $_git_objects/${id:0:2}/${id:2} ]; then
echo "Invalid id: $id" >&2
exit 1
fi
--
Jonas Fonseca
^ permalink raw reply
* Re: More gitweb queries..
From: Benjamin Herrenschmidt @ 2005-05-28 22:43 UTC (permalink / raw)
To: Kay Sievers; +Cc: Daniel Serpell, Git Mailing List
In-Reply-To: <20050528084255.GA32614@vrfy.org>
On Sat, 2005-05-28 at 10:42 +0200, Kay Sievers wrote:
> You know how that stuff works? :) It is a very nice idea for
> small stuff, but it uses a <div> for every pixel/line you draw and
> places this in the background and I expect it to kill your browser if
> you try to draw things like gitk does.
>
> > Alternatively, you could use a fixed set of little images, a bar "|", a
> > dot "o" and branches like "Y", "7" and "\". Obviously, octopus-merges
> > are very difficult to draw using only those.
>
> Did you look at gitk? With a all the crossing and long lines, you definitely
> need to draw the lines with colors. Otherwise you will see _nothing_, but
> random characters. :)
>
> > BTW, I tried searching on gitweb, and I think that found a problem, see:
> > http://ehlo.org/~kay/gitweb.cgi?p=git/git.git;a=search;s=check
> > At the bottom of the page, highlighting of the search term stops and the
> > commits are all the same color.
>
> Well, you see a list of files which contain the text, not the text
> itself. I can print the filename in red. :)
Best may be to have the server generate a picture ... ?
Ben.
^ permalink raw reply
* Re: [PATCH-RFC] Rewrite ls-tree to behave more like "/bin/ls -a"
From: Jason McMullan @ 2005-05-28 22:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <7vll5zygn1.fsf_-_@assigned-by-dhcp.cox.net>
[-- Attachment #1: Type: text/plain, Size: 1106 bytes --]
On Sat, 2005-05-28 at 00:05 -0700, Junio C Hamano wrote:
> - Unlike the old ls-tree behaviour that used paths arguments to
> restrict output (not that it worked as intended---as pointed
> out in the mailing list discussion, it was quite incoherent),
> this rewrite uses paths arguments to specify what to show.
>
> - Without arguments, it implicitly uses the root level as its
> sole argument ("/bin/ls -a" behaves as if "." is given
> without argument).
>
> - Without -r (recursive) flag, it shows the named blob (either
> file or symlink), or the named tree and its immediate
> children.
>
> - With -r flag, it shows the named path, and recursively
> descends into it if it is a tree.
>
> - With -d flag, it shows the named path and does not show its
> children even if the path is a tree, nor descends into it
> recursively.
This behavior pattern is very agreeable. I'll take it!
Consider your patch:
Signed-Off-By: Jason McMullan <jason.mcmullan@timesys.com>
--
Jason McMullan <jason.mcmullan@timesys.com>
TimeSys Corporation
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
* [PATCH] Add -B flag to diff-* brothers.
From: Junio C Hamano @ 2005-05-28 19:33 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List
This introduces diffcore-break.c, a new diffcore
transformation.
When the -B flag is given, a patch that represents a complete
rewrite is broken into a deletion followed by a creation. This
makes it easier to review such a complete rewrite patch.
The -B flag takes the same syntax as the -M and -C flags to
specify the maximum amount of source material the resulting file
can still have to be considered a complete rewrite, and defaults
to 15% if not specified. For example, this detects the complete
rewrite of ls-tree.c I sent earlier.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Makefile | 3 -
diff-cache.c | 7 +++
diff-files.c | 5 ++
diff-tree.c | 7 +++
diff.h | 2
diffcore-break.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
diffcore-rename.c | 4 -
diffcore.h | 3 -
8 files changed, 137 insertions(+), 4 deletions(-)
new file (100644): diffcore-break.c
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -48,7 +48,7 @@ LIB_OBJS += strbuf.o
LIB_H += diff.h count-delta.h
LIB_OBJS += diff.o diffcore-rename.o diffcore-pickaxe.o diffcore-pathspec.o \
- count-delta.o diffcore-order.o
+ count-delta.o diffcore-order.o diffcore-break.o
LIB_OBJS += gitenv.o
@@ -131,6 +131,7 @@ diffcore-rename.o : $(LIB_H) diffcore.h
diffcore-pathspec.o : $(LIB_H) diffcore.h
diffcore-pickaxe.o : $(LIB_H) diffcore.h
diffcore-order.o : $(LIB_H) diffcore.h
+diffcore-break.o : $(LIB_H) diffcore.h
test: all
$(MAKE) -C t/ all
diff --git a/diff-cache.c b/diff-cache.c
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -9,6 +9,7 @@ static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
static int pickaxe_opts = 0;
+static int diff_break_opt = -1;
static const char *orderfile = NULL;
/* A file entry went away or appeared */
@@ -189,6 +190,10 @@ int main(int argc, const char **argv)
diff_output_format = DIFF_FORMAT_PATCH;
continue;
}
+ if (!strncmp(arg, "-B", 2)) {
+ diff_break_opt = diff_scoreopt_parse(arg);
+ continue;
+ }
if (!strncmp(arg, "-M", 2)) {
detect_rename = DIFF_DETECT_RENAME;
diff_score_opt = diff_scoreopt_parse(arg);
@@ -251,6 +256,8 @@ int main(int argc, const char **argv)
diffcore_rename(detect_rename, diff_score_opt);
if (pickaxe)
diffcore_pickaxe(pickaxe, pickaxe_opts);
+ if (0 <= diff_break_opt)
+ diffcore_break(diff_break_opt);
if (orderfile)
diffcore_order(orderfile);
diff_flush(diff_output_format, 1);
diff --git a/diff-files.c b/diff-files.c
--- a/diff-files.c
+++ b/diff-files.c
@@ -15,6 +15,7 @@ static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
static int pickaxe_opts = 0;
+static int diff_break_opt = -1;
static const char *orderfile = NULL;
static int silent = 0;
@@ -60,6 +61,8 @@ int main(int argc, const char **argv)
orderfile = argv[1] + 2;
else if (!strcmp(argv[1], "--pickaxe-all"))
pickaxe_opts = DIFF_PICKAXE_ALL;
+ else if (!strncmp(argv[1], "-B", 2))
+ diff_break_opt = diff_scoreopt_parse(argv[1]);
else if (!strncmp(argv[1], "-M", 2)) {
diff_score_opt = diff_scoreopt_parse(argv[1]);
detect_rename = DIFF_DETECT_RENAME;
@@ -125,6 +128,8 @@ int main(int argc, const char **argv)
diffcore_rename(detect_rename, diff_score_opt);
if (pickaxe)
diffcore_pickaxe(pickaxe, pickaxe_opts);
+ if (0 <= diff_break_opt)
+ diffcore_break(diff_break_opt);
if (orderfile)
diffcore_order(orderfile);
diff_flush(diff_output_format, 1);
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -14,6 +14,7 @@ static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
static int pickaxe_opts = 0;
+static int diff_break_opt = -1;
static const char *orderfile = NULL;
static const char *header = NULL;
static const char *header_prefix = "";
@@ -266,6 +267,8 @@ static int call_diff_flush(void)
diffcore_rename(detect_rename, diff_score_opt);
if (pickaxe)
diffcore_pickaxe(pickaxe, pickaxe_opts);
+ if (0 <= diff_break_opt)
+ diffcore_break(diff_break_opt);
if (diff_queue_is_empty()) {
diff_flush(DIFF_FORMAT_NO_OUTPUT, 0);
return 0;
@@ -531,6 +534,10 @@ int main(int argc, const char **argv)
diff_score_opt = diff_scoreopt_parse(arg);
continue;
}
+ if (!strncmp(arg, "-B", 2)) {
+ diff_break_opt = diff_scoreopt_parse(arg);
+ continue;
+ }
if (!strcmp(arg, "-z")) {
diff_output_format = DIFF_FORMAT_MACHINE;
continue;
diff --git a/diff.h b/diff.h
--- a/diff.h
+++ b/diff.h
@@ -45,6 +45,8 @@ extern void diffcore_pathspec(const char
extern void diffcore_order(const char *orderfile);
+extern void diffcore_break(int max_score);
+
extern int diff_queue_is_empty(void);
#define DIFF_FORMAT_HUMAN 0
diff --git a/diffcore-break.c b/diffcore-break.c
new file mode 100644
--- /dev/null
+++ b/diffcore-break.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2005 Junio C Hamano
+ */
+#include "cache.h"
+#include "diff.h"
+#include "diffcore.h"
+#include "delta.h"
+#include "count-delta.h"
+
+static int very_different(struct diff_filespec *src,
+ struct diff_filespec *dst,
+ int max_score)
+{
+ /* dst is recorded as a modification of src. Are they so
+ * different that we are better off recording this as a pair
+ * of delete and create? max_score is maximum size that is
+ * common between src and dst for the pair to be still considered
+ * a change (not delete and create), and typically set to 5-10%.
+ */
+ void *delta;
+ unsigned long delta_size, base_size;
+
+ if (!S_ISREG(src->mode) || !S_ISREG(dst->mode))
+ return 0; /* leave symlink rename alone */
+
+ if (diff_populate_filespec(src, 1) || diff_populate_filespec(dst, 1))
+ return 0; /* error but caught downstream */
+
+ delta_size = ((src->size < dst->size) ?
+ (dst->size - src->size) : (src->size - dst->size));
+ base_size = ((src->size < dst->size) ? src->size : dst->size);
+
+ /*
+ * If delta size is larger than
+ * (MAX_SCORE-max_score)/MAX_SCORE * min(src->size, dst->size)
+ * then we declare this is too big a change to be a patch.
+ */
+ if (base_size * (MAX_SCORE-max_score) < delta_size * MAX_SCORE)
+ return 1;
+
+ if (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0))
+ return 0; /* error but caught downstream */
+
+ delta = diff_delta(src->data, src->size,
+ dst->data, dst->size,
+ &delta_size);
+
+ /* A delta that has a lot of literal additions would have
+ * big delta_size no matter what else it does.
+ */
+ if (base_size * (MAX_SCORE-max_score) < delta_size * MAX_SCORE)
+ return 1;
+
+ /* Estimate the edit size by interpreting delta. */
+ delta_size = count_delta(delta, delta_size);
+ free(delta);
+ if (delta_size == UINT_MAX)
+ return 0; /* error in delta computation */
+ /*
+ * So how big is the edit?
+ */
+ if (base_size * (MAX_SCORE-max_score) < delta_size * MAX_SCORE)
+ return 1;
+ return 0;
+}
+
+void diffcore_break(int max_score)
+{
+ struct diff_queue_struct *q = &diff_queued_diff;
+ struct diff_queue_struct outq;
+ int i;
+
+ if (!max_score)
+ max_score = DEFAULT_MAXIMUM_SCORE;
+
+ outq.nr = outq.alloc = 0;
+ outq.queue = NULL;
+
+ for (i = 0; i < q->nr; i++) {
+ struct diff_filepair *p = q->queue[i];
+ /* We deal only with in-place edit of non directory */
+ if (DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two) &&
+ !S_ISDIR(p->one->mode) && !S_ISDIR(p->two->mode) &&
+ !strcmp(p->one->path, p->two->path) &&
+ very_different(p->one, p->two, max_score)) {
+ /* Split this into delete and create */
+ struct diff_filespec *one_pre, *one_post,
+ *two_pre, *two_post;
+
+ /* deletion of one */
+ one_pre = alloc_filespec(p->one->path);
+ fill_filespec(one_pre, p->one->sha1, p->one->mode);
+ one_post = alloc_filespec(p->one->path);
+ diff_queue(&outq, one_pre, one_post);
+
+ /* creation of two */
+ two_pre = alloc_filespec(p->two->path);
+ two_post = alloc_filespec(p->two->path);
+ fill_filespec(two_post, p->two->sha1, p->two->mode);
+ diff_queue(&outq, two_pre, two_post);
+ diff_free_filepair(p);
+ }
+ else
+ diff_q(&outq, p);
+ }
+ free(q->queue);
+ *q = outq;
+
+ return;
+}
diff --git a/diffcore-rename.c b/diffcore-rename.c
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -208,8 +208,8 @@ static int score_compare(const void *a_,
int diff_scoreopt_parse(const char *opt)
{
int diglen, num, scale, i;
- if (opt[0] != '-' || (opt[1] != 'M' && opt[1] != 'C'))
- return -1; /* that is not a -M nor -C option */
+ if (opt[0] != '-' || (opt[1] != 'M' && opt[1] != 'C' && opt[1] != 'B'))
+ return -1; /* that is not a -M, -C nor -B option */
diglen = strspn(opt+2, "0123456789");
if (diglen == 0 || strlen(opt+2) != diglen)
return 0; /* use default */
diff --git a/diffcore.h b/diffcore.h
--- a/diffcore.h
+++ b/diffcore.h
@@ -9,7 +9,8 @@
* in anything else.
*/
#define MAX_SCORE 10000
-#define DEFAULT_MINIMUM_SCORE 5000
+#define DEFAULT_MINIMUM_SCORE 5000 /* rename/copy similarity minimum */
+#define DEFAULT_MAXIMUM_SCORE 1500 /* similarity maximum for break to happen */
#define RENAME_DST_MATCHED 01
------------------------------------------------
^ 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