Git development
 help / color / mirror / Atom feed
* Re: [PATCH] Resurrect diff-tree-helper -R
From: Petr Baudis @ 2005-05-13 22:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, git
In-Reply-To: <Pine.LNX.4.58.0504301805300.2296@ppc970.osdl.org>

Dear diary, on Sun, May 01, 2005 at 03:09:53AM CEST, I got a letter
where Linus Torvalds <torvalds@osdl.org> told me that...
> 
> 
> On Sat, 30 Apr 2005, Junio C Hamano wrote:
> >
> > Diff-tree-helper take two patch inadvertently dropped the
> > support of -R option
> 
> Talking about the diffs, I'm beginning to hate those "mode" things.
> 
> Not only do they screw up diffstat (big deal), but they are pointless, 
> since 99.9% of the time the mode stays the same.
> 
> So it would be much nicer (I think) if mode changes are handled 
> separately, with a simple separate line before the diff saying
> 
> 	"Mode change: %o->%o %s", oldmode, newmode, path
> 
> and not mess up the diff header. That way, you only see it when it
> actually makes any difference, and it's more readable both for humans
> _and_ machines as a result.
> 
> Normal "patch" will just ignore the extra lines before the diff anyway, so 
> it won't matter there.
> 
> Comments?

Sorry for replying after so much time, it looks like I missed this and
got here only after checking what change removed the mode: bits...

I'd personally prefer something like

	@.Mode change:

that is, using a '@.' prefix for those. It seems to be unique enough and
'@' is one of the four magic characters prefixing diff lines. Just using
the plain string seems too volatile, and I need to grep all the
interesting bits out of the diff file. This is because patch can
otherwise complain "only garbage found in the patch" when processing the
diff, which confuses my users greatly.

What do you think?

-- 
				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 2/2] update cg-* to use cg-Xignore
From: Petr Baudis @ 2005-05-13 22:55 UTC (permalink / raw)
  To: David Greaves; +Cc: GIT Mailing Lists
In-Reply-To: <E1DWihi-0007DQ-SD@ash.dgreaves.com>

Dear diary, on Sat, May 14, 2005 at 12:32:22AM CEST, I got a letter
where David Greaves <david@dgreaves.com> told me that...
> Updated
>     cg-add
>     cg-commit

I consider this Bad Thing (tm). Or could you please point a situation
where this would be actually useful? If you explicitly cg-add, you
likely know what are you doing, and same thing with cg-commit - if it's
already added, it should be watches, no matter what ignore patterns, I
think.
> --- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-commit  (mode:100755)
> +++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-commit  (mode:100755)
> @@ -65,6 +65,15 @@
>  	[ -s $_git/merging ] && merging=$(cat $_git/merging | sed 's/^/-p /')
>  fi
>  
> +# strip ignored files - *1 at a time* - any attempt to stream from 1
> +# while loop to another uses a subprocess and can't pass the variable
> +# back
> +# Also I don't know if this can be put in a shell function
> +for file in ${commitfiles[@]}
> +  do
> +  commitfiles[$i]=`echo $file | cg-Xignore`
> +  ((i++))
> +done
>  
>  LOGMSG=$(mktemp -t gitci.XXXXXX)
>  LOGMSG2=$(mktemp -t gitci.XXXXXX)

The variable? What variable?

> Index: cg-status
> ===================================================================
> --- d2490ad0bc8b38647c6baff9da3e72c0f25e9f35/cg-status  (mode:100755)
> +++ 03662df7d089d4a84987ef9edb50a017b8b42439/cg-status  (mode:100755)
> @@ -15,21 +15,11 @@
>  
>  {
>  	git-ls-files -z -t --others --deleted --unmerged $EXCLUDE
> -} | sort -z -k 2 | xargs -0 sh -c '
> -while [ "$1" ]; do
> -	tag=${1% *};
> -	filename=${1#* };
> -	case "$filename" in
> -	*.[ao] | tags | ,,merge*) ;;
> -	*)   echo "$tag $filename";;
> -	esac
> -	shift
> -done
> -' padding
> +} | sort -z -k 2 | cg-Xignore -0 -t | tr "\000" "\n"

So you have two ignores now - exclude and Xignore.

-- 
				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] Resurrect diff-tree-helper -R
From: Junio C Hamano @ 2005-05-13 22:50 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Linus Torvalds, git
In-Reply-To: <20050513224529.GF32232@pasky.ji.cz>

Have you checked what the current one does?


^ permalink raw reply

* Re: [PATCH] Resurrect diff-tree-helper -R
From: Junio C Hamano @ 2005-05-13 23:05 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Linus Torvalds, git
In-Reply-To: <20050513224529.GF32232@pasky.ji.cz>

>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:

PB> that is, using a '@.' prefix for those. It seems to be unique enough and
PB> '@' is one of the four magic characters prefixing diff lines. Just using
PB> the plain string seems too volatile, and I need to grep all the
PB> interesting bits out of the diff file. This is because patch can
PB> otherwise complain "only garbage found in the patch" when processing the
PB> diff, which confuses my users greatly.

PB> What do you think?

Personally what I think is that grepping in the diff, especially
if the diff is something you are generating (I am assuming that
you are taling about cg-diff fed to cg-patch to port work tree
changes forward), is a wrong way to do things.

The way JIT does the equivalent is via git-apply-patch-script.
You run git-diff-{files,cache,tree}, setting GIT_EXTERNAL_DIFF
environment variable to git-apply-patch-script, and have the
apply-patch-script to take care of the mode changes, creation,
etc.  See the implementation of the jit-patch command if you are
interested.


^ permalink raw reply

* Re: [PATCH] update README and #include in git.txt
From: Petr Baudis @ 2005-05-13 22:57 UTC (permalink / raw)
  To: David Greaves; +Cc: GIT Mailing Lists
In-Reply-To: <42852A44.7010806@dgreaves.com>

Dear diary, on Sat, May 14, 2005 at 12:29:24AM CEST, I got a letter
where David Greaves <david@dgreaves.com> told me that...
> >>Index: README
> >>===================================================================
> >>--- 3c79088f1832d78012ccdb63e5da1ab88fcf408e/README  (mode:100644)
> >>+++ e0e578bb02a7d8db1c105fddf5b5168ad0c79088/README  (mode:100644)
> >>@@ -1,9 +1,13 @@
> >>+////////////////////////////////////////////////////////////////
> >>+	GIT - the stupid content tracker
> >>
> >>
> >>-
> >>-	GIT - the stupid content tracker
> >>+Note that this README is written in asciidoc format and is #include'd
> >>+in the git.txt docs
> >>
> >>
> >>+The rest of this README is #included in the git.txt file
> >>+////////////////////////////////////////////////////////////////
> >> "git" can mean anything, depending on your mood.
> >>
> >>  - random three-letter combination that is pronounceable, and not
> >>    
> >>
> >
> >I'd probably prefer this being much less prominent. Can it be rather at
> >the bottom of the file?
> >  
> >
> If you mean the header in the ///'s?
> yes - but I wanted editors to realise it is asciidoc so kept it at the top.

But it's called README, not EDITME. And I think it's cluttering for the
readers.

> >You're reintroducing the "typos" fixed before, apparently.
> >  
> >
> I didn't notice the i.e. vs ie - I'm not that bothered ;)

But there were other typo fixes there and the big reindenting won't show
up any further changes to the text. I don't want to lose them so I'm
concerned 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: [PATCH] Resurrect diff-tree-helper -R
From: Junio C Hamano @ 2005-05-13 22:59 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Linus Torvalds, git
In-Reply-To: <20050513224529.GF32232@pasky.ji.cz>

PB> Sorry for replying after so much time, it looks like I missed this and
PB> got here only after checking what change removed the mode: bits...

PB> What do you think?

FYI, here is a demonsrtation of what you have right now.
Temporarily slurp in the test framework patch you hate so much
to get t/test-lib.sh ;-), apply this to get t/t2000-diff.sh, cd
to t and say sh ./t2000-diff.sh

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
jit-diff 1: t/t2000-diff.sh
# - HEAD: Fix git-diff-files for symlinks.
# + (working tree)
Created: t/t2000-diff.sh (mode:100755)
--- /dev/null
+++ b/t/t2000-diff.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Test built-in diff output engine.
+
+'
+. ./test-lib.sh
+
+echo >path0 'Line 1
+Line 2
+line 3'
+cat path0 >path1
+chmod +x path1
+git-update-cache --add path0 path1
+mv path0 path0-
+sed -e 's/line/Line/' <path0- >path0
+chmod +x path0
+rm -f path1
+git-diff-files -p >current
+cat >expected <<\EOF
+Mode changed: path0 (100644->100755)
+--- a/path0
++++ b/path0
+@@ -1,3 +1,3 @@
+ Line 1
+ Line 2
+-line 3
++Line 3
+Deleted: path1
+--- a/path1
++++ /dev/null
+@@ -1,3 +0,0 @@
+-Line 1
+-Line 2
+-line 3
+EOF
+
+test_expect_success 'cmp -s current expected'
+test_done



^ permalink raw reply

* Re: [PATCH 0/4] Pulling refs files
From: Daniel Barkalow @ 2005-05-13 23:14 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git, Linus Torvalds
In-Reply-To: <20050513221935.GC32232@pasky.ji.cz>

On Sat, 14 May 2005, Petr Baudis wrote:

> Hmm, I've honestly expected something different - a generic way to
> specify any file in the repository to be pulled along, instead of a
> introducing refs awareness at this level of git. What would be the
> advantages of that approach against just specifying list of other files
> to pull along?

The point is to specify the commit to pull by fetching a file from the
other side, not just to move a file. So you need to be specifying that the
file is a hex encoding of the sha1 hash of the starting point of the pull,
and the refs/ area is where these are expected to be. (Note that it still
doesn't have any knowledge about the meanings of files in refs/; you tell
it which one you want to use, and optionally which one you want to write
to, and it will use the names you provide).

It wouldn't help much to download the head file if you had to know the
contents of that file already in order to do everything as a single
transfer.

	-Daniel
*This .sig left intentionally blank*


^ permalink raw reply

* Re: [PATCH] Ignore file filter
From: Petr Baudis @ 2005-05-13 23:12 UTC (permalink / raw)
  To: David Greaves; +Cc: GIT Mailing Lists
In-Reply-To: <4283CAF8.3050304@dgreaves.com>

Dear diary, on Thu, May 12, 2005 at 11:30:32PM CEST, I got a letter
where David Greaves <david@dgreaves.com> told me that...
> # This doesn't allow the -h which is the [ arg for symlinks...

But so is -L. And I'd just use -l...

> #. ${COGITO_LIB}cg-Xlib
> _git=${GIT_DIR:-.git}

...but it makes no sense anyway I think to reinclude this stuff from a
cg-Xfile you are including from other scripts anyway.

> 	    if [[ $file =~ $patt ]]; then

I'm sorry but this is really nothing my bash-2.05.0(1)-release supports.
We're already bash-only, but further reducing that to bash3 really won't
work. I *might* get convinced to add some bash2+-only feature, but only
if you'll be really good at explaining that it makes sense.

Besides, I'd prefer just the shell globs in the ignore file, as it is
done in the rest of the world, and in all the real-world scenarios I've
seen, the globs were powerful enough.

Also, how does this interact with git-ls-files --exclude and
.git/exclude? We would have two ignoring mechanisms...

-- 
				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] Resurrect diff-tree-helper -R
From: Petr Baudis @ 2005-05-13 23:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <7vhdh691gs.fsf@assigned-by-dhcp.cox.net>

Dear diary, on Sat, May 14, 2005 at 12:59:31AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> Created: t/t2000-diff.sh (mode:100755)
> +Mode changed: path0 (100644->100755)

Great, so it's even worse than before. :/

My issues:

* Highly inconsistent format. Created has the "old-style" mode stuff
while changed mode looks completely differently. If you look at the
regular diffs, do you notice any format differences between creating
a file and modifying it?

	Actually, I think it should just always look as

		@ Mode changed: A->B C

	where either A or B may be empty (for file creation/deletion).
	I can see no point in further Created/Deleted lines.

* Filename not last. That'd be much friendlier to scripting, then you
could just split the line by spaces and at a certain point slurp the
rest and say that that would be a filename.

* No special prefix. Even if you think I shouldn't grep (it makes no
sense to me to redo half of the stuff when I already have something
reusable done, for no apparent benefit), I feel quite uncomfortable with
picking up and interpreting random pieces of surrounding text which
aren't marked as special in any way.

-- 
				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 0/4] Pulling refs files
From: Petr Baudis @ 2005-05-13 23:37 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: git, Linus Torvalds
In-Reply-To: <Pine.LNX.4.21.0505131853020.30848-100000@iabervon.org>

Dear diary, on Sat, May 14, 2005 at 01:14:22AM CEST, I got a letter
where Daniel Barkalow <barkalow@iabervon.org> told me that...
> On Sat, 14 May 2005, Petr Baudis wrote:
> 
> > Hmm, I've honestly expected something different - a generic way to
> > specify any file in the repository to be pulled along, instead of a
> > introducing refs awareness at this level of git. What would be the
> > advantages of that approach against just specifying list of other files
> > to pull along?
> 
> The point is to specify the commit to pull by fetching a file from the
> other side, not just to move a file. So you need to be specifying that the
> file is a hex encoding of the sha1 hash of the starting point of the pull,
> and the refs/ area is where these are expected to be. (Note that it still
> doesn't have any knowledge about the meanings of files in refs/; you tell
> it which one you want to use, and optionally which one you want to write
> to, and it will use the names you provide).
> 
> It wouldn't help much to download the head file if you had to know the
> contents of that file already in order to do everything as a single
> transfer.

So what about just something like

	git-wormhole-pull remote:refs/head/master wormhole://localhost/

That is, you could just specify remote:path_relative_to_url instead of
SHA1 id as the commit.

-- 
				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] [RFD] Add repoid identifier to commit [its a workspace id, isn't it?]
From: Petr Baudis @ 2005-05-13 23:39 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Jon Seymour, tglx, git
In-Reply-To: <428529AD.5000401@zytor.com>

Dear diary, on Sat, May 14, 2005 at 12:26:53AM CEST, I got a letter
where "H. Peter Anvin" <hpa@zytor.com> told me that...
> Petr Baudis wrote:
> >
> >Why not just call the thing "branch"? It's as well eligible for that
> >term as anything. :-)
> >
> 
> Because cogito already calls too many things "branches"?

Well, I know of one thing cogito calls "branch", and incidentally the
meaning if effectively same as this "branch" would have.

-- 
				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] [RFD] Add repoid identifier to commit [its a workspace id, isn't it?]
From: Jon Seymour @ 2005-05-13 23:49 UTC (permalink / raw)
  To: Petr Baudis; +Cc: H. Peter Anvin, tglx, git
In-Reply-To: <20050513222502.GD32232@pasky.ji.cz>

On 5/14/05, Petr Baudis <pasky@ucw.cz> wrote:
> Dear diary, on Fri, May 13, 2005 at 03:37:47AM CEST, I got a letter
> where Jon Seymour <jon.seymour@gmail.com> told me that...
> > >
> > > I would like to suggest a few limiters are set on the repoid.  In
> > > particular, I'd like to suggest that a repoid is a UUID, that a file is
> > > used to track it (.git/repoid), and that if it doesn't exist, a new one
> > > is created from /dev/urandom.
> > >
> >
> > I think I understand what Thomas is trying to achieve, but I think
> > there is a naming problem here. The marker really isn't a repoid - it
> > is a workspace id.
> 
> Why not just call the thing "branch"? It's as well eligible for that
> term as anything. :-)
> 

I very nearly agreed with you except for one thing. In a traditional
SCM, a branch is something that can be contributed by multiple people
but I don't think we want that meaning here.

Consider this graph where there is a main Trunk R, and a branch B and
two programmers Ba and Bb working on a branch B.  Thomas wants to be
able to form views of the merge order of 3 workspaces (W(R), W(Ba) and
W(Bb)), even though Ba and Bb are working on the same "branch" in SCM
terms.

Rn -------------
|      \         \ 
Rn-1 Ba,n   Bb,n
|     /             |
Rn-2             |
|       \           |
Rn-3 Ba,n-1  |
|    /             /
Rn-4 -----------

Also, most times in a traditional SCM, branches diverge, but the
behaviour we are interested in here is the repeated converging and
diverging of workspaces on the same "branch" [ I know, a branches can
be used in that way in traditional SCMs, but that is a degenerate case
of their intended use - maintaining paths of long term divergence ].

So, while I think there may well be some value is a separate
"branchid" attribute in a commit, I think they are describing
(slightly) different things.

jon
-- 
homepage: http://www.zeta.org.au/~jon/
blog: http://orwelliantremors.blogspot.com/

^ permalink raw reply

* Re: [PATCH] Resurrect diff-tree-helper -R
From: Junio C Hamano @ 2005-05-13 23:59 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Linus Torvalds, git
In-Reply-To: <20050513233354.GK32232@pasky.ji.cz>

>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:

PB> Dear diary, on Sat, May 14, 2005 at 12:59:31AM CEST, I got a letter
PB> where Junio C Hamano <junkio@cox.net> told me that...
>> Created: t/t2000-diff.sh (mode:100755)
>> +Mode changed: path0 (100644->100755)

PB> Great, so it's even worse than before. :/

Depends on the definition of "before".  At the beginning, we did
not do anything special and always said l/foo k/foo even when
create/delete was involved.  Then we did a misguided attempt to
minimally be cg-diff compatible, which Linus complained that it
was too distracting for human consumption.  The current one is
something in between, a lot more human side.

Yes, it is off course worse than the minimally cg-diff
compatible one, from cg-patch'es point of view.

You have seen what the current "something in between" does.
What I think is that in order not to distract human (read:
Linus) who reads patches, they should not share the same special
characters like "@".  Which unfortunately completely contradicts
what you are attempting to do.  Another thing we did while you
were looking other way ;-) was that we say mode changed only
when things change, so in that sense it is "inconsistent" from
the scripting point of view.  These were all done to make the
output more readable by and less distracting for humans, per
request from Linus.

I do not think nobody uses that current textual "comment"
information in automated tools (I do not), so changing them
should not be a problem.  How about we do something like this:

  1. Invent an environment variable you can define.  Let's say
     GIT_DIFF_SHOW_MODES.  It could alternatively a flag you
     pass from git-diff-{files,cache,tree,tree-helper} to the
     internal diff engine but then you need to add the necessary
     command line parameter for all these commands.  I can be
     persuaded in either way.

  2. When it is defined, we are not interested in pleasing Linus
     by trying not to be distracting.  We are more interested in
     producing patch that is easily script processible.

  3. Keep the current behaviour for human comsumption when we
     are operating without the option we define in 1.

  4. Change the mode stuff when GIT_DIFF_SHOW_MODES is defined.
     It would produce one of the following for _all_ entries;

     @. (100644->100755) path/to/a/file/that/changed/mode
     @. (100644->120000) path/to/a/file/that/changed/to/symlink
     @. (100644->100644) path/to/a/file/with/no/mode/change
     @. (.->100644) path/to/a/new/file
     @. (100644->.) path/to/a/deleted/file

     I have to stress that these would come immediately before
     the patch for each file.  Not upfront, not grouped together
     at the beginning.

BTW, what do you think about renaming git-diff-tree-helper to
just git-diff-helper?  It used to be for grokking diff-tree's
output but now the family have the same raw output format it
does not make much sense to keep "tree" in its name.


^ permalink raw reply

* Re: [PATCH] Resurrect diff-tree-helper -R
From: Junio C Hamano @ 2005-05-14  0:03 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Linus Torvalds, git
In-Reply-To: <20050513233354.GK32232@pasky.ji.cz>

>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:

PB> .... Even if you think I shouldn't grep

I do not mean you should never grep.  There are cases when there
is no alternative.  One case I did not mention is that you would
want to accept patches via e-mail and apply.  In such a case,
GIT_EXTERNAL_DIFF with git-apply-patch-script way would not work
because that approach is essentially to patch while you are
generating diff locally.


^ permalink raw reply

* Re: [PATCH] Resurrect diff-tree-helper -R
From: Junio C Hamano @ 2005-05-14  0:33 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Linus Torvalds, git
In-Reply-To: <7vmzqy7k47.fsf@assigned-by-dhcp.cox.net>

Another possibility.  How about generating the following _only_
when mode changes (including create and delete), even for human
consumption?  There will be _no_ such line when mode or type
does not change.

# mode: 100644 100755 path/to/a/file/that/changed/mode
# mode: 100644 120000 path/to/a/file/that/changed/to/symlink
# mode: 100644 100644 path/to/a/file/with/no/mode/change
# mode: . 100644 path/to/a/new/file
# mode: 100644 . path/to/a/deleted/file

This is not "something like this", but a proposal for the exact
output format specification (I am going to code immediately).
Each token above is separated with exactly one ' ' (ASCII 0x20)
each, and such a line comes immediately before the patch for the
file.  Showing both mode bits is to prepare for the case you
would want to apply the patch in reverse.

This is for machine consumption and there is no need to force
them to parse out -> and (), so I dropped them.  And mode or
type change happens so rarely, it would be OK for human
consumption if we show these garbage (from human point of view)
only when things change.  Can you parse this, or do you always
want to have them even if nothing changes?

Let's see how this would look like to humans.

    # mode: 100644 100755 path0
    --- a/path0
    +++ b/path0
    @@ -1,3 +1,3 @@
     Line 1
     Line 2
    -line 3
    +Line 3
    # mode: 100644 . path1
    --- a/path1
    +++ /dev/null
    @@ -1,3 +0,0 @@
    -Line 1
    -Line 2
    -line 3
    --- a/path2
    +++ b/path2
    @@ -1,3 +1,3 @@
     Line 1
     Line 2
    -line 3
    +Line 3
    # mode: . 100755 t/t2000-diff.sh
    --- /dev/null
    +++ b/t/t2000-diff.sh
    @@ -0,0 +1,41 @@
    ...

Doesn't look too bad, does it?


^ permalink raw reply

* [PATCH 0/3] diff overhaul
From: Junio C Hamano @ 2005-05-14  1:39 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

Here are three patches to update diff we discussed earlier.

  [PATCH 1/3] Update mode-change strings in diff output.
  [PATCH 2/3] Rename git-diff-tree-helper to git-diff-helper.
  [PATCH 3/3] Rename git-diff-tree-helper to git-diff-helper (part 2).

The first one is to normalize the mode bits output to be more
machine friendly, which we discussed.

The second commit records only renames for two files and there
is no content change.  The third one is to change the Makefiles,
documentation, and also usage string in git-diff-helper itself.

I am deliverately doing the 2 and 3 in separate steps for two
reasons.  (1) to reduce the possibility of mistakes during the
rename for myself; (2) people doing the git repository browser
can use the commit trail for practicing their rename detection
logic.  So please keep these two steps separate when you commit.


^ permalink raw reply

* [PATCH 1/3] Update mode-change strings in diff output.
From: Junio C Hamano @ 2005-05-14  1:40 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

This updates the mode change strings to be a bit more machine
friendly.  Although this might go against the spirit of
readability for human consumption, these mode bits strings are
shown only when unusual things (mode change, file creation and
deletion) happens, output normalized for machine consumption
would be permissible.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

diff.c |   22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)

--- a/diff.c
+++ b/diff.c
@@ -83,6 +83,7 @@
 			 struct diff_tempfile *temp)
 {
 	int i, next_at;
+	const char *git_prefix = "# mode: ";
 	const char *diff_cmd = "diff -L'%s%s' -L'%s%s'";
 	const char *diff_arg  = "'%s' '%s'||:"; /* "||:" is to return 0 */
 	const char *input_name_sq[2];
@@ -123,17 +124,18 @@
 			    diff_arg, input_name_sq[0], input_name_sq[1]);
 
 	if (!path1[0][0])
-		printf("Created: %s (mode:%s)\n", name, temp[1].mode);
+		printf("%s. %s %s\n", git_prefix, temp[1].mode, name);
 	else if (!path1[1][0])
-		printf("Deleted: %s\n", name);
-	else if (strcmp(temp[0].mode, temp[1].mode)) {
-		printf("Mode changed: %s (%s->%s)\n", name,
-		       temp[0].mode, temp[1].mode);
-		/* Be careful.  We do not want to diff between
-		 * symlink and a file.
-		 */
-		if (strncmp(temp[0].mode, "120", 3) !=
-		    strncmp(temp[1].mode, "120", 3))
+		printf("%s%s . %s\n", git_prefix, temp[0].mode, name);
+	else {
+		if (strcmp(temp[0].mode, temp[1].mode))
+			printf("%s%s %s %s\n", git_prefix,
+			       temp[0].mode, temp[1].mode, name);
+
+		if (strncmp(temp[0].mode, temp[1].mode, 3))
+			/* we do not run diff between different kind
+			 * of objects.
+			 */
 			exit(0);
 	}
 	fflush(NULL);


^ permalink raw reply

* [PATCH 2/3] Rename git-diff-tree-helper to git-diff-helper.
From: Junio C Hamano @ 2005-05-14  1:40 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

It used to be that diff-tree needed helper support to parse its
raw output to generate diffs, but these days git-diff-* family
produces the same output and the helper is not tied to diff-tree
anymore.  Drop "tree" from its name.

This commit is done separately to record just the rename and no
file content changes.  Makefiles and documentation needs to be
adjusted, which is done in the next commit.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

Documentation/git-diff-helper.txt      |   49 +++++++++++
Documentation/git-diff-tree-helper.txt |   49 -----------
diff-helper.c                          |  143 +++++++++++++++++++++++++++++++++
diff-tree-helper.c                     |  143 ---------------------------------
4 files changed, 192 insertions(+), 192 deletions(-)
Documentation/git-diff-helper.txt (. --> 100644)
Documentation/git-diff-tree-helper.txt (100644 --> .)
diff-helper.c (. --> 100644)
diff-tree-helper.c (100644 --> .)

--- a/Documentation/git-diff-helper.txt
+++ b/Documentation/git-diff-helper.txt
@@ -0,0 +1,49 @@
+git-diff-tree-helper(1)
+=======================
+v0.1, May 2005
+
+NAME
+----
+git-diff-tree-helper - Generates patch format output for git-diff-*
+
+
+SYNOPSIS
+--------
+'git-diff-tree-helper' [-z] [-R]
+
+DESCRIPTION
+-----------
+Reads output from "git-diff-cache", "git-diff-tree" and "git-diff-files" and
+generates patch format output.
+
+OPTIONS
+-------
+-z::
+	\0 line termination on input
+
+-R::
+	Output diff in reverse.  This is useful for displaying output from
+	"git-diff-cache" which always compares tree with cache or working
+	file.  E.g.
+
+		git-diff-cache <tree> | git-diff-tree-helper -R file.c
++
+would show a diff to bring the working file back to what is in the <tree>.
+
+See Also
+--------
+The section on generating patches in link:git-diff-cache.html[git-diff-cache]
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the link:git.html[git] suite
+
--- a/Documentation/git-diff-tree-helper.txt
+++ b/Documentation/git-diff-tree-helper.txt
@@ -1,49 +0,0 @@
-git-diff-tree-helper(1)
-=======================
-v0.1, May 2005
-
-NAME
-----
-git-diff-tree-helper - Generates patch format output for git-diff-*
-
-
-SYNOPSIS
---------
-'git-diff-tree-helper' [-z] [-R]
-
-DESCRIPTION
------------
-Reads output from "git-diff-cache", "git-diff-tree" and "git-diff-files" and
-generates patch format output.
-
-OPTIONS
--------
--z::
-	\0 line termination on input
-
--R::
-	Output diff in reverse.  This is useful for displaying output from
-	"git-diff-cache" which always compares tree with cache or working
-	file.  E.g.
-
-		git-diff-cache <tree> | git-diff-tree-helper -R file.c
-+
-would show a diff to bring the working file back to what is in the <tree>.
-
-See Also
---------
-The section on generating patches in link:git-diff-cache.html[git-diff-cache]
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the link:git.html[git] suite
-
--- a/diff-helper.c
+++ b/diff-helper.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2005 Junio C Hamano
+ */
+#include <limits.h>
+#include "cache.h"
+#include "strbuf.h"
+#include "diff.h"
+
+static int matches_pathspec(const char *name, const char **spec, int cnt)
+{
+	int i;
+	int namelen = strlen(name);
+	for (i = 0; i < cnt; i++) {
+		int speclen = strlen(spec[i]);
+		if (! strncmp(spec[i], name, speclen) &&
+		    speclen <= namelen &&
+		    (name[speclen] == 0 ||
+		     name[speclen] == '/'))
+			return 1;
+	}
+	return 0;
+}
+
+static int parse_oneside_change(const char *cp, struct diff_spec *one,
+				char *path)
+{
+	int ch;
+
+	one->file_valid = one->sha1_valid = 1;
+	one->mode = 0;
+	while ((ch = *cp) && '0' <= ch && ch <= '7') {
+		one->mode = (one->mode << 3) | (ch - '0');
+		cp++;
+	}
+
+	if (strncmp(cp, "\tblob\t", 6))
+		return -1;
+	cp += 6;
+	if (get_sha1_hex(cp, one->blob_sha1))
+		return -1;
+	cp += 40;
+	if (*cp++ != '\t')
+		return -1;
+	strcpy(path, cp);
+	return 0;
+}
+
+static int parse_diff_tree_output(const char *buf,
+				  const char **spec, int cnt, int reverse)
+{
+	struct diff_spec old, new;
+	char path[PATH_MAX];
+	const char *cp = buf;
+	int ch;
+
+	switch (*cp++) {
+	case 'U':
+		if (!cnt || matches_pathspec(cp + 1, spec, cnt))
+			diff_unmerge(cp + 1);
+		return 0;
+	case '+':
+		old.file_valid = 0;
+		parse_oneside_change(cp, &new, path);
+		break;
+	case '-':
+		new.file_valid = 0;
+		parse_oneside_change(cp, &old, path);
+		break;
+	case '*':
+		old.file_valid = old.sha1_valid =
+			new.file_valid = new.sha1_valid = 1;
+		old.mode = new.mode = 0;
+		while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
+			old.mode = (old.mode << 3) | (ch - '0');
+			cp++;
+		}
+		if (strncmp(cp, "->", 2))
+			return -1;
+		cp += 2;
+		while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
+			new.mode = (new.mode << 3) | (ch - '0');
+			cp++;
+		}
+		if (strncmp(cp, "\tblob\t", 6))
+			return -1;
+		cp += 6;
+		if (get_sha1_hex(cp, old.blob_sha1))
+			return -1;
+		cp += 40;
+		if (strncmp(cp, "->", 2))
+			return -1;
+		cp += 2;
+		if (get_sha1_hex(cp, new.blob_sha1))
+			return -1;
+		cp += 40;
+		if (*cp++ != '\t')
+			return -1;
+		strcpy(path, cp);
+		break;
+	default:
+		return -1;
+	}
+	if (!cnt || matches_pathspec(path, spec, cnt)) {
+		if (reverse)
+			run_external_diff(path, &new, &old);
+		else
+			run_external_diff(path, &old, &new);
+	}
+	return 0;
+}
+
+static const char *diff_tree_helper_usage =
+"diff-tree-helper [-R] [-z] paths...";
+
+int main(int ac, const char **av) {
+	struct strbuf sb;
+	int reverse = 0;
+	int line_termination = '\n';
+
+	strbuf_init(&sb);
+
+	while (1 < ac && av[1][0] == '-') {
+		if (av[1][1] == 'R')
+			reverse = 1;
+		else if (av[1][1] == 'z')
+			line_termination = 0;
+		else
+			usage(diff_tree_helper_usage);
+		ac--; av++;
+	}
+	/* the remaining parameters are paths patterns */
+
+	while (1) {
+		int status;
+		read_line(&sb, stdin, line_termination);
+		if (sb.eof)
+			break;
+		status = parse_diff_tree_output(sb.buf, av+1, ac-1, reverse);
+		if (status)
+			fprintf(stderr, "cannot parse %s\n", sb.buf);
+	}
+	return 0;
+}
--- a/diff-tree-helper.c
+++ b/diff-tree-helper.c
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2005 Junio C Hamano
- */
-#include <limits.h>
-#include "cache.h"
-#include "strbuf.h"
-#include "diff.h"
-
-static int matches_pathspec(const char *name, const char **spec, int cnt)
-{
-	int i;
-	int namelen = strlen(name);
-	for (i = 0; i < cnt; i++) {
-		int speclen = strlen(spec[i]);
-		if (! strncmp(spec[i], name, speclen) &&
-		    speclen <= namelen &&
-		    (name[speclen] == 0 ||
-		     name[speclen] == '/'))
-			return 1;
-	}
-	return 0;
-}
-
-static int parse_oneside_change(const char *cp, struct diff_spec *one,
-				char *path)
-{
-	int ch;
-
-	one->file_valid = one->sha1_valid = 1;
-	one->mode = 0;
-	while ((ch = *cp) && '0' <= ch && ch <= '7') {
-		one->mode = (one->mode << 3) | (ch - '0');
-		cp++;
-	}
-
-	if (strncmp(cp, "\tblob\t", 6))
-		return -1;
-	cp += 6;
-	if (get_sha1_hex(cp, one->blob_sha1))
-		return -1;
-	cp += 40;
-	if (*cp++ != '\t')
-		return -1;
-	strcpy(path, cp);
-	return 0;
-}
-
-static int parse_diff_tree_output(const char *buf,
-				  const char **spec, int cnt, int reverse)
-{
-	struct diff_spec old, new;
-	char path[PATH_MAX];
-	const char *cp = buf;
-	int ch;
-
-	switch (*cp++) {
-	case 'U':
-		if (!cnt || matches_pathspec(cp + 1, spec, cnt))
-			diff_unmerge(cp + 1);
-		return 0;
-	case '+':
-		old.file_valid = 0;
-		parse_oneside_change(cp, &new, path);
-		break;
-	case '-':
-		new.file_valid = 0;
-		parse_oneside_change(cp, &old, path);
-		break;
-	case '*':
-		old.file_valid = old.sha1_valid =
-			new.file_valid = new.sha1_valid = 1;
-		old.mode = new.mode = 0;
-		while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
-			old.mode = (old.mode << 3) | (ch - '0');
-			cp++;
-		}
-		if (strncmp(cp, "->", 2))
-			return -1;
-		cp += 2;
-		while ((ch = *cp) && ('0' <= ch && ch <= '7')) {
-			new.mode = (new.mode << 3) | (ch - '0');
-			cp++;
-		}
-		if (strncmp(cp, "\tblob\t", 6))
-			return -1;
-		cp += 6;
-		if (get_sha1_hex(cp, old.blob_sha1))
-			return -1;
-		cp += 40;
-		if (strncmp(cp, "->", 2))
-			return -1;
-		cp += 2;
-		if (get_sha1_hex(cp, new.blob_sha1))
-			return -1;
-		cp += 40;
-		if (*cp++ != '\t')
-			return -1;
-		strcpy(path, cp);
-		break;
-	default:
-		return -1;
-	}
-	if (!cnt || matches_pathspec(path, spec, cnt)) {
-		if (reverse)
-			run_external_diff(path, &new, &old);
-		else
-			run_external_diff(path, &old, &new);
-	}
-	return 0;
-}
-
-static const char *diff_tree_helper_usage =
-"diff-tree-helper [-R] [-z] paths...";
-
-int main(int ac, const char **av) {
-	struct strbuf sb;
-	int reverse = 0;
-	int line_termination = '\n';
-
-	strbuf_init(&sb);
-
-	while (1 < ac && av[1][0] == '-') {
-		if (av[1][1] == 'R')
-			reverse = 1;
-		else if (av[1][1] == 'z')
-			line_termination = 0;
-		else
-			usage(diff_tree_helper_usage);
-		ac--; av++;
-	}
-	/* the remaining parameters are paths patterns */
-
-	while (1) {
-		int status;
-		read_line(&sb, stdin, line_termination);
-		if (sb.eof)
-			break;
-		status = parse_diff_tree_output(sb.buf, av+1, ac-1, reverse);
-		if (status)
-			fprintf(stderr, "cannot parse %s\n", sb.buf);
-	}
-	return 0;
-}


^ permalink raw reply

* [PATCH 3/3] Rename git-diff-tree-helper to git-diff-helper (part 2).
From: Junio C Hamano @ 2005-05-14  1:41 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

It used to be that diff-tree needed helper support to parse its
raw output to generate diffs, but these days git-diff-* family
produces the same output and the helper is not tied to diff-tree
anymore.  Drop "tree" from its name.

This follows the "rename only" commit to adjust the contents of
the files involved.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

Documentation/diff-format.txt     |    2 +-
Documentation/git-diff-helper.txt |   10 +++++-----
Documentation/git.txt             |    2 +-
Makefile                          |    4 ++--
diff-helper.c                     |   12 ++++++------
diff.h                            |    2 +-
6 files changed, 16 insertions(+), 16 deletions(-)

--- a/Documentation/diff-format.txt
+++ b/Documentation/diff-format.txt
@@ -45,7 +45,7 @@
 instead they produce a patch file.
 
 The patch generation can be customized at two levels.  This
-customization also applies to "git-diff-tree-helper".
+customization also applies to "git-diff-helper".
 
 1. When the environment variable 'GIT_EXTERNAL_DIFF' is not set,
    these commands internally invoke "diff" like this:
--- a/Documentation/git-diff-helper.txt
+++ b/Documentation/git-diff-helper.txt
@@ -1,15 +1,15 @@
-git-diff-tree-helper(1)
+git-diff-helper(1)
 =======================
 v0.1, May 2005
 
 NAME
 ----
-git-diff-tree-helper - Generates patch format output for git-diff-*
+git-diff-helper - Generates patch format output for git-diff-*
 
 
 SYNOPSIS
 --------
-'git-diff-tree-helper' [-z] [-R]
+'git-diff-helper' [-z] [-R]
 
 DESCRIPTION
 -----------
@@ -26,8 +26,8 @@
 	"git-diff-cache" which always compares tree with cache or working
 	file.  E.g.
 
-		git-diff-cache <tree> | git-diff-tree-helper -R file.c
-+
+		git-diff-cache <tree> | git-diff-helper -R file.c
+
 would show a diff to bring the working file back to what is in the <tree>.
 
 See Also
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -149,7 +149,7 @@
 
 Interogators:
 
-link:git-diff-tree-helper.html[git-diff-tree-helper]::
+link:git-diff-helper.html[git-diff-helper]::
 	Generates patch format output for git-diff-*
 
 link:git-rpush.html[git-rpush]::
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@
 	git-check-files git-ls-tree git-merge-base git-merge-cache \
 	git-unpack-file git-export git-diff-cache git-convert-cache \
 	git-http-pull git-rpush git-rpull git-rev-list git-mktag \
-	git-diff-tree-helper git-tar-tree git-local-pull git-write-blob \
+	git-diff-helper git-tar-tree git-local-pull git-write-blob \
 	git-get-tar-commit-id
 
 all: $(PROG)
@@ -101,7 +101,7 @@
 git-rpull: rsh.c pull.c
 git-rev-list: rev-list.c
 git-mktag: mktag.c
-git-diff-tree-helper: diff-tree-helper.c
+git-diff-helper: diff-helper.c
 git-tar-tree: tar-tree.c
 git-write-blob: write-blob.c
 
--- a/diff-helper.c
+++ b/diff-helper.c
@@ -45,8 +45,8 @@
 	return 0;
 }
 
-static int parse_diff_tree_output(const char *buf,
-				  const char **spec, int cnt, int reverse)
+static int parse_diff_raw_output(const char *buf,
+				 const char **spec, int cnt, int reverse)
 {
 	struct diff_spec old, new;
 	char path[PATH_MAX];
@@ -109,8 +109,8 @@
 	return 0;
 }
 
-static const char *diff_tree_helper_usage =
-"diff-tree-helper [-R] [-z] paths...";
+static const char *diff_helper_usage =
+"git-diff-helper [-R] [-z] paths...";
 
 int main(int ac, const char **av) {
 	struct strbuf sb;
@@ -125,7 +125,7 @@
 		else if (av[1][1] == 'z')
 			line_termination = 0;
 		else
-			usage(diff_tree_helper_usage);
+			usage(diff_helper_usage);
 		ac--; av++;
 	}
 	/* the remaining parameters are paths patterns */
@@ -135,7 +135,7 @@
 		read_line(&sb, stdin, line_termination);
 		if (sb.eof)
 			break;
-		status = parse_diff_tree_output(sb.buf, av+1, ac-1, reverse);
+		status = parse_diff_raw_output(sb.buf, av+1, ac-1, reverse);
 		if (status)
 			fprintf(stderr, "cannot parse %s\n", sb.buf);
 	}
--- a/diff.h
+++ b/diff.h
@@ -17,7 +17,7 @@
 
 extern void diff_unmerge(const char *path);
 
-/* These are for diff-tree-helper */
+/* These are for diff-helper */
 
 struct diff_spec {
 	unsigned char blob_sha1[20];
------------------------------------------------


^ permalink raw reply

* Re: gitweb wishlist
From: Kay Sievers @ 2005-05-14  2:34 UTC (permalink / raw)
  To: Jonas Fonseca; +Cc: git
In-Reply-To: <20050513120618.GA26263@diku.dk>

On Fri, 2005-05-13 at 14:06 +0200, Jonas Fonseca wrote:
> I don't know if this is intentional, but it looks like gitweb discards
> everything after the first line starting with 'Signed-off-by:' on the
> log page. This will in some cases remove valuable log information when
> a second author or the committer adds additional comments to a commit:
> 
>         <log message by author>
> 
>         Signed-off-by: <author>
> 
>         <log message by committer>
> 
>         Signed-off-by: <committer>
> 
> The commit page gets it right, which is why I suspect it might just be a
> way to trim the amount of text on the log page.
> 
> I also noticed that there is a 'faulty' signed-off-by line in commit
> 14ebb908e10f068dc1901d35f4b716bc69143d19 in case the above is
> intentional. Dunno if that should be matched by relaxing the regexp a
> little.

All that should work now.

Thanks,
Kay


^ permalink raw reply

* Re: gitweb wishlist
From: Kay Sievers @ 2005-05-14  2:39 UTC (permalink / raw)
  To: Jan-Benedict Glaw; +Cc: Petr Baudis, git
In-Reply-To: <20050511093015.GK8176@lug-owl.de>

On Wed, 2005-05-11 at 11:30 +0200, Jan-Benedict Glaw wrote:
> On Wed, 2005-05-11 03:26:26 +0200, Petr Baudis <pasky@ucw.cz> wrote:
> >   I would be very happy if you could extend the gitweb scripts a little.
> > Basically, what I need is to have ability to create a permanent link to
> > a given file in the repository, which stays same across revisions (as
> > long as the file stays with the given name, obviously).
> 
> I've got another one. I'd like to see st_mtime on the file lists to see
> when a file was last touched...

We don't have that information in the trees. The date is only available
in the commits and reading all commits or storing that information in a
index or a database is beyond the scope of that simple cgi.

Thanks,
Kay


^ permalink raw reply

* Re: gitweb wishlist
From: Kay Sievers @ 2005-05-14  2:43 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git
In-Reply-To: <20050511012626.GL26384@pasky.ji.cz>

On Wed, 2005-05-11 at 03:26 +0200, Petr Baudis wrote:
>   I would be very happy if you could extend the gitweb scripts a little.
> Basically, what I need is to have ability to create a permanent link to
> a given file in the repository, which stays same across revisions (as
> long as the file stays with the given name, obviously).
> 
>   E.g. I would like to have something like
> 
> 	http://www.kernel.org/git/gitweb.cgi?p=cogito%2Fcogito.git;n=contrib/ciabot.pl
> 
> for file contrib/ciabot.pl in the latest Cogito tree, and

http://www.kernel.org/git/gitweb.cgi?p=cogito/cogito.git;a=blob;f=contrib/ciabot.pl

> 	http://www.kernel.org/git/gitweb.cgi?p=cogito%2Fcogito.git;n=contrib
> 
> for the list of the contrib/ directory in the latest Cogito tree.

http://www.kernel.org/git/gitweb.cgi?p=cogito/cogito.git;a=tree;f=contrib

>   I think I would prefer the link from the repository index to go not to
> the log page, but some "summary" page, which would have some short
> information about the repository (owner, description, list of branches
> if gitweb supports that, list of tags, link to the latest tree and link
> to the log).

Sounds reasonable, I will try that with the next round.

Thanks,
Kay


^ permalink raw reply

* [ANNOUNCE] mtkdiff-20050514 (integrated w/ gitk)
From: Tejun Heo @ 2005-05-14  2:58 UTC (permalink / raw)
  To: paulus; +Cc: git

 Hello, guys.

 This is mtkdiff-20050514.  I've modified gitk to invoke gitkdiff on
double click and right click.  If you double click on a commit mtkdiff
will show the commit.  If you right click on a commit while another
one is selected, mtkdiff will show the difference between the two
commits (as in bk revtool).  Also, I've modified gitk & gitkdiff to
show commit SHA1 in the info text when a commit is selected.

 The tarball can be found at

 http://home-tj.org/mtkdiff/files/mtkdiff-20050514.tar.gz

 Patch of the gitk changes follow.  (gitk-0.9 vs. the modified version)

 Thanks.

--- gitk-0.9	2005-05-14 11:57:02.000000000 +0900
+++ gitk	2005-05-14 11:57:04.000000000 +0900
@@ -175,6 +175,8 @@ proc makewindow {} {
     pack .ctop -side top -fill both -expand 1
 
     bindall <1> {selcanvline %x %y}
+    bindall <Double-1> {canvdclick %x %y}
+    bindall <3> {canvrclick %x %y}
     bindall <B1-Motion> {selcanvline %x %y}
     bindall <ButtonRelease-4> "allcanvs yview scroll -5 u"
     bindall <ButtonRelease-5> "allcanvs yview scroll 5 u"
@@ -473,7 +475,7 @@ proc drawgraph {start} {
     }
 }
 
-proc selcanvline {x y} {
+proc coordtoline {x, y} {
     global canv canvy0 ctext linespc selectedline
     global lineid linehtag linentag linedtag
     set ymax [lindex [$canv cget -scrollregion] 3]
@@ -483,8 +485,38 @@ proc selcanvline {x y} {
     if {$l < 0} {
 	set l 0
     }
-    if {[info exists selectedline] && $selectedline == $l} return
-    selectline $l
+    if {[info exists selectedline] && $selectedline == $l} {
+	return -1
+    }
+    return $l
+}
+
+proc selcanvline {x y} {
+    set l [coordtoline $x, $y]
+    if {$l >= 0} {
+	selectline $l
+    }
+}
+
+proc canvdclick {x y} {
+    global lineid selectedline
+    selcanvline $x $y
+    if {[info exists selectedline]} {
+	exec gitkdiff -r $lineid($selectedline) &
+    }
+}
+
+proc canvrclick {x y} {
+    global selectedline lineid
+
+    if {[info exists selectedline]} {
+	set l [coordtoline $x, $y]
+	if {$selectedline != $l} {
+	    exec gitkdiff -r $lineid($selectedline) -r $lineid($l) &
+	}
+    } else {
+	selcanvline $x $y
+    }
 }
 
 proc selectline {l} {
@@ -521,6 +553,7 @@ proc selectline {l} {
     $ctext conf -state normal
     $ctext delete 0.0 end
     set info $commitinfo($id)
+    $ctext insert end "Commit: $id\n"
     $ctext insert end "Author: [lindex $info 1]  [lindex $info 2]\n"
     $ctext insert end "Committer: [lindex $info 3]  [lindex $info 4]\n"
     $ctext insert end "\n"

^ permalink raw reply

* Re: [PATCH] [RFD] Add repoid identifier to commit [its a workspace id, isn't it?]
From: Jon Seymour @ 2005-05-14  5:02 UTC (permalink / raw)
  To: Petr Baudis; +Cc: H. Peter Anvin, tglx, git
In-Reply-To: <2cfc403205051316495b46115e@mail.gmail.com>

Of course, this graph wasn't really the best example of a traditional
SCM branch or the point I was trying to make.
> 
> Rn -------------
> |      \         \
> Rn-1 Ba,n   Bb,n
> |     /             |
> Rn-2             |
> |       \           |
> Rn-3 Ba,n-1  |
> |    /             /
> Rn-4 -----------

It's more like:

Tn     B,W(a),n
|        |                 \
|        B,W(a),n-1   B,W(b),n-1
|        |                  |
Tn-1  |                   |
|        B,W(a),1------|
|       /
Tn-2

Branch B diverges from the main trunk T, parallel (but frequently
convergent) development in branch B happens in two workspaces W(a) and
W(b).

So a branchid would track all commits that contribute to a branch,
while a workspace id would track which commits happened in which
workspace, to enable the reconstruction of the merge order of the
global history with respect to the workspaces that perform commits.

jon.
-- 
homepage: http://www.zeta.org.au/~jon/
blog: http://orwelliantremors.blogspot.com/

^ permalink raw reply

* [PATCH 1/2] Test framework take two.
From: Junio C Hamano @ 2005-05-14  5:50 UTC (permalink / raw)
  To: pasky, torvalds; +Cc: git

Petr Baudis raised many valid points at the earlier attempts in
git mailing list.  This round, test-lib.sh has beenupdated to a
bit more modern style, and the default output is made easier to
read.  Also included is one sample test script that tests the
very basics.  This test has already found one leftover bug
missed when we introduced symlink support, which has been fixed
since then.  The supplied Makefile is designed to run all the
available tests.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

t/Makefile       |   15 ++++
t/t0000-basic.sh |  179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
t/test-lib.sh    |  142 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 336 insertions(+)
t/Makefile (. --> 100644)
t/t0000-basic.sh (. --> 100755)
t/test-lib.sh (. --> 100755)

--- a/t/Makefile
+++ b/t/Makefile
@@ -0,0 +1,15 @@
+# Run tests
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+#OPTS=--verbose --debug
+OPTS=
+
+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
+
+all::
+	@$(foreach t,$T,echo "*** $t ***"; sh $t $(OPTS) || exit; )
+	rm -fr trash
+
+clean::
+	rm -fr trash
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -0,0 +1,179 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='Test the very basics part #1.
+
+The rest of the test suite does not check the basic operation of git
+plumbing commands to work very carefully.  Their job is to concentrate
+on tricky features that caused bugs in the past to detect regression.
+
+This test runs very basic features, like registering things in cache,
+writing tree, etc.
+
+Note that this test *deliberately* hard-codes many expected object
+IDs.  When object ID computation changes, like in the previous case of
+swapping compression and hashing order, the person who is making the
+modification *should* take notice and update the test vectors here.
+'
+. ./test-lib.sh
+
+################################################################
+# init-db has been done in an empty repository.
+# make sure it is empty.
+
+find .git/objects -type f -print >should-be-empty
+test_expect_success \
+    '.git/objects should be empty after git-init-db in an empty repo.' \
+    'cmp -s /dev/null should-be-empty' 
+
+# also it should have 256 subdirectories.  257 is counting "objects"
+find .git/objects -type d -print >full-of-directories
+test_expect_success \
+    '.git/objects should have 256 subdirectories.' \
+    'test "$(wc -l full-of-directories | sed -e "s/ .*//")" = 257'
+
+################################################################
+# Basics of the basics
+
+# updating a new file without --add should fail.
+test_expect_failure \
+    'git-update-cache without --add should fail adding.' \
+    'git-update-cache should-be-empty'
+
+# and with --add it should succeed, even if it is empty (it used to fail).
+test_expect_success \
+    'git-update-cache with --add should succeed.' \
+    'git-update-cache --add should-be-empty'
+
+test_expect_success \
+    'writing tree out with git-write-tree' \
+    'tree=$(git-write-tree)'
+
+# we know the shape and contents of the tree and know the object ID for it.
+test_expect_success \
+    'validate object ID of a known tree.' \
+    'test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a'
+
+# Removing paths.
+rm -f should-be-empty full-of-directories
+test_expect_failure \
+    'git-update-cache without --remove should fail removing.' \
+    'git-update-cache should-be-empty'
+
+test_expect_success \
+    'git-update-cache with --remove should be able to remove.' \
+    'git-update-cache --remove should-be-empty'
+
+# Empty tree can be written with recent write-tree.
+test_expect_success \
+    'git-write-tree should be able to write an empty tree.' \
+    'tree=$(git-write-tree)'
+
+test_expect_success \
+    'validate object ID of a known tree.' \
+    'test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904'
+
+# Various types of objects
+mkdir path2 path3 path3/subp3
+for p in path0 path2/file2 path3/file3 path3/subp3/file3
+do
+    echo "hello $p" >$p
+    ln -s "hello $p" ${p}sym
+done
+test_expect_success \
+    'adding various types of objects with git-update-cache --add.' \
+    'find path* ! -type d -print0 | xargs -0 -r git-update-cache --add'
+
+# Show them and see that matches what we expect.
+test_expect_success \
+    'showing stage with git-ls-files --stage' \
+    'git-ls-files --stage >current'
+
+cat >expected <<\EOF
+100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
+120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym
+100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2
+120000 d8ce161addc5173867a3c3c730924388daedbc38 0 path2/file2sym
+100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0 path3/file3
+120000 8599103969b43aff7e430efea79ca4636466794f 0 path3/file3sym
+100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0 path3/subp3/file3
+120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym
+EOF
+test_expect_success \
+    'validate git-ls-files output for a known tree.' \
+    'diff current expected'
+
+test_expect_success \
+    'writing tree out with git-write-tree.' \
+    'tree=$(git-write-tree)'
+test_expect_success \
+    'validate object ID for a known tree.' \
+    'test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b'
+
+test_expect_success \
+    'showing tree with git-ls-tree' \
+    'git-ls-tree $tree >current'
+cat >expected <<\EOF
+100644	blob	f87290f8eb2cbbea7857214459a0739927eab154	path0
+120000	blob	15a98433ae33114b085f3eb3bb03b832b3180a01	path0sym
+040000	tree	58a09c23e2ca152193f2786e06986b7b6712bdbe	path2
+040000	tree	21ae8269cacbe57ae09138dcc3a2887f904d02b3	path3
+EOF
+test_expect_success \
+    'git-ls-tree output for a known tree.' \
+    'diff current expected'
+
+test_expect_success \
+    'showing tree with git-ls-tree -r' \
+    'git-ls-tree -r $tree >current'
+cat >expected <<\EOF
+100644	blob	f87290f8eb2cbbea7857214459a0739927eab154	path0
+120000	blob	15a98433ae33114b085f3eb3bb03b832b3180a01	path0sym
+040000	tree	58a09c23e2ca152193f2786e06986b7b6712bdbe	path2
+100644	blob	3feff949ed00a62d9f7af97c15cd8a30595e7ac7	path2/file2
+120000	blob	d8ce161addc5173867a3c3c730924388daedbc38	path2/file2sym
+040000	tree	21ae8269cacbe57ae09138dcc3a2887f904d02b3	path3
+100644	blob	0aa34cae68d0878578ad119c86ca2b5ed5b28376	path3/file3
+120000	blob	8599103969b43aff7e430efea79ca4636466794f	path3/file3sym
+040000	tree	3c5e5399f3a333eddecce7a9b9465b63f65f51e2	path3/subp3
+100644	blob	00fb5908cb97c2564a9783c0c64087333b3b464f	path3/subp3/file3
+120000	blob	6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c	path3/subp3/file3sym
+EOF
+test_expect_success \
+    'git-ls-tree -r output for a known tree.' \
+    'diff current expected'
+
+################################################################
+rm .git/index
+test_expect_success \
+    'git-read-tree followed by write-tree should be idempotent.' \
+    'git-read-tree $tree &&
+     test -f .git/index &&
+     newtree=$(git-write-tree) &&
+     test "$newtree" = "$tree"'
+
+cat >expected <<\EOF
+*100644->100644	blob	f87290f8eb2cbbea7857214459a0739927eab154->0000000000000000000000000000000000000000	path0
+*120000->120000	blob	15a98433ae33114b085f3eb3bb03b832b3180a01->0000000000000000000000000000000000000000	path0sym
+*100644->100644	blob	3feff949ed00a62d9f7af97c15cd8a30595e7ac7->0000000000000000000000000000000000000000	path2/file2
+*120000->120000	blob	d8ce161addc5173867a3c3c730924388daedbc38->0000000000000000000000000000000000000000	path2/file2sym
+*100644->100644	blob	0aa34cae68d0878578ad119c86ca2b5ed5b28376->0000000000000000000000000000000000000000	path3/file3
+*120000->120000	blob	8599103969b43aff7e430efea79ca4636466794f->0000000000000000000000000000000000000000	path3/file3sym
+*100644->100644	blob	00fb5908cb97c2564a9783c0c64087333b3b464f->0000000000000000000000000000000000000000	path3/subp3/file3
+*120000->120000	blob	6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c->0000000000000000000000000000000000000000	path3/subp3/file3sym
+EOF
+test_expect_success \
+    'validate git-diff-files output for a know cache/work tree state.' \
+    'git-diff-files >current && cmp -s current expected'
+
+test_expect_success \
+    'git-update-cache --refresh should succeed.' \
+    'git-update-cache --refresh'
+
+test_expect_success \
+    'no diff after checkout and git-update-cache --refresh.' \
+    'git-diff-files >current && cmp -s current /dev/null'
+
+test_done
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -0,0 +1,142 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+# For repeatability, reset the environment to known value.
+LANG=C
+TZ=UTC
+export LANG TZ
+unset AUTHOR_DATE
+unset AUTHOR_EMAIL
+unset AUTHOR_NAME
+unset COMMIT_AUTHOR_EMAIL
+unset COMMIT_AUTHOR_NAME
+unset GIT_ALTERNATE_OBJECT_DIRECTORIES
+unset GIT_AUTHOR_DATE
+unset GIT_AUTHOR_EMAIL
+unset GIT_AUTHOR_NAME
+unset GIT_COMMITTER_EMAIL
+unset GIT_COMMITTER_NAME
+unset GIT_DIFF_OPTS
+unset GIT_DIR
+unset GIT_EXTERNAL_DIFF
+unset GIT_INDEX_FILE
+unset GIT_OBJECT_DIRECTORY
+unset SHA1_FILE_DIRECTORIES
+unset SHA1_FILE_DIRECTORY
+
+# Each test should start with something like this, after copyright notices:
+#
+# test_description='Description of this test...
+# This test checks if command xyzzy does the right thing...
+# '
+# . ./test-lib.sh
+
+error () {
+	echo "* error: $*"
+	exit 1
+}
+
+say () {
+	echo "* $*"
+}
+
+test "${test_description}" != "" ||
+error "Test script did not set test_description."
+
+while test "$#" -ne 0
+do
+	case "$1" in
+	-d|--d|--de|--deb|--debu|--debug)
+		debug=t; shift ;;
+	-h|--h|--he|--hel|--help)
+		echo "$test_description"
+		exit 0 ;;
+	-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
+		verbose=t; shift ;;
+	*)
+		break ;;
+	esac
+done
+
+if test "$verbose" = "t"
+then
+	exec 4>&2 3>&1
+else
+	exec 4>/dev/null 3>/dev/null
+fi
+
+test_failure=0
+test_count=0
+
+test_debug () {
+	test "$debug" == "" || eval "$1"
+}
+
+test_ok () {
+	test_count=$(expr "$test_count" + 1)
+	say "ok #$test_count: $@"
+}
+
+test_failure () {
+	test_count=$(expr "$test_count" + 1)
+	test_failure=$(expr "$test_failure" + 1);
+	say "NO #$test_count: $@"
+}
+
+test_expect_failure () {
+	test "$#" == 2 ||
+	error "bug in the test script: not 2 parameters to test-expect-failure"
+	say >&3 "expecting failure: $2"
+	if eval >&3 2>&4 "$2"
+	then
+		test_failure "$@"
+	else
+		test_ok "$1"
+	fi
+}
+
+test_expect_success () {
+	test "$#" == 2 ||
+	error "bug in the test script: not 2 parameters to test-expect-success"
+	say >&3 "expecting success: $2"
+	if eval >&3 2>&4 "$2"
+	then
+		test_ok "$1"
+	else
+		test_failure "$@"
+	fi
+}
+
+test_done () {
+	case "$test_failure" in
+	0)	
+		# We could:
+		# cd .. && rm -fr trash
+		# but that means we forbid any tests that use their own
+		# subdirectory from calling test_done without coming back
+		# to where they started from.
+		# The Makefile provided will clean this test area so
+		# we will leave things as they are.
+
+		say "passed all $test_count test(s)"
+		exit 0 ;;
+
+	*)
+		say "failed $test_failure among $test_count test(s)"
+		exit 1 ;;
+
+	esac
+}
+
+# Test the binaries we have just built.  The tests are kept in
+# t/ subdirectory and are run in trash subdirectory.
+PATH=$(pwd)/..:$PATH
+
+# Test repository
+test=trash
+rm -fr "$test"
+mkdir "$test"
+cd "$test"
+git-init-db 2>/dev/null || error "cannot run git-init-db"
------------------------------------------------


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox