* Re: [PATCH 1/2] daemon: add tests
From: Clemens Buchacher @ 2012-01-04 15:55 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <7v8vlovavj.fsf@alter.siamese.dyndns.org>
Thanks for your review. Please find fixes in reply to this email. In
order to better show individual changes I have not squashed them into
one commit. For upstream, you will probably want to squash patches 3-6
into patch 2. Patch 2 is the same as the one once queued as part of
cb/daemon-permission-errors.
[PATCH 1/6] t5550: repack everything into one file
[PATCH 2/6] daemon: add tests
[PATCH 3/6] avoid use of pkill
[PATCH 4/6] explain expected exit code
[PATCH 5/6] t5570: everything into one file
[PATCH 6/6] chmod: use lower-case x
On Tue, Jan 03, 2012 at 11:34:08AM -0800, Junio C Hamano wrote:
> >> +
> >> +LIB_DAEMON_PORT=${LIB_DAEMON_PORT-'8121'}
>
> In lib-httpd.sh, LIB_HTTPD_PORT is defined in a similar way, but that is
> always overridden by the users and the convention there is to use the test
> numbers (cf. "git grep LIB_HTTPD_PORT t/"), which should be followed here
> as well.
This you already fixed in the version previously queued and is contained
in [PATCH 2/6] daemon: add tests.
> I am not very keen on the "lib-daemon.sh", GIT_TEST_DAEMON, etc. naming to
> pretend as if "git daemon" will forever be the only daemon we will ever
> ship, by the way. We might one day want to add an inotify daemon, a
> daemon for the git-pubsub protocol or somesuch.
Are you saying that the name "daemon" is too general, and it should
instead be "lib-git-daemon.sh" and GIT_TEST_GIT_DAEMON? Or do you
mean that it is not general enough and it should be called
lib-networking.sh and "GIT_TEST_NETWORKING"?
Either way, I have no preference here. Feel free to change any way you
like.
> >> + # kill git-daemon child of git
> >> + say >&3 "Stopping git daemon ..."
> >> + pkill -P "$DAEMON_PID"
>
> How portable is this one (I usually do not trust use of pkill anywhere)?
I read that it is supposed to be more portable than skill or killall.
But I have no way to research this. I have implemented a workaround
using only 'ps' and 'kill' in [PATCH 3/6] avoid use of pkill.
> >> + wait "$DAEMON_PID"
> >> + ret=$?
> # Please comment what 143 is on this line.
> >> + if test $ret -ne 143
Fixed in [PATCH 4/6] explain expected exit code.
> >> + git --bare repack &&
>
> As the later tests assume there will be only one pack, don't you want at
> least "-a" and possibly "-a -d" here?
Fixed in
[PATCH 1/6] t5550: repack everything into one file,
[PATCH 5/6] t5570: repack everything into one file.
> I find the use of cap X here dubious; it makes your intention unclear.
>
> Are you interested in the current status of 'x' bits on that directory, or
> are you more interested in dropping the executable/searchable bits from
> the directory no matter what its current status is (rhetorical: I fully
> expect that the answer is the latter)?
For directories, upper-case X does not have that meaning. The status is
always overwritten, irrespective of the current status. I wanted to
emphasize the fact that I am changing 'searchable' bits. But since that
does not seem to have the desired effect, I changed it to lower-case in
[PATCH 6/6] chmod: use lower-case x.
Clemens
^ permalink raw reply
* [PATCH 4/6] explain expected exit code
From: Clemens Buchacher @ 2012-01-04 15:55 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at>
---
t/lib-daemon.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/t/lib-daemon.sh b/t/lib-daemon.sh
index 5edced5..4701124 100644
--- a/t/lib-daemon.sh
+++ b/t/lib-daemon.sh
@@ -62,6 +62,10 @@ stop_daemon() {
kill_children "$DAEMON_PID"
wait "$DAEMON_PID"
ret=$?
+ #
+ # We signal TERM=15 to the child and expect the parent to
+ # exit with 143 = 128+15.
+ #
if test $ret -ne 143
then
error "git daemon exited with status: $ret"
--
1.7.8
^ permalink raw reply related
* [PATCH 5/6] t5570: repack everything into one file
From: Clemens Buchacher @ 2012-01-04 15:55 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at>
Subsequently we assume that there is only one pack. Currently this is
true only by accident. Pass '-a -d' to repack in order to guarantee that
assumption to hold true.
The prune-packed command is now redundant since repack -d already calls
it.
---
t/t5570-git-daemon.sh | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index a7d666c..f2b374b 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -50,8 +50,7 @@ test_expect_failure 'remote detects correct HEAD' '
test_expect_success 'prepare pack objects' '
cp -R "$DAEMON_DOCUMENT_ROOT_PATH"/repo.git "$DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git &&
(cd "$DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git &&
- git --bare repack &&
- git --bare prune-packed
+ git --bare repack -a -d
)
'
--
1.7.8
^ permalink raw reply related
* [PATCH 1/6] t5550: repack everything into one file
From: Clemens Buchacher @ 2012-01-04 15:55 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at>
Subsequently we assume that there is only one pack. Currently this is
true only by accident. Pass '-a -d' to repack in order to guarantee that
assumption to hold true.
The prune-packed command is now redundant since repack -d already calls
it.
---
t/t5550-http-fetch.sh | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index 311a33c..7926ab3 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -118,8 +118,7 @@ test_expect_success 'http remote detects correct HEAD' '
test_expect_success 'fetch packed objects' '
cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
- git --bare repack &&
- git --bare prune-packed
+ git --bare repack -a -d
) &&
git clone $HTTPD_URL/dumb/repo_pack.git
'
--
1.7.8
^ permalink raw reply related
* [PATCH 6/6] chmod: use lower-case x
From: Clemens Buchacher @ 2012-01-04 15:55 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at>
---
t/t5570-git-daemon.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index f2b374b..d9667f9 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -92,7 +92,7 @@ test_remote_error()
case $1 in
-x)
shift
- chmod -X "$DAEMON_DOCUMENT_ROOT_PATH/repo.git"
+ chmod -x "$DAEMON_DOCUMENT_ROOT_PATH/repo.git"
;;
-n)
shift
@@ -126,7 +126,7 @@ test_remote_error()
echo "fatal: remote error: $msg: /$repo" >expect &&
test_cmp expect output
ret=$?
- chmod +X "$DAEMON_DOCUMENT_ROOT_PATH/repo.git"
+ chmod +x "$DAEMON_DOCUMENT_ROOT_PATH/repo.git"
(exit $ret)
}
--
1.7.8
^ permalink raw reply related
* [PATCH 3/6] avoid use of pkill
From: Clemens Buchacher @ 2012-01-04 15:55 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at>
---
t/lib-daemon.sh | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/t/lib-daemon.sh b/t/lib-daemon.sh
index 30a89ea..5edced5 100644
--- a/t/lib-daemon.sh
+++ b/t/lib-daemon.sh
@@ -31,6 +31,24 @@ start_daemon() {
DAEMON_PID=$!
}
+kill_children() {
+ parent=$1
+
+ ps -A -o ppid,pid |
+ (
+ # skip header
+ read
+ while read ppid pid
+ do
+ if test x"$ppid" = x"$parent"
+ then
+ echo "$pid"
+ fi
+ done
+ ) |
+ xargs kill
+}
+
stop_daemon() {
if test -z "$DAEMON_PID"
then
@@ -41,7 +59,7 @@ stop_daemon() {
# kill git-daemon child of git
say >&3 "Stopping git daemon ..."
- pkill -P "$DAEMON_PID"
+ kill_children "$DAEMON_PID"
wait "$DAEMON_PID"
ret=$?
if test $ret -ne 143
--
1.7.8
^ permalink raw reply related
* [PATCH 2/6] daemon: add tests
From: Clemens Buchacher @ 2012-01-04 15:55 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at>
The semantics of the git daemon tests are similar to the http
transport tests. In fact, they are only a slightly modified copy
of t5550, plus the newly added remote error tests.
All daemon tests will be skipped unless the environment variable
GIT_TEST_DAEMON is set.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/lib-daemon.sh | 52 +++++++++++++++++
t/t5570-git-daemon.sh | 149 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 201 insertions(+), 0 deletions(-)
create mode 100644 t/lib-daemon.sh
create mode 100755 t/t5570-git-daemon.sh
diff --git a/t/lib-daemon.sh b/t/lib-daemon.sh
new file mode 100644
index 0000000..30a89ea
--- /dev/null
+++ b/t/lib-daemon.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+if test -z "$GIT_TEST_DAEMON"
+then
+ skip_all="Daemon testing disabled (define GIT_TEST_DAEMON to enable)"
+ test_done
+fi
+
+LIB_DAEMON_PORT=${LIB_DAEMON_PORT-'8121'}
+
+DAEMON_PID=
+DAEMON_DOCUMENT_ROOT_PATH="$PWD"/repo
+DAEMON_URL=git://127.0.0.1:$LIB_DAEMON_PORT
+
+start_daemon() {
+ if test -n "$DAEMON_PID"
+ then
+ error "start_daemon already called"
+ fi
+
+ mkdir -p "$DAEMON_DOCUMENT_ROOT_PATH"
+
+ trap 'code=$?; stop_daemon; (exit $code); die' EXIT
+
+ say >&3 "Starting git daemon ..."
+ git daemon --listen=127.0.0.1 --port="$LIB_DAEMON_PORT" \
+ --reuseaddr --verbose \
+ --base-path="$DAEMON_DOCUMENT_ROOT_PATH" \
+ "$@" "$DAEMON_DOCUMENT_ROOT_PATH" \
+ >&3 2>&4 &
+ DAEMON_PID=$!
+}
+
+stop_daemon() {
+ if test -z "$DAEMON_PID"
+ then
+ return
+ fi
+
+ trap 'die' EXIT
+
+ # kill git-daemon child of git
+ say >&3 "Stopping git daemon ..."
+ pkill -P "$DAEMON_PID"
+ wait "$DAEMON_PID"
+ ret=$?
+ if test $ret -ne 143
+ then
+ error "git daemon exited with status: $ret"
+ fi
+ DAEMON_PID=
+}
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
new file mode 100755
index 0000000..a7d666c
--- /dev/null
+++ b/t/t5570-git-daemon.sh
@@ -0,0 +1,149 @@
+#!/bin/sh
+
+test_description='test fetching over git protocol'
+. ./test-lib.sh
+
+LIB_DAEMON_PORT=${LIB_DAEMON_PORT-5570}
+. "$TEST_DIRECTORY"/lib-daemon.sh
+start_daemon
+
+test_expect_success 'setup repository' '
+ echo content >file &&
+ git add file &&
+ git commit -m one
+'
+
+test_expect_success 'create git-accessible bare repository' '
+ mkdir "$DAEMON_DOCUMENT_ROOT_PATH/repo.git" &&
+ (cd "$DAEMON_DOCUMENT_ROOT_PATH/repo.git" &&
+ git --bare init &&
+ : >git-daemon-export-ok
+ ) &&
+ git remote add public "$DAEMON_DOCUMENT_ROOT_PATH/repo.git" &&
+ git push public master:master
+'
+
+test_expect_success 'clone git repository' '
+ git clone $DAEMON_URL/repo.git clone &&
+ test_cmp file clone/file
+'
+
+test_expect_success 'fetch changes via git protocol' '
+ echo content >>file &&
+ git commit -a -m two &&
+ git push public &&
+ (cd clone && git pull) &&
+ test_cmp file clone/file
+'
+
+test_expect_failure 'remote detects correct HEAD' '
+ git push public master:other &&
+ (cd clone &&
+ git remote set-head -d origin &&
+ git remote set-head -a origin &&
+ git symbolic-ref refs/remotes/origin/HEAD > output &&
+ echo refs/remotes/origin/master > expect &&
+ test_cmp expect output
+ )
+'
+
+test_expect_success 'prepare pack objects' '
+ cp -R "$DAEMON_DOCUMENT_ROOT_PATH"/repo.git "$DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+ (cd "$DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+ git --bare repack &&
+ git --bare prune-packed
+ )
+'
+
+test_expect_success 'fetch notices corrupt pack' '
+ cp -R "$DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git "$DAEMON_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+ (cd "$DAEMON_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+ p=`ls objects/pack/pack-*.pack` &&
+ chmod u+w $p &&
+ printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+ ) &&
+ mkdir repo_bad1.git &&
+ (cd repo_bad1.git &&
+ git --bare init &&
+ test_must_fail git --bare fetch $DAEMON_URL/repo_bad1.git &&
+ test 0 = `ls objects/pack/pack-*.pack | wc -l`
+ )
+'
+
+test_expect_success 'fetch notices corrupt idx' '
+ cp -R "$DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git "$DAEMON_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+ (cd "$DAEMON_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+ p=`ls objects/pack/pack-*.idx` &&
+ chmod u+w $p &&
+ printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+ ) &&
+ mkdir repo_bad2.git &&
+ (cd repo_bad2.git &&
+ git --bare init &&
+ test_must_fail git --bare fetch $DAEMON_URL/repo_bad2.git &&
+ test 0 = `ls objects/pack | wc -l`
+ )
+'
+
+test_remote_error()
+{
+ do_export=YesPlease
+ while test $# -gt 0
+ do
+ case $1 in
+ -x)
+ shift
+ chmod -X "$DAEMON_DOCUMENT_ROOT_PATH/repo.git"
+ ;;
+ -n)
+ shift
+ do_export=
+ ;;
+ *)
+ break
+ esac
+ done
+
+ if test $# -ne 3
+ then
+ error "invalid number of arguments"
+ fi
+
+ cmd=$1
+ repo=$2
+ msg=$3
+
+ if test -x "$DAEMON_DOCUMENT_ROOT_PATH/$repo"
+ then
+ if test -n "$do_export"
+ then
+ : >"$DAEMON_DOCUMENT_ROOT_PATH/$repo/git-daemon-export-ok"
+ else
+ rm -f "$DAEMON_DOCUMENT_ROOT_PATH/$repo/git-daemon-export-ok"
+ fi
+ fi
+
+ test_must_fail git "$cmd" "$DAEMON_URL/$repo" 2>output &&
+ echo "fatal: remote error: $msg: /$repo" >expect &&
+ test_cmp expect output
+ ret=$?
+ chmod +X "$DAEMON_DOCUMENT_ROOT_PATH/repo.git"
+ (exit $ret)
+}
+
+msg="access denied or repository not exported"
+test_expect_success 'clone non-existent' "test_remote_error clone nowhere.git '$msg'"
+test_expect_success 'push disabled' "test_remote_error push repo.git '$msg'"
+test_expect_success 'read access denied' "test_remote_error -x fetch repo.git '$msg'"
+test_expect_success 'not exported' "test_remote_error -n fetch repo.git '$msg'"
+
+stop_daemon
+start_daemon --informative-errors
+
+test_expect_success 'clone non-existent' "test_remote_error clone nowhere.git 'no such repository'"
+test_expect_success 'push disabled' "test_remote_error push repo.git 'service not enabled'"
+test_expect_success 'read access denied' "test_remote_error -x fetch repo.git 'no such repository'"
+test_expect_success 'not exported' "test_remote_error -n fetch repo.git 'repository not exported'"
+
+stop_daemon
+test_done
--
1.7.8
^ permalink raw reply related
* Re: [BUG] gitweb generates wrong links in grep search results (git_search_files)
From: Jakub Narębski @ 2012-01-04 16:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Thomas Perl, git
In-Reply-To: <7vhb0cqpix.fsf@alter.siamese.dyndns.org>
On Wed, Jan 4, 2012 at 1:28 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Thomas Perl <th.perl@gmail.com> writes:
>
>> I think I found a bug in gitweb when grep'ing for text in a branch
>> different from "master". Here's how to reproduce it:
>
> Thanks for a detailed report (and thanks for gpodder ;-).
>
> Jakub, care to take a look?
I see the bug: it should be 'hash_base' not 'hash' in href()
creating link to "blob" view in git_search_files().
I'll try to send a fix soon...
--
Jakub Narebski
^ permalink raw reply
* Re: Auto-refresh git-gui
From: Clemens Buchacher @ 2012-01-04 16:33 UTC (permalink / raw)
To: Victor Engmark; +Cc: git
In-Reply-To: <20120104091547.GC3484@victor>
Hi Victor,
On Wed, Jan 04, 2012 at 10:15:47AM +0100, Victor Engmark wrote:
>
> Is there some way to make `git-gui` rescan automatically when anything
> in the repository changes?
How about doing it each time git gui gets focus? Or if that's to
much do it only if it gets focus _and_ the index has changed?
Clemens
^ permalink raw reply
* Re: [PATCH] Catch invalid --depth option passed to clone or fetch
From: Junio C Hamano @ 2012-01-04 17:43 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
In-Reply-To: <1325671315-24931-1-git-send-email-pclouds@gmail.com>
Thanks.
^ permalink raw reply
* Re: [PATCH] gitweb: accept trailing "/" in $project_list
From: Junio C Hamano @ 2012-01-04 17:51 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git
In-Reply-To: <1325671665-16847-1-git-send-email-Matthieu.Moy@imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> The current code is removing the trailing "/", but computing the string
> length on the previous value, i.e. with the trailing "/". Later in the
> code, we do
>
> my $path = substr($File::Find::name, $pfxlen + 1);
>
> And the "$pfxlen + 1" is supposed to mean "the length of the prefix, plus
> 1 for the / separating the prefix and the path", but with an incorrect
> $pfxlen, this basically eats the first character of the path, and yields
> "404 - No projects found".
>
> While we're there, also fix $pfxdepth to use $dir, although a change of 1
> in the depth shouldn't really matter.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> I'm not fluent in Perl, and not familiar at all with gitweb, but this
> sounds a rather obvious (too obvious?) fix.
Yeah, probably not many people use $project_maxdepth with a meaningful
value.
^ permalink raw reply
* Re: [PATCH 1/2] daemon: add tests
From: Junio C Hamano @ 2012-01-04 18:00 UTC (permalink / raw)
To: Clemens Buchacher
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <1325692539-26748-1-git-send-email-drizzd@aon.at>
Clemens Buchacher <drizzd@aon.at> writes:
> Are you saying that the name "daemon" is too general, and it should
> instead be "lib-git-daemon.sh" and GIT_TEST_GIT_DAEMON? Or do you
> mean that it is not general enough and it should be called
> lib-networking.sh and "GIT_TEST_NETWORKING"?
The former. "daemon" is too general and letting "git daemon" squat on that
name makes it harder for other people to build daemons for new git
services and write tests for them.
> Either way, I have no preference here. Feel free to change any way you
> like.
No thanks.
>> >> + # kill git-daemon child of git
>> >> + say >&3 "Stopping git daemon ..."
>> >> + pkill -P "$DAEMON_PID"
>>
>> How portable is this one (I usually do not trust use of pkill anywhere)?
>
> I read that it is supposed to be more portable than skill or killall.
> But I have no way to research this. I have implemented a workaround
> using only 'ps' and 'kill' in [PATCH 3/6] avoid use of pkill.
Yuck, that patch looks even uglier X-<.
Do you really need to kill the children but not the daemon?
^ permalink raw reply
* Re: [PATCH 1/6] t5550: repack everything into one file
From: Junio C Hamano @ 2012-01-04 18:05 UTC (permalink / raw)
To: Clemens Buchacher; +Cc: git
In-Reply-To: <1325692539-26748-2-git-send-email-drizzd@aon.at>
Thanks; I assume this is also signed off?
^ permalink raw reply
* Re: [PATCH 1/2] git-svn, perl/Git.pm: add central method for prompting passwords honoring GIT_ASKPASS and SSH_ASKPASS
From: Junio C Hamano @ 2012-01-04 18:58 UTC (permalink / raw)
To: Sven Strickroth; +Cc: git, Jeff King, Jakub Narebski
In-Reply-To: <4F0405D4.9090102@tu-clausthal.de>
Sven Strickroth <sven.strickroth@tu-clausthal.de> writes:
> Some perl versions, like the one from msys, crash sometimes
> if reading from STDIN wasn't successful and chomp is applied
> to the variable into which was read.
Depending on how widespread such implementations of Perl are, a patch to
fix other uses of chomps might deserve to be on the maintenance track
independent from this patch series. I seem to find many hits to:
$ git grep -e 'chomp *([^)@]*='
already in our codebase.
^ permalink raw reply
* Re: [PATCH 1/2] git-svn, perl/Git.pm: add central method for prompting passwords honoring GIT_ASKPASS and SSH_ASKPASS
From: Junio C Hamano @ 2012-01-04 19:08 UTC (permalink / raw)
To: Sven Strickroth; +Cc: git, Jeff King, Jakub Narebski
In-Reply-To: <4F040E46.5030001@tu-clausthal.de>
Sven Strickroth <sven.strickroth@tu-clausthal.de> writes:
> Am 04.01.2012 08:55 schrieb Sven Strickroth:
>> The Git.pm part is easy, but I also tried to update prompt.c (untested).
>
> I said "easy" and then I mailed the wrong/outdated patch :(
> I'm sorry for the noise.
>
> From: Sven Strickroth <email@cs-ware.de>
> Date: Wed, 4 Jan 2012 08:44:48 +0100
> Subject: [PATCH] Git.pm, prompt: try reading from interactive terminal
> before using SSH_ASKPASS
>
> SVN tries to read reading from interactive terminal before using
> SSH_ASKPASS helper. This change adjust git to behave the same way.
It might be an accurate description of what Subversion does ("tries to" is
the key phrase). I however do not know if it is equivalent to what your
patch does.
When GIT_ASKPASS is not set, the $prompt is given to the standard error
stream unconditionally and then the "require Term::ReadKey" codepath is
used. When the terminal is unavailable, you might get undef in $ret and be
able to fall back on SSH_ASKPASS part, but you cannot take back the noise
you have given to the standard error stream.
Is there a way to ask Term::ReadKey (or possibly some other module) if we
will be able to interact with the terminal _before_ we give that prompt?
The simplest would be to do this, I would think, but I didn't test it.
if (!defined $ret && -t) {
print STDERR $prompt;
if ($isPassword) {
...
}
if (!defined $ret) {
$ret = _prompt($ENV{'SSH_ASKPASS'}, $prompt);
}
^ permalink raw reply
* Re: [PATCH 1/2] git-svn, perl/Git.pm: add central method for prompting passwords honoring GIT_ASKPASS and SSH_ASKPASS
From: Sven Strickroth @ 2012-01-04 19:20 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jeff King, Jakub Narebski
In-Reply-To: <7vmxa3pa6e.fsf@alter.siamese.dyndns.org>
Am 04.01.2012 19:58 schrieb Junio C Hamano:
> Depending on how widespread such implementations of Perl are, a patch to
> fix other uses of chomps might deserve to be on the maintenance track
> independent from this patch series. I seem to find many hits to:
>
> $ git grep -e 'chomp *([^)@]*='
>
> already in our codebase.
I'm not sure if this is a general chomp problem. I think that this is
more related to a variable which is accessed after a readfailure on STDIN.
Reported to msys team.
--
Best regards,
Sven Strickroth
ClamAV, a GPL anti-virus toolkit http://www.clamav.net
PGP key id F5A9D4C4 @ any key-server
^ permalink raw reply
* Re: How to deal with historic tar-balls
From: Philip Oakley @ 2012-01-04 20:04 UTC (permalink / raw)
To: Dirk Süsserott; +Cc: Tomas Carnecky, nn6eumtr, Git List
In-Reply-To: <4F01F6D2.8020005@dirk.my1.cc>
Many thanks - That explanation works for me. I just hadn't seen the
association.
Philip
From: "Dirk Süsserott" <newsletter@dirk.my1.cc>: Monday, January 02, 2012
6:26 PM
> Am 02.01.2012 11:07 schrieb Philip Oakley:
>>> From: "Tomas Carnecky" <tom@dbservice.com> : Sunday, January 01, 2012
>>> 12:27 AM
>>>> On 12/31/11 8:04 PM, nn6eumtr wrote:
>>>>> I have a number of older projects that I want to bring into a git
>>>>> repository. They predate a lot of the popular scm systems, so they are
>>>>> primarily a collection of tarballs today.
>>>> There is a script which will import sources from multiple tarballs,
>>>> creating a commit with the contents of each tarball. It's in the git
>>>> repository under contrib/fast-import/import-tars.perl.
>>> I wasn't aware of those scripts. I'll be having a look at the zip import
>>> script for my needs.
>>>
>>>> tom
>>> Philip
>>>
>> I had a look at the script but Python isn't part of the Msysgit install,
>> so the example wouldn't run.
>>
>> Also I couldn't see how the "fast_import.write(" method was being
>> created - my ignorance of Python? Otherwise I could look at scripting it.
>>
>> Philip
>
> Philip,
>
> I'm not a Python guy, but I think fast_import.write() writes sth. to
> whatever the popen() call in line 24 returned:
>
> fast_import = popen('git fast-import --quiet', 'w')
>
> I guess it returns a filehandle and 'git fast-import' reads its data
> from stdin. My guess is, that -- instead of writing to that pipe -- you
> could as well write everything to a temporary file and finally call
>
> git fast-import < $tempfile
>
> But that's only a guess.
>
> Dirk
>>
^ permalink raw reply
* Re: [PATCH 1/2] daemon: add tests
From: Junio C Hamano @ 2012-01-04 20:13 UTC (permalink / raw)
To: Clemens Buchacher
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <7vy5tnpcuw.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Clemens Buchacher <drizzd@aon.at> writes:
> ...
>>> >> + # kill git-daemon child of git
>>> >> + say >&3 "Stopping git daemon ..."
>>> >> + pkill -P "$DAEMON_PID"
>>>
>>> How portable is this one (I usually do not trust use of pkill anywhere)?
>>
>> I read that it is supposed to be more portable than skill or killall.
>> But I have no way to research this. I have implemented a workaround
>> using only 'ps' and 'kill' in [PATCH 3/6] avoid use of pkill.
>
> Yuck, that patch looks even uglier X-<.
>
> Do you really need to kill the children but not the daemon?
To reduce round-trip cost, here is what I'll queue for now.
-- >8 --
From: Clemens Buchacher <drizzd@aon.at>
Date: Wed, 4 Jan 2012 16:55:35 +0100
Subject: [PATCH] daemon: add tests
The semantics of the git daemon tests are similar to the http transport
tests. In fact, they are only a slightly modified copy of t5550, plus the
newly added remote error tests.
All git-daemon tests will be skipped unless the environment variable
GIT_TEST_GIT_DAEMON is set.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/lib-git-daemon.sh | 56 ++++++++++++++++++
t/t5570-git-daemon.sh | 148 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 204 insertions(+), 0 deletions(-)
create mode 100644 t/lib-git-daemon.sh
create mode 100755 t/t5570-git-daemon.sh
diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh
new file mode 100644
index 0000000..c0ff9e2
--- /dev/null
+++ b/t/lib-git-daemon.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+if test -z "$GIT_TEST_GIT_DAEMON"
+then
+ skip_all="git-daemon testing disabled (define GIT_TEST_GIT_DAEMON to enable)"
+ test_done
+fi
+
+LIB_GIT_DAEMON_PORT=${LIB_GIT_DAEMON_PORT-'8121'}
+
+GIT_DAEMON_PID=
+GIT_DAEMON_DOCUMENT_ROOT_PATH="$PWD"/repo
+GIT_DAEMON_URL=git://127.0.0.1:$LIB_GIT_DAEMON_PORT
+
+start_git_daemon() {
+ if test -n "$GIT_DAEMON_PID"
+ then
+ error "start_git_daemon already called"
+ fi
+
+ mkdir -p "$GIT_DAEMON_DOCUMENT_ROOT_PATH"
+
+ trap 'code=$?; stop_git_daemon; (exit $code); die' EXIT
+
+ say >&3 "Starting git daemon ..."
+ git daemon --listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \
+ --reuseaddr --verbose \
+ --base-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
+ "$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
+ >&3 2>&4 &
+ GIT_DAEMON_PID=$!
+}
+
+stop_git_daemon() {
+ if test -z "$GIT_DAEMON_PID"
+ then
+ return
+ fi
+
+ trap 'die' EXIT
+
+ # kill git-daemon child of git
+ say >&3 "Stopping git daemon ..."
+ pkill -P "$GIT_DAEMON_PID"
+ wait "$GIT_DAEMON_PID"
+ ret=$?
+ #
+ # We signal TERM=15 to the child and expect the parent to
+ # exit with 143 = 128+15.
+ #
+ if test $ret -ne 143
+ then
+ error "git daemon exited with status: $ret"
+ fi
+ GIT_DAEMON_PID=
+}
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
new file mode 100755
index 0000000..7cbc999
--- /dev/null
+++ b/t/t5570-git-daemon.sh
@@ -0,0 +1,148 @@
+#!/bin/sh
+
+test_description='test fetching over git protocol'
+. ./test-lib.sh
+
+LIB_GIT_DAEMON_PORT=${LIB_GIT_DAEMON_PORT-5570}
+. "$TEST_DIRECTORY"/lib-git-daemon.sh
+start_git_daemon
+
+test_expect_success 'setup repository' '
+ echo content >file &&
+ git add file &&
+ git commit -m one
+'
+
+test_expect_success 'create git-accessible bare repository' '
+ mkdir "$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo.git" &&
+ (cd "$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo.git" &&
+ git --bare init &&
+ : >git-daemon-export-ok
+ ) &&
+ git remote add public "$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo.git" &&
+ git push public master:master
+'
+
+test_expect_success 'clone git repository' '
+ git clone "$GIT_DAEMON_URL/repo.git" clone &&
+ test_cmp file clone/file
+'
+
+test_expect_success 'fetch changes via git protocol' '
+ echo content >>file &&
+ git commit -a -m two &&
+ git push public &&
+ (cd clone && git pull) &&
+ test_cmp file clone/file
+'
+
+test_expect_failure 'remote detects correct HEAD' '
+ git push public master:other &&
+ (cd clone &&
+ git remote set-head -d origin &&
+ git remote set-head -a origin &&
+ git symbolic-ref refs/remotes/origin/HEAD > output &&
+ echo refs/remotes/origin/master > expect &&
+ test_cmp expect output
+ )
+'
+
+test_expect_success 'prepare pack objects' '
+ cp -R "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo.git "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+ (cd "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+ git --bare repack -a -d
+ )
+'
+
+test_expect_success 'fetch notices corrupt pack' '
+ cp -R "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+ (cd "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+ p=`ls objects/pack/pack-*.pack` &&
+ chmod u+w $p &&
+ printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+ ) &&
+ mkdir repo_bad1.git &&
+ (cd repo_bad1.git &&
+ git --bare init &&
+ test_must_fail git --bare fetch "$GIT_DAEMON_URL/repo_bad1.git" &&
+ test 0 = `ls objects/pack/pack-*.pack | wc -l`
+ )
+'
+
+test_expect_success 'fetch notices corrupt idx' '
+ cp -R "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+ (cd "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+ p=`ls objects/pack/pack-*.idx` &&
+ chmod u+w $p &&
+ printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+ ) &&
+ mkdir repo_bad2.git &&
+ (cd repo_bad2.git &&
+ git --bare init &&
+ test_must_fail git --bare fetch "$GIT_DAEMON_URL/repo_bad2.git" &&
+ test 0 = `ls objects/pack | wc -l`
+ )
+'
+
+test_remote_error()
+{
+ do_export=YesPlease
+ while test $# -gt 0
+ do
+ case $1 in
+ -x)
+ shift
+ chmod -x "$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo.git"
+ ;;
+ -n)
+ shift
+ do_export=
+ ;;
+ *)
+ break
+ esac
+ done
+
+ if test $# -ne 3
+ then
+ error "invalid number of arguments"
+ fi
+
+ cmd=$1
+ repo=$2
+ msg=$3
+
+ if test -x "$GIT_DAEMON_DOCUMENT_ROOT_PATH/$repo"
+ then
+ if test -n "$do_export"
+ then
+ : >"$GIT_DAEMON_DOCUMENT_ROOT_PATH/$repo/git-daemon-export-ok"
+ else
+ rm -f "$GIT_DAEMON_DOCUMENT_ROOT_PATH/$repo/git-daemon-export-ok"
+ fi
+ fi
+
+ test_must_fail git "$cmd" "$GIT_DAEMON_URL/$repo" 2>output &&
+ echo "fatal: remote error: $msg: /$repo" >expect &&
+ test_cmp expect output
+ ret=$?
+ chmod +x "$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo.git"
+ (exit $ret)
+}
+
+msg="access denied or repository not exported"
+test_expect_success 'clone non-existent' "test_remote_error clone nowhere.git '$msg'"
+test_expect_success 'push disabled' "test_remote_error push repo.git '$msg'"
+test_expect_success 'read access denied' "test_remote_error -x fetch repo.git '$msg'"
+test_expect_success 'not exported' "test_remote_error -n fetch repo.git '$msg'"
+
+stop_git_daemon
+start_git_daemon --informative-errors
+
+test_expect_success 'clone non-existent' "test_remote_error clone nowhere.git 'no such repository'"
+test_expect_success 'push disabled' "test_remote_error push repo.git 'service not enabled'"
+test_expect_success 'read access denied' "test_remote_error -x fetch repo.git 'no such repository'"
+test_expect_success 'not exported' "test_remote_error -n fetch repo.git 'repository not exported'"
+
+stop_git_daemon
+test_done
--
1.7.8.2.340.gd18f0f
^ permalink raw reply related
* Re: [PATCH 1/2] daemon: add tests
From: Clemens Buchacher @ 2012-01-04 20:40 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <7vy5tnpcuw.fsf@alter.siamese.dyndns.org>
On Wed, Jan 04, 2012 at 10:00:07AM -0800, Junio C Hamano wrote:
>
> >> >> + # kill git-daemon child of git
> >> >> + say >&3 "Stopping git daemon ..."
> >> >> + pkill -P "$DAEMON_PID"
> >>
> >> How portable is this one (I usually do not trust use of pkill anywhere)?
> >
> > I read that it is supposed to be more portable than skill or killall.
> > But I have no way to research this. I have implemented a workaround
> > using only 'ps' and 'kill' in [PATCH 3/6] avoid use of pkill.
>
> Yuck, that patch looks even uglier X-<.
>
> Do you really need to kill the children but not the daemon?
If I kill just the parent "git daemon" command, then the actual
git-daemon (started by run_command) will be left behind.
^ permalink raw reply
* git log --since --until
From: Hilco Wijbenga @ 2012-01-04 21:46 UTC (permalink / raw)
To: Git Users
Hi all,
I need to write sort of a report listing what we worked on (month by
month) over the last year. Yippie. ;-)
Luckily most of the information I can get from our Git logs but I
noticed some "anomalies". The quotes are there because I do understand
(or I think I do anyway) why those "anomalies" are there.
As an example, I ran (on master)
git log --since="01-Dec-2011" --until="31-Dec-2011"
The returned list of commits also included a few from November. I'm
guessing that's because --since and --until simply determine a start
commit and an end commit in master and any commit that falls in that
range is included, whether its actual commit date is in the originally
specified date range or not.
Is there a way to just get the commits made in December? (I can
manually go through the list, of course, [and that's probably what
I'll do] but playing with Git is more fun than writing a report. ;-) )
Cheers,
Hilco
^ permalink raw reply
* [PATCH 1/3] verify_signed_buffer: fix stale comment
From: Junio C Hamano @ 2012-01-04 22:10 UTC (permalink / raw)
To: git
In-Reply-To: <1325715058-11984-1-git-send-email-gitster@pobox.com>
The function used to take an integer flag to specify where the output
should go, but these days we supply a strbuf to receive it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
gpg-interface.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/gpg-interface.c b/gpg-interface.c
index 18630ff..09ab64a 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -95,10 +95,7 @@ int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *sig
/*
* Run "gpg" to see if the payload matches the detached signature.
- * gpg_output_to tells where the output from "gpg" should go:
- * < 0: /dev/null
- * = 0: standard error of the calling process
- * > 0: the specified file descriptor
+ * gpg_output, when set, receives the diagnostic output from GPG.
*/
int verify_signed_buffer(const char *payload, size_t payload_size,
const char *signature, size_t signature_size,
--
1.7.8.2.340.gd18f0f
^ permalink raw reply related
* [PATCH 2/3] log-tree.c: small refactor in show_signature()
From: Junio C Hamano @ 2012-01-04 22:10 UTC (permalink / raw)
To: git
In-Reply-To: <1325715058-11984-1-git-send-email-gitster@pobox.com>
The next patch needs to show the result of signature verification on a
mergetag extended header in a way similar to how embedded signature for
the commit object itself is shown. Separate out the logic to go through
the message lines and show them in the "error" color (highlighted) or the
"correct" color (dim).
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
log-tree.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 142ba51..005c5a5 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -404,13 +404,27 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
*extra_headers_p = extra_headers;
}
+static void show_sig_lines(struct rev_info *opt, int status, const char *bol)
+{
+ const char *color, *reset, *eol;
+
+ color = diff_get_color_opt(&opt->diffopt,
+ status ? DIFF_WHITESPACE : DIFF_FRAGINFO);
+ reset = diff_get_color_opt(&opt->diffopt, DIFF_RESET);
+ while (*bol) {
+ eol = strchrnul(bol, '\n');
+ printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset,
+ *eol ? "\n" : "");
+ bol = (*eol) ? (eol + 1) : eol;
+ }
+}
+
static void show_signature(struct rev_info *opt, struct commit *commit)
{
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
struct strbuf gpg_output = STRBUF_INIT;
int status;
- const char *color, *reset, *bol, *eol;
if (parse_signed_commit(commit->object.sha1, &payload, &signature) <= 0)
goto out;
@@ -421,17 +435,7 @@ static void show_signature(struct rev_info *opt, struct commit *commit)
if (status && !gpg_output.len)
strbuf_addstr(&gpg_output, "No signature\n");
- color = diff_get_color_opt(&opt->diffopt,
- status ? DIFF_WHITESPACE : DIFF_FRAGINFO);
- reset = diff_get_color_opt(&opt->diffopt, DIFF_RESET);
-
- bol = gpg_output.buf;
- while (*bol) {
- eol = strchrnul(bol, '\n');
- printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset,
- *eol ? "\n" : "");
- bol = (*eol) ? (eol + 1) : eol;
- }
+ show_sig_lines(opt, status, gpg_output.buf);
out:
strbuf_release(&gpg_output);
--
1.7.8.2.340.gd18f0f
^ permalink raw reply related
* [PATCH 0/3] More on pulling signed tags
From: Junio C Hamano @ 2012-01-04 22:10 UTC (permalink / raw)
To: git
This extends on the earlier topic to pull and merge signed tags. So far,
we did record them for later auditing, but did not have an easy way to
perform the auditing, other than manually extracting the information from
the commit object.
Applies on top of the merge between the current 'master' and the
'jc/signed-commit' topic still in 'next', as the latter topic already has
necessary infrastructure to hook into the "log" machinery to show the
signatures embedded in commit objects with the "--show-signature" option.
Help on adding tests, docs and tying loose ends are very much appreciated.
A sample workflow with the command may look like this:
$ git checkout v1.7.8^0
$ git pull $elsewhere v1.7.8.2
$ git show -s --show-signature
commit e00ee29c760ae27c177ec16adb8c94b85909f464
parent #2, tagged 'v1.7.8.2'
gpg: Signature made Wed 28 Dec 2011 12:03:39 PM PST using RSA key ID 96AFE6CB
gpg: Good signature from "Junio C Hamano <gitster@pobox.com>"
gpg: aka "Junio C Hamano <junio@pobox.com>"
gpg: aka "Junio C Hamano <jch@google.com>"
Merge: 406da78 f3f778d
Author: Junio C Hamano <gitster@pobox.com>
Date: Wed Jan 4 14:05:03 2012 -0800
Merge tag 'v1.7.8.2' of ../git into HEAD
Git 1.7.8.2
$ git commit -S --amend --no-edit
commit df409f0d0b1f3f521dd0fd2baf6ecf01495c0191
gpg: Signature made Wed 04 Jan 2012 02:05:26 PM PST using RSA key ID 96AFE6CB
gpg: Good signature from "Junio C Hamano <gitster@pobox.com>"
gpg: aka "Junio C Hamano <junio@pobox.com>"
gpg: aka "Junio C Hamano <jch@google.com>"
parent #2, tagged 'v1.7.8.2'
gpg: Signature made Wed 28 Dec 2011 12:03:39 PM PST using RSA key ID 96AFE6CB
gpg: Good signature from "Junio C Hamano <gitster@pobox.com>"
gpg: aka "Junio C Hamano <junio@pobox.com>"
gpg: aka "Junio C Hamano <jch@google.com>"
Merge: 406da78 f3f778d
Author: Junio C Hamano <gitster@pobox.com>
Date: Wed Jan 4 14:05:03 2012 -0800
Merge tag 'v1.7.8.2' of ../git into HEAD
Git 1.7.8.2
Junio C Hamano (3):
verify_signed_buffer: fix stale comment
log-tree.c: small refactor in show_signature()
log-tree: show mergetag in log --show-signature output
gpg-interface.c | 5 +--
log-tree.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 92 insertions(+), 17 deletions(-)
--
1.7.8.2.340.gd18f0f
^ permalink raw reply
* [PATCH 3/3] log-tree: show mergetag in log --show-signature output
From: Junio C Hamano @ 2012-01-04 22:10 UTC (permalink / raw)
To: git
In-Reply-To: <1325715058-11984-1-git-send-email-gitster@pobox.com>
A commit object that merges a signed tag records the "mergetag" extended
header. Check the validity of the GPG signature on it, and show it in a
way similar to how "gpgsig" extended header is shown.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
log-tree.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 75 insertions(+), 1 deletions(-)
diff --git a/log-tree.c b/log-tree.c
index 005c5a5..b87dd53 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -443,6 +443,78 @@ static void show_signature(struct rev_info *opt, struct commit *commit)
strbuf_release(&signature);
}
+static int which_parent(const unsigned char *sha1, const struct commit *commit)
+{
+ int nth;
+ const struct commit_list *parent;
+
+ for (nth = 0, parent = commit->parents; parent; parent = parent->next) {
+ if (!hashcmp(parent->item->object.sha1, sha1))
+ return nth;
+ nth++;
+ }
+ return -1;
+}
+
+static void show_one_mergetag(struct rev_info *opt,
+ struct commit_extra_header *extra,
+ struct commit *commit)
+{
+ unsigned char sha1[20];
+ struct tag *tag;
+ struct strbuf verify_message;
+ int status, nth;
+ size_t payload_size, gpg_message_offset;
+
+ hash_sha1_file(extra->value, extra->len, typename(OBJ_TAG), sha1);
+ tag = lookup_tag(sha1);
+ if (!tag)
+ return; /* error message already given */
+
+ strbuf_init(&verify_message, 256);
+ if (parse_tag_buffer(tag, extra->value, extra->len))
+ strbuf_addstr(&verify_message, "malformed mergetag\n");
+ else if ((nth = which_parent(tag->tagged->sha1, commit)) < 0)
+ strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
+ tag->tag, tag->tagged->sha1);
+ else
+ strbuf_addf(&verify_message,
+ "parent #%d, tagged '%s'\n", nth + 1, tag->tag);
+ gpg_message_offset = verify_message.len;
+
+ payload_size = parse_signature(extra->value, extra->len);
+ if ((extra->len <= payload_size) ||
+ (verify_signed_buffer(extra->value, payload_size,
+ extra->value + payload_size,
+ extra->len - payload_size,
+ &verify_message) &&
+ verify_message.len <= gpg_message_offset)) {
+ strbuf_addstr(&verify_message, "No signature\n");
+ status = -1;
+ }
+ else if (strstr(verify_message.buf + gpg_message_offset,
+ ": Good signature from "))
+ status = 0;
+ else
+ status = -1;
+
+ show_sig_lines(opt, status, verify_message.buf);
+ strbuf_release(&verify_message);
+}
+
+static void show_mergetag(struct rev_info *opt, struct commit *commit)
+{
+ struct commit_extra_header *extra, *to_free;
+
+ to_free = read_commit_extra_headers(commit);
+ for (extra = to_free; extra; extra = extra->next) {
+ if (strcmp(extra->key, "mergetag"))
+ continue; /* not a merge tag */
+ show_one_mergetag(opt, extra, commit);
+ }
+ free_commit_extra_headers(to_free);
+}
+
void show_log(struct rev_info *opt)
{
struct strbuf msgbuf = STRBUF_INIT;
@@ -554,8 +626,10 @@ void show_log(struct rev_info *opt)
}
}
- if (opt->show_signature)
+ if (opt->show_signature) {
show_signature(opt, commit);
+ show_mergetag(opt, commit);
+ }
if (!commit->buffer)
return;
--
1.7.8.2.340.gd18f0f
^ permalink raw reply related
* Re: [PATCH 1/2] daemon: add tests
From: Junio C Hamano @ 2012-01-04 22:15 UTC (permalink / raw)
To: Clemens Buchacher
Cc: git, Jonathan Nieder, Jeff King, Erik Faye-Lund, Ilari Liusvaara,
Nguyễn Thái Ngọc Duy
In-Reply-To: <20120104204017.GC27567@ecki.lan>
Clemens Buchacher <drizzd@aon.at> writes:
> On Wed, Jan 04, 2012 at 10:00:07AM -0800, Junio C Hamano wrote:
>>
>> >> >> + # kill git-daemon child of git
>> >> >> + say >&3 "Stopping git daemon ..."
>> >> >> + pkill -P "$DAEMON_PID"
>> >>
>> >> How portable is this one (I usually do not trust use of pkill anywhere)?
>> >
>> > I read that it is supposed to be more portable than skill or killall.
>> > But I have no way to research this. I have implemented a workaround
>> > using only 'ps' and 'kill' in [PATCH 3/6] avoid use of pkill.
>>
>> Yuck, that patch looks even uglier X-<.
>>
>> Do you really need to kill the children but not the daemon?
>
> If I kill just the parent "git daemon" command, then the actual
> git-daemon (started by run_command) will be left behind.
Sounds like we would be better off with a new "--foreground" option other
daemon-ish projects seem to have?
^ 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