Git development
 help / color / mirror / Atom feed
* cg-restore - restoring modified files
From: Pavel Roskin @ 2005-06-15  1:45 UTC (permalink / raw)
  To: git

Hello!

I believe the documented behavior of cg-restore is inconsistent.

"Restore given files to their original state. Without any parameters, it
recovers any files removed locally whose removal was not recorded by
`cg-rm`."

I interpret it that cg-restore without arguments restores removed files
but not modified ones.

"If passed a set of file names, it restores those files to their state
as of the last commit (including bringing files removed with cg-rm back
to life; FIXME: does not do that part yet)."

I interpret it that cg-restore with arguments restores both removed and
modified files.

Maybe we need an option whether to restore modified files?  Or maybe
they should always be restored (I think it would more consistent)?  Then
the help text should be more clear about modified files.

The actual behavior is that modified files are never restored.  We need
"-f" option for git-checkout-cache to overwrite existing files, and it's
not used whether the filenames are specified or not.  I wanted to send a
patch, but after reading help I'm not sure what exactly cg-restore is
supposed to do.

-- 
Regards,
Pavel Roskin


^ permalink raw reply

* git pull problem
From: Dmitry Torokhov @ 2005-06-15  4:19 UTC (permalink / raw)
  To: git

Hi,

I was trying to do:

	git-pull-script rsync://www.kernel.org/pub/scm/git/git.git

And got the following response:

...
fe/ca5e9b7c86b1aaa5903f1c2ca3afde09531c7b

sent 3804 bytes  received 468743 bytes  85917.64 bytes/sec
total size is 4930906  speedup is 10.43
Updating from 98a96b00b88ee35866cd0b1e94697db76bd5ddf9 to ce30a4b68ac220a2322dfe2a182194910143fafd.
fatal: git diff header lacks filename information (line 846)

Last time I did a pull and rebuild was on June 9th:

[dtor@anvil git]$ ls -la ~/bin/git-pull-script
-rwxr-xr-x  1 dtor dtor 425 Jun  9 01:08 /home/dtor/bin/git-pull-script

Just FYI.

-- 
Dmitry

^ permalink raw reply

* [PATCH 1/2] Reorganization of git-commit-script
From: Jon Seymour @ 2005-06-15  5:45 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


This change re-organizes git-commit-script to break out
the different phases of execution into separate bash
functions.

The main body is now:

if ! print_status > .editmsg; then
	# error handling
fi

if edit_message .editmsg .cmitmsg; then
	exec_commit .cmitmsg
	# cleanup
fi

The subsequent patch in this series adds support for
an optional .nextmsg file to enable the pre-population
of commit message text by external tools.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---

 git-commit-script |  100 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 65 insertions(+), 35 deletions(-)

diff --git a/git-commit-script b/git-commit-script
old mode 100644
new mode 100755
--- a/git-commit-script
+++ b/git-commit-script
@@ -1,44 +1,74 @@
 #!/bin/sh
+
+print_status() {
+	if [ ! -r $GIT_DIR/HEAD ]; then
+		if [ -z "$(git-ls-files)" ]; then
+			echo Nothing to commit 1>&2
+			return 1
+		fi
+cat <<EOF
+#
+# Initial commit
+# 
+$(git-ls-files | sed s/^/# New file: )
+#
+EOF
+	elif [ -f $GIT_DIR/MERGE_HEAD ]; then
+cat <<EOF
+#
+# It looks like your may be committing a MERGE.
+# If this is not correct, please remove the file
+# $GIT_DIR/MERGE_HEAD
+# and try again
+#
+EOF
+	fi
+	git-status-script
+}
+
+edit_message() {
+	status=$1
+	msg=$2
+
+	:> $msg
+	${VISUAL:-${EDITOR:-vi}} "$status"
+	grep -v '^#' < $status | git-stripspace >$msg
+	[ -s $msg ]
+	return $?
+}
+
+commit_parents() {
+	[ -f $GIT_DIR/HEAD ] &&
+	echo -n "-p HEAD" &&
+	[ -f $GIT_DIR/MERGE_HEAD ] &&
+	echo -n "-p MERGE_HEAD"
+	echo ""
+}
+
+exec_commit() {
+	msg=$1
+	tree=$(git-write-tree) || exit 1
+	parents=$(commit_parents) || exit 1
+	commit=$(cat $msg | git-commit-tree $tree $parents) || exit 1
+	echo $commit > $GIT_DIR/HEAD
+	rm -f -- $GIT_DIR/MERGE_HEAD
+}
+
+SENTINEL="#SENTINEL - delete this line to confirm the commit"
 : ${GIT_DIR=.git}
 if [ ! -d $GIT_DIR ]; then
 	echo Not a git directory 1>&2
 	exit 1
 fi
-PARENTS="-p HEAD"
-if [ ! -r $GIT_DIR/HEAD ]; then
-	if [ -z "$(git-ls-files)" ]; then
-		echo Nothing to commit 1>&2
-		exit 1
-	fi
-	(
-		echo "#"
-		echo "# Initial commit"
-		echo "#"
-		git-ls-files | sed 's/^/# New file: /'
-		echo "#"
-	) > .editmsg
-	PARENTS=""
-else
-	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"
-		echo "#	$GIT_DIR/MERGE_HEAD"
-		echo "# and try again"
-		echo "#"
-		PARENTS="-p HEAD -p MERGE_HEAD"
-	fi > .editmsg
-	git-status-script >> .editmsg
-fi
-if [ "$?" != "0" ]
-then
+
+if ! print_status > .editmsg; then
 	cat .editmsg
+	rm .editmsg
 	exit 1
 fi
-${VISUAL:-${EDITOR:-vi}} .editmsg
-grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
-[ -s .cmitmsg ] || exit 1
-tree=$(git-write-tree) || exit 1
-commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) || exit 1
-echo $commit > $GIT_DIR/HEAD
-rm -f -- $GIT_DIR/MERGE_HEAD
+
+if edit_message .editmsg .cmitmsg; then
+	exec_commit .cmitmsg
+	[ -f .editmsg ] && rm .editmsg
+	[ -f .cmitmsg ] && rm .cmitmsg
+fi
------------

^ permalink raw reply

* [PATCH 2/2] Adds support to git-commit-script for an optional .nextmsg file.
From: Jon Seymour @ 2005-06-15  5:45 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


If ${GIT_DIR}/.nextmsg exists, the text will be copied into the .editmsg file
together with a sentinel line prior to invoking the editor.

After editing, the edited text (but not the status lines) are saved
back to the ${GIT_DIR}/.nextmsg file.

If the sentinel line still exists in .editmsg after editing, the
file is truncated, thereby causing the commit to abort (per previous
behaviour).

The ${GIT_DIR}/.nextmsg file is deleted if, and only if,
the commit was successful.

The behaviour of git-commit-script is unchanged with respect to the
previous versions if ${GIT_DIR}/.nextmsg does not exist.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>

---
This patch set is a complete replacement for:

     [PATCH 1/1] Add support for an optional .nextmsg file to git-commit-script

I have incorporated most of Junio's feedback, except the prompting
suggestion and the suggested restructuring is slightly different.
---

 git-commit-script |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/git-commit-script b/git-commit-script
--- a/git-commit-script
+++ b/git-commit-script
@@ -5,7 +5,7 @@ print_status() {
 		if [ -z "$(git-ls-files)" ]; then
 			echo Nothing to commit 1>&2
 			return 1
-		fi
+	fi
 cat <<EOF
 #
 # Initial commit
@@ -26,12 +26,41 @@ EOF
 	git-status-script
 }
 
+merge_next_message()
+{
+	status=$1
+	next=$2
+	mv -f $status .status.$$ || exit 1
+	cat >$status <<EOF
+$SENTINEL
+#---
+$(cat $next)
+#---
+$(cat .status.$$)
+EOF
+	rm .status.$$
+}
+
+save_next_message()
+{
+	status=$1
+	next=$2
+	if grep "^$SENTINEL" < $status >/dev/null; then
+		:> $status
+		echo "commit aborted - you must delete the SENTINEL line to confirm the commit"
+	fi
+	grep -v "^#" < $status > $next
+}
+
 edit_message() {
 	status=$1
 	msg=$2
+	next=$3
 
 	:> $msg
+	[ -f "$next" ] && merge_next_message "$status" "$next"
 	${VISUAL:-${EDITOR:-vi}} "$status"
+	[ -f "$next" ] && save_next_message "$status" "$next"
 	grep -v '^#' < $status | git-stripspace >$msg
 	[ -s $msg ]
 	return $?
@@ -67,8 +96,9 @@ if ! print_status > .editmsg; then
 	exit 1
 fi
 
-if edit_message .editmsg .cmitmsg; then
+if edit_message .editmsg .cmitmsg ${GIT_DIR}/.nextmsg ; then
 	exec_commit .cmitmsg
 	[ -f .editmsg ] && rm .editmsg
 	[ -f .cmitmsg ] && rm .cmitmsg
+	[ -f .nextmsg ] && rm .nextmsg
 fi
------------

^ permalink raw reply

* [PATCH 2/2] Adds support to git-commit-script for an optional .nextmsg file. [rev 2]
From: Jon Seymour @ 2005-06-15  6:07 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


If ${GIT_DIR}/.nextmsg exists, the text will be copied into the .editmsg file
together with a sentinel line prior to invoking the editor.

After editing, the edited text (but not the status lines) are saved
back to the ${GIT_DIR}/.nextmsg file.

If the sentinel line still exists in .editmsg after editing, the
file is truncated, thereby causing the commit to abort (per previous
behaviour).

The ${GIT_DIR}/.nextmsg file is deleted if, and only if,
the commit was successful.

The behaviour of git-commit-script is unchanged with respect to the
previous versions if ${GIT_DIR}/.nextmsg does not exist.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>

---
This patch set is a complete replacement for:

     [PATCH 1/1] Add support for an optional .nextmsg file to git-commit-script

I have incorporated most of Junio's feedback, except the prompting
suggestion and the suggested restructuring is slightly different.

[rev 2] fixed 2 errors with handling of .nextmsg file
---

 git-commit-script |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/git-commit-script b/git-commit-script
--- a/git-commit-script
+++ b/git-commit-script
@@ -5,7 +5,7 @@ print_status() {
 		if [ -z "$(git-ls-files)" ]; then
 			echo Nothing to commit 1>&2
 			return 1
-		fi
+	fi
 cat <<EOF
 #
 # Initial commit
@@ -26,12 +26,41 @@ EOF
 	git-status-script
 }
 
+merge_next_message()
+{
+	status=$1
+	next=$2
+	mv -f $status .status.$$ || exit 1
+	cat >$status <<EOF
+$SENTINEL
+#---
+$(cat $next)
+#---
+$(cat .status.$$)
+EOF
+	rm .status.$$
+}
+
+save_next_message()
+{
+	status=$1
+	next=$2
+	grep -v "^#" < $status > $next
+	if grep "^$SENTINEL" < $status >/dev/null; then
+		:> $status
+		echo "commit aborted - you must delete the SENTINEL line to confirm the commit"
+	fi
+}
+
 edit_message() {
 	status=$1
 	msg=$2
+	next=$3
 
 	:> $msg
+	[ -f "$next" ] && merge_next_message "$status" "$next"
 	${VISUAL:-${EDITOR:-vi}} "$status"
+	[ -f "$next" ] && save_next_message "$status" "$next"
 	grep -v '^#' < $status | git-stripspace >$msg
 	[ -s $msg ]
 	return $?
@@ -67,8 +96,9 @@ if ! print_status > .editmsg; then
 	exit 1
 fi
 
-if edit_message .editmsg .cmitmsg; then
+if edit_message .editmsg .cmitmsg ${GIT_DIR}/.nextmsg ; then
 	exec_commit .cmitmsg
 	[ -f .editmsg ] && rm .editmsg
 	[ -f .cmitmsg ] && rm .cmitmsg
+	[ -f ${GIT_DIR}/.nextmsg ] && rm ${GIT_DIR}/.nextmsg
 fi
------------

^ permalink raw reply

* [PATCH 1/2] Reorganization of git-commit-script [rev 3]
From: Jon Seymour @ 2005-06-15  7:35 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


This change re-organizes git-commit-script to break out
the different phases of execution into separate bash
functions.

The main body is now:

if ! print_status > .editmsg; then
	# error handling
fi

if edit_message .editmsg .cmitmsg; then
	exec_commit .cmitmsg
	# cleanup
fi

The subsequent patch in this series adds support for
an optional .nextmsg file to enable the pre-population
of commit message text by external tools.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>

[rev 3] - oops, sorry, forgot to test merge case
---

 git-commit-script |  100 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 65 insertions(+), 35 deletions(-)

diff --git a/git-commit-script b/git-commit-script
old mode 100644
new mode 100755
--- a/git-commit-script
+++ b/git-commit-script
@@ -1,44 +1,74 @@
 #!/bin/sh
+
+print_status() {
+	if [ ! -r $GIT_DIR/HEAD ]; then
+		if [ -z "$(git-ls-files)" ]; then
+			echo Nothing to commit 1>&2
+			return 1
+		fi
+cat <<EOF
+#
+# Initial commit
+# 
+$(git-ls-files | sed s/^/# New file: )
+#
+EOF
+	elif [ -f $GIT_DIR/MERGE_HEAD ]; then
+cat <<EOF
+#
+# It looks like your may be committing a MERGE.
+# If this is not correct, please remove the file
+# $GIT_DIR/MERGE_HEAD
+# and try again
+#
+EOF
+	fi
+	git-status-script
+}
+
+edit_message() {
+	status=$1
+	msg=$2
+
+	:> $msg
+	${VISUAL:-${EDITOR:-vi}} "$status"
+	grep -v '^#' < $status | git-stripspace >$msg
+	[ -s $msg ]
+	return $?
+}
+
+commit_parents() {
+	[ -f $GIT_DIR/HEAD ] &&
+	echo -n "-p HEAD" &&
+	[ -f $GIT_DIR/MERGE_HEAD ] &&
+	echo -n " -p MERGE_HEAD"
+	echo ""
+}
+
+exec_commit() {
+	msg=$1
+	tree=$(git-write-tree) || exit 1
+	parents=$(commit_parents) || exit 1
+	commit=$(cat $msg | git-commit-tree $tree $parents) || exit 1
+	echo $commit > $GIT_DIR/HEAD
+	rm -f -- $GIT_DIR/MERGE_HEAD
+}
+
+SENTINEL="#SENTINEL - delete this line to confirm the commit"
 : ${GIT_DIR=.git}
 if [ ! -d $GIT_DIR ]; then
 	echo Not a git directory 1>&2
 	exit 1
 fi
-PARENTS="-p HEAD"
-if [ ! -r $GIT_DIR/HEAD ]; then
-	if [ -z "$(git-ls-files)" ]; then
-		echo Nothing to commit 1>&2
-		exit 1
-	fi
-	(
-		echo "#"
-		echo "# Initial commit"
-		echo "#"
-		git-ls-files | sed 's/^/# New file: /'
-		echo "#"
-	) > .editmsg
-	PARENTS=""
-else
-	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"
-		echo "#	$GIT_DIR/MERGE_HEAD"
-		echo "# and try again"
-		echo "#"
-		PARENTS="-p HEAD -p MERGE_HEAD"
-	fi > .editmsg
-	git-status-script >> .editmsg
-fi
-if [ "$?" != "0" ]
-then
+
+if ! print_status > .editmsg; then
 	cat .editmsg
+	rm .editmsg
 	exit 1
 fi
-${VISUAL:-${EDITOR:-vi}} .editmsg
-grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
-[ -s .cmitmsg ] || exit 1
-tree=$(git-write-tree) || exit 1
-commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) || exit 1
-echo $commit > $GIT_DIR/HEAD
-rm -f -- $GIT_DIR/MERGE_HEAD
+
+if edit_message .editmsg .cmitmsg; then
+	exec_commit .cmitmsg
+	[ -f .editmsg ] && rm .editmsg
+	[ -f .cmitmsg ] && rm .cmitmsg
+fi
------------

^ permalink raw reply

* [PATCH 2/2] Adds support to git-commit-script for an optional .nextmsg file. [rev 3]
From: Jon Seymour @ 2005-06-15  7:36 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


If ${GIT_DIR}/.nextmsg exists, the text will be copied into the .editmsg file
together with a sentinel line prior to invoking the editor.

After editing, the edited text (but not the status lines) are saved
back to the ${GIT_DIR}/.nextmsg file.

If the sentinel line still exists in .editmsg after editing, the
file is truncated, thereby causing the commit to abort (per previous
behaviour).

The ${GIT_DIR}/.nextmsg file is deleted if, and only if,
the commit was successful.

The behaviour of git-commit-script is unchanged with respect to the
previous versions if ${GIT_DIR}/.nextmsg does not exist.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>

---
This patch set is a complete replacement for:

     [PATCH 1/1] Add support for an optional .nextmsg file to git-commit-script

I have incorporated most of Junio's feedback, except the prompting
suggestion and the suggested restructuring is slightly different.

[rev 2] fixed 2 errors with handling of .nextmsg file
[rev 3] whitespace fixups


---

 git-commit-script |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/git-commit-script b/git-commit-script
--- a/git-commit-script
+++ b/git-commit-script
@@ -26,12 +26,41 @@ EOF
 	git-status-script
 }
 
+merge_next_message()
+{
+	status=$1
+	next=$2
+	mv -f $status .status.$$ || exit 1
+	cat >$status <<EOF
+$SENTINEL
+#---
+$(cat $next)
+#---
+$(cat .status.$$)
+EOF
+	rm .status.$$
+}
+
+save_next_message()
+{
+	status=$1
+	next=$2
+	grep -v "^#" < $status > $next
+	if grep "^$SENTINEL" < $status >/dev/null; then
+		:> $status
+		echo "commit aborted - you must delete the SENTINEL line to confirm the commit"
+	fi
+}
+
 edit_message() {
 	status=$1
 	msg=$2
+	next=$3
 
 	:> $msg
+	[ -f "$next" ] && merge_next_message "$status" "$next"
 	${VISUAL:-${EDITOR:-vi}} "$status"
+	[ -f "$next" ] && save_next_message "$status" "$next"
 	grep -v '^#' < $status | git-stripspace >$msg
 	[ -s $msg ]
 	return $?
@@ -67,8 +96,9 @@ if ! print_status > .editmsg; then
 	exit 1
 fi
 
-if edit_message .editmsg .cmitmsg; then
+if edit_message .editmsg .cmitmsg ${GIT_DIR}/.nextmsg ; then
 	exec_commit .cmitmsg
 	[ -f .editmsg ] && rm .editmsg
 	[ -f .cmitmsg ] && rm .cmitmsg
+	[ -f ${GIT_DIR}/.nextmsg ] && rm ${GIT_DIR}/.nextmsg
 fi
------------

^ permalink raw reply

* [WITHDRAWN PATCH] Reorganization of git-commit-script [rev 3] etc..
From: Jon Seymour @ 2005-06-15  8:05 UTC (permalink / raw)
  To: git; +Cc: jon.seymour
In-Reply-To: <20050615073558.25126.qmail@blackcubes.dyndns.org>

Sorry,

I really didn't test these too well. 

I'll withdrawn them until I have tested them properly (with test cases).

jon.

^ permalink raw reply

* [PATCH 1/1] Fix to bug introduced into rev-list.c by [PATCH 5/7] Move...
From: Jon Seymour @ 2005-06-15 10:34 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


This fixes a problem introduced in the following patch:
	[PATCH 5/7] Move knowledge of UNINTERESTING flag into rev-list.c

I have also included a unit test that would detect this kind of error
in future.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>

---

Note: as of the time of writing, this patch had not yet been
merged with Linus' head.

For ease of reference, the set of pending changes still to be
applied (in application orderevese order of app;lication) 

[PATCH] Fix to bug introduced into rev-list.c by [PATCH 5/7] Move...
[PATCH 7/7] Move traversal parts of epoch.[ch] into traversal.[ch]
[PATCH 6/7] Remove DUPCHECK, UNINTERESTING flags from epoch.h
[PATCH 5/7] Move knowledge of UNINTERESTING flag into rev-list.c
[PATCH 4/7] Move two general purpose commit-related functions into commit.[ch]
[PATCH 3/7] Rename epoch.c entry points as traverse_* methods/stuctures
[PATCH 2/7] Introduce new methods into the epoch_methods structure.
[PATCH 1/7] Additional --merge-order tests and general cleanup of t/t6001-rev-list-merge-order.sh
[PATCH 2/2] Add support for author-oriented git-rev-list switches [rev 11]
[PATCH 1/2] Changes to non-epoch.c code required for author-oriented git-rev-list changes
---

 rev-list.c                      |    2 +-
 t/t6001-rev-list-merge-order.sh |   26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/rev-list.c b/rev-list.c
--- a/rev-list.c
+++ b/rev-list.c
@@ -91,7 +91,7 @@ static int process_commit(struct commit 
 	if (commit->object.flags & UNINTERESTING)
 		stop_traversal = 1;
 
-	if (action & STOP) {
+	if (action == STOP) {
 		return STOP;
 	}
 
diff --git a/t/t6001-rev-list-merge-order.sh b/t/t6001-rev-list-merge-order.sh
--- a/t/t6001-rev-list-merge-order.sh
+++ b/t/t6001-rev-list-merge-order.sh
@@ -464,6 +464,32 @@ test_output_expect_success "linear prune
 = l5
 EOF
 
+test_output_expect_success "max-count 10 - merge order" 'git-rev-list --show-breaks --max-count=10 l5' <<EOF
+= l5
+| l4
+| l3
+= a4
+| c3
+| c2
+| c1
+^ b4
+| b3
+| b2
+EOF
+
+test_output_expect_success "max-count 10 - non merge order" 'git-rev-list --max-count=10 l5 | sort' <<EOF
+a4
+b2
+b3
+b4
+c1
+c2
+c3
+l3
+l4
+l5
+EOF
+
 test_expect_failure "all heads uninteresting" 'git-rev-list --show-breaks a3 ^a3'
 #
 #
------------

^ permalink raw reply

* Re: reducing line crossings in gitk
From: Paul Mackerras @ 2005-06-15 11:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v8y1gvjfz.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano writes:

>  - What support from the core GIT side would you need if you
>    wanted to let users browse a remote repo?  A way to inspect
>    what is under ".git/refs/" hierarchy on the remote side?
>    Anything else?

I would need git-rev-list, git-cat-file, and git-diff-tree to be able
to operate on the remote repository.

>  - Pasting into the SHA1 field to "Go To" was a nuisance when
>    the field already had a string in it.  Clearing the SHA1
>    field when focus gets in would be one way to solve it, but
>    then you would lose the way to pasting out of that field, so
>    I do not know what to suggest offhand.

I could rebind the middle mouse button to replace the contents of the
sha1 field with the selection instead of inserting it.

>  - How do I "Find" backwards?  Not being able to find a way to
>    do this was the most annoying thing for me.

The "?" key is bound to find backwards (i.e. select previous match)
and the "/" key is bound to find forwards (select next match).  I
don't have a button for find backwards (and I'd rather not clutter it
up by adding one, but maybe I could add a menu item for it).

>  - After typing something in "Find" and hitting <ENTER>, if the
>    focus stays in it and lets me hit <ENTER> again to go to the
>    next one would be nicer.  Somehow hitting <ENTER> again would
>    not do this for me right now.

Hmmm, if the focus stays in the find field then you can't use "?", up,
down, etc.  I could make <enter> do find-next if you like.

>  - Indicaing "Find" wrapping around without annoying the user
>    too much (i.e. I do _not_ want you to add "Find reached the
>    beginning of time, wrapping around and continuing from the
>    top" pop-up window) would be nicer.  Currently I can tell by
>    looking at the scrollbar on the history pane jumping back, so
>    this is not a big issue, though.

I could make it beep - how about that?

>  - Can I have a way to "Find" next commit that touches a given
>    pathname?
> 
>     $ git-rev-list | git-diff-tree -s -r --stdin '<that pathname>'
> 
>    which would give you a sequence of lines that look like:
>        "commit-SHA1 (from parent-commit-SHA1)"
> 
>    you would pick the commit-SHA1 from the output and jump to it.

Interesting idea... I could add a "Path" entry to the find type menu.

>  - In addition to "Find" which looks at the commit message, can I
>    have one that uses pickaxe to find changes?
> 
>  - Can I have an option to use diffcore options to tweak the
>    diff that is shown in the lower-left pane?

Also interesting ideas, I'll see what I can do.

Regards,
Paul.

^ permalink raw reply

* Re: reducing line crossings in gitk
From: Jon Seymour @ 2005-06-15 12:34 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Junio C Hamano, git
In-Reply-To: <17072.3723.242985.824999@cargo.ozlabs.ibm.com>

Paul,

Another feature that would be handy is the ability to be able to
create tags by pointing to an item and selecting a "create-tag"
action. The effect would be to write the SHA1 id into
GIT_DIR/refs/tags in the expected way.

Regards, 

jon.

^ permalink raw reply

* [PATCH 1/3] Add test cases for git-commit-script.
From: Jon Seymour @ 2005-06-15 14:38 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


Adds some tests to show that git-commit-script behaves properly under a number
of different conditions.

The git-commit-script (f88a51a43ce2a3660fa82c13e502df429678d168) at Linus' HEAD
passes these tests.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---

 t/t1200-commit-script.sh |  153 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 153 insertions(+), 0 deletions(-)

diff --git a/t/t1200-commit-script.sh b/t/t1200-commit-script.sh
new file mode 100644
--- /dev/null
+++ b/t/t1200-commit-script.sh
@@ -0,0 +1,153 @@
+#!/bin/sh
+#
+# Copyright (C) 2005 Rene Scharfe
+# Copyright (C) 2005 Jon Seymour [ adapted to git-commit-script ]
+#
+
+test_description='git-commit-script
+
+This test checks that git-commit-script works as expected.
+'
+
+. ./test-lib.sh
+
+one_line()
+{
+echo "this is a commit test"
+}
+
+expected_commit ()
+{
+	tree=$1
+	shift 1
+cat <<EOF
+tree $tree
+EOF
+
+	for p in $*
+	do
+cat <<EOF
+parent $p
+EOF
+	done
+
+cat <<EOF
+author Author Name <author@email> 1117148400 +0000
+committer Committer Name <committer@email> 1117150200 +0000
+
+$(one_line)
+EOF
+}
+
+cat >add_one_line_editor <<EOF
+#!/bin/sh
+file=\$1
+echo "$(one_line)" >> \$file
+EOF
+
+cat >do_nothing_editor <<EOF
+#!/bin/sh
+:
+EOF
+
+cat >delete_sentinel_editor <<EOF
+#!/bin/sh
+file=\$1
+mv \$file \$file.\$\$
+sed "/^#SENTINEL/d" < \$file.\$\$ >\$file
+EOF
+
+chmod u+x add_one_line_editor
+chmod u+x do_nothing_editor
+chmod u+x delete_sentinel_editor
+
+: > foo
+: > bar
+
+run_with_vars()
+{
+     GIT_AUTHOR_NAME="Author Name" \
+     GIT_AUTHOR_EMAIL="author@email" \
+     GIT_AUTHOR_DATE="2005-05-26 23:00" \
+     GIT_COMMITTER_NAME="Committer Name" \
+     GIT_COMMITTER_EMAIL="committer@email" \
+     GIT_COMMITTER_DATE="2005-05-26 23:30" \
+     TZ= "$@" 2>/dev/null
+}
+
+test_phase1()
+{
+     condition=$1
+     editor=$2
+
+     test_expect_success \
+     "$condition - test preparation: add a file" \
+     'git-update-cache --add foo && git-write-tree > treeid'
+
+     test_expect_failure \
+     "$condition - Do not edit the commit message" \
+     "EDITOR=$editor run_with_vars git-commit-script"
+
+     test_expect_failure \
+     "$condition - No HEAD created when commit fails" \
+     '[ -f .git/HEAD ]'
+}
+
+test_phase2()
+{
+    condition=$1
+    editor=$2
+    test_expect_success \
+    "$condition - Single line message works" \
+    "EDITOR=$editor run_with_vars git-commit-script"
+
+    test_expect_success "$condition - HEAD created" '[ -f .git/HEAD ]'
+
+    test_expect_success \
+    "$condition - read commit 1" \
+    'git-cat-file commit HEAD >commit'
+
+    test_expect_success \
+    "$condition - compare commit" \
+    'expected_commit $(cat treeid) > expected && diff expected commit'
+
+    head=$(cat .git/HEAD)
+    test_expect_success \
+    "$condition - create a merge head" \
+    'merge_head=$(git-commit-tree $(cat treeid) -p HEAD < /dev/null)'
+
+    echo $merge_head > .git/MERGE_HEAD
+
+    test_expect_success \
+    "$condition - test preparation: write tree containing" \
+    'git-update-cache --add bar && git-write-tree > treeid.bar'
+
+}
+
+test_phase3()
+{
+    condition=$1
+    editor=$2
+
+    test_expect_success \
+    "$condition - write a tree with one merge head" \
+    "EDITOR=$editor run_with_vars git-commit-script"
+    
+    test_expect_success "$condition - MERGE_HEAD removed" '[ -f .git/HEAD ]'
+    test_expect_success "$condition - MERGE_HEAD removed by successful commit" '! [ -f .git/MERGE_HEAD ]'
+
+    test_expect_success \
+    "$condition - read commit 2" \
+    'git-cat-file commit HEAD >commit'
+
+    test_expect_success \
+    "$condition - compare commit 2" \
+    "expected_commit $(cat treeid.bar) ${head} ${merge_head} > expected && diff expected commit"
+
+}
+
+test_phase1 "simulated user" ./do_nothing_editor
+test_phase2 "simulated user" ./add_one_line_editor
+test_phase3 "simulated used" ./add_one_line_editor
+
+test_done
------------

^ permalink raw reply

* [PATCH 2/3] Reorganization of git-commit-script [rev 4]
From: Jon Seymour @ 2005-06-15 14:38 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


This change re-organizes git-commit-script to break out
the different phases of execution into separate bash
functions.

The main body is now:

if ! print_status > .editmsg; then
	# error handling
fi

if edit_message .editmsg .cmitmsg; then
	exec_commit .cmitmsg
	# cleanup
fi

The subsequent patch in this series adds support for
an optional .nextmsg file to enable the pre-population
of commit message text by external tools.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---

 git-commit-script |  110 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 75 insertions(+), 35 deletions(-)

diff --git a/git-commit-script b/git-commit-script
--- a/git-commit-script
+++ b/git-commit-script
@@ -1,44 +1,84 @@
 #!/bin/sh
+
+initial_commit() {
+cat <<EOF
+#
+# Initial commit:
+# 
+$(git-ls-files | sed "s/^/# New file: /")
+#
+EOF
+}
+
+merge_commit() {
+cat <<EOF
+#
+# It looks like your may be committing a MERGE.
+# If this is not correct, please remove the file
+# $GIT_DIR/MERGE_HEAD
+# and try again
+#
+EOF
+}
+
+print_status() {
+	if [ ! -r $GIT_DIR/HEAD ]; then
+		if [ -z "$(git-ls-files)" ]; then
+			echo Nothing to commit 1>&2
+			return 1
+		fi
+		initial_commit 
+	else
+		if [ -f $GIT_DIR/MERGE_HEAD ]; then
+			merge_commit
+		fi
+		git-status-script
+	fi
+}
+
+edit_message() {
+	status=$1
+	msg=$2
+
+	:> $msg
+	${VISUAL:-${EDITOR:-vi}} "$status"
+	grep -v '^#' < $status | git-stripspace >$msg
+	[ -s $msg ] || exit 1
+}
+
+commit_parents() {
+	[ -f $GIT_DIR/HEAD ] &&
+	echo -n "-p HEAD" &&
+	[ -f $GIT_DIR/MERGE_HEAD ] &&
+	echo -n " -p MERGE_HEAD"
+	echo ""
+}
+
+exec_commit() {
+	msg=$1
+	tree=$(git-write-tree) || exit 1
+	parents=$(commit_parents) || exit 1
+	commit=$(cat $msg | git-commit-tree $tree $parents) || exit 1
+	echo $commit > $GIT_DIR/HEAD
+	rm -f -- $GIT_DIR/MERGE_HEAD
+}
+
+SENTINEL="#SENTINEL - delete this line to confirm the commit"
 : ${GIT_DIR=.git}
 if [ ! -d $GIT_DIR ]; then
 	echo Not a git directory 1>&2
 	exit 1
 fi
-PARENTS="-p HEAD"
-if [ ! -r $GIT_DIR/HEAD ]; then
-	if [ -z "$(git-ls-files)" ]; then
-		echo Nothing to commit 1>&2
-		exit 1
-	fi
-	(
-		echo "#"
-		echo "# Initial commit"
-		echo "#"
-		git-ls-files | sed 's/^/# New file: /'
-		echo "#"
-	) > .editmsg
-	PARENTS=""
-else
-	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"
-		echo "#	$GIT_DIR/MERGE_HEAD"
-		echo "# and try again"
-		echo "#"
-		PARENTS="-p HEAD -p MERGE_HEAD"
-	fi > .editmsg
-	git-status-script >> .editmsg
-fi
-if [ "$?" != "0" ]
-then
+
+if ! print_status > .editmsg; then
 	cat .editmsg
+	rm .editmsg
 	exit 1
 fi
-${VISUAL:-${EDITOR:-vi}} .editmsg
-grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
-[ -s .cmitmsg ] || exit 1
-tree=$(git-write-tree) || exit 1
-commit=$(cat .cmitmsg | git-commit-tree $tree $PARENTS) || exit 1
-echo $commit > $GIT_DIR/HEAD
-rm -f -- $GIT_DIR/MERGE_HEAD
+
+if edit_message .editmsg .cmitmsg; then
+	exec_commit .cmitmsg
+	[ -f .editmsg ] && rm .editmsg
+	[ -f .cmitmsg ] && rm .cmitmsg
+	exit 0
+fi
------------

^ permalink raw reply

* [PATCH 3/3] Adds support to git-commit-script for an optional .nextmsg file. [rev 4]
From: Jon Seymour @ 2005-06-15 14:38 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


If ${GIT_DIR}/.nextmsg exists, the text will be copied into the .editmsg file
together with a sentinel line prior to invoking the editor.

After editing, the edited text (but not the status lines) are saved
back to the ${GIT_DIR}/.nextmsg file.

If the sentinel line still exists in .editmsg after editing, the
file is truncated, thereby causing the commit to abort (per previous
behaviour).

The ${GIT_DIR}/.nextmsg file is deleted if, and only if,
the commit was successful.

The behaviour of git-commit-script is unchanged with respect to the
previous versions if ${GIT_DIR}/.nextmsg does not exist.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---

 git-commit-script        |   32 +++++++++++++++++++++++++++++++-
 t/t1200-commit-script.sh |   41 ++++++++++++++++++++++++++++++++++++++---
 2 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/git-commit-script b/git-commit-script
--- a/git-commit-script
+++ b/git-commit-script
@@ -36,12 +36,41 @@ print_status() {
 	fi
 }
 
+merge_next_message()
+{
+	status=$1
+	next=$2
+	mv -f $status .status.$$ || exit 1
+	cat >$status <<EOF
+$SENTINEL
+#---
+$(cat $next)
+#---
+$(cat .status.$$)
+EOF
+	rm .status.$$
+}
+
+save_next_message()
+{
+	status=$1
+	next=$2
+	grep -v "^#" < $status > $next
+	if grep "^$SENTINEL" < $status >/dev/null; then
+		:> $status
+		echo "commit aborted - you must delete the SENTINEL line to confirm the commit"
+	fi
+}
+
 edit_message() {
 	status=$1
 	msg=$2
+	next=$3
 
 	:> $msg
+	[ -f "$next" ] && merge_next_message "$status" "$next"
 	${VISUAL:-${EDITOR:-vi}} "$status"
+	[ -f "$next" ] && save_next_message "$status" "$next"
 	grep -v '^#' < $status | git-stripspace >$msg
 	[ -s $msg ] || exit 1
 }
@@ -76,9 +105,10 @@ if ! print_status > .editmsg; then
 	exit 1
 fi
 
-if edit_message .editmsg .cmitmsg; then
+if edit_message .editmsg .cmitmsg ${GIT_DIR}/.nextmsg ; then
 	exec_commit .cmitmsg
 	[ -f .editmsg ] && rm .editmsg
 	[ -f .cmitmsg ] && rm .cmitmsg
+	[ -f ${GIT_DIR}/.nextmsg ] && rm ${GIT_DIR}/.nextmsg
 	exit 0
 fi
diff --git a/t/t1200-commit-script.sh b/t/t1200-commit-script.sh
--- a/t/t1200-commit-script.sh
+++ b/t/t1200-commit-script.sh
@@ -75,6 +75,15 @@ run_with_vars()
      TZ= "$@" 2>/dev/null
 }
 
+reset()
+{
+     [ -f .git/HEAD ] && rm .git/HEAD
+     [ -f .git/MERGE_HEAD ] && rm .git/MERGE_HEAD
+     [ -f .git/index ] && rm .git/index
+     [ -f treeid ] && rm treeid
+     [ -f commit ] && rm commit
+}
+
 test_phase1()
 {
      condition=$1
@@ -146,8 +155,34 @@ test_phase3()
 
 }
 
-test_phase1 "simulated user" ./do_nothing_editor
-test_phase2 "simulated user" ./add_one_line_editor
-test_phase3 "simulated used" ./add_one_line_editor
+test_phase1 "without .nextmsg" ./do_nothing_editor
+test_phase2 "without .nextmsg" ./add_one_line_editor
+test_phase3 "without .nextmsg" ./add_one_line_editor
+
+reset
+
+one_line > .git/.nextmsg
+test_phase1 "with .nextmsg" ./do_nothing_editor
+test_expect_success ".nextmsg file kept" "[ -f .git/.nextmsg -a \"$(cat .git/.nextmsg)\" == \"$(one_line)\" ]"
+
+one_line    > .git/.nextmsg
+test_phase2 "with .nextmsg" ./delete_sentinel_editor
+test_expect_success ".nextmsg file deleted" '! [ -f .git/.nextmsg ]'
+
+one_line    > .git/.nextmsg
+test_phase3 "with .nextmsg" ./delete_sentinel_editor
+test_expect_success ".nextmsg file deleted" '! [ -f .git/.nextmsg ]'
+
+reset
+
+: > .git/.nextmsg
+test_phase1 "with .nextmsg, change preserved, sentinel kept" ./add_one_line_editor
+test_expect_success "edit preserved - sentinel not deleted" "[ -f .git/.nextmsg -a \"$(cat .git/.nextmsg | tr -d \\012 )\" == \"$(one_line)\" ]"
+
+reset
+
+: > .git/.nextmsg
+test_phase1 "with .nextmsg, no data, no edit, sentinel kept" ./do_nothing_editor
+test_expect_success "no change - sentinel not deleted" "[ -f .git/.nextmsg -a \"$(cat .git/.nextmsg)\" == \"\" ]"
 
 test_done
------------

^ permalink raw reply

* time casts
From: Jason Wright @ 2005-06-15 15:30 UTC (permalink / raw)
  To: git

In porting cogito/git 0.11.3 to OpenBSD, I ran into casts of time_t
warnings for the printfs below.  I think the warnings are harmless, but
the patch below fixes 'em.

--Jason L. Wright

--- date.c.orig	Wed Jun 15 11:21:00 2005
+++ date.c	Wed Jun 15 11:21:30 2005
@@ -438,7 +438,8 @@ void parse_date(char *date, char *result
 		sign = '-';
 	}
 
-	snprintf(result, maxlen, "%lu %c%02d%02d", then, sign, offset/60, offset % 60);
+	snprintf(result, maxlen, "%lu %c%02d%02d", (unsigned long)then,
+	    sign, offset/60, offset % 60);
 }
 
 void datestamp(char *buf, int bufsize)
@@ -451,5 +452,6 @@ void datestamp(char *buf, int bufsize)
 	offset = my_mktime(localtime(&now)) - now;
 	offset /= 60;
 
-	snprintf(buf, bufsize, "%lu %+05d", now, offset/60*100 + offset%60);
+	snprintf(buf, bufsize, "%lu %+05d", (unsigned long)now,
+	    offset/60*100 + offset%60);
 }
--- tar-tree.c.orig	Wed Jun 15 11:24:07 2005
+++ tar-tree.c	Wed Jun 15 11:24:55 2005
@@ -318,7 +318,7 @@ static void write_header(const unsigned 
 	if (S_ISDIR(mode) || S_ISLNK(mode))
 		size = 0;
 	sprintf(&header[124], "%011lo", size);
-	sprintf(&header[136], "%011lo", archive_time);
+	sprintf(&header[136], "%011lo", (unsigned)archive_time);
 
 	header[156] = typeflag;
 

^ permalink raw reply

* execlp sentinel
From: Jason Wright @ 2005-06-15 15:33 UTC (permalink / raw)
  To: git

Another thing I ran into when porting cogito-0.11.3 to OpenBSD...  the
NULL last argument to execlp() must be cast to a pointer type (NULL
is an integer type on OpenBSD) in order for it to match as being
a proper sentinel value.

--Jason L. Wright

--- diff.c.orig	Thu Jun  9 05:15:09 2005
+++ diff.c	Wed Jun 15 11:20:08 2005
@@ -157,7 +157,7 @@ static void builtin_diff(const char *nam
 			exit(0);
 	}
 	fflush(NULL);
-	execlp("/bin/sh","sh", "-c", cmd, NULL);
+	execlp("/bin/sh","sh", "-c", cmd, (void *)NULL);
 }
 
 struct diff_filespec *alloc_filespec(const char *path)
@@ -518,7 +518,7 @@ static void run_external_diff(const char
 				execvp(pgm, (char *const*) exec_arg);
 			}
 			else
-				execlp(pgm, pgm, name, NULL);
+				execlp(pgm, pgm, name, (void *)NULL);
 		}
 		/*
 		 * otherwise we use the built-in one.
--- merge-cache.c.orig	Tue Jun 14 17:07:44 2005
+++ merge-cache.c	Tue Jun 14 17:07:50 2005
@@ -23,7 +23,7 @@ static void run_program(void)
 			    arguments[5],
 			    arguments[6],
 			    arguments[7],
-			    NULL);
+			    (void *)NULL);
 		die("unable to execute '%s'", pgm);
 	}
 	if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
--- rsh.c.orig	Wed Jun 15 11:21:57 2005
+++ rsh.c	Wed Jun 15 11:22:08 2005
@@ -57,7 +57,7 @@ int setup_connection(int *fd_in, int *fd
 		close(sv[1]);
 		dup2(sv[0], 0);
 		dup2(sv[0], 1);
-		execlp("ssh", "ssh", host, command, NULL);
+		execlp("ssh", "ssh", host, command, (void *)NULL);
 	}
 	close(sv[0]);
 	*fd_in = sv[1];

^ permalink raw reply

* [PATCH] link in gitweb rss feed
From: Erik van Konijnenburg @ 2005-06-15 15:41 UTC (permalink / raw)
  To: Kay Sievers; +Cc: Git Mailing List

The following patch makes the site name in an RSS
feedreader for a gitweb project refer to the summary
page for the the project, the same place where you picked
up the feed in the first place.  This seems more consistent
than linking to the overview of all projects where the
link used to up.  Changed the link in OPML feed accordingly;
this used to end up in the full log rather than the summary.

Patch was made against version 220 as shipped in Debian,
and applies (with offset) to your version 221.

Regards,
Erik

--- gitorg.cgi	2005-06-15 17:11:51.000000000 +0200
+++ gitweb.cgi	2005-06-15 17:16:42.000000000 +0200
@@ -1227,7 +1227,7 @@
 	      "<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n";
 	print "<channel>\n";
 	print "<title>$project</title>\n".
-	      "<link>" . escapeHTML("$my_url/$project/log") . "</link>\n".
+	      "<link>" . escapeHTML("$my_url?p=$project;a=summary") . "</link>\n".
 	      "<description>$project log</description>\n".
 	      "<language>en</language>\n";
 
@@ -1280,7 +1280,7 @@
 
 		my $path = escapeHTML(chop_str($proj{'path'}, 25, 5));
 		my $rss =  "$my_url?p=$proj{'path'};a=rss";
-		my $html =  "$my_url?p=$proj{'path'};a=log";
+		my $html =  "$my_url?p=$proj{'path'};a=summary";
 		print "<outline type=\"rss\" text=\"$path\" title=\"$path\" xmlUrl=\"$rss\" htmlUrl=\"$html\"/>\n";
 	}
 	print "</outline>\n".

^ permalink raw reply

* Converting SVN repository to git
From: Art Haas @ 2005-06-15 18:47 UTC (permalink / raw)
  To: git

Hi.

The utilities for converting CVS repositories to git repos have become
part of the standard git package, and hopefully they'll be used to
convert many CVS based projects to git. I've not seen anything, though,
on switching Subversion repositories to git. Has there been any public
activity in writing a tool/script to do this? Perhaps some offline
discussion about doing this?

Thanks in advance.

Art Haas
-- 
Man once surrendering his reason, has no remaining guard against absurdities
the most monstrous, and like a ship without rudder, is the sport of every wind.

-Thomas Jefferson to James Smith, 1822

^ permalink raw reply

* Re: [COGITO PATCH] Optimized print_help()
From: Rene Scharfe @ 2005-06-15 18:58 UTC (permalink / raw)
  To: Pavel Roskin; +Cc: git
In-Reply-To: <1118795583.3890.27.camel@dv>

Pavel Roskin schrieb:
>>> +	cat $toolpath | sed -n '3,/^$/s/^# *//p'
>> 
>> What about also removing UUOC from this line ...
> 
> 
> UUOC?  I had too look it up :-)
> 
> It's not just "useless use of cat", but also useless use of
> redirection in both cases.  I guess sed can exit after it finishes
> processing the range (I don't know if it actually does), so feeding
> it the whole file is not need.

It doesn't matter if the shell opens the file or if sed does it itself,
sed's ability to close the file and quit when done doesn't depend on
that.  So this call is equivalent and has the advantage of being
resistant against filenames starting with a "-":

   sed -n '3,/^$/s/^# *//p' <"$toolpath"

Rene

^ permalink raw reply

* Re: [COGITO PATCH] Optimized print_help()
From: Pavel Roskin @ 2005-06-15 21:14 UTC (permalink / raw)
  To: Rene Scharfe; +Cc: git
In-Reply-To: <42B07A6F.3000001@lsrfire.ath.cx>

Hello, Rene!

On Wed, 2005-06-15 at 20:58 +0200, Rene Scharfe wrote:
> It doesn't matter if the shell opens the file or if sed does it itself,
> sed's ability to close the file and quit when done doesn't depend on
> that.

I checked sed 4.1.4 and found following:

1) sed won't close stdin ever, but it will close files specified on the
command line.

2) sed will exit when told to do so by a command such as "q", and it
won't read the reminder of the file, whether it's stdin or not.

3) sed has code that makes it exit after it has processed all address
ranges and the "-n" option is used.  However, this feature is buggy and
disabled by default (see EXPERIMENTAL_DASH_N_OPTIMIZATION). It may be
enabled in the future versions.

In other words, you are correct (except the part about closing the
file).

>   So this call is equivalent and has the advantage of being
> resistant against filenames starting with a "-":
> 
>    sed -n '3,/^$/s/^# *//p' <"$toolpath"

OK.  Here's the third version of the patch.

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -130,10 +130,11 @@ update_index () {
 
 
 print_help () {
-	which "cg-$1" >/dev/null 2>&1 || exit 1
-	sed -n '/^USAGE=/,0s/.*"\(.*\)"/Usage: \1/p' < $(which cg-$1) 
+	local toolpath=$(which cg-$1 2>/dev/null)
+	[ -z "$toolpath" ] && exit 1
+	sed -n '/^USAGE=/,0s/.*"\(.*\)"/Usage: \1/p' <"$toolpath"
 	echo
-	cat $(which cg-$1) | sed -n '3,/^$/s/^# *//p'
+	sed -n '3,/^$/s/^# *//p' <"$toolpath"
 	exit
 }
 



-- 
Regards,
Pavel Roskin


^ permalink raw reply

* Re: Converting SVN repository to git
From: Adam Mercer @ 2005-06-15 22:02 UTC (permalink / raw)
  To: git
In-Reply-To: <20050615184720.GF31997@artsapartment.org>

On 15/06/05, Art Haas <ahaas@airmail.net> wrote:

> The utilities for converting CVS repositories to git repos have become
> part of the standard git package, and hopefully they'll be used to
> convert many CVS based projects to git. I've not seen anything, though,
> on switching Subversion repositories to git. Has there been any public
> activity in writing a tool/script to do this? Perhaps some offline
> discussion about doing this?

You could use something like svn2cvs (http://svn2cvs.tigris.org) and
then use the cvs2git tools.

Cheers

Adam

^ permalink raw reply

* Using local trees and cogito
From: Jon Smirl @ 2005-06-16  2:37 UTC (permalink / raw)
  To: git

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

I took Jeff Garzik's scripts for managing multiple trees and reworked
them a little for cogito. I changed the names to something that makes
more sense to me, but what does everyone think? Or can cogito already
do this I just can't figure it out?

In my terminology forks are different tree heads in the same git tree
(local branches).

cg-fork fname -- make a new tree head from the current tree and switch to it.
cg-goto fname -- switch the current working tree to one of the forks.
cg-goto -- display the name of the current fork
cg-goto -l -- display the name of all forks
cg-diff fname -- diff the current working tree to a fork
cg-merge fname -- merge another fork into the current fork

I fixed goto to not jump if there are pending changes. Is there a
better way to do this?

Is fork a good name since branches refer to other git trees? I'm
somewhat confused about exactly what a branch consists of, it looks to
me like the path to another external tree.

I do find Jeff's work very useful since it allows me to keep twenty
patches in a single tree and jump between them. This is better than bk
where I had to keep multiple entire trees with a build in each of
them. This way I only rebuild the files that changed after a jump.

One problem I did notice is that if you add file in a fork and jump to
a fork without the file, it doesn't get removed. That's not a big
problem but it can be confusing.

-- 
Jon Smirl
jonsmirl@gmail.com

[-- Attachment #2: cg-fork --]
[-- Type: application/octet-stream, Size: 251 bytes --]

#!/bin/sh

if [ ! -d .git/refs/heads ]
then
	echo Cannot find .git metadata, aborting.
	exit 1
fi

FN=".git/refs/heads/$1"

if [ -f $FN ]
then
	echo Branch $1 exists, moving to $1.old.
	mv -f $FN $FN.old
fi

cp .git/refs/heads/master $FN

cg-goto $1


[-- Attachment #3: cg-goto --]
[-- Type: application/octet-stream, Size: 421 bytes --]

#!/bin/sh

if [ "$1" == "-l" ]
then
	ls .git/refs/heads
elif [ "x$1" != "x" ]
then
	if [ ! -f .git/refs/heads/$1 ]
	then
		echo Branch $1 not found.
		exit 1
	fi
	diff=$(git-diff-cache -r -p HEAD)
	if [ "x$diff" != "x" ]
	then
		echo "Commit pending changes first"
		exit 1
	fi
	( cd .git && rm -f HEAD && ln -s refs/heads/$1 HEAD )

	git-read-tree -m HEAD && git-checkout-cache -q -f -u -a
else
	readlink .git/HEAD
fi



^ permalink raw reply

* [PATCH] fix scalability problems with git-deltafy-script
From: Nicolas Pitre @ 2005-06-16  2:59 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

Current version would spin forever  and exhaust memory while 
attempting to sort all files from all revisions at once, until it
dies before even doing any real work.  This is especially noticeable 
when used on a big repository like the imported  bkcvs repo for the
Linux kernel.

This patch allows for batching the sort to put a bound on needed 
resources and making progress early, as well as including some small
cleanups.

Signed-off-by: Nicolas Pitre <nico@cam.org>

diff --git a/git-deltafy-script b/git-deltafy-script
--- a/git-deltafy-script
+++ b/git-deltafy-script
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Example script to deltafy an entire GIT repository based on the commit list.
+# Example script to deltify an entire GIT repository based on the commit list.
 # The most recent version of a file is the reference and previous versions
 # are made delta against the best earlier version available. And so on for
 # successive versions going back in time.  This way the increasing delta
@@ -25,37 +25,51 @@
 
 set -e
 
-depth=
-[ "$1" == "-d" ] && depth="--max-depth=$2" && shift 2
+max_depth=
+[ "$1" == "-d" ] && max_depth="--max-depth=$2" && shift 2
+
+overlap=30
+max_behind="--max-behind=$overlap"
 
 function process_list() {
 	if [ "$list" ]; then
 		echo "Processing $curr_file"
-		echo "$head $list" | xargs git-mkdelta $depth --max-behind=30 -v
+		echo "$list" | xargs git-mkdelta $max_depth $max_behind -v
 	fi
 }
 
+rev_list=""
 curr_file=""
 
 git-rev-list HEAD |
-git-diff-tree -r -t --stdin |
-awk '/^:/ { if ($5 == "M" || $5 == "N") print $4, $6;
-            if ($5 == "M") print $3, $6 }' |
-LC_ALL=C sort -s -k 2 | uniq |
-while read sha1 file; do
-	if [ "$file" == "$curr_file" ]; then
-		list="$list $sha1"
-	else
-		process_list
-		curr_file="$file"
-		list=""
-		head="$sha1"
-	fi
+while true; do
+	# Let's batch revisions into groups of 1000 to give it a chance to
+	# scale with repositories containing long revision lists.  We also
+	# overlap with the previous batch the size of mkdelta's look behind
+	# value in order to account for the processing discontinuity.
+	rev_list="$(echo -e -n "$rev_list" | tail --lines=$overlap)"
+	for i in $(seq 1000); do
+		read rev || break
+		rev_list="$rev_list$rev\n"
+	done
+	echo -e -n "$rev_list" |
+	git-diff-tree -r -t --stdin |
+	awk '/^:/ { if ($5 == "M") printf "%s %s\n%s %s\n", $4, $6, $3, $6 }' |
+	LC_ALL=C sort -s -k 2 | uniq |
+	while read sha1 file; do
+		if [ "$file" == "$curr_file" ]; then
+			list="$list $sha1"
+		else
+			process_list
+			curr_file="$file"
+			list="$sha1"
+		fi
+	done
+	[ "$rev" ] || break
 done
 process_list
 
 curr_file="root directory"
-head=""
 list="$(
 	git-rev-list HEAD |
 	while read commit; do

^ permalink raw reply

* [PATCH 1/1] [PROPOSAL] Add a module (repo-log.c) to log repository events.
From: Jon Seymour @ 2005-06-16  3:59 UTC (permalink / raw)
  To: git; +Cc: jon.seymour


This patch contains a header file that illustrates a proposed
repository event logging module.

The motivations for introducing such a module are documented
in the proposed header. There are probably good reasons for
taking a similar approach to logging cache events, since
to do so would provide a robust undo/redo facility that
is guaranteed to be able to reconstruct the workspace to any
previous state.

This patch is posted to the list to solicit feedback that
I'll try to incorporate as I proceed with the implementation.
---

 repo-log.h |  135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/repo-log.h b/repo-log.h
new file mode 100644
--- /dev/null
+++ b/repo-log.h
@@ -0,0 +1,135 @@
+#ifndef REPOLOG_H
+#define REPOLOG_H
+/*
+ * Copyright (c) 2005, Jon Seymour
+ * 
+ * This module provides an API for logging significant 
+ * repository events via a logging API.
+ * 
+ * There are several uses for this feature:
+ * 	* identifying new objects to be pushed "somewhere else". Somewhere else
+ *        could be:
+ *             * another repository (via rsync)
+ * 	       * another kind of representation (e.g. an XML extract, 
+ * 		 a patch extract)
+ * 	       * another view (e.g. a GITK instance)
+ *             * another kind of repository database (e.g. MySQL)
+ *             * another kind of SCM (e.g. CVS)
+ *             * another more compact representation (e.g. an deltification 
+ * 		 process)
+ * 	* helping to locate versions of stuff when the workspace
+ *        (user) gets confused.
+ * 
+ * NOTE: this would probably be even more useful for the index 
+ * allowing a provably correct workspace undo/redo implementation, 
+ * however, let's bite-off one piece at a time.
+ */
+
+#define REPO_LOG_STOP  (1u << 1)
+#define REPO_LOG_ERROR (1u << 2)
+#define REPO_LOG_FATAL (1u << 4)
+
+struct repo_log_event_data {
+	/**
+	 * Flags set by handlers to communicate actions to the logging API
+	 *     STOP  - the event has been handled and no further dispatch
+	 *             should be performed. Filtering type handlers should
+	 * 	       set this flag.
+	 *     ERROR - a non-fatal error occured, but the logging API
+	 *             should return.
+	 *     FATAL - a fatal event occurred during logging and the logging
+	 * 	       API should die before returning.
+	 */
+	unsigned int flags;
+	
+	/**
+	 * The type of event being logged. It is either an object type
+	 * such as: blob, commit, tree, delta or tag or it is a label.
+	 */
+	char * objtype;
+	
+	/**
+	 * The timestamp of the event being logged.
+	 */
+	struct tm * timestamp;	
+	
+	/**
+	 * The sha1 associated with a repository object event. 
+	 * Set to NULL for label events.
+	 */
+	unsigned char * sha1;
+	
+	/**
+	 * The label associated with the event.
+	 */
+	char * label;
+};
+
+/**
+ * Describes a repository log event handler.
+ * 
+ * Private data associated with the handler can be placed in the 
+ * later parts of a containing data structure.
+ * 
+ * struct private_handler_data {
+ * 	struct repo_log_event_handler handler;
+ * 	char * some_private_data;
+ * 	...
+ * }
+ * repo_log_register_handler(&private_handler_data.handler);
+ * 
+ */
+struct repo_log_event_handler {
+	/**
+	 * This method is called once for each repo log event that occurs.
+	 */	 
+	void (*method)(struct repo_log_event_handler *, struct repo_log_event_data *);
+	
+	/**
+	 * Initialized by repo_log_register_handler. 
+	 * Private to repo-log.c, should not be used or modified elsewhere.
+	 */
+	struct repo_log_event_handler * next;
+}
+
+/*
+ * Answers true if repository logging is enabled.
+ * 
+ * Repository logging is enabled if repo_log_register_handler
+ * has been called or if GIT_REPO_LOG_PATH is set to a 
+ * writeable name.
+ */
+int repo_log_logging_enabled();
+
+/*
+ * Registers a new repo_log_event handler.
+ * 
+ * The method associated with this handler will be invoked
+ * each time a repository event occurs.
+ */
+void repo_log_register_handler(repo_log_event_handler * handler);
+
+/*
+ * Logs a repository event.
+ * 
+ * Returns false if the logging was not successful.
+ */ 
+int repo_log_event(struct tm * tm, char * objtype, unsigned char * sha1);
+
+/*
+ * Writes a label into the repository event log. 
+ * 
+ * The label is validated to ensure it only contains
+ * graphic ASCII characters in the range 0x21 -> 0x7f.
+ * 
+ * Labels are for informational purposes only and need 
+ * not be unique.
+ */ 
+int repo_log_label(char * label);
+
+/*
+ * Logs a repository event, using the timestamp extracted from the (closed) 
+ * file.
+ */
+int repo_log_event_file(char * filename, char * objtype, unsigned char * sha1);
+#endif /* REPOLOG_H */
------------

^ permalink raw reply

* [PROPOSAL] Add a module (repo-log.c) to log repository events.
From: Jon Seymour @ 2005-06-16  4:09 UTC (permalink / raw)
  To: git
In-Reply-To: <20050616035924.31808.qmail@blackcubes.dyndns.org>

A variety of log formats would be possible but the default log format
I intend to use is:

for object events:

     yy-mm-ddThh:mm:ss(+/-)oooo SP object-type SP sha1  LF

for label events:

     yy-mm-ddThh:mm:ss(+/-)oooo SP 'label' SP label LF

The default format uses ASCII text and human readable iso-8601,
locally zoned timestamps so that the logs are easily perused by both
humans and machines.

jon.

^ 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