* Re: [PATCH] xdiff/xdiffi.c: fix warnings about possibly uninitialized variables
From: Davide Libenzi @ 2006-04-08 17:18 UTC (permalink / raw)
To: Marco Roeland; +Cc: git
In-Reply-To: <20060408152720.GA11125@fiberbit.xs4all.nl>
On Sat, 8 Apr 2006, Marco Roeland wrote:
> Compiling this module gave the following warnings (some double dutch!):
>
> xdiff/xdiffi.c: In functie 'xdl_recs_cmp':
> xdiff/xdiffi.c:298: let op: 'spl.i1' may be used uninitialized in this function
> xdiff/xdiffi.c:298: let op: 'spl.i2' may be used uninitialized in this function
> xdiff/xdiffi.c:219: let op: 'fbest1' may be used uninitialized in this function
> xdiff/xdiffi.c:219: let op: 'bbest1' may be used uninitialized in this function
>
> A superficial tracking of their usage, without deeper knowledge about the
> algorithm, indeed confirms that there are code paths on which these
> variables will be used uninitialized. In practice these code paths might never
> be reached, but then these fixes will not change the algorithm. If these
> code paths are ever reached we now at least have a predictable outcome. And
> should the very small performance impact of these initializations be
> noticeable, then they should at least be replaced by comments why certain
> code paths will never be reached.
These paths are never reached because of the way data is prepared before
and passed to the function. Unfortunately the compiler cannot know this.
Using them as -1 or XDL_LINE_MAX won't help either, since those are out of
domain values. You can leave it there and the algo won't suffer, or you
can relax a little the warning level when building the file.
- Davide
^ permalink raw reply
* How to create independent branches
From: Peter Baumann @ 2006-04-08 18:02 UTC (permalink / raw)
To: git
In-Reply-To: <7vr749i48s.fsf@assigned-by-dhcp.cox.net>
On Fri, Apr 07, 2006 at 12:18:27PM -0700, Junio C Hamano wrote:
> Peter Baumann <peter.baumann@gmail.com> writes:
>
> > How can I get the inital commit as a patch?
>
> format-patch is designed to get a patch to send to upstream, and
> does not handle the root commit. In your two revisions
> repository, you could do something like this:
>
> $ git diff-tree -p --root master~1
>
> Or more in general:
>
> $ git rev-list master |
> git diff-tree --stdin --root --pretty=fuller -p
>
> BTW, I've been meaning to add --pretty=patch to give
> format-patch compatible output to diff-tree, but haven't got
> around to actually do it. Another thing I've been meaning to do
> is "git log --diff" which is more or less "git whatchanged".
>
Ok. That did it.
Another question. I'd like to create a totaly independent branch (like
the "todo" branch in git). Is there a more user friendly way than doing
git-checkout -b todo
rm .git/refs/heads/todo
rm .git/index
rm <all_files_in_your_workdir>
... hack hack hack ...
git-commit -a
I looked all over the docs, but can't find anything obvious.
-Peter
^ permalink raw reply
* Re: How to create independent branches
From: Jakub Narebski @ 2006-04-08 18:28 UTC (permalink / raw)
To: git
In-Reply-To: <20060408180244.GA4807@xp.machine.de>
Peter Baumann wrote:
> Another question. I'd like to create a totaly independent branch (like
> the "todo" branch in git). Is there a more user friendly way than doing
>
> git-checkout -b todo
> rm .git/refs/heads/todo
> rm .git/index
> rm <all_files_in_your_workdir>
>
> ... hack hack hack ...
> git-commit -a
Wouldn't it be better and more natural to go back to first commit, or even
empty repository state at the beginning, and branch there? Or make separate
repository?
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply
* Re: Funny repack behaviour
From: Nicolas Pitre @ 2006-04-08 19:44 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0604081233170.3283@wbgn013.biozentrum.uni-wuerzburg.de>
On Sat, 8 Apr 2006, Johannes Schindelin wrote:
> Hi,
>
> I just accidentally reran "git-repack -a -d" on a repository, where I just
> had run it. And I noticed a funny thing: Of about 4000 objects, it reused
> all but 8. So I reran it, and it reused all but 2. I ran it once again,
> and it reused all.
>
> The really funny thing is: it created the same pack every time!
Probably not. Subsequent packs were most probably even smaller !
> It is not critical, evidently, but I'd like to know what is causing this
> rather undeterministic behaviour. (Before you ask: no, I did not make a
> backup before running the tests, so I unfortunately cannot reproduce it).
To reproduce, or rather to reset the pack state, just use
"git-repack -a -f -d" then "git-repack -a -d" multiple times again.
For example, on the current git archive:
$ git-repack -a -f -d
[...]
Total 16548, written 16548 (delta 11007), reused 5390 (delta 0)
Pack pack-af9d39abfcb5fd6fd554f7fc8d1704f8dd2329e0 created.
pack size = 6032083 bytes.
$ git-repack -a -d
[...]
Total 16548, written 16548 (delta 11030), reused 16525 (delta 11007)
Pack pack-af9d39abfcb5fd6fd554f7fc8d1704f8dd2329e0 created.
pack size = 5976610 bytes
$ git-repack -a -d
[...]
Total 16548, written 16548 (delta 11030), reused 16548 (delta 11030)
Pack pack-af9d39abfcb5fd6fd554f7fc8d1704f8dd2329e0 created.
Pack size = 5976610 bytes
So in this case it took 2 itterations before converging on a smaller
pack by 55473 bytes.
I thought the reuse logic might sacrifice a bit on compression given the
speed boost, but I don't get why it is the opposite in practice and that
-f doesn't produce the smallest pack up front.
Nicolas
^ permalink raw reply
* strange behavior when pulling updates / get uptodate with git.git
From: Nicolas Vilz 'niv' @ 2006-04-08 19:57 UTC (permalink / raw)
To: git
Hello guys,
I experience a loss of tags- and branch-updates, when I try to update my
repository.
I normaly do following
git checkout master
git pull origin
my .git/remotes/origin-file looks like this:
URL: git://git.kernel.org/pub/scm/git/git.git
Pull: refs/heads/master:refs/heads/origin
Pull: refs/heads/todo:refs/heads/todo
Pull: refs/heads/maint:refs/heads/maint
Pull: refs/heads/pu:refs/heads/pu
Pull: refs/heads/man:refs/heads/man
Pull: refs/heads/next:refs/heads/next
Pull: refs/heads/html:refs/heads/html
so i suppose, if i try to pull origin, and i am in master, i should be
able to pull these remote heads each in the correct local head...
But I obviously don't.
after deleting the actual git-repository directory and recloning with
git clone <url>
I have obviously more tags than git was trying to merge before at git
pull origin..
I use git version 1.3.0.rc1.g4c0f (located in the next-tree).
Any hints how this could be better on my system?
Sincerly
Nicolas
^ permalink raw reply
* Re: [PATCH] Script for automated historical Git tree grafting
From: Nicholas Miell @ 2006-04-08 20:04 UTC (permalink / raw)
To: Petr Baudis; +Cc: Andrew Morton, torvalds, linux-kernel, git
In-Reply-To: <20060408030936.GN27631@pasky.or.cz>
On Sat, 2006-04-08 at 05:09 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 07, 2006 at 02:52:46AM CEST, I got a letter
> where Andrew Morton <akpm@osdl.org> said that...
> > Petr Baudis <pasky@suse.cz> wrote:
> > >
> > > This script enables Git users to easily graft the historical Git tree
> > > (Bitkeeper history import) to the current history.
> >
> > What impact will that have on the (already rather poor) performance of
> > git-whatchanged, gitk, etc?
>
> Negative. ;-)
>
> I didn't try gitk myself, but according to Nick Riviera it eats 1.6G...
> Otherwise, assuming that you have at least git-1.2.5, git-whatchanged on
> the whole tree should be roughly equally fast as it was before grafting,
> but git-whatchanged on individual paths is _significantly_ slower.
>
> That said, 1.3.0rc2 should already have Linus' optimization which should
> fix or at least mitigate the performance hit on narrowed-down
> git-whatchanged.
Actually, it ate more than 1.6G -- that was just the resident size, and
it likes to allocate more memory in between you closing the window and
it finally exiting (or, you killing it before it OOMs the box, whichever
comes first).
qgit has absolutely no problem with the grafted full history, though,
and those previously mentioned rev-list changes by Linus should fix
git-whatchanged.
Unfortunately, this does nothing to fix the disturbing lack of useless
Simpsons trivia knowledge in the git community. Keith Packard made the
same mistake last week.
--
Nicholas Miell <nmiell@comcast.net>
^ permalink raw reply
* [PATCH] Fix test for command line syntax.
From: Peter Eriksen @ 2006-04-08 20:24 UTC (permalink / raw)
To: git
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
---
test-delta.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
3e2552fff69fb01249fed53380e24e11754afcdf
diff --git a/test-delta.c b/test-delta.c
index 1be8ee0..94b47f0 100644
--- a/test-delta.c
+++ b/test-delta.c
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
void *from_buf, *data_buf, *out_buf;
unsigned long from_size, data_size, out_size;
- if (argc != 5 || (strcmp(argv[1], "-d") && strcmp(argv[1], "-p"))) {
+ if (argc != 5 || (strcmp(argv[1], "-d") || strcmp(argv[1], "-p"))) {
fprintf(stderr, "Usage: %s\n", usage);
return 1;
}
--
1.3.0.rc1.g40e9
^ permalink raw reply related
* Re: [PATCH] Fix test for command line syntax.
From: Peter Eriksen @ 2006-04-08 20:29 UTC (permalink / raw)
To: git
In-Reply-To: <20060408202450.GA5548@bohr.gbar.dtu.dk>
On Sat, Apr 08, 2006 at 10:24:50PM +0200, Peter Eriksen wrote:
>
> Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
>
>
> ---
>
> test-delta.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Please ignore this. Sorry for the noise.
Peter
^ permalink raw reply
* Re: blame now knows -S
From: Junio C Hamano @ 2006-04-08 20:39 UTC (permalink / raw)
To: Fredrik Kuivinen; +Cc: Martin Langhoff, git
In-Reply-To: <20060408114240.GA10137@c165.ib.student.liu.se>
Fredrik Kuivinen <freku045@student.liu.se> writes:
> There is another possible optimisation with respect to xdiff. Instead
> of producing the diff on the xdiff side and parsing the diff in
> blame.c, we could add another call back which just gets the relevant
> information from the hunk header. I don't know how much we would gain
> from this, but it might be worth a try.
I've tried and then it turned out it did not make much of a
difference.
^ permalink raw reply
* Re: How to create independent branches
From: Junio C Hamano @ 2006-04-08 20:49 UTC (permalink / raw)
To: Peter Baumann; +Cc: git
In-Reply-To: <20060408180244.GA4807@xp.machine.de>
Peter Baumann <peter.baumann@gmail.com> writes:
> Another question. I'd like to create a totaly independent branch (like
> the "todo" branch in git). Is there a more user friendly way than doing
>
> git-checkout -b todo
> rm .git/refs/heads/todo
> rm .git/index
> rm <all_files_in_your_workdir>
>
> ... hack hack hack ...
> git-commit -a
>
> I looked all over the docs, but can't find anything obvious.
My "todo" branch is not even part of my main git repository. I
just have two independent repositories (git and todo) locally,
and push into the same public repository.
^ permalink raw reply
* Re: strange behavior when pulling updates / get uptodate with git.git
From: Junio C Hamano @ 2006-04-08 20:55 UTC (permalink / raw)
To: Nicolas Vilz 'niv'; +Cc: git
In-Reply-To: <4438158C.1080208@iaglans.de>
Nicolas Vilz 'niv' <niv@iaglans.de> writes:
> URL: git://git.kernel.org/pub/scm/git/git.git
> Pull: refs/heads/master:refs/heads/origin
> Pull: refs/heads/todo:refs/heads/todo
> Pull: refs/heads/maint:refs/heads/maint
> Pull: refs/heads/pu:refs/heads/pu
> Pull: refs/heads/man:refs/heads/man
> Pull: refs/heads/next:refs/heads/next
> Pull: refs/heads/html:refs/heads/html
>
> so i suppose, if i try to pull origin, and i am in master, i should be
> able to pull these remote heads each in the correct local head...
>
> But I obviously don't.
Most likely it is aborted by the "pu" branch not
fast-forwarding.
Pull: +refs/heads/pu:refs/heads/pu
or dropping "pu" altogether if you are not interested in it,
would help. My repositories (the ones I fetch/pull from for
testing) have only these:
URL: git://git.kernel.org/pub/scm/git/git.git
Pull: refs/heads/master:refs/heads/origin
Pull: refs/heads/next:refs/heads/next
Pull: +refs/heads/pu:refs/heads/pu
Pull: refs/heads/maint:refs/heads/maint
^ permalink raw reply
* Re: How to create independent branches
From: Petr Baudis @ 2006-04-08 20:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Peter Baumann, git
In-Reply-To: <7vsloneqtb.fsf@assigned-by-dhcp.cox.net>
Dear diary, on Sat, Apr 08, 2006 at 10:49:04PM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> said that...
> Peter Baumann <peter.baumann@gmail.com> writes:
>
> > Another question. I'd like to create a totaly independent branch (like
> > the "todo" branch in git). Is there a more user friendly way than doing
> >
> > git-checkout -b todo
> > rm .git/refs/heads/todo
> > rm .git/index
> > rm <all_files_in_your_workdir>
> >
> > ... hack hack hack ...
> > git-commit -a
> >
> > I looked all over the docs, but can't find anything obvious.
>
> My "todo" branch is not even part of my main git repository. I
> just have two independent repositories (git and todo) locally,
> and push into the same public repository.
Wouldn't it be better to separate it to two distinct public repositories
as well? It's confusing people and encouraging a practice that really
isn't very feasible and practical in Git.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time. I think
I have forgotten this before.
^ permalink raw reply
* Re: How to create independent branches
From: Junio C Hamano @ 2006-04-08 21:00 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20060408205747.GT27689@pasky.or.cz>
Petr Baudis <pasky@suse.cz> writes:
> Wouldn't it be better to separate it to two distinct public repositories
> as well? It's confusing people and encouraging a practice that really
> isn't very feasible and practical in Git.
That's mainly historical. I haven't bothered to check it
recently, but /pub/scm/git was not writable by me on kernel.org
machine, only /pub/scm/git/git.git/ was.
^ permalink raw reply
* Re: strange behavior when pulling updates / get uptodate with git.git
From: Nicolas Vilz 'niv' @ 2006-04-08 21:19 UTC (permalink / raw)
To: git
In-Reply-To: <7vmzeveqin.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> Most likely it is aborted by the "pu" branch not
> fast-forwarding.
>
> Pull: +refs/heads/pu:refs/heads/pu
>
> or dropping "pu" altogether if you are not interested in it,
> would help.
Thank you, the +-sign helped me out.
Sincerly
Nicolas
^ permalink raw reply
* Re: How to create independent branches
From: Johannes Schindelin @ 2006-04-08 22:09 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20060408205747.GT27689@pasky.or.cz>
Hi,
On Sat, 8 Apr 2006, Petr Baudis wrote:
> Dear diary, on Sat, Apr 08, 2006 at 10:49:04PM CEST, I got a letter
> where Junio C Hamano <junkio@cox.net> said that...
> >
> > My "todo" branch is not even part of my main git repository. I
> > just have two independent repositories (git and todo) locally,
> > and push into the same public repository.
>
> Wouldn't it be better to separate it to two distinct public repositories
> as well? It's confusing people and encouraging a practice that really
> isn't very feasible and practical in Git.
How so? I find it highly practical, and do it myself. For example, I track
a project which is not version-controlled at all. So I have a "branch" in
git where I keep the tools to fake that version-controlling. And git makes
it easy to just fetch the changes of both the project and my tools.
Ciao,
Dscho
^ permalink raw reply
* Re: Funny repack behaviour
From: Johannes Schindelin @ 2006-04-08 22:11 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0604081528070.2215@localhost.localdomain>
Hi,
On Sat, 8 Apr 2006, Nicolas Pitre wrote:
> On Sat, 8 Apr 2006, Johannes Schindelin wrote:
>
> > Hi,
> >
> > I just accidentally reran "git-repack -a -d" on a repository, where I just
> > had run it. And I noticed a funny thing: Of about 4000 objects, it reused
> > all but 8. So I reran it, and it reused all but 2. I ran it once again,
> > and it reused all.
> >
> > The really funny thing is: it created the same pack every time!
>
> Probably not. Subsequent packs were most probably even smaller !
Oh, you're right. I was tricked by the identical pack-names. Somehow I
forgot that the pack name just reflects a hash of the _unpacked_ objects,
not the pack file itself.
Sorry for the noise.
Ciao,
Dscho
^ permalink raw reply
* Re: How to create independent branches
From: colin @ 2006-04-08 23:15 UTC (permalink / raw)
To: peter.baumann; +Cc: git
669 git-symbolic-ref HEAD refs/heads/slave
670 echo "ref: refs/heads/master" > .git/HEAD
671 git-symbolic-ref HEAD refs/heads/slave
672 git add bar
> Another question. I'd like to create a totaly independent branch (like
> the "todo" branch in git). Is there a more user friendly way than doing
>
> git-checkout -b todo
> rm .git/refs/heads/todo
> rm .git/index
> rm <all_files_in_your_workdir>
>
> ... hack hack hack ...
> git-commit -a
>
> I looked all over the docs, but can't find anything obvious.
If I undertstand, you basically want to create a second
initial commit, so you have two trees in your repository.
Well, an initial commit is just a commit object with no parents.
Try:
- Set up the workdir the way you want. You have to git-add
any newly added files, but git-update-index (called by
git-commit -a) will remove from the index any files
removed from the working directory, so you don't have to
worry about those.
- Make sure refs/heads/todo doesn't exist
- "git-symbolic-ref HEAD refs/heads/todo"
This makes HEAD a symlink (well, symref) to refs/heads/todo,
which doesn't exist.
- git-commit -a
Since the HEAD link doesn't exist, this does an initial
commit.
It's not supremely user friendly, because multiple initial commits can
lead to problems down the road trying to merge, so you'd better know what
you're doing.
Another option is to just set up a second working directory, with a
shared object store, and do the checkin from there. You can have the
.git/refs directories shared (via a symlink) or not. If they're not
shared, you can later make them shared by copying over the relevant refs.
Oh, yes, note that if you fat-finger the "git-symbolic-ref HEAD" command,
any attempts to fix it will complain "not a git repository".
That's because a reference to refs/heads/ in HEAD is how git
identifies a repository. "echo ref: refs/heads/master > .git/HEAD"
will fix it.
^ permalink raw reply
* Make "--parents" logs also be incremental
From: Linus Torvalds @ 2006-04-09 0:05 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
The parent rewriting feature caused us to create the whole history in one
go, and then simplify it later, because of how rewrite_parents() had been
written. However, with a little tweaking, it's perfectly possible to do
even that one incrementally.
Right now, this doesn't really much matter, because every user of
"--parents" will probably generally _also_ use "--topo-order", which will
cause the old non-incremental behaviour anyway. However, I'm hopeful that
we could make even the topological sort incremental, or at least
_partially_ so (for example, make it incremental up to the first merge).
In the meantime, this at least moves things in the right direction, and
removes a strange special case.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/http-push.c b/http-push.c
index b60fa8d..57cefde 100644
--- a/http-push.c
+++ b/http-push.c
@@ -59,12 +59,12 @@ #define LOCK_REQUEST "<?xml version=\"1.
#define LOCK_TIME 600
#define LOCK_REFRESH 30
-/* bits #0-4 in revision.h */
+/* bits #0-6 in revision.h */
-#define LOCAL (1u << 5)
-#define REMOTE (1u << 6)
-#define FETCHING (1u << 7)
-#define PUSHING (1u << 8)
+#define LOCAL (1u << 7)
+#define REMOTE (1u << 8)
+#define FETCHING (1u << 9)
+#define PUSHING (1u << 10)
/* We allow "recursive" symbolic refs. Only within reason, though */
#define MAXDEPTH 5
diff --git a/rev-list.c b/rev-list.c
index 1301502..359195b 100644
--- a/rev-list.c
+++ b/rev-list.c
@@ -7,9 +7,9 @@ #include "blob.h"
#include "tree-walk.h"
#include "revision.h"
-/* bits #0-5 in revision.h */
+/* bits #0-6 in revision.h */
-#define COUNTED (1u<<6)
+#define COUNTED (1u<<7)
static const char rev_list_usage[] =
"git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
diff --git a/revision.c b/revision.c
index ce35b5a..fe26562 100644
--- a/revision.c
+++ b/revision.c
@@ -340,6 +340,10 @@ static void add_parents_to_list(struct r
{
struct commit_list *parent = commit->parents;
+ if (commit->object.flags & ADDED)
+ return;
+ commit->object.flags |= ADDED;
+
/*
* If the commit is uninteresting, don't try to
* prune parents - we want the maximal uninteresting
@@ -705,13 +709,6 @@ int setup_revisions(int argc, const char
if (revs->prune_data) {
diff_tree_setup_paths(revs->prune_data);
revs->prune_fn = try_to_simplify_commit;
-
- /*
- * If we fix up parent data, we currently cannot
- * do that on-the-fly.
- */
- if (revs->parents)
- revs->limited = 1;
}
return left;
@@ -728,10 +725,12 @@ void prepare_revision_walk(struct rev_in
revs->topo_getter);
}
-static int rewrite_one(struct commit **pp)
+static int rewrite_one(struct rev_info *revs, struct commit **pp)
{
for (;;) {
struct commit *p = *pp;
+ if (!revs->limited)
+ add_parents_to_list(revs, p, &revs->commits);
if (p->object.flags & (TREECHANGE | UNINTERESTING))
return 0;
if (!p->parents)
@@ -740,12 +739,12 @@ static int rewrite_one(struct commit **p
}
}
-static void rewrite_parents(struct commit *commit)
+static void rewrite_parents(struct rev_info *revs, struct commit *commit)
{
struct commit_list **pp = &commit->parents;
while (*pp) {
struct commit_list *parent = *pp;
- if (rewrite_one(&parent->item) < 0) {
+ if (rewrite_one(revs, &parent->item) < 0) {
*pp = parent->next;
continue;
}
@@ -802,7 +801,7 @@ struct commit *get_revision(struct rev_i
if (!(commit->object.flags & TREECHANGE))
continue;
if (revs->parents)
- rewrite_parents(commit);
+ rewrite_parents(revs, commit);
}
commit->object.flags |= SHOWN;
return commit;
diff --git a/revision.h b/revision.h
index 0caeecf..83d28d5 100644
--- a/revision.h
+++ b/revision.h
@@ -7,6 +7,7 @@ #define TREECHANGE (1u<<2)
#define SHOWN (1u<<3)
#define TMP_MARK (1u<<4) /* for isolated cases; clean after use */
#define BOUNDARY (1u<<5)
+#define ADDED (1u<<6) /* Parents already parsed and added? */
struct rev_info;
^ permalink raw reply related
* git-diff-tree -B broken
From: Petr Baudis @ 2006-04-09 0:46 UTC (permalink / raw)
To: git
Hi,
no pun intended in the $SUBJ, but git-diff-tree -B seems to be giving
me bogus output
$ git-diff-tree -r -p -B -M 916d8240bfc8ef5b80780b1a32ebb83ed055a178 \
3c9324ea16c345fc0bc0f11041905ba714797e4a cg-mkpatch
diff --git a/cg-mkpatch b/cg-mkpatch
dissimilarity index 57%
index 74fe917..c932bc9 100755
--- cg-mkpatch
+++ cg-mkpatch
@@ -0,0 +0,0 @@
and nothing else. I'm too tired to debug or bisect this (xdiff
introduction is the obvious suspect, I guess), just didn't want this
to slip into the looming 1.3.0 so reporting early.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time. I think
I have forgotten this before.
^ permalink raw reply
* Re: git-diff-tree -B broken
From: Junio C Hamano @ 2006-04-09 2:51 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <20060409004605.GU27689@pasky.or.cz>
Petr Baudis <pasky@ucw.cz> writes:
> $ git-diff-tree -r -p -B -M 916d8240bfc8ef5b80780b1a32ebb83ed055a178 \
> 3c9324ea16c345fc0bc0f11041905ba714797e4a cg-mkpatch
> diff --git a/cg-mkpatch b/cg-mkpatch
> dissimilarity index 57%
> index 74fe917..c932bc9 100755
> --- cg-mkpatch
> +++ cg-mkpatch
> @@ -0,0 +0,0 @@
>
> and nothing else. I'm too tired to debug or bisect this (xdiff
> introduction is the obvious suspect, I guess), just didn't want this
> to slip into the looming 1.3.0 so reporting early.
Thanks.
There are two issues. One of them is addressed with the
attached patch, which is just an artifact of the xdiff
introduction.
Another issue is a bit bigger.
The changes to the sample cg-mkpatch is estimated to be big
enough to get broken, just in case if there is another file
whose postimage that is more similar than the postimage of
cg-mkpatch itself, so that it can be matched up with the other
file, but it is _not_ dissimilar enough that diffcore_break()
code marks it to be merged back together if pieces of the broken
pair do not get matched up with other files. And in this
particular case, since you are limiting the search space to a
single file, there is no other files to match, so the broken
pair should survive the rename detection match-up, and they
should be shown as a normal diff without dissimilarity index at
all.
The funny thing is, the broken pair are matched up with
themselves, with similarity index of 57% (they originally are
from the same filepair, so that is natural). So in this case,
rename code _should_ take notice. I'll work on a fix.
-- >8 --
diff --git a/diff.c b/diff.c
index ce98a90..e887410 100644
--- a/diff.c
+++ b/diff.c
@@ -145,8 +145,9 @@ static void emit_rewrite_diff(const char
struct diff_filespec *one,
struct diff_filespec *two)
{
- /* Use temp[i].name as input, name_a and name_b as labels */
int lc_a, lc_b;
+ diff_populate_filespec(one, 0);
+ diff_populate_filespec(two, 0);
lc_a = count_lines(one->data, one->size);
lc_b = count_lines(two->data, two->size);
printf("--- %s\n+++ %s\n@@ -", name_a, name_b);
^ permalink raw reply related
* [PATCH] diffcore-rename: fix merging back a broken pair.
From: Junio C Hamano @ 2006-04-09 3:30 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
In-Reply-To: <7vwtdzcvhb.fsf@assigned-by-dhcp.cox.net>
When a broken pair is matched up by rename detector to be merged
back, we do not want to say it is "dissimilar" with the
similarity index. The output should just say they were changed,
taking the break score left by the earlier diffcore-break run if
any.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diffcore-rename.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
c17de73d793ff20fce6bcc8427e5f10ab8a2a7c5
diff --git a/diffcore-rename.c b/diffcore-rename.c
index e992698..d57e865 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -54,12 +54,14 @@ static struct diff_rename_dst *locate_re
/* Table of rename/copy src files */
static struct diff_rename_src {
struct diff_filespec *one;
+ unsigned short score; /* to remember the break score */
unsigned src_path_left : 1;
} *rename_src;
static int rename_src_nr, rename_src_alloc;
static struct diff_rename_src *register_rename_src(struct diff_filespec *one,
- int src_path_left)
+ int src_path_left,
+ unsigned short score)
{
int first, last;
@@ -89,6 +91,7 @@ static struct diff_rename_src *register_
memmove(rename_src + first + 1, rename_src + first,
(rename_src_nr - first - 1) * sizeof(*rename_src));
rename_src[first].one = one;
+ rename_src[first].score = score;
rename_src[first].src_path_left = src_path_left;
return &(rename_src[first]);
}
@@ -198,7 +201,10 @@ static void record_rename_pair(int dst_i
fill_filespec(two, dst->sha1, dst->mode);
dp = diff_queue(NULL, one, two);
- dp->score = score;
+ if (!strcmp(src->path, dst->path))
+ dp->score = rename_src[src_index].score;
+ else
+ dp->score = score;
dp->source_stays = rename_src[src_index].src_path_left;
rename_dst[dst_index].pair = dp;
}
@@ -256,10 +262,10 @@ void diffcore_rename(struct diff_options
* that means the source actually stays.
*/
int stays = (p->broken_pair && !p->score);
- register_rename_src(p->one, stays);
+ register_rename_src(p->one, stays, p->score);
}
else if (detect_rename == DIFF_DETECT_COPY)
- register_rename_src(p->one, 1);
+ register_rename_src(p->one, 1, p->score);
}
if (rename_dst_nr == 0 || rename_src_nr == 0 ||
(0 < rename_limit && rename_limit < rename_dst_nr))
--
1.2.6.gad0b
^ permalink raw reply related
* Re: How to create independent branches
From: Peter Baumann @ 2006-04-09 8:11 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
In-Reply-To: <e18vcv$rhf$1@sea.gmane.org>
On Sat, Apr 08, 2006 at 08:28:58PM +0200, Jakub Narebski wrote:
> Peter Baumann wrote:
>
> > Another question. I'd like to create a totaly independent branch (like
> > the "todo" branch in git). Is there a more user friendly way than doing
> >
> > git-checkout -b todo
> > rm .git/refs/heads/todo
> > rm .git/index
> > rm <all_files_in_your_workdir>
> >
> > ... hack hack hack ...
> > git-commit -a
>
> Wouldn't it be better and more natural to go back to first commit? >
If I go back to the first commit, I'll get the following:
first
/ \
/ \
master todo
That's not what I want, because in the near future I want to merge
master and todo, but in my case, todo consists of only of one file (lets
call it file_a), and the master branch has severeal files (file_{a..z}).
If I go back to first, I have to delete all files file_{b..z}.
Further file_a from todo and file_a from master are not equal, the share
just the same name. But in the near future, they will be merged
together, so they are equal.
If I go with the above branching, I'll _think_ (I may be wrong, please
correct me if I am) I get a merge conflict or worse, all my other files
file_a{b..z} are merged as "deleted", wich is wrong.
> Or even empty repository state at the beginning, and branch there?
This isn't possible because the repository already exists and I don't
know how to go back to the empty repository state. Even
git-init-db
git branch todo master
didn't work.
> Or make separate repository?
Ok. You got it. In fact, the todo branch alread exists as a seperate
repository and I'd like to integrate this in my master repository for
easier handling (diff etc.)
To import todo as a subproject doesn't seem right, because it's not
something really independent in the view of the master repo and I'am
going to merge todo _into_ master in the near future.
Any further suggestions?
-Peter
^ permalink raw reply
* Re: How to create independent branches
From: Peter Baumann @ 2006-04-09 8:22 UTC (permalink / raw)
To: git
In-Reply-To: <20060409081105.GA4798@xp.machine.de>
On Sun, Apr 09, 2006 at 10:11:05AM +0200, Peter Baumann wrote:
> On Sat, Apr 08, 2006 at 08:28:58PM +0200, Jakub Narebski wrote:
> > Peter Baumann wrote:
> >
> > > Another question. I'd like to create a totaly independent branch (like
> > > the "todo" branch in git). Is there a more user friendly way than doing
> > >
> > > git-checkout -b todo
> > > rm .git/refs/heads/todo
> > > rm .git/index
> > > rm <all_files_in_your_workdir>
> > >
> > > ... hack hack hack ...
> > > git-commit -a
> >
> > Wouldn't it be better and more natural to go back to first commit? >
>
> If I go back to the first commit, I'll get the following:
>
> first
> / \
> / \
> master todo
>
> That's not what I want, because in the near future I want to merge
> master and todo, but in my case, todo consists of only of one file (lets
> call it file_a), and the master branch has severeal files (file_{a..z}).
> If I go back to first, I have to delete all files file_{b..z}.
> Further file_a from todo and file_a from master are not equal, the share
> just the same name. But in the near future, they will be merged
> together, so they are equal.
>
> If I go with the above branching, I'll _think_ (I may be wrong, please
> correct me if I am) I get a merge conflict or worse, all my other files
> file_a{b..z} are merged as "deleted", wich is wrong.
>
> > Or even empty repository state at the beginning, and branch there?
>
> This isn't possible because the repository already exists and I don't
> know how to go back to the empty repository state. Even
>
> git-init-db
> git branch todo master
>
> didn't work.
>
> > Or make separate repository?
>
> Ok. You got it. In fact, the todo branch alread exists as a seperate
> repository and I'd like to integrate this in my master repository for
> easier handling (diff etc.)
>
> To import todo as a subproject doesn't seem right, because it's not
> something really independent in the view of the master repo and I'am
> going to merge todo _into_ master in the near future.
>
> Any further suggestions?
>
Just in case nobody noticed, that's why I asked for exporting the whole repo
with git-format-patch in the first place, because I'd like to import the
patches with git-am in the totally independent branch.
Peter
^ permalink raw reply
* [PATCH] log-tree: separate major part of diff-tree.
From: Junio C Hamano @ 2006-04-09 9:03 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
This separates out the part that deals with one-commit diff-tree
(and --stdin form) into a separate log-tree module.
There are two goals with this. The more important one is to be
able to make this part available to "git log --diff", so that we
can have a native "git whatchanged" command. Another is to
simplify the commit log generation part simpler.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
* I tried to be very careful while doing this, to make sure
there is no behaviour change. This is a preparation step for
the next one, which is...
Makefile | 4 +
diff-tree.c | 226 ++++++-----------------------------------------------------
log-tree.c | 175 ++++++++++++++++++++++++++++++++++++++++++++++
log-tree.h | 23 ++++++
4 files changed, 224 insertions(+), 204 deletions(-)
create mode 100644 log-tree.c
create mode 100644 log-tree.h
5f1c3f07b7f4a8436c7773b8e7a04998190c125e
diff --git a/Makefile b/Makefile
index 6b10eaa..b272146 100644
--- a/Makefile
+++ b/Makefile
@@ -194,12 +194,12 @@ LIB_H = \
blob.h cache.h commit.h csum-file.h delta.h \
diff.h object.h pack.h pkt-line.h quote.h refs.h \
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
- tree-walk.h
+ tree-walk.h log-tree.h
DIFF_OBJS = \
diff.o diffcore-break.o diffcore-order.o diffcore-pathspec.o \
diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
- diffcore-delta.o
+ diffcore-delta.o log-tree.o
LIB_OBJS = \
blob.o commit.o connect.o csum-file.o \
diff --git a/diff-tree.c b/diff-tree.c
index d1265d7..2a088d1 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -1,152 +1,16 @@
#include "cache.h"
#include "diff.h"
#include "commit.h"
+#include "log-tree.h"
-static int show_root_diff = 0;
-static int no_commit_id = 0;
-static int verbose_header = 0;
-static int ignore_merges = 1;
-static int combine_merges = 0;
-static int dense_combined_merges = 0;
-static int read_stdin = 0;
-static int always_show_header = 0;
+static struct log_tree_opt log_tree_opt;
-static const char *header = NULL;
-static const char *header_prefix = "";
-static enum cmit_fmt commit_format = CMIT_FMT_RAW;
-
-static struct diff_options diff_options;
-
-static int call_diff_flush(void)
-{
- diffcore_std(&diff_options);
- if (diff_queue_is_empty()) {
- int saved_fmt = diff_options.output_format;
- diff_options.output_format = DIFF_FORMAT_NO_OUTPUT;
- diff_flush(&diff_options);
- diff_options.output_format = saved_fmt;
- return 0;
- }
- if (header) {
- if (!no_commit_id)
- printf("%s%c", header, diff_options.line_termination);
- header = NULL;
- }
- diff_flush(&diff_options);
- return 1;
-}
-
-static int diff_tree_sha1_top(const unsigned char *old,
- const unsigned char *new, const char *base)
-{
- int ret;
-
- ret = diff_tree_sha1(old, new, base, &diff_options);
- call_diff_flush();
- return ret;
-}
-
-static int diff_root_tree(const unsigned char *new, const char *base)
-{
- int retval;
- void *tree;
- struct tree_desc empty, real;
-
- tree = read_object_with_reference(new, tree_type, &real.size, NULL);
- if (!tree)
- die("unable to read root tree (%s)", sha1_to_hex(new));
- real.buf = tree;
-
- empty.buf = "";
- empty.size = 0;
- retval = diff_tree(&empty, &real, base, &diff_options);
- free(tree);
- call_diff_flush();
- return retval;
-}
-
-static const char *generate_header(const unsigned char *commit_sha1,
- const unsigned char *parent_sha1,
- const struct commit *commit)
-{
- static char this_header[16384];
- int offset;
- unsigned long len;
- int abbrev = diff_options.abbrev;
- const char *msg = commit->buffer;
-
- if (!verbose_header)
- return sha1_to_hex(commit_sha1);
-
- len = strlen(msg);
-
- offset = sprintf(this_header, "%s%s ",
- header_prefix,
- diff_unique_abbrev(commit_sha1, abbrev));
- if (commit_sha1 != parent_sha1)
- offset += sprintf(this_header + offset, "(from %s)\n",
- parent_sha1
- ? diff_unique_abbrev(parent_sha1, abbrev)
- : "root");
- else
- offset += sprintf(this_header + offset, "(from parents)\n");
- offset += pretty_print_commit(commit_format, commit, len,
- this_header + offset,
- sizeof(this_header) - offset, abbrev);
- if (always_show_header) {
- puts(this_header);
- return NULL;
- }
- return this_header;
-}
-
-static int diff_tree_commit(struct commit *commit)
-{
- struct commit_list *parents;
- unsigned const char *sha1 = commit->object.sha1;
-
- /* Root commit? */
- if (show_root_diff && !commit->parents) {
- header = generate_header(sha1, NULL, commit);
- diff_root_tree(sha1, "");
- }
-
- /* More than one parent? */
- if (commit->parents && commit->parents->next) {
- if (ignore_merges)
- return 0;
- else if (combine_merges) {
- header = generate_header(sha1, sha1, commit);
- header = diff_tree_combined_merge(sha1, header,
- dense_combined_merges,
- &diff_options);
- if (!header && verbose_header)
- header_prefix = "\ndiff-tree ";
- return 0;
- }
- }
-
- for (parents = commit->parents; parents; parents = parents->next) {
- struct commit *parent = parents->item;
- header = generate_header(sha1, parent->object.sha1, commit);
- diff_tree_sha1_top(parent->object.sha1, sha1, "");
- if (!header && verbose_header) {
- header_prefix = "\ndiff-tree ";
- /*
- * Don't print multiple merge entries if we
- * don't print the diffs.
- */
- }
- }
- return 0;
-}
-
static int diff_tree_commit_sha1(const unsigned char *sha1)
{
struct commit *commit = lookup_commit_reference(sha1);
if (!commit)
return -1;
- return diff_tree_commit(commit);
+ return log_tree_commit(&log_tree_opt, commit);
}
static int diff_tree_stdin(char *line)
@@ -184,7 +48,7 @@ static int diff_tree_stdin(char *line)
pos += 41;
}
}
- return diff_tree_commit(commit);
+ return log_tree_commit(&log_tree_opt, commit);
}
static const char diff_tree_usage[] =
@@ -200,13 +64,15 @@ int main(int argc, const char **argv)
char line[1000];
unsigned char sha1[2][20];
const char *prefix = setup_git_directory();
+ static struct log_tree_opt *opt = &log_tree_opt;
+ int read_stdin = 0;
git_config(git_diff_config);
nr_sha1 = 0;
- diff_setup(&diff_options);
+ init_log_tree_opt(opt);
for (;;) {
- int diff_opt_cnt;
+ int opt_cnt;
const char *arg;
argv++;
@@ -223,84 +89,39 @@ int main(int argc, const char **argv)
break;
}
- diff_opt_cnt = diff_opt_parse(&diff_options, argv, argc);
- if (diff_opt_cnt < 0)
+ opt_cnt = log_tree_opt_parse(opt, argv, argc);
+ if (opt_cnt < 0)
usage(diff_tree_usage);
- else if (diff_opt_cnt) {
- argv += diff_opt_cnt - 1;
- argc -= diff_opt_cnt - 1;
+ else if (opt_cnt) {
+ argv += opt_cnt - 1;
+ argc -= opt_cnt - 1;
continue;
}
-
if (!strcmp(arg, "--")) {
argv++;
argc--;
break;
- }
- if (!strcmp(arg, "-r")) {
- diff_options.recursive = 1;
- continue;
- }
- if (!strcmp(arg, "-t")) {
- diff_options.recursive = 1;
- diff_options.tree_in_recursive = 1;
- continue;
- }
- if (!strcmp(arg, "-m")) {
- ignore_merges = 0;
- continue;
}
- if (!strcmp(arg, "-c")) {
- combine_merges = 1;
- continue;
- }
- if (!strcmp(arg, "--cc")) {
- dense_combined_merges = combine_merges = 1;
- continue;
- }
- if (!strcmp(arg, "-v")) {
- verbose_header = 1;
- header_prefix = "diff-tree ";
- continue;
- }
- if (!strncmp(arg, "--pretty", 8)) {
- verbose_header = 1;
- header_prefix = "diff-tree ";
- commit_format = get_commit_format(arg+8);
- continue;
- }
if (!strcmp(arg, "--stdin")) {
read_stdin = 1;
- continue;
- }
- if (!strcmp(arg, "--root")) {
- show_root_diff = 1;
- continue;
- }
- if (!strcmp(arg, "--no-commit-id")) {
- no_commit_id = 1;
- continue;
- }
- if (!strcmp(arg, "--always")) {
- always_show_header = 1;
continue;
}
usage(diff_tree_usage);
}
- if (combine_merges)
- ignore_merges = 0;
+ if (opt->combine_merges)
+ opt->ignore_merges = 0;
/* We can only do dense combined merges with diff output */
- if (dense_combined_merges)
- diff_options.output_format = DIFF_FORMAT_PATCH;
+ if (opt->dense_combined_merges)
+ opt->diffopt.output_format = DIFF_FORMAT_PATCH;
- if (diff_options.output_format == DIFF_FORMAT_PATCH)
- diff_options.recursive = 1;
+ if (opt->diffopt.output_format == DIFF_FORMAT_PATCH)
+ opt->diffopt.recursive = 1;
diff_tree_setup_paths(get_pathspec(prefix, argv));
- diff_setup_done(&diff_options);
+ diff_setup_done(&opt->diffopt);
switch (nr_sha1) {
case 0:
@@ -311,15 +132,16 @@ int main(int argc, const char **argv)
diff_tree_commit_sha1(sha1[0]);
break;
case 2:
- diff_tree_sha1_top(sha1[0], sha1[1], "");
+ diff_tree_sha1(sha1[0], sha1[1], "", &opt->diffopt);
+ log_tree_diff_flush(opt);
break;
}
if (!read_stdin)
return 0;
- if (diff_options.detect_rename)
- diff_options.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
+ if (opt->diffopt.detect_rename)
+ opt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
DIFF_SETUP_USE_CACHE);
while (fgets(line, sizeof(line), stdin))
diff_tree_stdin(line);
diff --git a/log-tree.c b/log-tree.c
new file mode 100644
index 0000000..3d40482
--- /dev/null
+++ b/log-tree.c
@@ -0,0 +1,175 @@
+#include "cache.h"
+#include "diff.h"
+#include "commit.h"
+#include "log-tree.h"
+
+void init_log_tree_opt(struct log_tree_opt *opt)
+{
+ memset(opt, 0, sizeof *opt);
+ opt->ignore_merges = 1;
+ opt->header_prefix = "";
+ opt->commit_format = CMIT_FMT_RAW;
+ diff_setup(&opt->diffopt);
+}
+
+int log_tree_opt_parse(struct log_tree_opt *opt, const char **av, int ac)
+{
+ const char *arg;
+ int cnt = diff_opt_parse(&opt->diffopt, av, ac);
+ if (0 < cnt)
+ return cnt;
+ arg = *av;
+ if (!strcmp(arg, "-r"))
+ opt->diffopt.recursive = 1;
+ else if (!strcmp(arg, "-t")) {
+ opt->diffopt.recursive = 1;
+ opt->diffopt.tree_in_recursive = 1;
+ }
+ else if (!strcmp(arg, "-m"))
+ opt->ignore_merges = 0;
+ else if (!strcmp(arg, "-c"))
+ opt->combine_merges = 1;
+ else if (!strcmp(arg, "--cc")) {
+ opt->dense_combined_merges = 1;
+ opt->combine_merges = 1;
+ }
+ else if (!strcmp(arg, "-v")) {
+ opt->verbose_header = 1;
+ opt->header_prefix = "diff-tree ";
+ }
+ else if (!strncmp(arg, "--pretty", 8)) {
+ opt->verbose_header = 1;
+ opt->header_prefix = "diff-tree ";
+ opt->commit_format = get_commit_format(arg+8);
+ }
+ else if (!strcmp(arg, "--root"))
+ opt->show_root_diff = 1;
+ else if (!strcmp(arg, "--no-commit-id"))
+ opt->no_commit_id = 1;
+ else if (!strcmp(arg, "--always"))
+ opt->always_show_header = 1;
+ else
+ return 0;
+ return 1;
+}
+
+int log_tree_diff_flush(struct log_tree_opt *opt)
+{
+ diffcore_std(&opt->diffopt);
+ if (diff_queue_is_empty()) {
+ int saved_fmt = opt->diffopt.output_format;
+ opt->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT;
+ diff_flush(&opt->diffopt);
+ opt->diffopt.output_format = saved_fmt;
+ return 0;
+ }
+ if (opt->header) {
+ if (!opt->no_commit_id)
+ printf("%s%c", opt->header,
+ opt->diffopt.line_termination);
+ opt->header = NULL;
+ }
+ diff_flush(&opt->diffopt);
+ return 1;
+}
+
+static int diff_root_tree(struct log_tree_opt *opt,
+ const unsigned char *new, const char *base)
+{
+ int retval;
+ void *tree;
+ struct tree_desc empty, real;
+
+ tree = read_object_with_reference(new, tree_type, &real.size, NULL);
+ if (!tree)
+ die("unable to read root tree (%s)", sha1_to_hex(new));
+ real.buf = tree;
+
+ empty.buf = "";
+ empty.size = 0;
+ retval = diff_tree(&empty, &real, base, &opt->diffopt);
+ free(tree);
+ log_tree_diff_flush(opt);
+ return retval;
+}
+
+static const char *generate_header(struct log_tree_opt *opt,
+ const unsigned char *commit_sha1,
+ const unsigned char *parent_sha1,
+ const struct commit *commit)
+{
+ static char this_header[16384];
+ int offset;
+ unsigned long len;
+ int abbrev = opt->diffopt.abbrev;
+ const char *msg = commit->buffer;
+
+ if (!opt->verbose_header)
+ return sha1_to_hex(commit_sha1);
+
+ len = strlen(msg);
+
+ offset = sprintf(this_header, "%s%s ",
+ opt->header_prefix,
+ diff_unique_abbrev(commit_sha1, abbrev));
+ if (commit_sha1 != parent_sha1)
+ offset += sprintf(this_header + offset, "(from %s)\n",
+ parent_sha1
+ ? diff_unique_abbrev(parent_sha1, abbrev)
+ : "root");
+ else
+ offset += sprintf(this_header + offset, "(from parents)\n");
+ offset += pretty_print_commit(opt->commit_format, commit, len,
+ this_header + offset,
+ sizeof(this_header) - offset, abbrev);
+ if (opt->always_show_header) {
+ puts(this_header);
+ return NULL;
+ }
+ return this_header;
+}
+
+static int do_diff_combined(struct log_tree_opt *opt, struct commit *commit)
+{
+ unsigned const char *sha1 = commit->object.sha1;
+
+ opt->header = generate_header(opt, sha1, sha1, commit);
+ opt->header = diff_tree_combined_merge(sha1, opt->header,
+ opt->dense_combined_merges,
+ &opt->diffopt);
+ if (!opt->header && opt->verbose_header)
+ opt->header_prefix = "\ndiff-tree ";
+ return 0;
+}
+
+int log_tree_commit(struct log_tree_opt *opt, struct commit *commit)
+{
+ struct commit_list *parents;
+ unsigned const char *sha1 = commit->object.sha1;
+
+ /* Root commit? */
+ if (opt->show_root_diff && !commit->parents) {
+ opt->header = generate_header(opt, sha1, NULL, commit);
+ diff_root_tree(opt, sha1, "");
+ }
+
+ /* More than one parent? */
+ if (commit->parents && commit->parents->next) {
+ if (opt->ignore_merges)
+ return 0;
+ else if (opt->combine_merges)
+ return do_diff_combined(opt, commit);
+ }
+
+ for (parents = commit->parents; parents; parents = parents->next) {
+ struct commit *parent = parents->item;
+ unsigned const char *psha1 = parent->object.sha1;
+ opt->header = generate_header(opt, sha1, psha1, commit);
+ diff_tree_sha1(psha1, sha1, "", &opt->diffopt);
+ log_tree_diff_flush(opt);
+
+ if (!opt->header && opt->verbose_header)
+ opt->header_prefix = "\ndiff-tree ";
+ }
+ return 0;
+}
diff --git a/log-tree.h b/log-tree.h
new file mode 100644
index 0000000..da166c6
--- /dev/null
+++ b/log-tree.h
@@ -0,0 +1,23 @@
+#ifndef LOG_TREE_H
+#define LOG_TREE_H
+
+struct log_tree_opt {
+ struct diff_options diffopt;
+ int show_root_diff;
+ int no_commit_id;
+ int verbose_header;
+ int ignore_merges;
+ int combine_merges;
+ int dense_combined_merges;
+ int always_show_header;
+ const char *header_prefix;
+ const char *header;
+ enum cmit_fmt commit_format;
+};
+
+void init_log_tree_opt(struct log_tree_opt *);
+int log_tree_diff_flush(struct log_tree_opt *);
+int log_tree_commit(struct log_tree_opt *, struct commit *);
+int log_tree_opt_parse(struct log_tree_opt *, const char **, int);
+
+#endif
--
1.2.6.gad0b
^ permalink raw reply related
* [PATCH] git log [diff-tree options]...
From: Junio C Hamano @ 2006-04-09 9:04 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
And this makes "git log" to take common diff-tree options, so
that it can be used as "git whatchanged".
The recent revision walker updates by Linus to make path
limiting low-latency helps this quite a bit.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
git.c | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
52b70d56bd23811003a72866cc23a0a44b9da1b7
diff --git a/git.c b/git.c
index fa58232..8776088 100644
--- a/git.c
+++ b/git.c
@@ -16,6 +16,8 @@ #include "common-cmds.h"
#include "cache.h"
#include "commit.h"
#include "revision.h"
+#include "diff.h"
+#include "log-tree.h"
#ifndef PATH_MAX
# define PATH_MAX 4096
@@ -285,7 +287,10 @@ static int cmd_log(int argc, const char
int abbrev = DEFAULT_ABBREV;
int abbrev_commit = 0;
const char *commit_prefix = "commit ";
+ struct log_tree_opt opt;
+ int do_diff = 0;
+ init_log_tree_opt(&opt);
argc = setup_revisions(argc, argv, &rev, "HEAD");
while (1 < argc) {
const char *arg = argv[1];
@@ -310,9 +315,31 @@ static int cmd_log(int argc, const char
else if (40 < abbrev)
abbrev = 40;
}
- else
+ else {
+ int cnt = log_tree_opt_parse(&opt, argv+1, argc-1);
+ if (0 < cnt) {
+ do_diff = 1;
+ argv += cnt;
+ argc -= cnt;
+ continue;
+ }
die("unrecognized argument: %s", arg);
+ }
+
argc--; argv++;
+ }
+ if (do_diff) {
+ opt.diffopt.abbrev = abbrev;
+ opt.verbose_header = 0;
+ opt.always_show_header = 0;
+ opt.no_commit_id = 1;
+ if (opt.combine_merges)
+ opt.ignore_merges = 0;
+ if (opt.dense_combined_merges)
+ opt.diffopt.output_format = DIFF_FORMAT_PATCH;
+ if (opt.diffopt.output_format == DIFF_FORMAT_PATCH)
+ opt.diffopt.recursive = 1;
+ diff_setup_done(&opt.diffopt);
}
prepare_revision_walk(&rev);
@@ -350,6 +377,9 @@ static int cmd_log(int argc, const char
pretty_print_commit(commit_format, commit, ~0, buf,
LOGSIZE, abbrev);
printf("%s\n", buf);
+
+ if (do_diff)
+ log_tree_commit(&opt, commit);
}
free(buf);
return 0;
--
1.2.6.gad0b
^ 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