Git development
 help / color / mirror / Atom feed
* Re: [PATCH] One Git To Rule Them All
From: McMullan, Jason @ 2005-06-01 12:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vis0yr41f.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: text/plain, Size: 786 bytes --]

On Tue, 2005-05-31 at 23:21 -0700, Junio C Hamano wrote:
> I think we had this discussion long time ago on the list, and
> instead of using cvs/svn style of "cmd subcmd" syntax, the
> consensus back then was that using "cmd-" prefix without spaces
> is easier for making TAB completion to work (you do not have to
> muck with command specific rules in the readline configuration),
> and this is especially helpful for people who ends up using the
> bare Plumbing. IIUC, the same reason is behind cg-* command set.

But all the git-<mumble> commands are still there, as symlinks to
git. ie 'git-update-cache' and 'git update-cache' both work.

git-<TAB> still works.

Am I missing something here?

-- 
Jason McMullan <jason.mcmullan@timesys.com>
TimeSys Corporation


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Using cvs2git to track an external CVS project
From: Martin Langhoff @ 2005-06-01 12:35 UTC (permalink / raw)
  To: Git Mailing List

Following the cvs2git threads, I'm left with a few doubts.

Linus has stated that it can be used incrementally to track a project
that uses CVS -- in which case I assume I would be maintaining two git
repos, one strictly tracking "upstream", pulling changes from CVS on a
crontab, and the 2nd one with my local changes. Or is it meant to work
on the "local" repo as a pull/merge/update?

What'd be the strategy in that case if I am working on patches that I
intend to feed upstream? To what degree will git try and remerge
against the local repo where the patch originates from? This kind of
smarts are nice when they work -- but I am interested in exploring
more git-style approaches, if git supports this at all.

In the scenario above, if I push _some_ patches upstream, does git
help me at all in sorting out what is upstream and what is not?

I suspect all this patch-based horsetrading amounts to cherry-picking,
and is therefore not supported. What strategy would work with git to
run local branches with a mix of patches that go upstream and others
that don't (or just may take longer to get there).

Right now we are using arch where a long-lived branch tracks
theexternal cvs repo, and we open short-lived branches where we do a
mix of development -- most of which is merged upstream in several
stages.

cheers,


martin

^ permalink raw reply

* Re: [COGITO PATCH] Heads and tags in subdirectories
From: Santi Béjar @ 2005-06-01 12:59 UTC (permalink / raw)
  To: Git Mailing List
In-Reply-To: <87is0zginw.fsf@ifae.es>


Teach cg-init about the origin directory.

Signed-off-by: "Santi Béjar" <sbejar@gmail.com>
---
 cg-init |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -29,8 +29,9 @@ ln -s refs/heads/master $_git/HEAD
 if [ "$uri" ]; then
 	echo "$uri" >$_git/branches/origin
 	cg-pull origin || die "pull failed"
-
-	cp $_git/refs/heads/origin $_git/refs/heads/master
+	uribranch=$(echo $uri | cut -d '#' -f 2 -s)
+	uribranch=${uribranch:-master}
+	cp $_git/refs/heads/origin/$uribranch $_git/refs/heads/master
 	git-read-tree HEAD
 	git-checkout-cache -a
 	git-update-cache --refresh


^ permalink raw reply

* [COGITO PATCH] cg-branch-switch and local branches
From: Santi Béjar @ 2005-06-01 13:03 UTC (permalink / raw)
  To: Git Mailing List


Make origin a symbolic link to the origin branch.
Make master a symbolic link to the local branch or
            a file for an unnamed branch.
Add cg-branch-switch to switch branches.

Signed-off-by: "Santi Béjar" <sbejar@gmail.com>

---
 Makefile         |    3 +
 cg-Xnormid       |    2 +
 cg-branch-add    |   19 +++++++++
 cg-branch-switch |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 cg-clone         |   32 ++++++++++++----
 cg-commit        |   11 ++++-
 cg-merge         |    3 +
 cg-pull          |   14 +++++--
 8 files changed, 177 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,8 @@ PROG=   git-update-cache git-diff-files 
 SCRIPT=	commit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \
 	cg-branch-add cg-branch-ls cg-cancel cg-clone cg-commit cg-diff \
 	cg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch cg-patch \
-	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update
+	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
+	cg-branch-switch
 
 LIB_SCRIPT=cg-Xlib cg-Xmergefile cg-Xnormid
 
diff --git a/cg-Xnormid b/cg-Xnormid
--- a/cg-Xnormid
+++ b/cg-Xnormid
@@ -16,6 +16,8 @@
 
 id="$1"
 
+[ -L $_git/refs/heads/$id ] &&
+id=$(readlink $_git/refs/heads/$id | sed 's@/@#@')
 repo=$(echo $id | cut -d '#' -f 1)
 (echo $repo | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \
 	die "name contains invalid characters"
diff --git a/cg-branch-add b/cg-branch-add
--- a/cg-branch-add
+++ b/cg-branch-add
@@ -1,8 +1,11 @@
 #!/usr/bin/env bash
 #
 # Add new branch to the GIT repository.
+# Or create local branch in the GIT repository.
 # Copyright (c) Petr Baudis, 2005
 #
+# Adding a new branch
+# -------------------
 # Takes the branch name and source location as parameters.
 # After you add a branch, you can `cg-pull` it whenever you want and
 # it will keep your objects database in sync with it. Its latest
@@ -29,6 +32,22 @@
 #	$ cg-branch-add repo-testing rsync://host/path/repo.git#testing
 #
 # and refer to it as 'repo-testing' anytime later.
+#
+# Creating a local branch
+# -----------------------
+# Takes the local branch name and origin branch as parameters.
+#
+# After you create a local branch, you can `cg-branch-switch` it whenever you
+# want and you will be able to work on your local branch. Its {latest,origin}
+# commit is accessible as `.git/refs/heads/{master,origin}` (or - more
+# conveniently - as `$(commit-id {master,origin})`).
+# For example, to make a diff between your origin and your current tree, do:
+#
+#	$ cg-diff -r origin
+#
+# The origin specifier is a name of a branch added with cg-branch-add,
+# followed with an optional fragment part, which identifies a alternative
+# branch inside of the repository.
 
 USAGE="cg-branch-add BRANCH_NAME LOCATION"
 
diff --git a/cg-branch-switch b/cg-branch-switch
new file mode 100644
--- /dev/null
+++ b/cg-branch-switch
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+#
+# Switch to a local branch.
+# Without arguments prints the branch.
+#
+# Takes the branch name as an argument.
+# If the argument is an external branch switch to an unnamed branch.
+#
+# Local branches
+# --------------
+#
+# The master file is always a link:
+#
+# master -> ${localbranch}
+#
+# The content of $_git/branches/${localbranch} is the original branch of
+# local branch. The cases and the corresponding origin links are:
+#
+# 1a.- name         : a name of an external repository
+#                     $branch corresponding to the definition
+#                     origin -> $name/$branch
+# 1b.- name#branch : optionally with a branch
+#                     origin -> $name/$branch
+# 2 .- name         : a name of another local branch
+#                     $branch corresponding to the definition
+#                     origin -> $name/$branch
+#
+# Local unnamed branches
+# ----------------------
+#
+# The master file is a regula file and the origin link only has the cases
+# 1a and 1b where the $name is the parameter to the script.
+
+USAGE="cg-switch-tree [BRANCH]"
+
+. ${COGITO_LIB}cg-Xlib
+
+name=$1
+
+[ -e $_git/refs/heads/origin ] && [ ! -L $_git/refs/heads/origin ] &&
+die "$_git/refs/heads/origin must be a symbolic link"
+
+[ -e $_git/blocked ] && die "switch blocked: $(cat $_git/blocked)"
+
+oldmaster=$(readlink $_git/refs/heads/master)
+oldorigin=$(readlink $_git/refs/heads/origin)
+
+[ -z "$name" ] && echo "master $(echo $oldmaster | sed 's@/@#@' )" &&
+echo "origin $(echo $oldorigin | sed 's@/@#@' )" && exit 0
+
+oldmaster=${oldmaster:-master}
+
+namerepo=$(echo $name | cut -d '#' -f 1)
+namebranch=$(echo $name | cut -d '#' -f 2 -s)
+[ -e "$_git/branches/$namerepo" ] || die "unknown branch: $name"
+origuri=$(cat "$_git/branches/$namerepo")
+origrepo=$(echo $origuri | cut -d '#' -f 1)
+origbranch=$(echo $origuri | cut -d '#' -f 2 -s)
+
+if [ -e "$_git/branches/$origrepo" ] ; then
+    # $name is a local branch
+    switch=local
+    master=$namerepo
+    [ -e "$_git/branches/$origrepo" ] || die "do not exist local branch: $name"
+    uri=$(cat $_git/branches/$origrepo)
+    if [ -e "$_git/branches/$(echo $uri| cut -d '#' -f 1)" ] ; then
+    # Origin is a local branch
+	origlink=$origuri
+	[ "$namebranch" ] && die "local branches cannot have branches"
+    else
+    # Origin is a external branch
+	extbranch=${namebranch:-$origbranch}
+	extbranch=${extbranch:-master}
+	origlink=$origrepo/$extbranch
+    fi
+else
+    # Origin is an external unnamed branch
+    switch=unnnamed
+    extbranch=${namebranch:-$origbranch}
+    extbranch=${extbranch:-master}
+    origlink=$namerepo/$extbranch
+    master=$namerepo/$extbranch
+fi
+
+[ ! -r $_git/refs/heads/$origlink ] && die "unknown branch: $origlink"
+
+if [ "$(git-diff-files -s)" ] || [ "$(git-diff-cache HEAD 2>/dev/null)" ]; then
+	die "switch blocked: local changes"
+fi
+
+[ ! -r $_git/refs/heads/$master -o ! -s $_git/refs/heads/$master ] &&
+[ "$switch" = "local" ] && cp $_git/refs/heads/$origlink $_git/refs/heads/$master
+
+( cd $_git/refs/heads/ &&
+    [ -f master ] && [ ! -L master ] &&
+    [ "$(cat master)" != "$(cat origin)" ] &&
+    cp master master_$(date +%Y%m%d%H%M%S)
+    rm -f master
+    if [ "$switch" = "local" ] ; then
+	ln -s $master master
+    else
+	cp $master master
+    fi
+    ln -fs $origlink origin )
+
+git-read-tree -m HEAD && git-checkout-cache -q -f -u -a
+
diff --git a/cg-clone b/cg-clone
--- a/cg-clone
+++ b/cg-clone
@@ -6,10 +6,10 @@
 # This is like cg-init, but it will create a new directory where it will do
 # the checkout.
 #
-# Takes a parameter specifying the location of the source repository and an
-# optional second parameter specifying the destination. If the second
-# parameter is omitted, the basename of the source repository is used as the
-# destination.
+# Takes two parameter specifying the name and location of the source
+# repository, an optional third parameter specifying name of the local branch
+# (defaults to an unnamed branch) and an optional fourth parameter specifying
+# the destination (defaults to the basename of the source repository).
 #
 # OPTIONS
 # -------
@@ -17,7 +17,7 @@
 #	Clone in the current directory instead of creating a new one.
 #	Specifying both -s and a desination directory makes no sense .
 
-USAGE="cg-clone [-s] LOCATION [DESTDIR]"
+USAGE="cg-clone [-s] NAME LOCATION [LOCALNAME [DESTDIR]]"
 
 . ${COGITO_LIB}cg-Xlib
 
@@ -27,9 +27,16 @@ if [ "$1" = "-s" ]; then
 	same_dir=1
 fi
 
+name=$1 && shift
 location=$1
 [ "$location" ] || usage
 location=${location%/}
+if [ $location = $1 ] ; then
+    branch=$(echo $location | cut -d '#' -f 2 -s)
+    location=$(echo $location | cut -d '#' -f 1)
+fi
+shift
+localbranch=$1
 
 destdir=$2
 if [ "$destdir" ]; then
@@ -45,6 +52,8 @@ else
 	location="$location"
 fi
 
+[ "$branch" ] && location=$location#$branch
+
 if [ ! "$same_dir" ]; then
 	[ -e "$dir" ] && die "$dir/ already exists"
 	mkdir "$dir" || exit $?
@@ -54,6 +63,15 @@ else
 fi
 
 trap "rm -rf $dir" SIGTERM EXIT
-cg-init $location || exit $?
+git-init-db
+cg-branch-add $name $location
+cg-pull $name || die "pull failed"
+if [ "$localbranch" ] ; then
+    cg-branch-add $localbranch $name
+    cg-branch-switch $localbranch
+else
+    cg-branch-switch $name
+fi
+echo "Master and origin branches are:"
+cg-branch-switch
 trap "" SIGTERM EXIT
-echo "Cloned to $dir/ (origin $location available as branch \"origin\")"
diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -144,9 +144,16 @@ if [ "$merging" ]; then
 		repo=$(echo $sym | cut -d '#' -f 1)
 		branch=$(echo $sym | cut -d '#' -f 2 -s)
 		uri=$(cat $_git/branches/$repo)
+		urirepo=$(echo $uri | cut -d '#' -f 1)
 		uribranch=$(echo $uri | cut -d '#' -f 2 -s)
-		[ -z "$uribranch" ] && [ -n "$branch" ] &&
-		[ "$branch" != master ] && uri=${uri}#$branch
+		if [ -e $_git/branches/$urirepo ]; then
+		    # local branch
+		    uri="$sym"
+		else
+ 		    # remote branch
+		    [ -z "$uribranch" ] && [ -n "$branch" ] &&
+		    [ "$branch" != master ] && uri=${uri}#$branch
+		fi
 		[ "$uri" ] || uri="$sym"
 		echo "$uri" >>$LOGMSG
 		[ "$msgs" ] && echo "$uri"
diff --git a/cg-merge b/cg-merge
--- a/cg-merge
+++ b/cg-merge
@@ -42,7 +42,8 @@ fi
 [ "$1" ] || usage
 branchname="$1"
 branch=$(commit-id "$branchname") || exit 1
-
+[ -L $_git/refs/heads/$branchname ] &&
+branchname=$(readlink $_git/refs/heads/$branchname| sed 's@/@#@')
 [ "$base" ] || base=$(git-merge-base "$head" "$branch")
 [ "$base" ] || die "unable to automatically determine merge base"
 
diff --git a/cg-pull b/cg-pull
--- a/cg-pull
+++ b/cg-pull
@@ -19,16 +19,24 @@ USAGE="cg-pull [-a] [BRANCH_NAME]"
 [ "$1" == "-a" ] && all=yes && shift
 name=$1 && shift
 
-[ "$name" ] || { [ -s $_git/refs/heads/origin ] && name=origin; }
+if [ -z "$name" ] && [ -f $_git/branches/origin ]; then
+	#Convert the old layout 2005/06
+	mv $_git/branches/origin $_git/branches/original
+	branch=$(cat $_git/branches/original | cut -s -d '#' -f 2)
+	branch=${branch:-master}
+	[ -f $_git/refs/heads/origin -o -d $_git/refs/heads/origin ] &&
+	rm -rf $_git/refs/heads/origin &&
+	ln -s original/$branch $_git/refs/heads/origin
+fi
+[ "$name" ] || name=$(readlink $_git/refs/heads/origin | sed 's@/@#@')
 [ "$name" ] || die "where to pull from?"
 
 repo=$(echo $name | cut -d '#' -f 1)
 repobranch=$(echo $name | cut -s -d '#' -f 2)
 
-uri=$(cat "$_git/branches/$name" 2>/dev/null) || die "unknown branch: $name"
+uri=$(cat "$_git/branches/$repo" 2>/dev/null) || die "unknown branch: $name"
 if echo "$uri" | grep -q '#'; then
 	[ -z "$repobranch" ] && repobranch=$(echo $uri | cut -d '#' -f 2)
-	rembranch=$(echo $uri | cut -d '#' -f 2)
 	uri=$(echo $uri | cut -d '#' -f 1)
 fi
 repobranch=${repobranch:-master}


^ permalink raw reply

* Re: Using cvs2git to track an external CVS project
From: Anton Altaparmakov @ 2005-06-01 13:07 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: Git Mailing List
In-Reply-To: <46a038f905060105358e24723@mail.gmail.com>

On Thu, 2005-06-02 at 00:35 +1200, Martin Langhoff wrote:
> Following the cvs2git threads, I'm left with a few doubts.
> 
> Linus has stated that it can be used incrementally to track a project
> that uses CVS -- in which case I assume I would be maintaining two git
> repos, one strictly tracking "upstream", pulling changes from CVS on a
> crontab, and the 2nd one with my local changes. Or is it meant to work
> on the "local" repo as a pull/merge/update?
> 
> What'd be the strategy in that case if I am working on patches that I
> intend to feed upstream? To what degree will git try and remerge
> against the local repo where the patch originates from? This kind of
> smarts are nice when they work -- but I am interested in exploring
> more git-style approaches, if git supports this at all.
> 
> In the scenario above, if I push _some_ patches upstream, does git
> help me at all in sorting out what is upstream and what is not?
> 
> I suspect all this patch-based horsetrading amounts to cherry-picking,
> and is therefore not supported. What strategy would work with git to
> run local branches with a mix of patches that go upstream and others
> that don't (or just may take longer to get there).

Disregarding anything about cvs2git there is one point you may not be
thinking about but you may want to care about:  when you send something
upstream to the cvs repository and then get it back via cvs2git you will
get a completely different commit to the one your local git repository
has.  So while the file changes inside those two commits are the same
the actual commits are not and you will end up with all those commits in
duplicate because of it as well as an automatic merge commit to merge
the two commits.  If you don't want that to happen you would need to do
your local changes in throw-away git trees which you rm -rf after the
patch gets applied and you use cvs2git to get your changes.  You could
of course do your local things in git branches and then throw-away the
branch that got applied to cvs and only keep the main trunk in sync but
I personally prefer separate trees to branches.

> Right now we are using arch where a long-lived branch tracks
> theexternal cvs repo, and we open short-lived branches where we do a
> mix of development -- most of which is merged upstream in several
> stages.

Best regards,

        Anton
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/


^ permalink raw reply

* Re: [PATCH] Add -d flag to git-pull-* family.
From: Nicolas Pitre @ 2005-06-01 14:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Linus Torvalds, Git Mailing List
In-Reply-To: <7vu0kilc21.fsf_-_@assigned-by-dhcp.cox.net>

On Wed, 1 Jun 2005, Junio C Hamano wrote:

> When a remote repository is deltified, we need to get the
> objects that a deltified object we want to obtain is based upon.
> Since checking representation type of all objects we retreive
> from remote side may be costly, this is made into a separate
> option -d; -a implies it for convenience and safety.

I wonder if making this optional makes sense.  In fact, if you believe 
having the option is useful then it should probably be the other 
way around i.e. to _not_ look at deltas when it is specified.  Otherwise 
you'll end up with an incoherent repository.

To minimize the cost a lot it could be possible to uncompress just the 
first 40 bytes or so which is enough to determine if the object is a 
delta and if so what object it is against.

What do you think?


Nicolas

^ permalink raw reply

* Re: [COGITO PATCH] cg-branch-switch and local branches
From: Santi Béjar @ 2005-06-01 14:41 UTC (permalink / raw)
  To: Git Mailing List
In-Reply-To: <87ekbmi5zl.fsf@ifae.es>

Hi,

        after reading it I think I have to explain it better.

        And first I have to say that this patch depends on my patches
        in the thread "[COGITO PATCH] Heads and tags in subdirectories".
        But the logic does not depend on it, I think :)

Suppose I want to make some modifications to the cogito. So I do:

cg-clone cogito rsync://rsync.kernel.org/pub/scm/cogito/cogito.git

the first argument been the name I've gave to this repositori. Now I can
do the changes/commits in the usual way. But I want to work in two
differents patches, named dirs and switch, so I do:

cg-branch-add dirs cogito
cg-branch-add switch cogito

Now I have to local branches with their respective names, and the origin
been the cogito branch for both (but it can be different).

If I want to work on the dirs branch I do:

cg-branch-switch dirs

an the same for switch. In each case I can do a:

cg-merge origin

and merge their respective origin (in this case is the same).

If I want to work directly in cogito, I can do:

cg-branch-switch cogito

and work in the usual way. If the cogito repository have a branche
called cogito2 I could do:

cg-branch-switch cogito#cogito2

in the case I've already pulled this branch.

Internally it is:

Local branches
--------------

The master file is always a link:

master -> ${localbranch}

The content of $_git/branches/${localbranch} is the original branch of
local branch. The cases and the corresponding origin links are:

1a.- name         : a name of an external repository
                    $branch corresponding to the definition
                    origin -> $name/$branch
1b.- name#branch : optionally with a branch
                    origin -> $name/$branch
2 .- name         : a name of another local branch
                    $branch corresponding to the definition
                    origin -> $name/$branch

Local unnamed branches
----------------------

The master file is a regular file and the origin link only has the cases
1a and 1b where the $name is name of the local branch.




^ permalink raw reply

* Re: [PATCH] Add -d flag to git-pull-* family.
From: Junio C Hamano @ 2005-06-01 16:00 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: Linus Torvalds, Git Mailing List
In-Reply-To: <Pine.LNX.4.63.0506011032570.7439@localhost.localdomain>

>>>>> "NP" == Nicolas Pitre <nico@cam.org> writes:

NP> What do you think?

What you say makes a lot more sense than my quick hack on both
counts.


^ permalink raw reply

* Re: [PATCH] One Git To Rule Them All
From: Junio C Hamano @ 2005-06-01 16:12 UTC (permalink / raw)
  To: McMullan, Jason; +Cc: Junio C Hamano, git
In-Reply-To: <1117627661.19629.1.camel@jmcmullan.timesys>

>>>>> "JM" == McMullan, Jason <jason.mcmullan@timesys.com> writes:

JM> Am I missing something here?

No, but one thing I failed to mention was that I am not a big
fan of busybox.  It is a cute hack to save "disk" space in an
embedded environment, but I find the way many commands are
bundled together a bit too hacky for my taste to use on my
regular work box.  I also suspect the change makes the
maintenance of the result harder than having them separate.

You said with this change there is only one file to install, but
you are not bundling the git-* scripts in the "single git", so
that claim is not true either.  If your patch handled the git-*
script parts as well, then I would have admired that part of the
change ;-).

Personally I find the mandatory documentation requirements this
patch brings us is a good thing ;-).


^ permalink raw reply

* Re: [COGITO PATCH] Heads and tags in subdirectories
From: Santi Béjar @ 2005-06-01 16:17 UTC (permalink / raw)
  To: Git Mailing List
In-Reply-To: <87is0yi66t.fsf@ifae.es>


Here it is un updated version, fixing some bugs.

 cg-Xnormid |   14 +++++++++-
 cg-commit  |    7 ++++-
 cg-init    |    5 ++-
 cg-pull    |   78 ++++++++++++++++++++++++++++++++++++-------------------------
 4 files changed, 68 insertions(+), 36 deletions(-)

diff --git a/cg-Xnormid b/cg-Xnormid
--- a/cg-Xnormid
+++ b/cg-Xnormid
@@ -16,15 +16,25 @@
 
 id="$1"
 
+repo=$(echo $id | cut -d '#' -f 1)
+(echo $repo | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \
+	die "name contains invalid characters"
+id=$(echo $id | sed 's@#@/@')
+
 if [ ! "$id" ] || [ "$id" = "this" ] || [ "$id" = "HEAD" ]; then
 	read id < "$_git/HEAD"
 
-elif [ -r "$_git/refs/tags/$id" ]; then
+elif [ -r "$_git/refs/tags/$id" ] && [ ! -d "$_git/refs/tags/$id" ]; then
 	read id < "$_git/refs/tags/$id"
 
-elif [ -r "$_git/refs/heads/$id" ]; then
+elif [ -r "$_git/refs/heads/$id" ] && [ ! -d "$_git/refs/heads/$id" ]; then
 	read id < "$_git/refs/heads/$id"
 
+elif [ -r "$_git/branches/$id" ]; then
+	repobranch=$(cat "$_git/branches/$id" | cut -d '#' -f 2 -s)
+	repobranch=${repobranch:-master}
+	read id < "$_git/refs/heads/$id/$repobranch"
+
 # Short id's must be lower case and at least 4 digits.
 elif [[ "$id" == [0-9a-z][0-9a-z][0-9a-z][0-9a-z]* ]]; then
 	idpref=${id:0:2}
diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -141,7 +141,12 @@ if [ "$merging" ]; then
 	[ "$msgs" ] && echo -n 'Merge with '
 	[ -s $_git/merging-sym ] || cp $_git/merging $_git/merging-sym
 	for sym in $(cat $_git/merging-sym); do
-		uri=$(cat $_git/branches/$sym)
+		repo=$(echo $sym | cut -d '#' -f 1)
+		branch=$(echo $sym | cut -d '#' -f 2 -s)
+		uri=$(cat $_git/branches/$repo)
+		uribranch=$(echo $uri | cut -d '#' -f 2 -s)
+		[ -z "$uribranch" ] && [ -n "$branch" ] &&
+		[ "$branch" != master ] && uri=${uri}#$branch
 		[ "$uri" ] || uri="$sym"
 		echo "$uri" >>$LOGMSG
 		[ "$msgs" ] && echo "$uri"
diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -29,8 +29,9 @@ ln -s refs/heads/master $_git/HEAD
 if [ "$uri" ]; then
 	echo "$uri" >$_git/branches/origin
 	cg-pull origin || die "pull failed"
-
-	cp $_git/refs/heads/origin $_git/refs/heads/master
+	uribranch=$(echo $uri | cut -d '#' -f 2 -s)
+	uribranch=${uribranch:-master}
+	cp $_git/refs/heads/origin/$uribranch $_git/refs/heads/master
 	git-read-tree HEAD
 	git-checkout-cache -a
 	git-update-cache --refresh
diff --git a/cg-pull b/cg-pull
--- a/cg-pull
+++ b/cg-pull
@@ -6,23 +6,41 @@
 # Takes the branch name as an argument, defaulting to "origin".
 #
 # See `cg-branch-add` for some description.
+#
+# OPTIONS
+# -------
+# -a::
+#       Pull all the heads from repositori.
 
-USAGE="cg-pull [BRANCH_NAME]"
+USAGE="cg-pull [-a] [BRANCH_NAME]"
 
 . ${COGITO_LIB}cg-Xlib
 
-name=$1
-
+[ "$1" == "-a" ] && all=yes && shift
+name=$1 && shift
 
 [ "$name" ] || { [ -s $_git/refs/heads/origin ] && name=origin; }
 [ "$name" ] || die "where to pull from?"
-uri=$(cat "$_git/branches/$name" 2>/dev/null) || die "unknown branch: $name"
 
-rembranch=master
+repo=$(echo $name | cut -d '#' -f 1)
+repobranch=$(echo $name | cut -s -d '#' -f 2)
+
+uri=$(cat "$_git/branches/$name" 2>/dev/null) || die "unknown branch: $name"
 if echo "$uri" | grep -q '#'; then
+	[ -z "$repobranch" ] && repobranch=$(echo $uri | cut -d '#' -f 2)
 	rembranch=$(echo $uri | cut -d '#' -f 2)
 	uri=$(echo $uri | cut -d '#' -f 1)
 fi
+repobranch=${repobranch:-master}
+branch=$repo/$repobranch
+[ "$all" ] && repobranch=
+
+# So long we have:
+# $repo       = name of the repositori
+# $uri        = uri of the repositori
+# $repobranch = name of the branch in the repositori
+#               empty if we want all the branches
+# $branch     = name of the local branch in refs/heads/
 
 pull_progress() {
 	percentage=""
@@ -197,15 +215,15 @@ fetch_local () {
 		shift
 	fi
 
-	cut_last=
+	dirs=
 	if [ "$1" = "-d" ]; then
-		cut_last=1
+		dirs=1
 		shift
 	fi
 
 	src="$1"
 	dest="$2"
-	[ "$cut_last" ] && dest=${dest%/*}
+	[ "$dirs" ] && src="${src%/}/."
 
 	cp $cp_flags_l "$src" "$dest"
 }
@@ -232,39 +250,37 @@ fi
 
 
 orig_head=
-[ -s "$_git/refs/heads/$name" ] && orig_head=$(cat "$_git/refs/heads/$name")
-
+[ -s "$_git/refs/heads/$branch" ] && orig_head=$(cat "$_git/refs/heads/$branch")
 
-mkdir -p $_git/refs/heads
-rsyncerr=
-$fetch -i "$uri/refs/heads/$rembranch" "$_git/refs/heads/$name" || rsyncerr=1
-if [ "$rsyncerr" ]; then
-	rsyncerr=
-	$fetch -s "$uri/heads/$rembranch" "$_git/refs/heads/$name" || rsyncerr=1
-fi
-if [ "$rsyncerr" ] && [ "$rembranch" = "master" ]; then
-	rsyncerr=
-	$fetch -s "$uri/HEAD" "$_git/refs/heads/$name" || rsyncerr=1
+# 2005/05 Convert old layout
+[ -f $_git/refs/heads/$repo ] && orig_head=$(cat $_git/refs/heads/$repo) &&
+rm -f $_git/refs/heads/$repo
+
+mkdir -p $_git/refs/heads/$repo
+if [ "$repobranch" ] ; then
+    $fetch -i "$uri/refs/heads/$repobranch" "$_git/refs/heads/$branch" ||
+    $fetch -s "$uri/heads/$repobranch" "$_git/refs/heads/$branch" ||
+    { [ "$repobranch" = "master" ] && $fetch -s "$uri/HEAD" "$_git/refs/heads/$branch"; } ||
+    rsyncerr=1
+else
+    $fetch -i -d "$uri/refs/heads" "$_git/refs/heads/$repo" ||
+    $fetch -s -d "$uri/heads" "$_git/refs/heads/$repo" ||
+    rsyncerr=1
 fi
-[ "$rsyncerr" ] && die "unable to get the head pointer of branch $rembranch"
+[ "$rsyncerr" ] && die "unable to get the head pointer of branch $repobranch"
 
 [ -d $_git_objects ] || mkdir -p $_git_objects
-$pull "$name" "$uri" || die "objects pull failed"
+$pull "$branch" "$uri" || die "objects pull failed"
 
-# FIXME: Warn about conflicting tag names?
 # XXX: We now throw stderr to /dev/null since not all repositories
 # may have tags/ and users were confused by the harmless errors.
-[ -d $_git/refs/tags ] || mkdir -p $_git/refs/tags
+[ -d $_git/refs/tags/$repo ] || mkdir -p $_git/refs/tags/$repo
 rsyncerr=
-$fetch -i -s -u -d "$uri/refs/tags" "$_git/refs/tags" || rsyncerr=1
-if [ "$rsyncerr" ]; then
-	rsyncerr=
-	$fetch -i -s -u -d "$uri/tags" "$_git/refs/tags" || rsyncerr=1
-fi
+$fetch -i -s -u -d "$uri/refs/tags" "$_git/refs/tags/$repo" ||
+$fetch -i -s -u -d "$uri/tags" "$_git/refs/tags/$repo" || rsyncerr=1
 [ "$rsyncerr" ] && echo "unable to get tags list (non-fatal)" >&2
 
-
-new_head=$(cat "$_git/refs/heads/$name")
+new_head=$(cat "$_git/refs/heads/$branch")
 
 if [ ! "$orig_head" ]; then
 	echo "New branch: $new_head"


^ permalink raw reply

* Re: [COGITO PATCH] cg-branch-switch and local branches
From: Santi Béjar @ 2005-06-01 16:20 UTC (permalink / raw)
  To: Git Mailing List
In-Reply-To: <87mzqaqgv1.fsf@gmail.com>


Here it is un update version fixing some bugs. It depends on my update
version of the "[COGITO PATCH] Heads and tags in subdirectories" patch.

        Santi

 Makefile         |    3 +
 cg-Xnormid       |    2 +
 cg-branch-add    |   19 +++++++++
 cg-branch-switch |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 cg-clone         |   32 ++++++++++++----
 cg-commit        |   17 +++++++-
 cg-merge         |    3 +
 cg-pull          |   24 ++++++++----
 8 files changed, 189 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,8 @@ PROG=   git-update-cache git-diff-files 
 SCRIPT=	commit-id tree-id parent-id cg-add cg-admin-lsobj cg-admin-uncommit \
 	cg-branch-add cg-branch-ls cg-cancel cg-clone cg-commit cg-diff \
 	cg-export cg-help cg-init cg-log cg-ls cg-merge cg-mkpatch cg-patch \
-	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update
+	cg-pull cg-restore cg-rm cg-seek cg-status cg-tag cg-tag-ls cg-update \
+	cg-branch-switch
 
 LIB_SCRIPT=cg-Xlib cg-Xmergefile cg-Xnormid
 
diff --git a/cg-Xnormid b/cg-Xnormid
--- a/cg-Xnormid
+++ b/cg-Xnormid
@@ -16,6 +16,8 @@
 
 id="$1"
 
+[ -L $_git/refs/heads/$id ] &&
+id=$(readlink $_git/refs/heads/$id | sed 's@/@#@')
 repo=$(echo $id | cut -d '#' -f 1)
 (echo $repo | egrep -qv '[^a-zA-Z0-9_.@!:-]') || \
 	die "name contains invalid characters"
diff --git a/cg-branch-add b/cg-branch-add
--- a/cg-branch-add
+++ b/cg-branch-add
@@ -1,8 +1,11 @@
 #!/usr/bin/env bash
 #
 # Add new branch to the GIT repository.
+# Or create local branch in the GIT repository.
 # Copyright (c) Petr Baudis, 2005
 #
+# Adding a new branch
+# -------------------
 # Takes the branch name and source location as parameters.
 # After you add a branch, you can `cg-pull` it whenever you want and
 # it will keep your objects database in sync with it. Its latest
@@ -29,6 +32,22 @@
 #	$ cg-branch-add repo-testing rsync://host/path/repo.git#testing
 #
 # and refer to it as 'repo-testing' anytime later.
+#
+# Creating a local branch
+# -----------------------
+# Takes the local branch name and origin branch as parameters.
+#
+# After you create a local branch, you can `cg-branch-switch` it whenever you
+# want and you will be able to work on your local branch. Its {latest,origin}
+# commit is accessible as `.git/refs/heads/{master,origin}` (or - more
+# conveniently - as `$(commit-id {master,origin})`).
+# For example, to make a diff between your origin and your current tree, do:
+#
+#	$ cg-diff -r origin
+#
+# The origin specifier is a name of a branch added with cg-branch-add,
+# followed with an optional fragment part, which identifies a alternative
+# branch inside of the repository.
 
 USAGE="cg-branch-add BRANCH_NAME LOCATION"
 
diff --git a/cg-branch-switch b/cg-branch-switch
new file mode 100644
--- /dev/null
+++ b/cg-branch-switch
@@ -0,0 +1,107 @@
+#!/usr/bin/env bash
+#
+# Switch to a local branch.
+# Without arguments prints the branch.
+#
+# Takes the branch name as an argument.
+# If the argument is an external branch switch to an unnamed branch.
+#
+# Local branches
+# --------------
+#
+# The master file is always a link:
+#
+# master -> ${localbranch}
+#
+# The content of $_git/branches/${localbranch} is the original branch of
+# local branch. The cases and the corresponding origin links are:
+#
+# 1a.- name         : a name of an external repository
+#                     $branch corresponding to the definition
+#                     origin -> $name/$branch
+# 1b.- name#branch : optionally with a branch
+#                     origin -> $name/$branch
+# 2 .- name         : a name of another local branch
+#                     $branch corresponding to the definition
+#                     origin -> $name/$branch
+#
+# Local unnamed branches
+# ----------------------
+#
+# The master file is a regula file and the origin link only has the cases
+# 1a and 1b where the $name is the parameter to the script.
+
+USAGE="cg-switch-tree [BRANCH]"
+
+. ${COGITO_LIB}cg-Xlib
+
+name=$1
+
+[ -e $_git/refs/heads/origin ] && [ ! -L $_git/refs/heads/origin ] &&
+die "$_git/refs/heads/origin must be a symbolic link"
+
+[ -e $_git/blocked ] && die "switch blocked: $(cat $_git/blocked)"
+
+oldmaster=$(readlink $_git/refs/heads/master)
+oldorigin=$(readlink $_git/refs/heads/origin)
+
+[ -z "$name" ] && echo "master $(echo $oldmaster | sed 's@/@#@' )" &&
+echo "origin $(echo $oldorigin | sed 's@/@#@' )" && exit 0
+
+oldmaster=${oldmaster:-master}
+
+namerepo=$(echo $name | cut -d '#' -f 1)
+namebranch=$(echo $name | cut -d '#' -f 2 -s)
+[ -e "$_git/branches/$namerepo" ] || die "unknown branch: $name"
+origuri=$(cat "$_git/branches/$namerepo")
+origrepo=$(echo $origuri | cut -d '#' -f 1)
+origbranch=$(echo $origuri | cut -d '#' -f 2 -s)
+
+if [ -e "$_git/branches/$origrepo" ] ; then
+    # $name is a local branch
+    switch=local
+    master=$namerepo
+    [ -e "$_git/branches/$origrepo" ] || die "do not exist local branch: $name"
+    uri=$(cat $_git/branches/$origrepo)
+    if [ -e "$_git/branches/$(echo $uri| cut -d '#' -f 1)" ] ; then
+    # Origin is a local branch
+	origlink=$origuri
+	[ "$namebranch" ] && die "local branches cannot have branches"
+    else
+    # Origin is a external branch
+	extbranch=${namebranch:-$origbranch}
+	extbranch=${extbranch:-master}
+	origlink=$origrepo/$extbranch
+    fi
+else
+    # Origin is an external unnamed branch
+    switch=unnnamed
+    extbranch=${namebranch:-$origbranch}
+    extbranch=${extbranch:-master}
+    origlink=$namerepo/$extbranch
+    master=$namerepo/$extbranch
+fi
+
+[ ! -r $_git/refs/heads/$origlink ] && die "unknown branch: $origlink"
+
+if [ "$(git-diff-files -s)" ] || [ "$(git-diff-cache HEAD 2>/dev/null)" ]; then
+	die "switch blocked: local changes"
+fi
+
+[ ! -r $_git/refs/heads/$master -o ! -s $_git/refs/heads/$master ] &&
+[ "$switch" = "local" ] && cp $_git/refs/heads/$origlink $_git/refs/heads/$master
+
+( cd $_git/refs/heads/ &&
+    [ -f master ] && [ ! -L master ] &&
+    [ "$(cat master)" != "$(cat origin)" ] &&
+    cp master master_$(date +%Y%m%d%H%M%S)
+    rm -f master
+    if [ "$switch" = "local" ] ; then
+	ln -s $master master
+    else
+	cp $master master
+    fi
+    ln -fs $origlink origin )
+
+git-read-tree -m HEAD && git-checkout-cache -q -f -u -a
+
diff --git a/cg-clone b/cg-clone
--- a/cg-clone
+++ b/cg-clone
@@ -6,10 +6,10 @@
 # This is like cg-init, but it will create a new directory where it will do
 # the checkout.
 #
-# Takes a parameter specifying the location of the source repository and an
-# optional second parameter specifying the destination. If the second
-# parameter is omitted, the basename of the source repository is used as the
-# destination.
+# Takes two parameter specifying the name and location of the source
+# repository, an optional third parameter specifying name of the local branch
+# (defaults to an unnamed branch) and an optional fourth parameter specifying
+# the destination (defaults to the basename of the source repository).
 #
 # OPTIONS
 # -------
@@ -17,7 +17,7 @@
 #	Clone in the current directory instead of creating a new one.
 #	Specifying both -s and a desination directory makes no sense .
 
-USAGE="cg-clone [-s] LOCATION [DESTDIR]"
+USAGE="cg-clone [-s] NAME LOCATION [LOCALNAME [DESTDIR]]"
 
 . ${COGITO_LIB}cg-Xlib
 
@@ -27,9 +27,16 @@ if [ "$1" = "-s" ]; then
 	same_dir=1
 fi
 
+name=$1 && shift
 location=$1
 [ "$location" ] || usage
 location=${location%/}
+if [ $location = $1 ] ; then
+    branch=$(echo $location | cut -d '#' -f 2 -s)
+    location=$(echo $location | cut -d '#' -f 1)
+fi
+shift
+localbranch=$1
 
 destdir=$2
 if [ "$destdir" ]; then
@@ -45,6 +52,8 @@ else
 	location="$location"
 fi
 
+[ "$branch" ] && location=$location#$branch
+
 if [ ! "$same_dir" ]; then
 	[ -e "$dir" ] && die "$dir/ already exists"
 	mkdir "$dir" || exit $?
@@ -54,6 +63,15 @@ else
 fi
 
 trap "rm -rf $dir" SIGTERM EXIT
-cg-init $location || exit $?
+git-init-db
+cg-branch-add $name $location
+cg-pull $name || die "pull failed"
+if [ "$localbranch" ] ; then
+    cg-branch-add $localbranch $name
+    cg-branch-switch $localbranch
+else
+    cg-branch-switch $name
+fi
+echo "Master and origin branches are:"
+cg-branch-switch
 trap "" SIGTERM EXIT
-echo "Cloned to $dir/ (origin $location available as branch \"origin\")"
diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -143,10 +143,23 @@ if [ "$merging" ]; then
 	for sym in $(cat $_git/merging-sym); do
 		repo=$(echo $sym | cut -d '#' -f 1)
 		branch=$(echo $sym | cut -d '#' -f 2 -s)
+		if [ -L $_git/refs/heads/$sym ]; then
+			uri=$(readlink $_git/refs/heads/$sym)
+			repo=$(echo $uri | cut -d '#' -f 1)
+			[ -z "$branch" ] &&
+			branch=$(echo $uri | cut -d '#' -f 2 -s)
+		fi
 		uri=$(cat $_git/branches/$repo)
+		urirepo=$(echo $uri | cut -d '#' -f 1)
 		uribranch=$(echo $uri | cut -d '#' -f 2 -s)
-		[ -z "$uribranch" ] && [ -n "$branch" ] &&
-		[ "$branch" != master ] && uri=${uri}#$branch
+		if [ -e $_git/branches/$urirepo ]; then
+		    # local branch
+		    uri="$repo"
+		else
+ 		    # remote branch
+		    [ -z "$uribranch" ] && [ -n "$branch" ] &&
+		    [ "$branch" != master ] && uri=${uri}#$branch
+		fi
 		[ "$uri" ] || uri="$sym"
 		echo "$uri" >>$LOGMSG
 		[ "$msgs" ] && echo "$uri"
diff --git a/cg-merge b/cg-merge
--- a/cg-merge
+++ b/cg-merge
@@ -42,7 +42,8 @@ fi
 [ "$1" ] || usage
 branchname="$1"
 branch=$(commit-id "$branchname") || exit 1
-
+[ -L $_git/refs/heads/$branchname ] &&
+branchname=$(readlink $_git/refs/heads/$branchname| sed 's@/@#@')
 [ "$base" ] || base=$(git-merge-base "$head" "$branch")
 [ "$base" ] || die "unable to automatically determine merge base"
 
diff --git a/cg-pull b/cg-pull
--- a/cg-pull
+++ b/cg-pull
@@ -19,18 +19,28 @@ USAGE="cg-pull [-a] [BRANCH_NAME]"
 [ "$1" == "-a" ] && all=yes && shift
 name=$1 && shift
 
-[ "$name" ] || { [ -s $_git/refs/heads/origin ] && name=origin; }
+if [ -z "$name" ] && [ -f $_git/branches/origin ]; then
+	#Convert the old layout 2005/06
+	mv $_git/branches/origin $_git/branches/original
+	branch=$(cat $_git/branches/original | cut -s -d '#' -f 2)
+	branch=${branch:-master}
+	[ -f $_git/refs/heads/origin -o -d $_git/refs/heads/origin ] &&
+	rm -rf $_git/refs/heads/origin &&
+	ln -s original/$branch $_git/refs/heads/origin
+fi
+[ "$name" ] || name=$(readlink $_git/refs/heads/origin | sed 's@/@#@')
 [ "$name" ] || die "where to pull from?"
 
 repo=$(echo $name | cut -d '#' -f 1)
 repobranch=$(echo $name | cut -s -d '#' -f 2)
 
-uri=$(cat "$_git/branches/$name" 2>/dev/null) || die "unknown branch: $name"
-if echo "$uri" | grep -q '#'; then
-	[ -z "$repobranch" ] && repobranch=$(echo $uri | cut -d '#' -f 2)
-	rembranch=$(echo $uri | cut -d '#' -f 2)
-	uri=$(echo $uri | cut -d '#' -f 1)
-fi
+uri=$(cat "$_git/branches/$repo" 2>/dev/null) || die "unknown branch: $name"
+urirepo=$(echo $uri | cut -d '#' -f 1)
+uribranch=$(echo $uri | cut -d '#' -f 2 -s)
+
+[ -e $_git/branches/$urirepo ] && die "Local branches are already pulled"
+
+repobranch=${repobranch:-$uribranch}
 repobranch=${repobranch:-master}
 branch=$repo/$repobranch
 [ "$all" ] && repobranch=


^ permalink raw reply

* Re: [PATCH] One Git To Rule Them All
From: McMullan, Jason @ 2005-06-01 16:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vekbmkqeg.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

On Wed, 2005-06-01 at 09:12 -0700, Junio C Hamano wrote:
> You said with this change there is only one file to install, but
> you are not bundling the git-* scripts in the "single git", so
> that claim is not true either.  If your patch handled the git-*
> script parts as well, then I would have admired that part of the
> change ;-).

	You want git-* scripts? You sure? I can supply that patch
in about an hour... ;^)

> Personally I find the mandatory documentation requirements this
> patch brings us is a good thing ;-).

	So do I. Also, I really like the 'ordered by workflow'
help of 'git help'.

-- 
Jason McMullan <jason.mcmullan@timesys.com>
TimeSys Corporation


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: git-rev-list: proper lazy reachability
From: Matthias Urlichs @ 2005-06-01 16:38 UTC (permalink / raw)
  To: git
In-Reply-To: <Pine.LNX.4.58.0505310813540.1876@ppc970.osdl.org>

Hi, Linus Torvalds wrote:

> So I guess you'll have to wait for the end and do the toposort after all.

We could add a cache file, listing commit nodes which predate one of
their parents. Hit one of those and you know you need to immediately
examine their parents instead of waiting for them to come up in date order.

There shouldn't be too many of those in any tree.

-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
Truth is a statue, and you are all just a bunch of pigeons.



^ permalink raw reply

* Re: [SCRIPT] cg-rpush & locking
From: Tony Lindgren @ 2005-06-01 16:55 UTC (permalink / raw)
  To: Thomas Glanzmann; +Cc: Nicolas Pitre, git, Matthias Urlichs
In-Reply-To: <20050601065123.GA23358@cip.informatik.uni-erlangen.de>

* Thomas Glanzmann <sithglan@stud.uni-erlangen.de> [050531 23:56]:
> Hello,
> 
> > Why do you need a lock at all?
> 
> > Just update your HEAD reference last when you push and get it first when 
> > you pull.
> 
> consider the following scenario: Two people push at the same time. One
> HEAD gets actually written, but both think that their changes got
> upstream. Of course the 'upstream' tree is consitent, but incomplete.
> That is why we need a lock. And the lock should be obtained before the
> remote HEAD is retrieved, I think the following scenario is how to
> handle it:
> 
> 	1. acquire remote lock
> 	2. get remote HEAD
> 	3. if remote HEAD is ahead (not included in our history) abort
> 	   and free lock.
> 	4. push objects
> 	5. update remote HEAD with local
> 	6. free remote lock.

Yes, that's basically what the script does. We have several people
committing patches.

Tony

^ permalink raw reply

* [PATCH] One-Git Part 2 (3 patches to follow)
From: Jason McMullan @ 2005-06-01 18:22 UTC (permalink / raw)
  To: git


The following set of patches add to the original 'one git'
patch series, and wrap the git-*-script scripts into the
one-git binary via zlib compression.

Have fun!

-- 
Jason McMullan <jason.mcmullan@timesys.com>
TimeSys Corporation

^ permalink raw reply

* [PATCH] One-Git Part 2 (Patch 1/3)
From: Jason McMullan @ 2005-06-01 18:22 UTC (permalink / raw)
  To: git

Add: Empty documentation for some scripts

Signed-off-by: Jason McMullan <jason.mcmullan@timesys.com>

diff --git a/Documentation/git-commit-script.txt b/Documentation/git-commit-script.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/git-commit-script.txt
@@ -0,0 +1,29 @@
+git-commit-script(1)
+====================
+v0.1, May 2005
+
+NAME
+----
+git-commit-script - Commit working directory
+
+
+SYNOPSIS
+--------
+'git-commit-script' 
+
+DESCRIPTION
+-----------
+
+
+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
+
diff --git a/Documentation/git-deltafy-script.txt b/Documentation/git-deltafy-script.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/git-deltafy-script.txt
@@ -0,0 +1,29 @@
+git-deltafy-script(1)
+=====================
+v0.1, May 2005
+
+NAME
+----
+git-deltafy-script - Convery repository into delta format
+
+
+SYNOPSIS
+--------
+'git-deltafy-script'
+
+DESCRIPTION
+-----------
+
+
+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
+
diff --git a/Documentation/git-fetch-script.txt b/Documentation/git-fetch-script.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/git-fetch-script.txt
@@ -0,0 +1,29 @@
+git-fetch-script(1)
+===================
+v0.1, May 2005
+
+NAME
+----
+git-fetch-script - Fetch an object from a remote repository
+
+
+SYNOPSIS
+--------
+'git-fetch-script' <sha1>
+
+DESCRIPTION
+-----------
+
+
+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
+
diff --git a/Documentation/git-log-script.txt b/Documentation/git-log-script.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/git-log-script.txt
@@ -0,0 +1,29 @@
+git-log-script(1)
+=================
+v0.1, May 2005
+
+NAME
+----
+git-log-script - Prettified version of git-rev-list
+
+
+SYNOPSIS
+--------
+'git-log-script' 
+
+DESCRIPTION
+-----------
+
+
+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
+
diff --git a/Documentation/git-status-script.txt b/Documentation/git-status-script.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/git-status-script.txt
@@ -0,0 +1,29 @@
+git-status-script(1)
+====================
+v0.1, May 2005
+
+NAME
+----
+git-status-script - Show status of working directory files
+
+
+SYNOPSIS
+--------
+'git-status-script' 
+
+DESCRIPTION
+-----------
+
+
+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
+
======== end ========


^ permalink raw reply

* [PATCH] One-Git Part 2 (Patch 2/3)
From: Jason McMullan @ 2005-06-01 18:23 UTC (permalink / raw)
  To: git

Rename: git-whatchanged to git-whatchanged-script

Signed-off-by: Jason McMullan <jason.mcmullan@timesys.com>

diff --git a/Documentation/git-whatchanged-script.txt b/Documentation/git-whatchanged-script.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/git-whatchanged-script.txt
@@ -0,0 +1,29 @@
+git-whatchanged(1)
+==================
+v0.1, May 2005
+
+NAME
+----
+git-whatchanged - Find out what changed
+
+
+SYNOPSIS
+--------
+'git-whatchanged' 
+
+DESCRIPTION
+-----------
+
+
+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
+
diff --git a/git-whatchanged b/git-whatchanged
deleted file mode 100755
--- a/git-whatchanged
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-git-rev-list HEAD | git-diff-tree --stdin -v -r "$@" | LESS="$LESS -S" ${PAGER:-less}
diff --git a/git-whatchanged-script b/git-whatchanged-script
new file mode 100755
--- /dev/null
+++ b/git-whatchanged-script
@@ -0,0 +1,2 @@
+#!/bin/sh
+git-rev-list HEAD | git-diff-tree --stdin -v -r "$@" | LESS="$LESS -S" ${PAGER:-less}
======== end ========


^ permalink raw reply

* [PATCH] One-Git Part 2 (Patch 3/3)
From: Jason McMullan @ 2005-06-01 18:23 UTC (permalink / raw)
  To: git

Add: 'compiled in' scripts, using zlib

one-git now includes everything!

Requires: one-git Part 1 (all patches), and one-git Part 2 (pre 1, pre 2)

Signed-off-by: Jason McMullan <jason.mcmullan@timesys.com>

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -20,18 +20,16 @@ CC=gcc
 AR=ar
 INSTALL=install
 
-SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
-	git-pull-script git-tag-script git-resolve-script git-whatchanged \
-	git-deltafy-script git-fetch-script git-status-script git-commit-script \
-	git-log-script
-
 # The following order determines 'git help' command order.
 # The general idea is 'pull, push, inspect, commit, db, misc'
 PROG=   \
+	git-pull \
 	git-local-pull \
 	git-http-pull \
 	git-rpull \
 	git-rpush \
+	git-whatchanged \
+	git-log \
 	git-rev-tree \
 	git-rev-list \
 	git-export \
@@ -45,20 +43,29 @@ PROG=   \
 	git-diff-files \
 	git-diff-cache \
 	git-diff-tree \
+	git-status \
 	git-merge-base \
 	git-merge-cache \
+	git-merge-one-file \
+	git-resolve \
 	git-apply \
+	git-apply-patch \
 	git-check-files \
 	git-write-tree \
 	git-commit-tree \
+	git-commit \
 	git-mktag \
+	git-tag \
 	git-init-db \
 	git-fsck-cache \
+	git-prune \
 	git-convert-cache \
 	git-mkdelta \
+	git-deltafy \
 	git-tar-tree \
 	git-get-tar-commit-id \
 	git-write-blob \
+	git-fetch \
 	git-diff-helper \
 	git-stripspace
 
@@ -86,6 +93,8 @@ LIB_OBJS += pull.o
 
 LIB_OBJS += rsh.o
 
+LIB_OBJS += zscript.o
+
 LIBS = $(LIB_FILE)
 LIBS += -lz
 
@@ -116,8 +125,14 @@ test-date: test-date.c date.o
 test-delta: test-delta.c diff-delta.o patch-delta.o
 	$(CC) $(CFLAGS) -o $@ $^
 
-git-%.o: %.c #Makefile
-	$(CC) $(CFLAGS) -c -o $@ $*.c -Dmain=git_$(subst -,_,$*) -Ddesc=git_$(subst -,_,$*)_desc
+git-%-script.h: git-%-script
+	./zwrap script <git-$*-script >git-$*-script.h
+
+git-%.o: zwrap git-%-script git-%-script.h git-script.c
+	$(CC) $(CFLAGS) -c -o $@ git-script.c -Dscript=git_$(subst -,_,$*)_script -Dmain=git_$(subst -,_,$*) --include git-$*-script.h
+
+git-%.o: %.c Makefile
+	$(CC) $(CFLAGS) -c -o $@ $*.c -Dmain=git_$(subst -,_,$*)
 
 $(PROG):
 	ln -s git $@
@@ -127,7 +142,10 @@ git.o: git-commands.h
 git: git.o $(patsubst %,%.o,$(PROG)) $(LIBS)
 	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
-git-commands.h: Makefile $(patsubst %,Documentation/%.txt,$(PROG))
+zwrap: zwrap.o $(LIBS)
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+
+git-commands.h: Makefile #$(patsubst %,Documentation/%.txt,$(PROG))
 	echo -n >git-commands.h
 	for prog in $(subst -,_,$(PROG)); do \
 		echo "extern int $${prog}(int argc, char **argv);" >>git-commands.h ; \
@@ -139,7 +157,14 @@ git-commands.h: Makefile $(patsubst %,Do
 	echo "	const char *desc; } commands[]={" >>git-commands.h
 	for cmd in $(patsubst git-%,%,$(PROG)); do \
 		prog=`echo $$cmd | sed -e 's/-/_/g'` ; \
-		desc=`grep "^git-$$cmd - " Documentation/git-$$cmd.txt | cut -d' ' -f3-` ; \
+		if [ -f Documentation/git-$${cmd}-script.txt ]; then \
+		  doc=Documentation/git-$${cmd}-script.txt; \
+		else doc=Documentation/git-$${cmd}.txt; fi; \
+		if [ ! -e $${doc} ]; then \
+			echo "MISSING: $$doc" 1>&2; \
+			rm -f git-commands.h; \
+			exit 1; fi; \
+		desc=`grep "^git-$$cmd - " $$doc | cut -d' ' -f3-` ; \
 		desc=`echo "$$desc" | sed -e 's/"/\\\\"/g'` ; \
 		echo -n "	{ " >>git-commands.h ; \
 		echo -n ".command = \"$${cmd}\", " >>git-commands.h ; \
@@ -172,7 +197,8 @@ test: all
 	$(MAKE) -C t/ all
 
 clean:
-	rm -f *.o mozilla-sha1/*.o ppc/*.o git $(PROG) $(LIB_FILE)
+	rm -f *.o mozilla-sha1/*.o ppc/*.o \
+		zwrap git $(PROG) $(LIB_FILE) git-*-script.h
 	$(MAKE) -C Documentation/ clean
 
 backup: clean
diff --git a/git b/git
deleted file mode 100755
--- a/git
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-cmd="git-$1-script"
-shift
-exec $cmd "$@"
diff --git a/git-script.c b/git-script.c
new file mode 100644
--- /dev/null
+++ b/git-script.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+extern int zscript(const void *s, size_t s_len, int argc, char **argv);
+
+int main(int argc, char **argv)
+{
+	return zscript(script,sizeof(script),argc,argv);
+}
diff --git a/zscript.c b/zscript.c
new file mode 100644
--- /dev/null
+++ b/zscript.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+#include <zlib.h>
+
+#include "cache.h"
+
+int zscript(void *script, size_t script_len, int argc, char **argv)
+{
+	z_stream stream;
+	char buff[8192];
+	int fd, ret, status;
+	pid_t pid;
+	char template[]="/tmp/git-script.XXXXXX";
+
+	fd = mkstemp(template);
+	if (fd < 0)
+		die("Can't create file %s\n",template);
+
+	memset(&stream, 0, sizeof(stream));
+	stream.next_in = script;
+	stream.avail_in = script_len;
+
+	inflateInit(&stream);
+	do {
+		stream.next_out = buff;
+		stream.avail_out = sizeof(buff);
+		ret = inflate(&stream, Z_SYNC_FLUSH);
+		write(fd,buff,sizeof(buff)-stream.avail_out);
+	} while (stream.avail_in && ret == Z_OK);
+	inflateEnd(&stream);
+
+	pid = fork();
+	if (pid < 0) {
+		unlink(template);
+		die("Can't fork.");
+	}
+
+	if (! pid) {	/* Child */
+		char **args;
+		args=xmalloc(sizeof(char *)*(argc+1));
+		memcpy(&args[2],&argv[1],sizeof(char *)*(argc-1));
+		argv[0]="/bin/sh";
+		argv[1]=template;
+		execv("/bin/sh",argv);
+		exit(1);	/* Hopefully unreachable */
+	}
+
+	if (waitpid(pid, &status, 0) < 0 ||
+		!WIFEXITED(status) || WEXITSTATUS(status))
+		goto error;
+
+	unlink(template);
+	return 0;
+
+
+error:
+	unlink(template);
+	return 1;
+}
+		
diff --git a/zwrap.c b/zwrap.c
new file mode 100644
--- /dev/null
+++ b/zwrap.c
@@ -0,0 +1,88 @@
+/* Takes stdin, and makes a C header file out of it, compressed
+ * with zlib.
+ *
+ * Author: Jason McMullan <jason.mcmullan@timesys.com>
+ */
+
+#include <stdio.h>
+#include <zlib.h>
+
+#include "cache.h"
+
+unsigned char *read_from(int fd, size_t *bsize)
+{
+	unsigned char *buff;
+	int len;
+	size_t size;
+
+	buff=xmalloc(1024);
+	size = 0;
+
+	while ((len = read(fd, buff, 1024-(size % 1024))) > 0) {
+		size += len;
+		if ((size % 1024)==0)
+			buff = xrealloc(buff, size+1024);
+	}
+
+	if (len < 0) {
+		size=0;
+		free(buff);
+		buff=NULL;
+	}
+
+	*bsize = size;
+	return buff;
+}
+
+
+int main(int argc, char **argv)
+{
+	const char *name="data";
+	z_stream stream;
+	size_t size, dsize;
+	unsigned char *dbuff,*buff;
+
+	if (argc == 2)
+		name=argv[1];
+	else if (argc != 1) {
+		fprintf(stderr,"Usage:\n%s [name] <somefile\n",argv[0]);
+		return 1;
+	}
+
+	buff=read_from(0, &size);
+	if (buff == NULL)
+		return 1;
+
+	/* Init zlib */
+	memset(&stream, 0, sizeof(stream));
+	deflateInit(&stream, Z_BEST_COMPRESSION);
+	dsize = deflateBound(&stream, size);
+	dbuff = xmalloc(dsize);
+
+	stream.next_out = dbuff;
+	stream.avail_out = dsize;
+
+	while (deflate(&stream, 0) == Z_OK)
+		/* nothing */;
+
+	stream.next_in  = buff;
+	stream.avail_in  = size;
+	while (deflate(&stream, Z_FINISH) == Z_OK)
+		/* nothing */;
+	deflateEnd(&stream);
+
+	dsize = stream.total_out;
+
+	printf("const unsigned char %s[] = {\n", name);
+	for ( size = 0; size < dsize; size++) {
+		if ((size % 8) == 0)
+			printf("\t");
+		printf("0x%.2x,",dbuff[size]);
+		if ((size % 8) == 7)
+			printf("\n");
+	}
+	printf("};\n");
+
+	return 0;
+}
+
======== end ========


^ permalink raw reply

* Re: git-rev-list: proper lazy reachability
From: Marco Costalba @ 2005-06-01 19:02 UTC (permalink / raw)
  To: git

Linus Torvalds wrote:
> 
> On Tue, 31 May 2005, Linus Torvalds wrote:
> 
>>You should never see a parent before a child from git-rev-list.
> 
> 
> Actually, I take that back.
> 
...

> 
> The thing is, since B has such an "old" date, the traversal assumes that
> it is old and very low down in the tree, and that it's better off parsing
> other commits first, so it will never look more closely at B and notice
> that it has a parent that has already been parsed.
> 

If this is an exception, and I it is, peraphs can be treated in a special way.

As example, when adding a new parent to the pending list of parents to be processed in time-based
ordering, should be easy to inc a counter if  the last one is always the same, e.g. there is the
same very old node around, and check closer to it if the counter reach some allowed maximum.

I know it's a hack, and is not a solution in the general case, but also the last century developer
clock is very rare, more, it is a warning for a bad commit. 

Do not wait for the end of the toposort its a very big advantage for, e.g. GUI git viewers
launched on big trees with long histories.

Marco Costalba







	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it

^ permalink raw reply

* [COGITO PATCH] Small, simple and obvious cleanups (are they wanted at this stage?)
From: C. Cooke @ 2005-06-01 19:22 UTC (permalink / raw)
  To: git

This is a simple example - giving a nice error if you're in the wrong
directory.

Is this sort of patch wanted? If so, I'm sure I can spare the time to
look into some polishing.

------------------------------
Add some sanity checking - does $_git exist, and is it writable.

---
commit 06afdeefff9fe02cd2a67f223e687646cacf736f
tree cebc55541b89b5370335fc172814feb48456dc85
parent 20e473c9afd8b5d2d549b0e7881473600beb9c37
author C. Cooke <ccooke@slab.earth.gkhs.net> Wed, 01 Jun 2005 20:03:46 +0100
committer C. Cooke <ccooke@slab.earth.gkhs.net> Wed, 01 Jun 2005
20:03:46 +0100

 cg-Xnormid |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/cg-Xnormid b/cg-Xnormid
--- a/cg-Xnormid
+++ b/cg-Xnormid
@@ -16,6 +16,15 @@

 id="$1"

+# A little sanity checking.
+if [ ! -d "$_git" ]; then
+       echo "There is no Git repository here ($_git not found)" >&2
+       exit 1
+elif [ ! -r "$_git" ] || [ ! -x "$_git" ]; then
+       echo "You do not have permission to access this git repository" >&2
+       exit 1
+fi
+
 if [ ! "$id" ] || [ "$id" = "this" ] || [ "$id" = "HEAD" ]; then
        read id < "$_git/HEAD"


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

^ permalink raw reply

* Re: git-rev-list: proper lazy reachability
From: Marco Costalba @ 2005-06-01 18:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Git Mailing List

Linus Torvalds wrote:
> 
> On Tue, 31 May 2005, Linus Torvalds wrote:
> 
>>You should never see a parent before a child from git-rev-list.
> 
> 
> Actually, I take that back.
> 
...

> 
> The thing is, since B has such an "old" date, the traversal assumes that
> it is old and very low down in the tree, and that it's better off parsing
> other commits first, so it will never look more closely at B and notice
> that it has a parent that has already been parsed.
> 

If this is an exception, and I it is, peraphs can be treated in a special way.

As example, when adding a new parent to the pending list of parents to be processed in time-based
ordering, should be easy to inc a counter if  the last one is always the same, e.g. there is the
same very old node around, and check closer to it if the counter reach some allowed maximum.

I know it's a hack, and is not a solution in the general case, but also the last century developer
clock is very rare, more, it is a warning for a bad commit. 

Do not wait for the end of the toposort its a very big advantage for, e.g. GUI git viewers
launched on big trees with long histories.

Marco Costalba




	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it

^ permalink raw reply

* [PATCH] diff: mode bits fixes
From: Junio C Hamano @ 2005-06-01 18:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <7vy89ums2l.fsf@assigned-by-dhcp.cox.net>

The core GIT repository has trees that record regular file mode
in 0664 instead of normalized 0644 pattern.  Comparing such a
tree with another tree that records the same file in 0644
pattern without content changes with git-diff-tree causes it to
feed otherwise unmodified pairs to the diff_change() routine,
which triggers a sanity check routine and barfs.  This patch
fixes the problem, along with the fix to another caller that
uses unnormalized mode bits to call diff_change() routine in a
similar way.

Without this patch, you will see "fatal error" from diff-tree
when you run git-deltafy-script on the core GIT repository
itself.

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

*** Linus, I decided to bite the bullet and audited the callers.
*** There was only one that was not quite right, other than the
*** diff-tree one.  Please disregard the one I sent last night
*** which incorrectly said "S_ISDIR() || S_ISREG()".  Please
*** also disregard the other one that silently ignores
*** unmodified filepairs in the output routine.  Warning about
*** callers should be the most appropriate action as this
*** version does.

 diff.h       |    4 ++++
 diffcore.h   |    4 ----
 diff-files.c |    8 +++-----
 diff-tree.c  |    4 +++-
 diff.c       |   12 +++++++-----
 5 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/diff.h b/diff.h
--- a/diff.h
+++ b/diff.h
@@ -4,6 +4,10 @@
 #ifndef DIFF_H
 #define DIFF_H
 
+#define DIFF_FILE_CANON_MODE(mode) \
+	(S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
+	S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
+
 extern void diff_addremove(int addremove,
 			   unsigned mode,
 			   const unsigned char *sha1,
diff --git a/diffcore.h b/diffcore.h
--- a/diffcore.h
+++ b/diffcore.h
@@ -59,10 +59,6 @@ struct diff_filepair {
 
 #define DIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
 
-#define DIFF_FILE_CANON_MODE(mode) \
-	(S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
-	S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
-
 extern void diff_free_filepair(struct diff_filepair *);
 
 extern int diff_unmodified_pair(struct diff_filepair *);
diff --git a/diff-files.c b/diff-files.c
--- a/diff-files.c
+++ b/diff-files.c
@@ -88,7 +88,7 @@ int main(int argc, const char **argv)
 
 	for (i = 0; i < entries; i++) {
 		struct stat st;
-		unsigned int oldmode, mode;
+		unsigned int oldmode;
 		struct cache_entry *ce = active_cache[i];
 		int changed;
 
@@ -116,10 +116,8 @@ int main(int argc, const char **argv)
 			continue;
 
 		oldmode = ntohl(ce->ce_mode);
-		mode = (S_ISLNK(st.st_mode) ? S_IFLNK :
-			S_IFREG | ce_permissions(st.st_mode));
-
-		show_modified(oldmode, mode, ce->sha1, null_sha1,
+		show_modified(oldmode, DIFF_FILE_CANON_MODE(st.st_mode),
+			      ce->sha1, null_sha1,
 			      ce->name);
 	}
 	diffcore_std((1 < argc) ? argv + 1 : NULL,
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -44,10 +44,12 @@ static const unsigned char *extract(void
 	int len = strlen(tree)+1;
 	const unsigned char *sha1 = tree + len;
 	const char *path = strchr(tree, ' ');
+	unsigned int mode;
 
-	if (!path || size < len + 20 || sscanf(tree, "%o", modep) != 1)
+	if (!path || size < len + 20 || sscanf(tree, "%o", &mode) != 1)
 		die("corrupt tree file");
 	*pathp = path+1;
+	*modep = DIFF_FILE_CANON_MODE(mode);
 	return sha1;
 }
 
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -854,12 +854,14 @@ static void diff_resolve_rename_copy(voi
 		else if (memcmp(p->one->sha1, p->two->sha1, 20) ||
 			 p->one->mode != p->two->mode)
 			p->status = 'M';
-		else
-			/* this is a "no-change" entry.
-			 * should not happen anymore.
-			 * p->status = 'X';
+		else {
+			/* This is a "no-change" entry and should not
+			 * happen anymore, but prepare for broken callers.
 			 */
-			die("internal error in diffcore: unmodified entry remains");
+			error("feeding unmodified %s to diffcore",
+			      p->one->path);
+			p->status = 'X';
+		}
 	}
 	diff_debug_queue("resolve-rename-copy done", q);
 }
------------


^ permalink raw reply

* Re: I want to release a "git-1.0"
From: David Lang @ 2005-06-01 20:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Chris Wedgwood, Linus Torvalds, Git Mailing List
In-Reply-To: <7vhdgismo0.fsf@assigned-by-dhcp.cox.net>

On Tue, 31 May 2005, Junio C Hamano wrote:

>>>>>> "DL" == David Lang <david.lang@digitalinsight.com> writes:
>
> DL> Hmm, thinking out loud. would it help to look at the deltify scripts
> DL> and let them find the major chunks and then look in detail only when
> DL> that fails?
>
> It's unclear to me which part you are trying to help with
> deltify algorithm [*1*].

I was thinking that the speedups (only look for similar sized files, etc) 
would help narrow the search. Also each chunk that's different should be 
able to be able to be annotated as a chunk, instead of by individual line

> Internally, git-diff-cache -B -C is used which does use the
> deltify to locate complete rewrites, renames and copies (that's
> why the script is so slow).  For passing on and assigning blames
> line by line, parsing "diff --unified=0" output was a lot easier
> for this script and that was what I did in this quick-and-dirty
> version.

I was under the impressin that the deltafy stuff was significantly faster 
then you are suggeting that it is here

> [Footnotes]
>
> *1* David says "deltify" and Nico calls it "deltafy".  I am not
> a native speaker so I cannot tell, but which one is correct?

Nico is correct

David Lang

-- 
There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.
  -- C.A.R. Hoare

^ permalink raw reply

* Re: I want to release a "git-1.0"
From: C. Scott Ananian @ 2005-06-01 20:16 UTC (permalink / raw)
  To: David Lang
  Cc: Junio C Hamano, Chris Wedgwood, Linus Torvalds, Git Mailing List
In-Reply-To: <Pine.LNX.4.62.0506011304001.21267@qynat.qvtvafvgr.pbz>

On Wed, 1 Jun 2005, David Lang wrote:

>> *1* David says "deltify" and Nico calls it "deltafy".  I am not
>> a native speaker so I cannot tell, but which one is correct?
>
> Nico is correct

Au contraire.  The common *pronunciation* may be 'delta-fy', but the 
correct spelling should be 'deltify'.  The google oracle agrees (1,440 vs 
54) as does the spelling of the svnadmin command.  (Of course, what google 
is really measuring is relative frequency of 'git' vs 'svn'.)

$ grep '[^if]fy$' /usr/dict/american-english-large

shows that the only vowels other than 'i' which preced the '-fy' morpheme 
are 'e's, and they only appear in words like 'liquefy' where the root has 
been substantially altered.  Most sources (eg
http://www.southampton.liunet.edu/academic/pau/course/websuf.htm#IFYVERB
) list the morpheme as '-ify'.  See
     http://m-w.com/cgi-bin/dictionary?book=Dictionary&va=ify
and compare
     http://m-w.com/cgi-bin/dictionary?book=Dictionary&va=fy

Contrary to David's assertion, David is right.
  --scott

United Nations KMPLEBE AMTHUG AVBRANDY UNIFRUIT chemical agent tonight 
ZPSEMANTIC ODYOKE struggle PBCABOOSE FJDEFLECT CLOWER MKSEARCH ZRBRIEF
                          ( http://cscott.net/ )

^ permalink raw reply

* Re: I want to release a "git-1.0"
From: Daniel Barkalow @ 2005-06-01 22:00 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Eric W. Biederman, Git Mailing List
In-Reply-To: <Pine.LNX.4.58.0505312002160.1876@ppc970.osdl.org>

On Tue, 31 May 2005, Linus Torvalds wrote:

> On Tue, 31 May 2005, Eric W. Biederman wrote:
> > 
> > I way behind the power curve on learning git at this point but
> > one piece of the puzzle that CVS has that I don't believe git does
> > are multiple people committing to the same repository, especially
> > remotely.  I don't see that as a down side of git but it is a common
> > way people CVS so it is worth documenting.
> 
> It's actually one thing git doesn't do per se.
> 
> You have to do a "git-pull-script" from the common repository side, 
> there's no "git-push-script". Ugly.

It shouldn't be hard to do one, except that locking with rsync is going to
be a pain. I had a patch to make it work with the rpush/rpull pair, but I
didn't get its dependancies in at the time. I can dust those patches off
again if you want that functionality included.

The patches are essentially:

 - make the transport protocol handle things other than objects
 - library procedure for locking atomic update of refs files
 - fetching refs in general
 - rpull/rpush that updates a specified ref file atomically

At least the first would be very nice to get in before 1.0, since it is an
incompatible change to the protocol.

	-Daniel
*This .sig left intentionally blank*


^ 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