* Re: [PATCH 2/2] Fix oversimplified optimization for add_cache_entry().
From: Junio C Hamano @ 2005-06-25 2:40 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0506241755280.11175@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> I really don't want to do this.
LT> Can you fix the "optimized" one instead?
Will do.
^ permalink raw reply
* Re: Updated git HOWTO for kernel hackers
From: Jeff Garzik @ 2005-06-25 3:33 UTC (permalink / raw)
To: Dave Jones; +Cc: Linux Kernel, Git Mailing List
In-Reply-To: <20050622224003.GA21298@redhat.com>
Dave Jones wrote:
> On Wed, Jun 22, 2005 at 06:24:54PM -0400, Jeff Garzik wrote:
> >
> > Things in git-land are moving at lightning speed, and usability has
> > improved a lot since my post a month ago: http://lkml.org/lkml/2005/5/26/11
> >
> >
> >
> > 1) installing git
> >
> > git requires bootstrapping, since you must have git installed in order
> > to check out git.git (git repo), and linux-2.6.git (kernel repo). I
> > have put together a bootstrap tarball of today's git repository.
> >
> > Download tarball from:
> > http://www.kernel.org/pub/linux/kernel/people/jgarzik/git-20050622.tar.bz2
>
> <blatant self-promotion>
> daily snapshots (refreshed once an hour) are available at:
> http://www.codemonkey.org.uk/projects/git-snapshots/git/
> </blatant self-promotion>
I was about to link to this, but a problem arose: your snapshots don't
include the .git/objects directory.
Also, a git-latest.tar.gz symlink would be nice.
Jeff
^ permalink raw reply
* kernel.org and GIT tree rebuilding
From: David S. Miller @ 2005-06-25 4:20 UTC (permalink / raw)
To: git
To get a clean history to push to Linus, I typically blow
away my trees and make fresh ones to stick patches into
which I want to merge.
That mostly works fine here on my local systems, but I know this
brings the master.org mirroring system to it's knees. So what is the
generally condoned way to do stuff like this in a more friendly way?
Should I:
1) Do a git pull from Linus's tree once he takes my changes, then
ask GIT to prune the tree? How do I do that and how does it work?
2) Should I use .git/object/ database symlinking?
Are there any scripts out there which do this automatically?
Something as simple to run as "git-pull-script" and it takes
care of using links when possible on a local filesystem.
It takes sometimes an hour for my tree updates on master.kernel.org
to propagate to rsync.kernel.org so I can ask Linus to pull.
That's crazy.
^ permalink raw reply
* Re: kernel.org and GIT tree rebuilding
From: Jeff Garzik @ 2005-06-25 4:40 UTC (permalink / raw)
To: David S. Miller; +Cc: git
In-Reply-To: <20050624.212009.92584730.davem@davemloft.net>
David S. Miller wrote:
> To get a clean history to push to Linus, I typically blow
> away my trees and make fresh ones to stick patches into
> which I want to merge.
>
> That mostly works fine here on my local systems, but I know this
> brings the master.org mirroring system to it's knees. So what is the
> generally condoned way to do stuff like this in a more friendly way?
>
> Should I:
>
> 1) Do a git pull from Linus's tree once he takes my changes, then
> ask GIT to prune the tree? How do I do that and how does it work?
> It takes sometimes an hour for my tree updates on master.kernel.org
> to propagate to rsync.kernel.org so I can ask Linus to pull.
> That's crazy.
Unfortunately you cannot fix this by changing your actions. This is the
cumulative effect of all the git kernel trees on kernel.org. It now
takes over an hour for my non-git changes to propagate from master to
the mirrors, as well.
This is all due to the rsync sweeps, which have to scan metric tons of
inodes and dentries. Orders of magnitude over the pre-git days.
ftpadmin@kernel.org folks are supposedly working on an inotify-based
system, and an improved rsync application. No ETA or details.
As an aside, cold-cache, git really punishes my disks. Ted T'so noted
that it really drains laptop batteries, too.
> 2) Should I use .git/object/ database symlinking?
>
> Are there any scripts out there which do this automatically?
> Something as simple to run as "git-pull-script" and it takes
> care of using links when possible on a local filesystem.
On both kernel.org and locally, I use 'cp -al' to duplicate the initial
.git/objects directory, and then rsync (->kernel.org) or git-pull-script
(<-kernel.org) to update it after that.
That definitely helps.
Maybe somebody needs to script a relink cron job for kernel.org?
Jeff
^ permalink raw reply
* Re: kernel.org and GIT tree rebuilding
From: Junio C Hamano @ 2005-06-25 5:04 UTC (permalink / raw)
To: David S. Miller; +Cc: git
In-Reply-To: <20050624.212009.92584730.davem@davemloft.net>
>>>>> "DSM" == David S Miller <davem@davemloft.net> writes:
DSM> To get a clean history to push to Linus, I typically blow
DSM> away my trees and make fresh ones to stick patches into
DSM> which I want to merge.
DSM> Should I:
DSM> 1) Do a git pull from Linus's tree once he takes my changes, then
DSM> ask GIT to prune the tree? How do I do that and how does it work?
DSM> 2) Should I use .git/object/ database symlinking?
DSM> Are there any scripts out there which do this automatically?
DSM> Something as simple to run as "git-pull-script" and it takes
DSM> care of using links when possible on a local filesystem.
git-pull-script internally uses git-fetch-script which knows how
to do the local tree using hardlinks. Presumably, the following
workflow would work:
(1) You hack away in your private tree, while you keep a "to be
published" clean tree, both on your local machine.
(2) Do a GIT pull, merge in your private tree, to come up with
a clean set of changes in your private tree. This is the
tree you "typically blow away". Reordering the commits to
come up with a clean history since you last pulled from
Linus would also happen in this tree.
(3) Once you have a commit that you want to publish (i.e. the
commit chain between that commit and the point you last
pulled from Linus is the "clean history to push to Linus"),
you go to your "to be published" clean tree, and run
git-fetch-script to fetch the commit you want to publish
from your private tree. When you give an absolute path as
the "remote repo", git-local-pull with linking behaviour is
used by git-fetch-script; otherwise rsync backend is used
so you end up polluted object database. This way you copy
only the clean stuff from your private tree. Your HEAD in
this tree should be set to the commit you wanted to
publish. Running git-prune would be nicer but if your
history is truly clean it should not be necessary.
(4) Garbage collecting with git-prune your private tree is your
business.
^ permalink raw reply
* Re: kernel.org and GIT tree rebuilding
From: Linus Torvalds @ 2005-06-25 5:23 UTC (permalink / raw)
To: Jeff Garzik; +Cc: David S. Miller, git
In-Reply-To: <42BCE026.8050405@pobox.com>
On Sat, 25 Jun 2005, Jeff Garzik wrote:
>
> This is all due to the rsync sweeps, which have to scan metric tons of
> inodes and dentries. Orders of magnitude over the pre-git days.
Well, the real solution is to use a git-aware protocol, not rsync.
rsync is wonderful for prototyping, and I wanted to make the database
rsync'able for that reason, but it clearly doesn't scale.
I think I'll make a "pack"/"unpack" pair that just packs all the necessary
objects between two commits. Then you can basically sync the object file
by doing
git-pack OLD..NEW | ssh other-end git-unpack
and you'd basically be done. It looks pretty easy to do, too..
Linus
^ permalink raw reply
* Re: kernel.org and GIT tree rebuilding
From: Jeff Garzik @ 2005-06-25 5:48 UTC (permalink / raw)
To: Linus Torvalds; +Cc: David S. Miller, git
In-Reply-To: <Pine.LNX.4.58.0506242208210.11175@ppc970.osdl.org>
Linus Torvalds wrote:
>
> On Sat, 25 Jun 2005, Jeff Garzik wrote:
>
>>This is all due to the rsync sweeps, which have to scan metric tons of
>>inodes and dentries. Orders of magnitude over the pre-git days.
>
>
> Well, the real solution is to use a git-aware protocol, not rsync.
>
> rsync is wonderful for prototyping, and I wanted to make the database
> rsync'able for that reason, but it clearly doesn't scale.
>
> I think I'll make a "pack"/"unpack" pair that just packs all the necessary
> objects between two commits. Then you can basically sync the object file
> by doing
>
> git-pack OLD..NEW | ssh other-end git-unpack
>
> and you'd basically be done. It looks pretty easy to do, too..
The problem is kernel.org mirroring, not individual pushes and pulls,
really.
Would git-pack be the best solution for mirroring a bunch of git trees?
Jeff
^ permalink raw reply
* Re: kernel.org and GIT tree rebuilding
From: Linus Torvalds @ 2005-06-25 6:16 UTC (permalink / raw)
To: Jeff Garzik; +Cc: David S. Miller, git
In-Reply-To: <42BCF02B.5090706@pobox.com>
On Sat, 25 Jun 2005, Jeff Garzik wrote:
>
> The problem is kernel.org mirroring, not individual pushes and pulls,
> really.
>
> Would git-pack be the best solution for mirroring a bunch of git trees?
No guarantees, but here's a rough plan:
- I just committed a fairly trivial change to add a "--objects" flag to
git-rev-list, which allows you to basically say "I want to see the
difference not just in commit ID's, but also trees and blobs"
What does that mean? It means that in a mirroring schenario, you can,
for each git tree, do:
(a) On the slave:
cat .git/refs/*/* | sort | uniq > slave-ref-list
(b) On the master:
cat .git/refs/*/* | sort | uniq > master-ref-list
(c) On the master:
cmp $master-ref-list $slave-ref-list && exit 1
list=$(cat master-ref-list)
for i in $(cat slave-ref-list)
do
list=$list ^$i
done
git-rev-list --objects $list
and now that "git-rev-list" will list every object that needs to be
copied from the master to the slave. No need to read huge directories
etc, you get the list computed for you.
yeah, it clearly needs some refining to be useful, but I think you can
kind of see how it would work.
Now, the secondary advantage of this is that once you don't use rsync as
the mirroring method, you can now change the filesystem object database
layout. In particular, the packing thing that Chris Mason was working on
at some point suddenly becomes a lot more viable.
(In fact, more than that. You can make a single packed blob for all
"historical" objects, and that also gives you an efficient archive format
- if you're not required to have the full filesystem layout, you could
have a much more efficient packing that you basically do once a week or
something, so that you only keep the last week in the regular "one file
per object" format).
Linus
^ permalink raw reply
* [PATCH] git-merge-one-file-script: do not misinterpret rm failure
From: Junio C Hamano @ 2005-06-25 6:20 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
When a merge adds a file DF and removes a directory there by
deleting a path DF/DF, git-merge-one-file-script can be called
for the removal of DF/DF when the path DF is already created by
"git-read-tree -m -u". When this happens, we get confused by a
failure return from 'rm -f -- "$4"' (where $4 is DF/DF); finding
file DF there the "rm -f" command complains that DF is not a
directory.
What we want to ensure is that there is no file DF/DF in this
case. Avoid getting ourselves confused by first checking if
there is a file, and only then try to remove it (and check for
failure from the "rm" command).
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
cd /opt/packrat/playpen/public/in-place/git/git.junio/
jit-diff : git-merge-one-file-script
# - master: Add more tests for read-tree --emu23.
# + (working tree)
diff --git a/git-merge-one-file-script b/git-merge-one-file-script
--- a/git-merge-one-file-script
+++ b/git-merge-one-file-script
@@ -22,8 +22,11 @@ case "${1:-.}${2:-.}${3:-.}" in
#
"$1.." | "$1.$1" | "$1$1.")
echo "Removing $4"
- rm -f -- "$4" &&
- exec git-update-cache --remove -- "$4"
+ if test -f "$4"
+ then
+ rm -f -- "$4"
+ fi &&
+ exec git-update-cache --remove -- "$4"
;;
#
^ permalink raw reply
* qgit-0.61
From: Marco Costalba @ 2005-06-25 9:03 UTC (permalink / raw)
To: git; +Cc: mingo, berkus
Here is qgit-0.61
This is mainly a fix release with some work in annotation code.
Changelog from qgit-0.6:
- improve annotation algorithm to detect annotations behind merges
- qgit arguments parsing: switch to use git-rev-parse
- added find function in file viewer
- double click in annotate shows revision
- set Monospace font in file and diff viewer (suggested by Radoslaw Szkodzinski)
- added filter on path in main view
- pretty format annotation header
- fixed annotate alignement
- detect also cogito type tags, i.e. tags shown with cg-tag-ls
Download from:
http://prdownloads.sourceforge.net/qgit/qgit-0.61.tar.bz2?download
Annotation code should be much improved now, but still experimental.
I need more time to workout all corner cases ( and there are a lot ;-) )
And now a wish:
If may I ask, should be possible to add the object type and name, togheter with sha
in git-rev-list --objects output?
This new option looks very promising to speed up my startup loading.
Thanks
Marco
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply
* [PATCH 0/9] Fix oversimplified optimization for add_cache_entry().
From: Junio C Hamano @ 2005-06-25 9:16 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vaclf6tw7.fsf@assigned-by-dhcp.cox.net>
>>>>> "JCH" == Junio C Hamano <junkio@cox.net> writes:
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> I really don't want to do this.
LT> Can you fix the "optimized" one instead?
JCH> Will do.
I have this list which logically consists of three sets. I am
using the new "git rebase" to maintain it and your not taking my
patch stream gave me a good opportunity to test it ;-).
[PATCH 1/9] [RFC] fix date parsing for GIT raw commit timestamp format.
[PATCH 2/9] git-commit-script: get commit message from an existing one.
[PATCH 3/9] git-cherry: find commits not merged upstream.
[PATCH 4/9] git-rebase-script: rebase local commits to new upstream head.
These four are updated "git rebase" I've written while on-road
without knowing about your git-patch-id; the updated one uses
git-patch-id to identify which are merged and which are not.
To carry earlier commit datetime forward, date.c needs to be
fixed (PATCH 1/9, which I sent you separately Friday), and
enhancing git-commit-script to be able to specify an existing
commit to slurp the commit message (and author & date
information) was necessary (well, not strictly necessary, but
that is the way I am used to, which is stolen from JIT), which
is PATCH 2/9. PATCH 3/9 and PATCH 4/9 use git-patch-id to
implement the cherrypick/rebase.
[PATCH 5/9] Add more tests for read-tree --emu23.
[PATCH 6/9] git-merge-one-file-script: do not misinterpret rm failure
[PATCH 7/9] Fix oversimplified optimization for add_cache_entry().
These three are reworked D/F conflict fix. PATCH 5/9 is the
same demonstration of what is broken in the current code. The
problem fixed by PATCH 6/9 was discovered while I was trying out
the fixes. PATCH 7/9 teaches your "optimized" has_file/has_dir
implementation to honor stages while they operate.
[PATCH 8/9] http-pull: documentation updates.
[PATCH 9/9] Add a bit of developer documentation to pull.h
These are resend.
^ permalink raw reply
* [PATCH 1/9] fix date parsing for GIT raw commit timestamp format.
From: Junio C Hamano @ 2005-06-25 9:21 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
Usually all of the match_xxx routines in date.c fill tm
structure assuming that the parsed string talks about local
time, and parse_date routine compensates for it by adjusting the
value with tz offset parsed out separately. However, this logic
does not work well when we feed GIT raw commit timestamp to it,
because what match_digits gets is already in GMT.
A good testcase is:
$ make test-date
$ ./test-date 'Fri Jun 24 16:55:27 2005 -0700' '1119657327 -0700'
These two timestamps represent the same time, but the second one
without the fix this commit introduces gives you 7 hours off.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
date.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
dff2db477c3d450350a0dfdce4fa3f9543206b86
diff --git a/date.c b/date.c
--- a/date.c
+++ b/date.c
@@ -270,7 +270,7 @@ static int match_multi_number(unsigned l
/*
* We've seen a digit. Time? Year? Date?
*/
-static int match_digit(char *date, struct tm *tm, int *offset)
+static int match_digit(char *date, struct tm *tm, int *offset, int *tm_gmt)
{
int n;
char *end;
@@ -283,8 +283,10 @@ static int match_digit(char *date, struc
*/
if (num > 946684800) {
time_t time = num;
- if (gmtime_r(&time, tm))
+ if (gmtime_r(&time, tm)) {
+ *tm_gmt = 1;
return end - date;
+ }
}
/*
@@ -389,7 +391,7 @@ static int match_tz(char *date, int *off
void parse_date(char *date, char *result, int maxlen)
{
struct tm tm;
- int offset, sign;
+ int offset, sign, tm_gmt;
time_t then;
memset(&tm, 0, sizeof(tm));
@@ -398,6 +400,7 @@ void parse_date(char *date, char *result
tm.tm_mday = -1;
tm.tm_isdst = -1;
offset = -1;
+ tm_gmt = 0;
for (;;) {
int match = 0;
@@ -410,7 +413,7 @@ void parse_date(char *date, char *result
if (isalpha(c))
match = match_alpha(date, &tm, &offset);
else if (isdigit(c))
- match = match_digit(date, &tm, &offset);
+ match = match_digit(date, &tm, &offset, &tm_gmt);
else if ((c == '-' || c == '+') && isdigit(date[1]))
match = match_tz(date, &offset);
@@ -430,7 +433,8 @@ void parse_date(char *date, char *result
if (then == -1)
return;
- then -= offset * 60;
+ if (!tm_gmt)
+ then -= offset * 60;
sign = '+';
if (offset < 0) {
------------
^ permalink raw reply
* [PATCH 2/9] git-commit-script: get commit message from an existing one.
From: Junio C Hamano @ 2005-06-25 9:22 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
With -m flag specified, git-commit-script takes the commit
message along with author information from an existing commit.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
git-commit-script | 75 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 67 insertions(+), 8 deletions(-)
da2ff8148a94b982c7ee369d5a37c4d20e8dd2a4
diff --git a/git-commit-script b/git-commit-script
--- a/git-commit-script
+++ b/git-commit-script
@@ -1,12 +1,37 @@
#!/bin/sh
+#
+# Copyright (c) 2005 Linus Torvalds
+#
+
+usage () {
+ echo 'git commit [-m existing-commit] [<path>...]'
+ exit 1
+}
+
: ${GIT_DIR=.git}
-if [ ! -d $GIT_DIR ]; then
+if [ ! -d "$GIT_DIR" ]; then
echo Not a git directory 1>&2
exit 1
fi
+while case "$#" in 0) break ;; esac
+do
+ case "$1" in
+ -m) shift
+ case "$#" in
+ 0) usage ;;
+ *) use_commit=`git-rev-parse "$1"` ||
+ exit ;;
+ esac
+ ;;
+ *) break
+ ;;
+ esac
+ shift
+done
+
git-update-cache -q --refresh -- "$@" || exit 1
PARENTS="-p HEAD"
-if [ ! -r $GIT_DIR/HEAD ]; then
+if [ ! -r "$GIT_DIR/HEAD" ]; then
if [ -z "$(git-ls-files)" ]; then
echo Nothing to commit 1>&2
exit 1
@@ -20,7 +45,7 @@ if [ ! -r $GIT_DIR/HEAD ]; then
) > .editmsg
PARENTS=""
else
- if [ -f $GIT_DIR/MERGE_HEAD ]; then
+ if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
echo "#"
echo "# It looks like your may be committing a MERGE."
echo "# If this is not correct, please remove the file"
@@ -28,8 +53,38 @@ else
echo "# and try again"
echo "#"
PARENTS="-p HEAD -p MERGE_HEAD"
- fi > .editmsg
- git-status-script >> .editmsg
+ elif test "$use_commit" != ""
+ then
+ pick_author_script='
+ /^author /{
+ h
+ s/^author \([^<]*\) <[^>]*> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_NAME='\''&'\''/p
+
+ g
+ s/^author [^<]* <\([^>]*\)> .*$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
+
+ g
+ s/^author [^<]* <[^>]*> \(.*\)$/\1/
+ s/'\''/'\''\'\'\''/g
+ s/.*/GIT_AUTHOR_DATE='\''&'\''/p
+
+ q
+ }
+ '
+ set_author_env=`git-cat-file commit "$use_commit" |
+ sed -ne "$pick_author_script"`
+ eval "$set_author_env"
+ export GIT_AUTHOR_NAME
+ export GIT_AUTHOR_EMAIL
+ export GIT_AUTHOR_DATE
+ git-cat-file commit "$use_commit" |
+ sed -e '1,/^$/d'
+ fi >.editmsg
+ git-status-script >>.editmsg
fi
if [ "$?" != "0" ]
then
@@ -37,13 +92,17 @@ then
rm .editmsg
exit 1
fi
-${VISUAL:-${EDITOR:-vi}} .editmsg
+case "$use_commit" in
+'')
+ ${VISUAL:-${EDITOR:-vi}} .editmsg
+ ;;
+esac
grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
[ -s .cmitmsg ] &&
tree=$(git-write-tree) &&
commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) &&
- echo $commit > $GIT_DIR/HEAD &&
- rm -f -- $GIT_DIR/MERGE_HEAD
+ echo $commit > "$GIT_DIR/HEAD" &&
+ rm -f -- "$GIT_DIR/MERGE_HEAD"
ret="$?"
rm -f .cmitmsg .editmsg
exit "$ret"
------------
^ permalink raw reply
* [PATCH 3/9] git-cherry: find commits not merged upstream.
From: Junio C Hamano @ 2005-06-25 9:22 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
The git-cherry command helps the git-rebase script by finding
commits that have not been merged upstream. Commits already
included in upstream are prefixed with '-' (meaning "drop from
my local pull"), while commits missing from upstream are
prefixed with '+' (meaning "add to the updated upstream").
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Makefile | 2 +
git-cherry | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 1 deletions(-)
create mode 100755 git-cherry
350e3957925c9b4404977bbd6f65bf68ba28d26f
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@ SCRIPTS=git git-apply-patch-script git-m
git-deltafy-script git-fetch-script git-status-script git-commit-script \
git-log-script git-shortlog git-cvsimport-script git-diff-script \
git-reset-script git-add-script git-checkout-script git-clone-script \
- gitk
+ gitk git-cherry
PROG= git-update-cache git-diff-files git-init-db git-write-tree \
git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-cherry b/git-cherry
new file mode 100755
--- /dev/null
+++ b/git-cherry
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano.
+#
+
+usage="usage: $0 "'<upstream> [<head>]
+
+ __*__*__*__*__> <upstream>
+ /
+ fork-point
+ \__+__+__+__+__+__+__+__> <head>
+
+Each commit between the fork-point and <head> is examined, and
+compared against the change each commit between the fork-point and
+<upstream> introduces. If the change does not seem to be in the
+upstream, it is shown on the standard output.
+
+The output is intended to be used as:
+
+ OLD_HEAD=$(git-rev-parse HEAD)
+ git-rev-parse linus >${GIT_DIR-.}/HEAD
+ git-cherry linus OLD_HEAD |
+ while read commit
+ do
+ GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p "$commit" &&
+ git-commit-script -m "$commit"
+ done
+'
+
+case "$#" in
+1) linus=`git-rev-parse "$1"` &&
+ junio=`git-rev-parse HEAD` || exit
+ ;;
+2) linus=`git-rev-parse "$1"` &&
+ junio=`git-rev-parse "$2"` || exit
+ ;;
+*) echo >&2 "$usage"; exit 1 ;;
+esac
+
+# Note that these list commits in reverse order;
+# not that the order in inup matters...
+inup=`git-rev-list ^$junio $linus` &&
+ours=`git-rev-list $junio ^$linus` || exit
+
+tmp=.cherry-tmp$$
+patch=$tmp-patch
+mkdir $patch
+trap "rm -rf $tmp-*" 0 1 2 3 15
+
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+
+for c in $inup
+do
+ git-diff-tree -p $c
+done | git-patch-id |
+while read id name
+do
+ echo $name >>$patch/$id
+done
+
+LF='
+'
+
+O=
+for c in $ours
+do
+ set x `git-diff-tree -p $c | git-patch-id`
+ if test "$2" != ""
+ then
+ if test -f "$patch/$2"
+ then
+ sign=-
+ else
+ sign=+
+ fi
+ case "$O" in
+ '') O="$sign $c" ;;
+ *) O="$sign $c$LF$O" ;;
+ esac
+ fi
+done
+case "$O" in
+'') ;;
+*) echo "$O" ;;
+esac
------------
^ permalink raw reply
* [PATCH 4/9] git-rebase-script: rebase local commits to new upstream head.
From: Junio C Hamano @ 2005-06-25 9:23 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
Using git-cherry, forward port local commits missing from the
new upstream head. This also depends on "-m" flag support in
git-commit-script.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Makefile | 2 +-
git-rebase-script | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletions(-)
create mode 100755 git-rebase-script
39830aca0319e04ed6c45203614543418974f877
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@ SCRIPTS=git git-apply-patch-script git-m
git-deltafy-script git-fetch-script git-status-script git-commit-script \
git-log-script git-shortlog git-cvsimport-script git-diff-script \
git-reset-script git-add-script git-checkout-script git-clone-script \
- gitk git-cherry
+ gitk git-cherry git-rebase-script
PROG= git-update-cache git-diff-files git-init-db git-write-tree \
git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-rebase-script b/git-rebase-script
new file mode 100755
--- /dev/null
+++ b/git-rebase-script
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano.
+#
+
+usage="usage: $0 "'<upstream> [<head>]
+
+Uses output from git-cherry to rebase local commits to the new head of
+upstream tree.'
+
+: ${GIT_DIR=.git}
+
+case "$#" in
+1) linus=`git-rev-parse "$1"` &&
+ junio=`git-rev-parse HEAD` || exit
+ ;;
+2) linus=`git-rev-parse "$1"` &&
+ junio=`git-rev-parse "$2"` || exit
+ ;;
+*) echo >&2 "$usage"; exit 1 ;;
+esac
+
+git-read-tree -m -u $junio $linus &&
+echo "$linus" >"$GIT_DIR/HEAD" || exit
+
+tmp=.rebase-tmp$$
+fail=$tmp-fail
+trap "rm -rf $tmp-*" 0 1 2 3 15
+
+>$fail
+
+git-cherry $linus $junio |
+while read sign commit
+do
+ case "$sign" in
+ -) continue ;;
+ esac
+ S=`cat "$GIT_DIR/HEAD"` &&
+ GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $commit &&
+ git-commit-script -m "$commit" || {
+ echo $commit >>$fail
+ git-read-tree --reset -u $S
+ }
+done
+if test -s $fail
+then
+ echo Some commits could not be rebased, check by hand:
+ cat $fail
+fi
------------
^ permalink raw reply
* [PATCH 5/9] Add more tests for read-tree --emu23.
From: Junio C Hamano @ 2005-06-25 9:24 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
This adds more tests for --emu23. One is to show how it can
carry forward more local changes than the straightforward
two-way fast forward, and another is to show the recent
overeager optimization of directory/file conflict check broke
things, which will be fixed in the next commit.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
t/t1001-read-tree-m-2way.sh | 70 +++++++++++++++++++++++++---
t/t1005-read-tree-m-2way-emu23.sh | 94 ++++++++++++++++++++++++++++++++++---
2 files changed, 150 insertions(+), 14 deletions(-)
633115eb1338884fd9488fe57ef4ea2fb91559d5
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -29,7 +29,6 @@ read_tree_twoway () {
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
compare_change () {
- cat current
sed -n >current \
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
@@ -51,11 +50,22 @@ check_cache_at () {
esac
}
+cat >bozbar-old <<\EOF
+This is a sample file used in two-way fast forward merge
+tests. Its second line ends with a magic word bozbar
+which will be modified by the merged head to gnusto.
+It has some extra lines so that external tools can
+successfully merge independent changes made to later
+lines (such as this one), avoiding line conflicts.
+EOF
+
+sed -e 's/bozbar/gnusto (earlier bozbar)/' bozbar-old >bozbar-new
+
test_expect_success \
setup \
'echo frotz >frotz &&
echo nitfol >nitfol &&
- echo bozbar >bozbar &&
+ cat bozbar-old >bozbar &&
echo rezrov >rezrov &&
echo yomin >yomin &&
git-update-cache --add nitfol bozbar rezrov &&
@@ -63,7 +73,7 @@ test_expect_success \
echo treeH $treeH &&
git-ls-tree $treeH &&
- echo gnusto >bozbar &&
+ cat bozbar-new >bozbar &&
git-update-cache --add frotz bozbar --force-remove rezrov &&
git-ls-files --stage >M.out &&
treeM=`git-write-tree` &&
@@ -86,6 +96,8 @@ echo '+100644 X 0 yomin' >expected
test_expect_success \
'4 - carry forward local addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
git-update-cache --add yomin &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >4.out || exit
@@ -96,6 +108,8 @@ test_expect_success \
test_expect_success \
'5 - carry forward local addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo yomin >yomin &&
git-update-cache --add yomin &&
echo yomin yomin >yomin &&
@@ -108,6 +122,8 @@ test_expect_success \
test_expect_success \
'6 - local addition already has the same.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
git-update-cache --add frotz &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >6.out &&
@@ -117,6 +133,8 @@ test_expect_success \
test_expect_success \
'7 - local addition already has the same.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo frotz >frotz &&
git-update-cache --add frotz &&
echo frotz frotz >frotz &&
@@ -128,6 +146,8 @@ test_expect_success \
test_expect_success \
'8 - conflicting addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo frotz frotz >frotz &&
git-update-cache --add frotz &&
if read_tree_twoway $treeH $treeM; then false; else :; fi'
@@ -135,6 +155,8 @@ test_expect_success \
test_expect_success \
'9 - conflicting addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo frotz frotz >frotz &&
git-update-cache --add frotz &&
echo frotz >frotz &&
@@ -143,6 +165,8 @@ test_expect_success \
test_expect_success \
'10 - path removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov >rezrov &&
git-update-cache --add rezrov &&
read_tree_twoway $treeH $treeM &&
@@ -152,6 +176,8 @@ test_expect_success \
test_expect_success \
'11 - dirty path removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov >rezrov &&
git-update-cache --add rezrov &&
echo rezrov rezrov >rezrov &&
@@ -160,6 +186,8 @@ test_expect_success \
test_expect_success \
'12 - unmatching local changes being removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov rezrov >rezrov &&
git-update-cache --add rezrov &&
if read_tree_twoway $treeH $treeM; then false; else :; fi'
@@ -167,6 +195,8 @@ test_expect_success \
test_expect_success \
'13 - unmatching local changes being removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov rezrov >rezrov &&
git-update-cache --add rezrov &&
echo rezrov >rezrov &&
@@ -180,6 +210,8 @@ EOF
test_expect_success \
'14 - unchanged in two heads.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo nitfol nitfol >nitfol &&
git-update-cache --add nitfol &&
read_tree_twoway $treeH $treeM &&
@@ -191,6 +223,8 @@ test_expect_success \
test_expect_success \
'15 - unchanged in two heads.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo nitfol nitfol >nitfol &&
git-update-cache --add nitfol &&
echo nitfol nitfol nitfol >nitfol &&
@@ -203,6 +237,8 @@ test_expect_success \
test_expect_success \
'16 - conflicting local change.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo bozbar bozbar >bozbar &&
git-update-cache --add bozbar &&
if read_tree_twoway $treeH $treeM; then false; else :; fi'
@@ -210,6 +246,8 @@ test_expect_success \
test_expect_success \
'17 - conflicting local change.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo bozbar bozbar >bozbar &&
git-update-cache --add bozbar &&
echo bozbar bozbar bozbar >bozbar &&
@@ -218,7 +256,9 @@ test_expect_success \
test_expect_success \
'18 - local change already having a good result.' \
'rm -f .git/index &&
- echo gnusto >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-new >bozbar &&
git-update-cache --add bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >18.out &&
@@ -228,7 +268,9 @@ test_expect_success \
test_expect_success \
'19 - local change already having a good result, further modified.' \
'rm -f .git/index &&
- echo gnusto >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-new >bozbar &&
git-update-cache --add bozbar &&
echo gnusto gnusto >bozbar &&
read_tree_twoway $treeH $treeM &&
@@ -239,7 +281,9 @@ test_expect_success \
test_expect_success \
'20 - no local change, use new tree.' \
'rm -f .git/index &&
- echo bozbar >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-old >bozbar &&
git-update-cache --add bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >20.out &&
@@ -249,11 +293,23 @@ test_expect_success \
test_expect_success \
'21 - no local change, dirty cache.' \
'rm -f .git/index &&
- echo bozbar >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-old >bozbar &&
git-update-cache --add bozbar &&
echo gnusto gnusto >bozbar &&
if read_tree_twoway $treeH $treeM; then false; else :; fi'
+# This fails with straight two-way fast forward.
+test_expect_success \
+ '22 - local change cache updated.' \
+ 'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ sed -e "s/such as/SUCH AS/" bozbar-old >bozbar &&
+ git-update-cache --add bozbar &&
+ if read_tree_twoway $treeH $treeM; then false; else :; fi'
+
# Also make sure we did not break DF vs DF/DF case.
test_expect_success \
'DF vs DF/DF case setup.' \
diff --git a/t/t1005-read-tree-m-2way-emu23.sh b/t/t1005-read-tree-m-2way-emu23.sh
--- a/t/t1005-read-tree-m-2way-emu23.sh
+++ b/t/t1005-read-tree-m-2way-emu23.sh
@@ -32,7 +32,6 @@ read_tree_twoway () {
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
compare_change () {
- cat current
sed -n >current \
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
@@ -60,11 +59,22 @@ check_stages () {
diff -u expected_stages current_stages
}
+cat >bozbar-old <<\EOF
+This is a sample file used in two-way fast forward merge
+tests. Its second line ends with a magic word bozbar
+which will be modified by the merged head to gnusto.
+It has some extra lines so that external tools can
+successfully merge independent changes made to later
+lines (such as this one), avoiding line conflicts.
+EOF
+
+sed -e 's/bozbar/gnusto (earlier bozbar)/' bozbar-old >bozbar-new
+
test_expect_success \
setup \
'echo frotz >frotz &&
echo nitfol >nitfol &&
- echo bozbar >bozbar &&
+ cat bozbar-old >bozbar &&
echo rezrov >rezrov &&
echo yomin >yomin &&
git-update-cache --add nitfol bozbar rezrov &&
@@ -72,7 +82,7 @@ test_expect_success \
echo treeH $treeH &&
git-ls-tree $treeH &&
- echo gnusto >bozbar &&
+ cat bozbar-new >bozbar &&
git-update-cache --add frotz bozbar --force-remove rezrov &&
git-ls-files --stage >M.out &&
treeM=`git-write-tree` &&
@@ -106,6 +116,8 @@ echo '+100644 X 0 yomin' >expected
test_expect_success \
'4 - carry forward local addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
git-update-cache --add yomin &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >4.out || exit
@@ -118,6 +130,8 @@ test_expect_success \
test_expect_success \
'5 - carry forward local addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo yomin >yomin &&
git-update-cache --add yomin &&
echo yomin yomin >yomin &&
@@ -132,6 +146,8 @@ test_expect_success \
test_expect_success \
'6 - local addition already has the same.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
git-update-cache --add frotz &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >6.out &&
@@ -143,6 +159,8 @@ test_expect_success \
test_expect_success \
'7 - local addition already has the same.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo frotz >frotz &&
git-update-cache --add frotz &&
echo frotz frotz >frotz &&
@@ -154,6 +172,8 @@ test_expect_success \
test_expect_success \
'8 - conflicting addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo frotz frotz >frotz &&
git-update-cache --add frotz &&
if read_tree_twoway $treeH $treeM; then false; else :; fi'
@@ -161,6 +181,8 @@ test_expect_success \
test_expect_success \
'9 - conflicting addition.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo frotz frotz >frotz &&
git-update-cache --add frotz &&
echo frotz >frotz &&
@@ -169,6 +191,8 @@ test_expect_success \
test_expect_success \
'10 - path removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov >rezrov &&
git-update-cache --add rezrov &&
read_tree_twoway $treeH $treeM &&
@@ -178,6 +202,8 @@ test_expect_success \
test_expect_success \
'11 - dirty path removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov >rezrov &&
git-update-cache --add rezrov &&
echo rezrov rezrov >rezrov &&
@@ -186,6 +212,8 @@ test_expect_success \
test_expect_success \
'12 - unmatching local changes being removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov rezrov >rezrov &&
git-update-cache --add rezrov &&
if read_tree_twoway $treeH $treeM; then false; else :; fi'
@@ -193,6 +221,8 @@ test_expect_success \
test_expect_success \
'13 - unmatching local changes being removed.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo rezrov rezrov >rezrov &&
git-update-cache --add rezrov &&
echo rezrov >rezrov &&
@@ -206,6 +236,8 @@ EOF
test_expect_success \
'14 - unchanged in two heads.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo nitfol nitfol >nitfol &&
git-update-cache --add nitfol &&
read_tree_twoway $treeH $treeM &&
@@ -217,6 +249,8 @@ test_expect_success \
test_expect_success \
'15 - unchanged in two heads.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo nitfol nitfol >nitfol &&
git-update-cache --add nitfol &&
echo nitfol nitfol nitfol >nitfol &&
@@ -233,6 +267,8 @@ test_expect_success \
test_expect_success \
'16 - conflicting local change.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo bozbar bozbar >bozbar &&
git-update-cache --add bozbar &&
git-read-tree --emu23 $treeH $treeM &&
@@ -249,6 +285,8 @@ EOF
test_expect_success \
'17 - conflicting local change.' \
'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
echo bozbar bozbar >bozbar &&
git-update-cache --add bozbar &&
echo bozbar bozbar bozbar >bozbar &&
@@ -257,7 +295,9 @@ test_expect_success \
test_expect_success \
'18 - local change already having a good result.' \
'rm -f .git/index &&
- echo gnusto >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-new >bozbar &&
git-update-cache --add bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >18.out &&
@@ -267,7 +307,9 @@ test_expect_success \
test_expect_success \
'19 - local change already having a good result, further modified.' \
'rm -f .git/index &&
- echo gnusto >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-new >bozbar &&
git-update-cache --add bozbar &&
echo gnusto gnusto >bozbar &&
read_tree_twoway $treeH $treeM &&
@@ -278,7 +320,9 @@ test_expect_success \
test_expect_success \
'20 - no local change, use new tree.' \
'rm -f .git/index &&
- echo bozbar >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-old >bozbar &&
git-update-cache --add bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >20.out &&
@@ -288,11 +332,31 @@ test_expect_success \
test_expect_success \
'21 - no local change, dirty cache.' \
'rm -f .git/index &&
- echo bozbar >bozbar &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ cat bozbar-old >bozbar &&
git-update-cache --add bozbar &&
echo gnusto gnusto >bozbar &&
if read_tree_twoway $treeH $treeM; then false; else :; fi'
+echo '-100644 X 0 bozbar
++100644 X 0 bozbar' >expected
+
+# This fails with straight two-way fast forward, but emu23
+# can merge them.
+test_expect_success \
+ '22 - local change cache updated.' \
+ 'rm -f .git/index &&
+ git-read-tree $treeH &&
+ git-checkout-cache -u -f -q -a &&
+ sed -e "s/such as/SUCH AS/" bozbar-old >bozbar &&
+ git-update-cache --add bozbar &&
+ read_tree_twoway $treeH $treeM &&
+ git-ls-files --stage >22.out || exit
+ diff -u M.out 22.out >22diff.out
+ compare_change 22diff.out &&
+ check_cache_at bozbar clean'
+
# Also make sure we did not break DF vs DF/DF case.
test_expect_success \
'DF vs DF/DF case setup.' \
@@ -324,4 +388,20 @@ test_expect_success \
check_cache_at DF/DF clean && # different from pure 2-way
:'
+# Emu23 can grok I having more than H. Make sure we did not
+# botch the conflict tests (Linus code botches this test).
+test_expect_success \
+ 'DF vs DF/DF case test (#2).' \
+ 'rm -f .git/index &&
+ rm -fr DF &&
+ mkdir DF &&
+ echo DF/DF >DF/DF &&
+ git-update-cache --add DF/DF &&
+ # This should fail because I and H have a conflict
+ # at DF.
+ if git-read-tree --emu23 $treeDF $treeDFDF
+ then true ;# should be false
+ else false ;# should be true
+ fi'
+
test_done
------------
^ permalink raw reply
* [PATCH 6/9] git-merge-one-file-script: do not misinterpret rm failure.
From: Junio C Hamano @ 2005-06-25 9:24 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
When a merge adds a file DF and removes a directory there by
deleting a path DF/DF, git-merge-one-file-script can be called
for the removal of DF/DF when the path DF is already created by
"git-read-tree -m -u". When this happens, we get confused by a
failure return from 'rm -f -- "$4"' (where $4 is DF/DF); finding
file DF there the "rm -f" command complains that DF is not a
directory.
What we want to ensure is that there is no file DF/DF in this
case. Avoid getting ourselves confused by first checking if
there is a file, and only then try to remove it (and check for
failure from the "rm" command).
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
git-merge-one-file-script | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
7edbb24f69809eb41de865701bc4f17774348043
diff --git a/git-merge-one-file-script b/git-merge-one-file-script
--- a/git-merge-one-file-script
+++ b/git-merge-one-file-script
@@ -22,8 +22,11 @@ case "${1:-.}${2:-.}${3:-.}" in
#
"$1.." | "$1.$1" | "$1$1.")
echo "Removing $4"
- rm -f -- "$4" &&
- exec git-update-cache --remove -- "$4"
+ if test -f "$4"
+ then
+ rm -f -- "$4"
+ fi &&
+ exec git-update-cache --remove -- "$4"
;;
#
------------
^ permalink raw reply
* [PATCH 7/9] Fix oversimplified optimization for add_cache_entry().
From: Junio C Hamano @ 2005-06-25 9:25 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
An earlier change to optimize directory-file conflict check
broke what "read-tree --emu23" expects. This is fixed by this
commit.
(1) Introduces an explicit flag to tell add_cache_entry() not to
check for conflicts and use it when reading an existing tree
into an empty stage --- by definition this case can never
introduce such conflicts.
(2) Makes read-cache.c:has_file_name() and read-cache.c:has_dir_name()
aware of the cache stages, and flag conflict only with paths
in the same stage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
cache.h | 1 +
read-cache.c | 32 +++++++++++++++++++++-----------
t/t1005-read-tree-m-2way-emu23.sh | 25 ++++++++++++++++++++-----
tree.c | 2 +-
4 files changed, 43 insertions(+), 17 deletions(-)
904dbb145f2f42227ea5b94752146ef8d4c2b153
diff --git a/cache.h b/cache.h
--- a/cache.h
+++ b/cache.h
@@ -130,6 +130,7 @@ extern int write_cache(int newfd, struct
extern int cache_name_pos(const char *name, int namelen);
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
+#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
extern int add_cache_entry(struct cache_entry *ce, int option);
extern int remove_cache_entry_at(int pos);
extern int remove_file_from_cache(char *path);
diff --git a/read-cache.c b/read-cache.c
--- a/read-cache.c
+++ b/read-cache.c
@@ -179,6 +179,7 @@ static int has_file_name(const struct ca
{
int retval = 0;
int len = ce_namelen(ce);
+ int stage = ce_stage(ce);
const char *name = ce->name;
while (pos < active_nr) {
@@ -188,6 +189,8 @@ static int has_file_name(const struct ca
break;
if (memcmp(name, p->name, len))
break;
+ if (ce_stage(p) != stage)
+ continue;
if (p->name[len] != '/')
continue;
retval = -1;
@@ -205,6 +208,7 @@ static int has_file_name(const struct ca
static int has_dir_name(const struct cache_entry *ce, int pos, int ok_to_replace)
{
int retval = 0;
+ int stage = ce_stage(ce);
const char *name = ce->name;
const char *slash = name + ce_namelen(ce);
@@ -219,7 +223,7 @@ static int has_dir_name(const struct cac
}
len = slash - name;
- pos = cache_name_pos(name, len);
+ pos = cache_name_pos(name, ntohs(create_ce_flags(len, stage)));
if (pos >= 0) {
retval = -1;
if (ok_to_replace)
@@ -231,18 +235,23 @@ static int has_dir_name(const struct cac
/*
* Trivial optimization: if we find an entry that
* already matches the sub-directory, then we know
- * we're ok, and we can exit
+ * we're ok, and we can exit.
*/
pos = -pos-1;
- if (pos < active_nr) {
+ while (pos < active_nr) {
struct cache_entry *p = active_cache[pos];
- if (ce_namelen(p) <= len)
- continue;
- if (p->name[len] != '/')
- continue;
- if (memcmp(p->name, name, len))
- continue;
- break;
+ if ((ce_namelen(p) <= len) ||
+ (p->name[len] != '/') ||
+ memcmp(p->name, name, len))
+ break; /* not our subdirectory */
+ if (ce_stage(p) == stage)
+ /* p is at the same stage as our entry, and
+ * is a subdirectory of what we are looking
+ * at, so we cannot have conflicts at our
+ * level or anything shorter.
+ */
+ return retval;
+ pos++;
}
}
return retval;
@@ -277,6 +286,7 @@ int add_cache_entry(struct cache_entry *
int pos;
int ok_to_add = option & ADD_CACHE_OK_TO_ADD;
int ok_to_replace = option & ADD_CACHE_OK_TO_REPLACE;
+ int skip_df_check = option & ADD_CACHE_SKIP_DFCHECK;
pos = cache_name_pos(ce->name, ntohs(ce->ce_flags));
/* existing match? Just replace it */
@@ -302,7 +312,7 @@ int add_cache_entry(struct cache_entry *
if (!ok_to_add)
return -1;
- if (!ce_stage(ce) && check_file_directory_conflict(ce, pos, ok_to_replace)) {
+ if (!skip_df_check && check_file_directory_conflict(ce, pos, ok_to_replace)) {
if (!ok_to_replace)
return -1;
pos = cache_name_pos(ce->name, ntohs(ce->ce_flags));
diff --git a/t/t1005-read-tree-m-2way-emu23.sh b/t/t1005-read-tree-m-2way-emu23.sh
--- a/t/t1005-read-tree-m-2way-emu23.sh
+++ b/t/t1005-read-tree-m-2way-emu23.sh
@@ -366,6 +366,7 @@ test_expect_success \
treeDF=`git-write-tree` &&
echo treeDF $treeDF &&
git-ls-tree $treeDF &&
+ git-ls-files --stage >DF.out
rm -f DF &&
mkdir DF &&
@@ -377,7 +378,7 @@ test_expect_success \
git-ls-files --stage >DFDF.out'
test_expect_success \
- 'DF vs DF/DF case test.' \
+ 'DF vs DF/DF case test (#1)' \
'rm -f .git/index &&
rm -fr DF &&
echo DF >DF &&
@@ -388,10 +389,24 @@ test_expect_success \
check_cache_at DF/DF clean && # different from pure 2-way
:'
+# The other way around
+test_expect_success \
+ 'DF vs DF/DF case test (#2)' \
+ 'rm -f .git/index &&
+ rm -fr DF &&
+ mkdir DF &&
+ echo DF/DF >DF/DF &&
+ git-update-cache --add DF/DF &&
+ read_tree_twoway $treeDFDF $treeDF &&
+ git-ls-files --stage >DFDFcheck.out &&
+ diff -u DF.out DFDFcheck.out &&
+ check_cache_at DF clean && # different from pure 2-way
+ :'
+
# Emu23 can grok I having more than H. Make sure we did not
-# botch the conflict tests (Linus code botches this test).
+# botch the conflict tests (fixed).
test_expect_success \
- 'DF vs DF/DF case test (#2).' \
+ 'DF vs DF/DF case test (#3).' \
'rm -f .git/index &&
rm -fr DF &&
mkdir DF &&
@@ -400,8 +415,8 @@ test_expect_success \
# This should fail because I and H have a conflict
# at DF.
if git-read-tree --emu23 $treeDF $treeDFDF
- then true ;# should be false
- else false ;# should be true
+ then false
+ else true
fi'
test_done
diff --git a/tree.c b/tree.c
--- a/tree.c
+++ b/tree.c
@@ -18,7 +18,7 @@ static int read_one_entry(unsigned char
memcpy(ce->name, base, baselen);
memcpy(ce->name + baselen, pathname, len+1);
memcpy(ce->sha1, sha1, 20);
- return add_cache_entry(ce, ADD_CACHE_OK_TO_ADD);
+ return add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
}
static int read_tree_recursive(void *buffer, unsigned long size,
------------
^ permalink raw reply
* [PATCH 8/9] http-pull: documentation updates.
From: Junio C Hamano @ 2005-06-25 9:25 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
Describe -w option.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Documentation/git-http-pull.txt | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
bce3da4d8421812b0eb1d433b0af0fc3fc9bb54a
diff --git a/Documentation/git-http-pull.txt b/Documentation/git-http-pull.txt
--- a/Documentation/git-http-pull.txt
+++ b/Documentation/git-http-pull.txt
@@ -9,7 +9,7 @@ git-http-pull - Downloads a remote GIT r
SYNOPSIS
--------
-'git-http-pull' [-c] [-t] [-a] [-v] [-d] [--recover] commit-id url
+'git-http-pull' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] commit-id url
DESCRIPTION
-----------
@@ -30,7 +30,9 @@ Downloads a remote GIT repository via HT
usual, to recover after earlier pull that was interrupted.
-v::
Report what is downloaded.
-
+-w::
+ Writes the commit-id into the filename under $GIT_DIR/refs/ on
+ the local end after the transfer is complete.
Author
------
------------
^ permalink raw reply
* [PATCH 9/9] Add a bit of developer documentation to pull.h
From: Junio C Hamano @ 2005-06-25 9:26 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
Describe what to implement in fetch() and fetch_ref() for
pull backend writers a bit better.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
pull.h | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
190061e326b73dcf76d301d8b17ce96c783d7251
diff --git a/pull.h b/pull.h
--- a/pull.h
+++ b/pull.h
@@ -1,24 +1,33 @@
#ifndef PULL_H
#define PULL_H
-/** To be provided by the particular implementation. **/
+/*
+ * Fetch object given SHA1 from the remote, and store it locally under
+ * GIT_OBJECT_DIRECTORY. Return 0 on success, -1 on failure. To be
+ * provided by the particular implementation.
+ */
extern int fetch(unsigned char *sha1);
+/*
+ * Fetch ref (relative to $GIT_DIR/refs) from the remote, and store
+ * the 20-byte SHA1 in sha1. Return 0 on success, -1 on failure. To
+ * be provided by the particular implementation.
+ */
extern int fetch_ref(char *ref, unsigned char *sha1);
-/** If set, the ref filename to write the target value to. **/
+/* If set, the ref filename to write the target value to. */
extern const char *write_ref;
-/** If set, the hash that the current value of write_ref must be. **/
+/* If set, the hash that the current value of write_ref must be. */
extern const unsigned char *current_ref;
-/** Set to fetch the target tree. */
+/* Set to fetch the target tree. */
extern int get_tree;
-/** Set to fetch the commit history. */
+/* Set to fetch the commit history. */
extern int get_history;
-/** Set to fetch the trees in the commit history. **/
+/* Set to fetch the trees in the commit history. */
extern int get_all;
/* Set to zero to skip the check for delta object base;
------------
^ permalink raw reply
* Re: Updated git HOWTO for kernel hackers
From: Dave Jones @ 2005-06-25 17:29 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Linux Kernel, Git Mailing List
In-Reply-To: <42BCD092.6050201@pobox.com>
On Fri, Jun 24, 2005 at 11:33:38PM -0400, Jeff Garzik wrote:
> Dave Jones wrote:
> >On Wed, Jun 22, 2005 at 06:24:54PM -0400, Jeff Garzik wrote:
> > >
> > > Things in git-land are moving at lightning speed, and usability has
> > > improved a lot since my post a month ago:
> > http://lkml.org/lkml/2005/5/26/11
> > >
> > >
> > >
> > > 1) installing git
> > >
> > > git requires bootstrapping, since you must have git installed in order
> > > to check out git.git (git repo), and linux-2.6.git (kernel repo). I
> > > have put together a bootstrap tarball of today's git repository.
> > >
> > > Download tarball from:
> > >
> > http://www.kernel.org/pub/linux/kernel/people/jgarzik/git-20050622.tar.bz2
> >
> ><blatant self-promotion>
> >daily snapshots (refreshed once an hour) are available at:
> >http://www.codemonkey.org.uk/projects/git-snapshots/git/
> ></blatant self-promotion>
>
> I was about to link to this, but a problem arose: your snapshots don't
> include the .git/objects directory.
This is intentional. Why is this a problem ?
In the same way, the bitkeeper snapshots I used to do never included
Bitkeeper/, and CVS snapshots don't include the CVS/ dirs.
> Also, a git-latest.tar.gz symlink would be nice.
That's doable.
Dave
^ permalink raw reply
* [PATCH] git-write-tree doesn't check alternate directories
From: Jan Harkes @ 2005-06-25 18:23 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds
git-write-tree failed when referenced objects only exist in the
GIT_ALTERNATE_OBJECT_DIRECTORIES path.
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
diff --git a/write-tree.c b/write-tree.c
--- a/write-tree.c
+++ b/write-tree.c
@@ -7,14 +7,13 @@
static int check_valid_sha1(unsigned char *sha1)
{
- char *filename = sha1_file_name(sha1);
int ret;
/* If we were anal, we'd check that the sha1 of the contents actually matches */
- ret = access(filename, R_OK);
- if (ret)
- perror(filename);
- return ret;
+ ret = has_sha1_file(sha1);
+ if (ret == 0)
+ perror(sha1_file_name(sha1));
+ return ret ? 0 : -1;
}
static int write_tree(struct cache_entry **cachep, int maxentries, const char *base, int baselen, unsigned char *returnsha1)
^ permalink raw reply
* git-verify-tag script
From: Jan Harkes @ 2005-06-25 18:35 UTC (permalink / raw)
To: git; +Cc: Linus Torvalds
Here is a script to simplify validating the gpg signature created by
git-tag-script. Might be useful to add to the git tree so that people
don't have to search for the right post in the git mailinglist archives
when they want to validate a tag.
Jan
----
#!/bin/sh
GIT_DIR=${GIT_DIR:-.git}
tag=$1
[ -f "$GIT_DIR/refs/tags/$tag" ] && tag=$(cat "$GIT_DIR/refs/tags/$tag")
git-cat-file tag $tag > .tmp-vtag || exit 1
cat .tmp-vtag | sed '/-----BEGIN PGP/Q' | gpg --verify .tmp-vtag -
rm -f .tmp-vtag
^ permalink raw reply
* [RFD] consider "git" wrapper semi-Porcelain
From: Junio C Hamano @ 2005-06-26 1:02 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <7vmzpe4x08.fsf_-_@assigned-by-dhcp.cox.net>
Currently "git" wrapper suggests both low-level git-* commands
and git-*-script commands as alternatives. Earlier I stated
that git-*-script commands, like it or not, form a perfectly
good set of barebone Porcelain, as opposed to all the other
commands that do not end with "script" are low-level Plumbing.
After reviewing the current set of commands and scripts again, I
still think this view holds true [*1*, *2*].
I would propose the following, preferably before we go 1.0:
(1) Do not suggest low-level Plumbing commands to "git" wrapper
users, and do not call anything but git-*-script from "git"
wrapper. Once *-script Porcelain matures, hopefully
everyday workflow would not require access to low-level
Plumbing and can be done with git-*-script Porcelain. When
people know the GIT way, they can also work it around
things that git-*-script Porcelain does not support well by
writing their own git-*-script in terms of Plumbing-ish
git-* commands, and if it is good enough for public
consumption, propose it for inclusion upstream.
(2) Make an alias git-whatchanged-script that just "exec"s
git-whatchanged, to make things consistent.
(3) Rename some git-*-script that are misnamed in the sense
that they are not useful standalone scripts but more of
Plumbing that happen to be written in shell [*3*]. I do
not particularly like this proposal, because this breaks
existing scripts. However, if we go this route for
consistency, I would further suggest renaming Porcelain-ish
things git-*-cmd or something, call and suggest them from
"git" wrapper, regardless of which language they are
written in [*4*].
[Footnotes]
*1* One exception is git-whatchanged.
*2* That is the reason I did not name git-cherry
"git-cherry-script". It is not useful standalone but meant to
be useful in scripting environment.
*3* git-apply-patch-script (my fault) and
git-merge-one-file-script fall into this category.
*4* Current naming and the proposal (1) above have a problem in
that they muddy the definition of what is "script": the name
"script" were originally used because they were written in
shell, and all of the Porcelain-ish things happen to be
"script". Writing Porcelain-ish things in shell should not be a
requirement.
^ permalink raw reply
* Re: [RFD] consider "git" wrapper semi-Porcelain
From: Linus Torvalds @ 2005-06-26 1:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vy88yvsjl.fsf_-_@assigned-by-dhcp.cox.net>
On Sat, 25 Jun 2005, Junio C Hamano wrote:
>
> I would propose the following, preferably before we go 1.0:
Agreed on all counts.
Linus
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox