* Re: [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables
From: Brandon Casey @ 2008-06-19 18:12 UTC (permalink / raw)
To: Mike Hommey; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <frLVfPcFTL8gWg3cEzx3q-MMBWxW3Ts2EnBH2U39k5_QFQTfThtN-A@cipher.nrlssc.navy.mil>
Brandon Casey wrote:
> If I change #!/bin/sh to #!/bin/bash I get what is expected:
>
> foo: yo adrian
> foo: wo adrian
>
> #!/bin/ksh
> foo:
> foo: yo adrian
Unless I'm on solaris, then #!/bin/ksh gives me the same result
as bash:
foo: yo adrian
foo: wo adrian
-brandon
^ permalink raw reply
* Re: [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables
From: Brandon Casey @ 2008-06-19 18:07 UTC (permalink / raw)
To: Mike Hommey; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <20080619175639.GA1604@glandium.org>
Mike Hommey wrote:
> On Thu, Jun 19, 2008 at 12:44:23PM -0500, Brandon Casey wrote:
>> Mike Hommey wrote:
>>> On Thu, Jun 19, 2008 at 12:32:02PM -0500, Brandon Casey wrote:
>>>> - test_must_fail GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
>>>> + # We intentionally do not use test_must_fail on the next line since the
>>>> + # mechanism does not work when setting environment variables inline
>>>> + ! GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
>>> Doesn't GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" test_must_fail git commit
>>> work ?
>> That leaves GIT_EDITOR set to the new value after the command completes.
>
> It really shouldn't.
The change you suggested is also what I tried first. Looks like it depends on the
shell. On my system /bin/sh is a symlink to /bin/bash and that is the behavior
I observed. On other shells the assignment is not passed to the environment of
the called procedure at all.
Here is an example script:
#!/bin/sh
test_must_fail () {
"$@"
test $? -gt 0 -a $? -le 129
}
foo='wo adrian'
foo='yo adrian' test_must_fail sh -c 'echo foo: $foo'
echo "foo: $foo"
When /bin/sh is a symlink to bash, I get:
foo: yo adrian
foo: yo adrian
If I change #!/bin/sh to #!/bin/bash I get what is expected:
foo: yo adrian
foo: wo adrian
#!/bin/ksh
foo:
foo: yo adrian
#!/bin/dash
foo:
foo: yo adrian
-brandon
^ permalink raw reply
* Re: [PATCH] Authentication support for pserver
From: Ævar Arnfjörð Bjarmason @ 2008-06-19 17:38 UTC (permalink / raw)
To: Martin Langhoff; +Cc: Junio C Hamano, git, martyn, martin, avar
In-Reply-To: <86iqzyse9u.fsf@cpan.org>
avar@cpan.org (Ævar Arnfjörð Bjarmason) writes:
> avar@cpan.org (Ævar Arnfjörð Bjarmason) writes:
>
>> Better late than never, here's a more complete and hopefully final patch
>> to add authentication support to CVS. Thanks to Sam Vilain for
>> contributing and kicking me into action.
>>
>> Now you specify a user:password authentication database in the [gitcvs]
>> section. The passwords are crypt()-ed and can be produced by htpasswd,
>> example config file:
>>
>> [gitcvs]
>> enabled = 1
>> authdb = /tmp/authdb.htpasswd
>>
>> The patch can be pulled from git://git.nix.is/avar/git
>>
>> It's also produced below:
>
> The patch needed a small fix, I didn't exit(1) after an error
> condition[1]. This can also be got at git://git.nix.is/avar/git and is
> produced in full below:
>
>
> From 5900732b52c3a693bfb36c0bf56e3c5eb83ef65e Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= <avar@cpan.org>
> Date: Fri, 14 Dec 2007 08:08:46 +0000
> Subject: [PATCH] git-cvsserver: authentication support for pserver
> MIME-Version: 1.0
> Content-Type: text/plain; charset=utf-8
> Content-Transfer-Encoding: 8bit
>
> Allow git-cvsserver to use authentication over pserver mode. The
> pserver user/password database is stored in the config file for each
> repository.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avar@cpan.org>
> Worriedly-Acked-by: Martin Langhoff <martin.langhoff@gmail.com>
> ---
> Documentation/git-cvsserver.txt | 21 +++++++++--
> git-cvsserver.perl | 74 ++++++++++++++++++++++++++++++++++----
> 2 files changed, 83 insertions(+), 12 deletions(-)
>
> diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
> index d3e9993..98183d4 100644
> --- a/Documentation/git-cvsserver.txt
> +++ b/Documentation/git-cvsserver.txt
> @@ -69,9 +69,6 @@ plugin. Most functionality works fine with both of these clients.
> LIMITATIONS
> -----------
>
> -Currently cvsserver works over SSH connections for read/write clients, and
> -over pserver for anonymous CVS access.
> -
> CVS clients cannot tag, branch or perform GIT merges.
>
> git-cvsserver maps GIT branches to CVS modules. This is very different
> @@ -81,7 +78,7 @@ one or more directories.
> INSTALLATION
> ------------
>
> -1. If you are going to offer anonymous CVS access via pserver, add a line in
> +1. If you are going to offer CVS access via pserver, add a line in
> /etc/inetd.conf like
> +
> --
> @@ -98,6 +95,22 @@ looks like
> cvspserver stream tcp nowait nobody /usr/bin/git-cvsserver git-cvsserver pserver
>
> ------
> +
> +Only anonymous access is provided by pserve by default. To commit you
> +will have to create pserver accounts, simply add a [gitcvs.users]
> +section to the repositories you want to access, for example:
> +
> +------
> +
> + [gitcvs.users]
> + someuser = somepassword
> + otheruser = otherpassword
> +
> +------
> +Then provide your password via the pserver method, for example:
> +------
> + cvs -d:pserver:someuser:somepassword <at> server/path/repo.git co <HEAD_name>
> +------
> No special setup is needed for SSH access, other than having GIT tools
> in the PATH. If you have clients that do not accept the CVS_SERVER
> environment variable, you can rename git-cvsserver to cvs.
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index afe3d0b..9bc2ff5 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -150,12 +150,35 @@ if ($state->{method} eq 'pserver') {
> exit 1;
> }
> $line = <STDIN>; chomp $line;
> - unless ($line eq 'anonymous') {
> - print "E Only anonymous user allowed via pserver\n";
> - print "I HATE YOU\n";
> - exit 1;
> + my $user = $line;
> + $line = <STDIN>; chomp $line;
> + my $password = $line;
> +
> + unless ($user eq 'anonymous') {
> + # Trying to authenticate a user
> + if (not exists $cfg->{gitcvs}->{users}) {
> + print "E the repo config file needs a [gitcvs.users] section with user/password key-value pairs\n";
> + print "I HATE YOU\n";
> + exit 1;
> + } elsif (exists $cfg->{gitcvs}->{users} and not exists $cfg->{gitcvs}->{users}->{$user}) {
> + #print "E the repo config file has a [gitcvs.users] section but the user $user is not defined in it\n";
> + print "I HATE YOU\n";
> + exit 1;
> + } else {
> + my $descrambled_password = descramble($password);
> + my $cleartext_password = $cfg->{gitcvs}->{users}->{$user};
> + if ($descrambled_password ne $cleartext_password) {
> + #print "E The password supplied for user $user was incorrect\n";
> + print "I HATE YOU\n";
> + exit 1;
> + }
> + # else fall through to LOVE
> + }
> }
> - $line = <STDIN>; chomp $line; # validate the password?
> +
> + # For checking whether the user is anonymous on commit
> + $state->{user} = $user;
> +
> $line = <STDIN>; chomp $line;
> unless ($line eq "END $request REQUEST") {
> die "E Do not understand $line -- expecting END $request REQUEST\n";
> @@ -273,7 +296,7 @@ sub req_Root
> }
> foreach my $line ( @gitvars )
> {
> - next unless ( $line =~ /^(gitcvs)\.(?:(ext|pserver)\.)?([\w-]+)=(.*)$/ );
> + next unless ( $line =~ /^(gitcvs)\.(?:(ext|pserver|users)\.)?([\w-]+)=(.*)$/ );
> unless ($2) {
> $cfg->{$1}{$3} = $4;
> } else {
> @@ -1176,9 +1199,9 @@ sub req_ci
>
> $log->info("req_ci : " . ( defined($data) ? $data : "[NULL]" ));
>
> - if ( $state->{method} eq 'pserver')
> + if ($state->{method} eq 'pserver' and $state->{user} eq 'anonymous')
> {
> - print "error 1 pserver access cannot commit\n";
> + print "error 1 anonymous user cannot commit via pserver\n";
> exit;
> }
>
> @@ -2107,6 +2130,41 @@ sub kopts_from_path
> }
> }
>
> +
> +sub descramble
> +{
> + # This table is from src/scramble.c in the CVS source
> + my @SHIFTS = (
> + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
> + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
> + 114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87,
> + 111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105,
> + 41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35,
> + 125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56,
> + 36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
> + 58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223,
> + 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
> + 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
> + 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
> + 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
> + 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
> + 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
> + 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
> + 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
> + );
> + my ($str) = @_;
> +
> + # This should never happen, the same password format (A) bas been
> + # used by CVS since the beginning of time
> + $str =~ s/^(.)//;
> + die "invalid password format $1" unless $1 eq 'A';
> +
> + $str =~ s/(.)/chr $SHIFTS[ord $1]/ge;
> +
> + return $str;
> +}
> +
> +
> package GITCVS::log;
>
> ####
> --
> 1.5.3.rc3.120.g68d422
>
>
> From f59c255ed14c5b80d5328f94f6934461cfe454da Mon Sep 17 00:00:00 2001
> From: Sam Vilain <sam.vilain@catalyst.net.nz>
> Date: Fri, 7 Mar 2008 11:03:14 +1300
> Subject: [PATCH] git-cvsserver: use a password file cvsserver pserver
>
> If a git repository is shared via HTTP, the config file is typically
> visible. Use an external file instead.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avar@cpan.org>
> ---
> Documentation/git-cvsserver.txt | 21 ++++++++++++++++-----
> git-cvsserver.perl | 27 ++++++++++++++-------------
> 2 files changed, 30 insertions(+), 18 deletions(-)
>
> diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
> index 98183d4..c642f12 100644
> --- a/Documentation/git-cvsserver.txt
> +++ b/Documentation/git-cvsserver.txt
> @@ -97,16 +97,27 @@ looks like
> ------
>
> Only anonymous access is provided by pserve by default. To commit you
> -will have to create pserver accounts, simply add a [gitcvs.users]
> -section to the repositories you want to access, for example:
> +will have to create pserver accounts, simply add a gitcvs.authdb
> +setting in the config file of the repositories you want the cvsserver
> +to allow writes to, for example:
>
> ------
>
> - [gitcvs.users]
> - someuser = somepassword
> - otheruser = otherpassword
> + [gitcvs]
> + authdb = /etc/cvsserver/passwd
>
> ------
> +The format of these files is username followed by the crypted password,
> +for example:
> +
> +------
> + myuser:$1Oyx5r9mdGZ2
> + myuser:$1$BA)@$vbnMJMDym7tA32AamXrm./
> +------
> +You can use the 'htpasswd' facility that comes with Apache to make these
> +files, but Apache's MD5 crypt method differs from the one used by most C
> +library's crypt() function, so don't use the -m option.
> +
> Then provide your password via the pserver method, for example:
> ------
> cvs -d:pserver:someuser:somepassword <at> server/path/repo.git co <HEAD_name>
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index 9bc2ff5..e54cbcd 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -156,24 +156,25 @@ if ($state->{method} eq 'pserver') {
>
> unless ($user eq 'anonymous') {
> # Trying to authenticate a user
> - if (not exists $cfg->{gitcvs}->{users}) {
> - print "E the repo config file needs a [gitcvs.users] section with user/password key-value pairs\n";
> + if (not exists $cfg->{gitcvs}->{authdb}) {
> + print "E the repo config file needs a [gitcvs.authdb] section with a filename\n";
> print "I HATE YOU\n";
> exit 1;
> - } elsif (exists $cfg->{gitcvs}->{users} and not exists $cfg->{gitcvs}->{users}->{$user}) {
> - #print "E the repo config file has a [gitcvs.users] section but the user $user is not defined in it\n";
> + }
> + my $auth_ok;
> + open PASSWD, "<$cfg->{gitcvs}->{authdb}" or die $!;
> + while(<PASSWD>) {
> + if (m{^\Q$user\E:(.*)}) {
> + if (crypt($user, $1) eq $1) {
> + $auth_ok = 1;
> + }
> + };
> + }
> + unless ($auth_ok) {
> print "I HATE YOU\n";
> exit 1;
> - } else {
> - my $descrambled_password = descramble($password);
> - my $cleartext_password = $cfg->{gitcvs}->{users}->{$user};
> - if ($descrambled_password ne $cleartext_password) {
> - #print "E The password supplied for user $user was incorrect\n";
> - print "I HATE YOU\n";
> - exit 1;
> - }
> - # else fall through to LOVE
> }
> + # else fall through to LOVE
> }
>
> # For checking whether the user is anonymous on commit
> --
> 1.5.3.rc3.120.g68d422
>
>
> From e8b69f313888900447f45ac3a8dceb38bd5c261e Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= <avar@cpan.org>
> Date: Thu, 6 Mar 2008 23:43:13 +0000
> Subject: [PATCH] Indent the last commit to fit with the rest of the code.
>
> Use lexical filehandles instead of global globs
>
> Close the filehandle after the password database has been read
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avar@cpan.org>
> ---
> git-cvsserver.perl | 23 +++++++++++++----------
> 1 files changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index e54cbcd..f956ac9 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -161,16 +161,19 @@ if ($state->{method} eq 'pserver') {
> print "I HATE YOU\n";
> exit 1;
> }
> - my $auth_ok;
> - open PASSWD, "<$cfg->{gitcvs}->{authdb}" or die $!;
> - while(<PASSWD>) {
> - if (m{^\Q$user\E:(.*)}) {
> - if (crypt($user, $1) eq $1) {
> - $auth_ok = 1;
> - }
> - };
> - }
> - unless ($auth_ok) {
> +
> + my $auth_ok;
> + open my $passwd, "<", $cfg->{gitcvs}->{authdb} or die $!;
> + while (<$passwd>) {
> + if (m{^\Q$user\E:(.*)}) {
> + if (crypt($user, $1) eq $1) {
> + $auth_ok = 1;
> + }
> + };
> + }
> + close $passwd;
> +
> + unless ($auth_ok) {
> print "I HATE YOU\n";
> exit 1;
> }
> --
> 1.5.3.rc3.120.g68d422
>
>
> From 90d3468556b46fc649a9408af42ff24ed2e50455 Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= <avar@cpan.org>
> Date: Fri, 7 Mar 2008 00:06:52 +0000
> Subject: [PATCH] Produce an error if the user tries to supply a password for anonymous
>
> Clarify the error message produced when there's no [gitcvs.authdb]
>
> Produce an E error if the authdb doesn't exist instead of spewing $!
> to the user
>
> do crypt($user, descramble($pass)) eq $hash; crypt($user, $hash) eq
> $hash would accept any password
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avar@cpan.org>
> ---
> git-cvsserver.perl | 28 +++++++++++++++++++++++-----
> 1 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index f956ac9..aa0299e 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -154,19 +154,36 @@ if ($state->{method} eq 'pserver') {
> $line = <STDIN>; chomp $line;
> my $password = $line;
>
> - unless ($user eq 'anonymous') {
> + if ($user eq 'anonymous') {
> + # "A" will be 1 byte, use length instead in case the
> + # encryption method ever changes (yeah, right!)
> + if (length($password) > 1 ) {
> + print "E Don't supply a password for the `anonymous' user\n";
> + print "I HATE YOU\n";
> + }
> +
> + # Fall through to LOVE
> + } else {
> # Trying to authenticate a user
> if (not exists $cfg->{gitcvs}->{authdb}) {
> - print "E the repo config file needs a [gitcvs.authdb] section with a filename\n";
> + print "E the repo config file needs a [gitcvs] section with an 'authdb' parameter set to the filename of the authentication database\n";
> + print "I HATE YOU\n";
> + exit 1;
> + }
> +
> + my $authdb = $cfg->{gitcvs}->{authdb};
> +
> + unless (-e $authdb) {
> + print "E The authentication database specified in [gitcvs.authdb] does not exist\n";
> print "I HATE YOU\n";
> exit 1;
> }
>
> my $auth_ok;
> - open my $passwd, "<", $cfg->{gitcvs}->{authdb} or die $!;
> + open my $passwd, "<", $authdb or die $!;
> while (<$passwd>) {
> if (m{^\Q$user\E:(.*)}) {
> - if (crypt($user, $1) eq $1) {
> + if (crypt($user, descramble($password)) eq $1) {
> $auth_ok = 1;
> }
> };
> @@ -177,7 +194,8 @@ if ($state->{method} eq 'pserver') {
> print "I HATE YOU\n";
> exit 1;
> }
> - # else fall through to LOVE
> +
> + # Fall through to LOVE
> }
>
> # For checking whether the user is anonymous on commit
> --
> 1.5.3.rc3.120.g68d422
>
>
> From a55dfa2667da1473199ee70ca6cfd53094001119 Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= <avar@cpan.org>
> Date: Fri, 7 Mar 2008 00:09:14 +0000
> Subject: [PATCH] document a perl snippet to produce passwords for those that don't have htpasswd
>
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avar@cpan.org>
> ---
> Documentation/git-cvsserver.txt | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
> index c642f12..d410a11 100644
> --- a/Documentation/git-cvsserver.txt
> +++ b/Documentation/git-cvsserver.txt
> @@ -118,6 +118,11 @@ You can use the 'htpasswd' facility that comes with Apache to make these
> files, but Apache's MD5 crypt method differs from the one used by most C
> library's crypt() function, so don't use the -m option.
>
> +Alternatively you can produce the password with perl's crypt() operator:
> +-----
> + perl -e 'my ($user, $pass) = @ARGV; printf "%s:%s\n", $user, crypt($user, $pass)' $USER password
> +-----
> +
> Then provide your password via the pserver method, for example:
> ------
> cvs -d:pserver:someuser:somepassword <at> server/path/repo.git co <HEAD_name>
> --
> 1.5.3.rc3.120.g68d422
>
>
> From 60f893bd9fe329bd5cf8ec513d10ec00e85feb2c Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= <avar@cpan.org>
> Date: Fri, 7 Mar 2008 16:06:31 +0000
> Subject: [PATCH] exit after producing the error about anonymous having a password
>
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avar@cpan.org>
> ---
> git-cvsserver.perl | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index aa0299e..da48ebd 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -160,6 +160,7 @@ if ($state->{method} eq 'pserver') {
> if (length($password) > 1 ) {
> print "E Don't supply a password for the `anonymous' user\n";
> print "I HATE YOU\n";
> + exit 1;
> }
>
> # Fall through to LOVE
> --
> 1.5.3.rc3.120.g68d422
>
>
>
> 1. http://git.nix.is/?p=avar/git;a=commitdiff;h=60f893bd9fe329bd5cf8ec513d10ec00e85feb2c
It has been over 3 months since I submitted this patch without anyone
acting on it. In absence of comment from the Mart[yi]ns could this
please applied anyway?
^ permalink raw reply
* Re: [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables
From: Mike Hommey @ 2008-06-19 17:56 UTC (permalink / raw)
To: Brandon Casey; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <gASAIyn4TvarEmVo9rWtEKa6eROfKXwowHxH6j05FzPARJ-CDBCHLw@cipher.nrlssc.navy.mil>
On Thu, Jun 19, 2008 at 12:44:23PM -0500, Brandon Casey wrote:
> Mike Hommey wrote:
> > On Thu, Jun 19, 2008 at 12:32:02PM -0500, Brandon Casey wrote:
> >> - test_must_fail GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
> >> + # We intentionally do not use test_must_fail on the next line since the
> >> + # mechanism does not work when setting environment variables inline
> >> + ! GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
> >
> > Doesn't GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" test_must_fail git commit
> > work ?
>
> That leaves GIT_EDITOR set to the new value after the command completes.
It really shouldn't.
Mike
^ permalink raw reply
* Re: [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables
From: Brandon Casey @ 2008-06-19 17:44 UTC (permalink / raw)
To: Mike Hommey; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <20080619173932.GA32593@glandium.org>
Mike Hommey wrote:
> On Thu, Jun 19, 2008 at 12:32:02PM -0500, Brandon Casey wrote:
>> - test_must_fail GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
>> + # We intentionally do not use test_must_fail on the next line since the
>> + # mechanism does not work when setting environment variables inline
>> + ! GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
>
> Doesn't GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" test_must_fail git commit
> work ?
That leaves GIT_EDITOR set to the new value after the command completes.
-brandon
^ permalink raw reply
* Re: [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables
From: Mike Hommey @ 2008-06-19 17:39 UTC (permalink / raw)
To: Brandon Casey; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <JvISWq5uUteLVQOl-3QkroLV8SsQufGuWrfseMUjpYY@cipher.nrlssc.navy.mil>
On Thu, Jun 19, 2008 at 12:32:02PM -0500, Brandon Casey wrote:
> - test_must_fail GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
> + # We intentionally do not use test_must_fail on the next line since the
> + # mechanism does not work when setting environment variables inline
> + ! GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
Doesn't GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" test_must_fail git commit
work ?
Mike
^ permalink raw reply
* [PATCH] t7502-commit.sh: test_must_fail doesn't work with inline environment variables
From: Brandon Casey @ 2008-06-19 17:32 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List
When the arguments to test_must_fail() begin with a variable assignment,
test_must_fail() attempts to execute the variable assignment as a command.
This fails, and so test_must_fail returns with a successful status value
without running the command it was intended to test.
For example, the following script:
#!/bin/sh
test_must_fail () {
"$@"
test $? -gt 0 -a $? -le 129
}
foo='wo adrian'
test_must_fail foo='yo adrian' sh -c 'echo foo: $foo'
always exits zero and prints the message:
test.sh: line 3: foo=yo adrian: command not found
Test 16 calls test_must_fail in such a way and therefore has not been
testing whether git 'do[es] not fire editor in the presence of conflicts'.
Fix this by reverting to the traditional negation operator '!' and accept
the caveat that segfault will not be detected.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
Unless you have a better work around...
-brandon
t/t7502-commit.sh | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index ed871a6..e3469e0 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -212,7 +212,9 @@ test_expect_success 'do not fire editor in the presence of conflicts' '
# Must fail due to conflict
test_must_fail git cherry-pick -n master &&
echo "editor not started" >.git/result &&
- test_must_fail GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
+ # We intentionally do not use test_must_fail on the next line since the
+ # mechanism does not work when setting environment variables inline
+ ! GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" git commit &&
test "$(cat .git/result)" = "editor not started"
'
--
1.5.5.3
^ permalink raw reply related
* Further Re: Getting the path right for git over SSH
From: Ben Schmidt @ 2008-06-19 17:13 UTC (permalink / raw)
To: git
[Further to my previous message...]
[When starting a non-interactive non-login shell from an ssh session...]
> What bash does is source /etc/bashrc and ~/.bashrc--it evidently
> treats ssh like rsh and does a little more than is documented even for
> rsh (search for rsh in the bash man page for details).
So another, simpler, system-wide solution is to set your $PATH in
/etc/bashrc. However, this is not documented in the bash man page (which
is why I came up with the more complicated solution, as I hadn't
realised this behaviour at that stage). So I'm not sure whether it is
standard/will occur on all systems, etc.
If you're like me and like to have interactive stuff in bashrc and login
stuff in profile, you can arrange your files like this (very similar to
before, but ~/.bashrc needn't source /etc/profile now, nor do its check
with $- and grep, as /etc/bashrc does that and avoids setting $PS1).
In /etc/profile
# System-wide .profile for sh(1)
PATH=...
export PATH
# Source /etc/bashrc for interactive shells.
[ -n "$PS1" -a -r /etc/bashrc ] && source /etc/bashrc
... stuff for login shells (more environment mostly)
In /etc/bashrc
# System-wide .bashrc file for interactive bash(1) shells.
# If the shell isn't actually interactive it is an ssh session, and
# we want to source etc/profile instead.
if [ -z "$PS1" ] ; then
[ -r /etc/profile ] && source /etc/profile
return
fi
... stuff for interactive shells (aliases and terminal stuff mostly)
In ~/.profile
# For login shells (interactive or not).
# For interactive non-login shells see ~/.bashrc.
# For non-interactive non-login ssh shells see ~/.bashrc.
# For other non-interactive non-login shells see $BASH_ENV.
# At present this is sourced by ~/.bashrc for the ssh case, so
# all ssh sessions act like login sessions.
PATH=...
export PATH
# Source ~/.bashrc for interactive shells.
if [ -n "$PS1" -a -r ~/.bashrc ]; then source ~/.bashrc ; fi
... stuff for login shells (more environment mostly)
In ~/.bashrc
# For interactive non-login shells
# and non-interactive non-login ssh shells.
# For login shells (interactive or not) see first existent of
# ~/.bash_profile, ~/.bash_login and ~/.profile.
# For other non-interactive non-login shells see $BASH_ENV.
# At present, this is sourced by ~/.profile so runs for all
# interactive shells (login or not).
# If the shell isn't actually interactive it is an ssh session, and
# we want to source ~/.profile instead.
if [ -z "$PS1" ] ; then
source ~/.profile
return
fi
... stuff for interactive shells (aliases and terminal stuff mostly)
Ben.
^ permalink raw reply
* Re: Is there a repository for git-cvsserver?
From: Jakub Narebski @ 2008-06-19 17:11 UTC (permalink / raw)
To: Le; +Cc: git
In-Reply-To: <485A891E.5080605@distributel.ca>
"Le" <le_wen@distributel.ca> writes:
> I've tried to find it but in vain. What I got is only git itself.
>
> If anyone knows, please let me know. Thank you!
No, git-cvsserver is part of git. You probably have it in separate
package named git-cvs (or perhaps even git-cvsserver).
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply
* Re: [PATCH v2] Make git_dir a path relative to work_tree in setup_work_tree()
From: Johannes Schindelin @ 2008-06-19 17:09 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Junio C Hamano, Linus Torvalds, git
In-Reply-To: <alpine.LNX.1.00.0806191146210.19665@iabervon.org>
Hi,
On Thu, 19 Jun 2008, Daniel Barkalow wrote:
> On Thu, 19 Jun 2008, Johannes Schindelin wrote:
>
> > On Wed, 18 Jun 2008, Daniel Barkalow wrote:
> >
> > > diff --git a/setup.c b/setup.c
> > > index d630e37..1643ee4 100644
> > > --- a/setup.c
> > > +++ b/setup.c
> > > @@ -292,7 +292,8 @@ void setup_work_tree(void)
> > > work_tree = get_git_work_tree();
> > > git_dir = get_git_dir();
> > > if (!is_absolute_path(git_dir))
> >
> > I suspect it needs "work_tree &&" here.
>
> I'm not clear on the semantics of !get_git_work_tree(); is a non-absolute
> path for git_dir right then?
My reading was: if there is no work_tree, then a relative git_dir is just
fine, since we are quite unlikely to jump around in the file system.
And your implementation of make_relative_path() is nice enough to a
(work_tree ==) base == NULL, but would return the absolute path in that
case.
Haven't had time to test anything, though.
Ciao,
Dscho
^ permalink raw reply
* Re: sharing object packs
From: marc zonzon @ 2008-06-19 17:01 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20080619090129.GJ11793@spearce.org>
Thank You Shawn
On Thu, Jun 19, 2008 at 11:01 AM, Shawn O. Pearce <spearce@spearce.org> wrote:
> marc.zonzon+git@gmail.com wrote:
>> I have a big bare repository 'main.git' and many small git repositories sub1, sub2, ... subn.
>>
>> All repositories lie in the same file file system, and each subx
>> repository track and fetch main.git in a remote branch.
>>
>> I would like to avoid duplicating main.git objects
> ...
>> - Using an objects/info/alternates with the path of main.git object repository.
>> It work well too, but I import objects from main.git inside subx,
>> and they don't have the same life time than those in main.git. So
>> they can, disapear during a git-prune-packed or gc. (The same
>> problem we have with: git clone --share)
>
> This is the approach you want to use. The risk is that you do
> not allow objects to be added to main.git to later be deleted from
> main.git. This means main.git cannot rewind/reset/delete a branch.
>
> If that is not acceptable perhaps you could instead create 3 tiers:
>
> main.git ---
> \
> shared.git
> /
> subx.git ---
>
> Have main.git and subx.git both use shared.git as an alternate
> (place path of shared.git/objects in their objects/info/alternates).
> You can still allow subx.git to fetch main.git.
>
Your solution of 3 tiers seems to solve the problems I met when trying
to take main.git as alternates.
But I feel we can even make it more secure than what you explain:
> Push only stable commits to shared.git that will never be
> rewind/reset/deleted. Once something enters shared.git it should
> never be deleted. This way shared objects will not be removed by
> git-prune or git-gc. Every so often push newer stable branches from
> main.git to shared.git, once they cannot be rewind/reset/deleted.
>
My option is to fetch from shared not only the branches of main, but
all the branches of all the subx.
So shared.git host all the objects of the sum of main and all subx.
Then there is any problem to reset, delete, or rewind a
branch in main, even if you fetch the resetted branch from shared (a
non fast-forward fetch), The objects of the deleted branch are either
not in any sub directory, and nothing is lost when they are
pruned, or they have been imported in some branch and they will be
kept, since there is a reference to them.
> Repack main.git and subx.git using `git gc` as that includes the
> -l flag to `git repack`. Any objects which are now available from
> shared.git will not be included in main.git or subx.git, so their
> usage will shrink after shared.git is updated.
>
Yes I tested that, with git gc, I had no immediate shrinking, I suppose
we have to wait for gc.pruneExpire to see the result.
But:
* fetching the remotes of shared.git,
* packing shared.git,
* packing and pruning (with git prune) the directories subx and
main.git
reduces immediately the object store of the subx to nearly nothing.
> If you also configure gc.packrefs to never in shared.git and
> symlink shared.git/refs into main.git/refs/shared and also into
> subx.git/refs/shared and do this configuration on both server and
> client systems you can have everyone transfer only the minimal
> objects necessary.
Thank you also for this setting, my level of knowledge of git transfer
mechanism is yet too low for understanding it without further
explanation/reading. If you can give some pointers they are welcome.
This solution seems great to implement some kind of submodules.
I suppose we could also use this 3 tiers solution to do a more clever
clone --share by the following scheme:
# mkdir shared
# cd shared
# git init
# cd ..
# git clone --no-hardlinks --bare shared shared.git
# rm -rf shared
# cd shared.git
# git remote add -f repo ../repo
* [new branch] master -> repo/master
# cd ..
# git clone repo repo_copy
# echo $PWD/shared.git/objects >> repo/.git/objects/alternates
# cd shared.git
# git remote add -f repo_copy ../repo_copy
* [new branch] master -> repo_copy/master
# cd ..
# echo $PWD/shared.git/objects >> repo_copy/.git/objects/alternates
then the sequence of repack, gc, prune outlined above.
But I have not yet the experience in git, to allow me to foresee the
consequences of these settings.
All criticisms are welcome.
Marc
^ permalink raw reply
* Is there a repository for git-cvsserver?
From: Le @ 2008-06-19 16:28 UTC (permalink / raw)
To: git
I've tried to find it but in vain. What I got is only git itself.
If anyone knows, please let me know. Thank you!
^ permalink raw reply
* Re: Best practice question
From: Avery Pennarun @ 2008-06-19 16:39 UTC (permalink / raw)
To: stuart.freeman; +Cc: git
In-Reply-To: <485A6E03.6090509@et.gatech.edu>
On 6/19/08, D. Stuart Freeman <stuart.freeman@et.gatech.edu> wrote:
> My project has an "about" page that lists the version. I understand why
> git doesn't do keyword expansion, but I'm wondering if there's a
> recommended best practice for keeping that up to date.
If you compile git yourself and run "git --version", it contains the
current version number. You may want to do it the same way.
See also the "git-describe" command.
Have fun,
Avery
^ permalink raw reply
* Re: [PATCH] git-send-pack: don't consider branch lagging behind as errors.
From: Pierre Habouzit @ 2008-06-19 16:28 UTC (permalink / raw)
To: Jeff King; +Cc: git, gitster
In-Reply-To: <20080619151110.GA31654@sigill.intra.peff.net>
[-- Attachment #1: Type: text/plain, Size: 1906 bytes --]
On Thu, Jun 19, 2008 at 03:11:10PM +0000, Jeff King wrote:
> On Thu, Jun 19, 2008 at 03:52:00PM +0200, Pierre Habouzit wrote:
> > > - there is a possible danger with "git push -f", in that you force
> > > both rejected branches as well as stale branches. Junio and I
> > Well afaict this is a separate issue, as we're (with such a patch)
> > only changing what gets printed on the console, not the internal
> > behavior. So solving this second issue should not really be a
> > precondition to the inclusion of such a patch.
>
> It is a separate issue, but it is exacerbated by hiding stale refs.
> Imagine:
>
> $ git push
> To /path/to/repo
> ! [rejected] master -> master (non-fast forward)
>
> $ git push -f
> To /path/to/repo
> + 0abfa88...c1ed93b master -> master (forced update)
> + 0329485...3498576 stale_branch -> stale_branch (forced update)
>
> I think that is a nasty surprise to spring on an unsuspecting user.
> Another solution might be "-f" not pushing rewound branches, but then we
> need a way to specify "no, really, push this rewound branch". Perhaps
> "-f -f"?
Well then we could keep the [stalled] lines for now until this issue
is resolved then, despite what the people at the beginning of the other
thread complained about. My real issue is that I have my shell
configured so that my prompt becomes inverted if the last command
failed. So do many people I know, and well, git push for stalled
references should just not generate an error. _this_ is my sole concern
:)
> > Please please please do :)
> > The exit 1 of git-push is really annoying me these days.
>
> OK, I will try to take a look in the next few days.
>
> -Peff
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [EGIT PATCH 21/20] Make isBetterDeltaReuseLoader() static in PackWriter
From: Marek Zawirski @ 2008-06-19 16:26 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: spearce, git
In-Reply-To: <200806180007.01061.robin.rosenberg.lists@dewire.com>
Robin Rosenberg wrote:
> tisdagen den 17 juni 2008 23.28.54 skrev Marek Zawirski:
>> Implementation was already static, it's just a fix for clarity and
>> potential speed-up.
>>
>> Reported-by: Shawn O. Pearce <spearce@spearce.org>
>> Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
>> ---
>> It could be squashed with patch 19/20. I can clean up this mess, adding
>> also Shawn's patch - just let me know what is preferred way (squash
>> commits, commits on top?).
>
> If the code is already merged then patch on top, else squashing or rebase,
> unless you feel there is a reason not to. We can pretend it was right from
> the start :)
So let's pretend that...
I have squashed these 2 additional patches (Shawn's improvement for
reverse index and my minor fix) into appropriate commits. "packwriter"
branch was updated (non fast-forward):
http://repo.or.cz/w/egit/zawir.git?a=shortlog;h=refs/heads/packwriter
> I see no educational value in having a separate patch in this case.
The only educational value was to type Reported-by on my own ;)
--
Marek Zawirski [zawir]
marek.zawirski@gmail.com
^ permalink raw reply
* Re: [PATCH v2] Make git_dir a path relative to work_tree in setup_work_tree()
From: Daniel Barkalow @ 2008-06-19 16:12 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, Linus Torvalds, git
In-Reply-To: <alpine.DEB.1.00.0806191510060.6439@racer>
On Thu, 19 Jun 2008, Johannes Schindelin wrote:
> Hi,
>
> On Wed, 18 Jun 2008, Daniel Barkalow wrote:
>
> > diff --git a/setup.c b/setup.c
> > index d630e37..1643ee4 100644
> > --- a/setup.c
> > +++ b/setup.c
> > @@ -292,7 +292,8 @@ void setup_work_tree(void)
> > work_tree = get_git_work_tree();
> > git_dir = get_git_dir();
> > if (!is_absolute_path(git_dir))
>
> I suspect it needs "work_tree &&" here.
I'm not clear on the semantics of !get_git_work_tree(); is a non-absolute
path for git_dir right then?
> > - set_git_dir(make_absolute_path(git_dir));
> > + set_git_dir(make_relative_path(make_absolute_path(git_dir),
> > + work_tree));
> > if (!work_tree || chdir(work_tree))
> > die("This operation must be run in a work tree");
> > initialized = 1;
>
> All in all I am pretty surprised how easy it was. I tried yesterday, for
> half an hour, to come up with something sensible, and failed.
I was sure you'd come up with just this solution, because you'd just
recently explained that make_absolute_path() means you can find when one
path is in another path with a simple string compare. And, since we know
what pwd is going to be...
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Including branch info in git format-patch
From: Mukund Sivaraman @ 2008-06-19 15:42 UTC (permalink / raw)
To: git
Hi all
We have two public branches on the tinyproxy project[1]: master and 1.6.
We send patches to the mailing list to get them reviewed before they are
applied and pushed to the public repo.
When i use "git format-patch", it doesn't seem to include the branch (or
remote) name in the email it creates. So a reader of this mail may not
know what branch to apply it on to test it. Aside from adding in branch
information manually in the body of the message, is there any other
existing way to get git format-patch to include it?
Apologies in advance if this is a stupid question.
Mukund
Refs:
1. http://git.banu.com/?p=tinyproxy;a=summary
^ permalink raw reply
* Re: git-diff question
From: Alf Clement @ 2008-06-19 15:55 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
In-Reply-To: <m3tzfpmy2b.fsf@localhost.localdomain>
Hi,
regarding git diff --help:
--diff-filter=[ACDMRTUXB*]
Select only files that are Added (A), Copied (C), Deleted (D),
Modified (M), Renamed (R), have their type (mode) changed (T),
are Unmerged (U), are Unknown (X), or have had their pairing
and git diff reports mode changes...
CU,
Alf
On Thu, Jun 19, 2008 at 2:03 PM, Jakub Narebski <jnareb@gmail.com> wrote:
> "Alf Clement" <alf.clement@gmail.com> writes:
>
>> $ git diff
>> diff --git a/Firmware/Firmware.ccscc b/Firmware/Firmware.ccscc
>> old mode 100755
>> new mode 100644
>> ....
>> returns a list of files where the mode was changed, which seems to be
>> correct. Also
>> modified files are flaged.
>> I wonder why
>> $ git diff --diff-filter=T
>> outputs nothing.
>
> Isn't 'T' about *t*ype change, i.e. change between ordinary file,
> symlink, directory and commit (submodule)?
>
>> I am running this under Cygwin.
>
> Or perhaps this is a cause.
>
> --
> Jakub Narebski
> Poland
> ShadeHawk on #git
>
^ permalink raw reply
* Re: [PATCH] Add option to git-branch to set up automatic rebasing
From: Björn Steinbrink @ 2008-06-19 15:43 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Pieter de Bie, Git Mailinglist, Junio C Hamano
In-Reply-To: <alpine.DEB.1.00.0806191459150.6439@racer>
On 2008.06.19 15:00:19 +0100, Johannes Schindelin wrote:
> Hi,
>
> On Thu, 19 Jun 2008, Pieter de Bie wrote:
>
> > This functionality was actually introduced in
> > 0a02186f924aee1bd69f18ed01f645aa332ce0d1, but can only be activated by the
> > configuration flag. Now we can also setup auto rebasing using the --rebase
> > flag in git-branch or git-checkout, similar to how --track works.
>
> How about "--rebasing"? I would scratch my head a bit how a new branch
> and a rebase would go together.
Hm, --rebasing sounds weird to me as well. Maybe --track=merge and
--track=rebase, with --track being equal to --track=merge?
Björn
^ permalink raw reply
* Re: Best practice question
From: Santi Béjar @ 2008-06-19 15:40 UTC (permalink / raw)
To: stuart.freeman; +Cc: git
In-Reply-To: <485A6E03.6090509@et.gatech.edu>
On Thu, Jun 19, 2008 at 16:32, D. Stuart Freeman
<stuart.freeman@et.gatech.edu> wrote:
> My project has an "about" page that lists the version. I understand why
> git doesn't do keyword expansion, but I'm wondering if there's a
> recommended best practice for keeping that up to date.
You can look at how git does it:
It generates a GIT-VERSION-FILE with:
http://git.kernel.org/?p=git/git.git;a=blob;f=GIT-VERSION-GEN;hb=HEAD
and reads it in the Makefile. Or you could generate a version.h file.
Santi
^ permalink raw reply
* Re: [PATCH] git-send-pack: don't consider branch lagging behind as errors.
From: Jeff King @ 2008-06-19 15:11 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: git, gitster
In-Reply-To: <20080619135159.GA19560@artemis.madism.org>
On Thu, Jun 19, 2008 at 03:52:00PM +0200, Pierre Habouzit wrote:
> > http://thread.gmane.org/gmane.comp.version-control.git/73038/focus=73186
> [...]
> > - should stale branches be shown without -v?
>
> I believe so, it's valuable information. It's as valuable as what you
> get after a git fetch nowadays (like branches have diverged n and m
> commits each or similar) But oh well… I don't care that much.
If you read the beginning of that thread, the original impetus was
people cloning repos that had dozens of branches, then doing a push.
If they hadn't recently done a fetch, they got dozens of lines of
"rejected".
> > - calling ref_newer here is inefficient, since we have already called
> > it in the other direction. We should probably do the traversal once
> > in such a way as to find out which ref is newer (or if it is
> > indeterminate).
>
> Well, true, though I don't expect people to have tons of local
> branches that match a refspec _and_ lag behind. I suspect this is a very
> minor performance loss.
Yeah, maybe it is not worth worrying about; I haven't actually measured
any performance issue. I'll try to look and see how painful it is to
combine the traversals.
> > - there is a possible danger with "git push -f", in that you force
> > both rejected branches as well as stale branches. Junio and I
> Well afaict this is a separate issue, as we're (with such a patch)
> only changing what gets printed on the console, not the internal
> behavior. So solving this second issue should not really be a
> precondition to the inclusion of such a patch.
It is a separate issue, but it is exacerbated by hiding stale refs.
Imagine:
$ git push
To /path/to/repo
! [rejected] master -> master (non-fast forward)
$ git push -f
To /path/to/repo
+ 0abfa88...c1ed93b master -> master (forced update)
+ 0329485...3498576 stale_branch -> stale_branch (forced update)
I think that is a nasty surprise to spring on an unsuspecting user.
Another solution might be "-f" not pushing rewound branches, but then we
need a way to specify "no, really, push this rewound branch". Perhaps
"-f -f"?
> Please please please do :)
> The exit 1 of git-push is really annoying me these days.
OK, I will try to take a look in the next few days.
-Peff
^ permalink raw reply
* Re: Best practice question
From: Karl Hasselström @ 2008-06-19 14:54 UTC (permalink / raw)
To: D. Stuart Freeman; +Cc: git
In-Reply-To: <485A6E03.6090509@et.gatech.edu>
On 2008-06-19 10:32:35 -0400, D. Stuart Freeman wrote:
> My project has an "about" page that lists the version. I understand
> why git doesn't do keyword expansion, but I'm wondering if there's a
> recommended best practice for keeping that up to date.
Usually when people ask this question on this list, the recommendation
is to have the build system generate a suitable version string. Look
at how git's own built-in version string is generated, for example.
(The GIT-VERSION-GEN script.)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply
* Best practice question
From: D. Stuart Freeman @ 2008-06-19 14:32 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 248 bytes --]
My project has an "about" page that lists the version. I understand why
git doesn't do keyword expansion, but I'm wondering if there's a
recommended best practice for keeping that up to date.
--
D. Stuart Freeman
Georgia Institute of Technology
[-- Attachment #2: stuart_freeman.vcf --]
[-- Type: text/x-vcard, Size: 162 bytes --]
begin:vcard
fn:D. Stuart Freeman
n:Freeman;Douglas
email;internet:stuart.freeman@et.gatech.edu
tel;work:(404)385-1473
x-mozilla-html:FALSE
version:2.1
end:vcard
^ permalink raw reply
* Re: [PATCH 1/2] parse_options: Add flag to prevent errors for further processing
From: Shawn Bohrer @ 2008-06-19 14:25 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, Jeff King, git, madcoder
In-Reply-To: <7v8wx2zibp.fsf@gitster.siamese.dyndns.org>
On Wed, Jun 18, 2008 at 11:52:42AM -0700, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > On Tue, 17 Jun 2008, Junio C Hamano wrote:
> >
> >> Jeff King <peff@peff.net> writes:
> >>
> >> > I think the only right way to accomplish this is to convert the revision
> >> > and diff parameters into a parseopt-understandable format.
> >>
> >> Not necessarily. You could structure individual option parsers like how
> >> diff option parsers are done. You iterate over argv[], feed diff option
> >> parser the current index into argv[] and ask if it is an option diff
> >> understands, have diff eat the option (and possibly its parameter) to
> >> advance the index, or allow diff option to say "I do not understand
> >> this", and then handle it yourself or hand it to other parsers.
> >
> > AFAIR Pierre tried a few ways, and settled with a macro to introduce the
> > diff options into a caller's options.
> >
> > IOW it would look something like this:
> >
> > static struct option builtin_what_options[] = {
> > [... options specific to this command ...]
> > DIFF__OPT(&diff_options)
> > };
>
> I think that is the more painful approach Jeff mentioned, and my comment
> was to show that it is not the only way.
>
It seems to me that you could implement Jeff's
PARSE_OPT_STOP_AT_UNKNOWN, and then if multiple option parsers are
needed you would simply loop over parse_options for each of the
commands, waiting for argc to stop changing. Of course Jeff's flag
would also need to stop parse_options from eating the first argument.
Is this sort of what you are suggesting Junio?
--
Shawn
^ permalink raw reply
* [PATCH] git-push: add a --delete flag to allow branch deletion
From: Pieter de Bie @ 2008-06-19 14:13 UTC (permalink / raw)
To: Git Mailinglist, Junio C Hamano; +Cc: Pieter de Bie
While this is already possible with the :<dst> refspec syntax,
a flag specifically for this action is more userfriendly.
Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl>
---
The question on how to delete remote branches appears frequently in the
irc channel. If we add an explicit option to do this to git push, hopefully
it will be more clear.
Documentation/git-push.txt | 13 ++++++++++++-
builtin-push.c | 37 +++++++++++++++++++++++++++++++++++--
t/t5516-fetch-push.sh | 13 +++++++++++++
3 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 89e0049..6a772a5 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -11,6 +11,8 @@ SYNOPSIS
[verse]
'git-push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
[--repo=all] [-f | --force] [-v | --verbose] [<repository> <refspec>...]
+'git push' --delete <repository> <branchname> [<branch2> ...]
+
DESCRIPTION
-----------
@@ -18,6 +20,8 @@ DESCRIPTION
Updates remote refs using local refs, while sending objects
necessary to complete the given refs.
+In the second form, deletes one or more branches on a given repository.
+
You can make interesting things happen to a repository
every time you push into it, by setting up 'hooks' there. See
documentation for linkgit:git-receive-pack[1].
@@ -52,7 +56,7 @@ A parameter <ref> without a colon pushes the <ref> from the source
repository to the destination repository under the same name.
+
Pushing an empty <src> allows you to delete the <dst> ref from
-the remote repository.
+the remote repository. The same can be done by using the --delete flag.
+
The special refspec `:` (or `+:` to allow non-fast forward updates)
directs git to push "matching" heads: for every head that exists on
@@ -75,6 +79,10 @@ nor in any Push line of the corresponding remotes file---see below).
if the configuration option `remote.<remote>.mirror` is
set.
+--delete::
+ Does not push anything, but instead deletes <branchname> on the
+ remote repository.
+
--dry-run::
Do everything except actually send the updates.
@@ -179,6 +187,9 @@ git push origin :experimental::
Find a ref that matches `experimental` in the `origin` repository
(e.g. `refs/heads/experimental`), and delete it.
+git push --delete origin experimental::
+ Does the same as the above, but is more friendly.
+
git push origin master:satellite/master::
Find a ref that matches `master` in the source repository
(most likely, it would find `refs/heads/master`), and update
diff --git a/builtin-push.c b/builtin-push.c
index b35aad6..81f9a58 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,8 @@
#include "parse-options.h"
static const char * const push_usage[] = {
- "git-push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git push --delete <repository> <branchname> [<branch2> ...]",
NULL,
};
@@ -48,6 +49,24 @@ static void set_refspecs(const char **refs, int nr)
}
}
+static void set_delete_refspecs(const char **branches, int nr)
+{
+ int i;
+ for (i = 0; i < nr; i++) {
+ const char *branch = branches[i];
+ int len;
+ char *delete_refspec;
+
+ if (strchr(branch, ':'))
+ die("%s is not a valid branchname", branch);
+ len = strlen(branch) + 1;
+ delete_refspec = xmalloc(len);
+ *delete_refspec = ':';
+ strcpy(delete_refspec + 1, branch);
+ add_refspec(delete_refspec);
+ }
+}
+
static int do_push(const char *repo, int flags)
{
int i, errs;
@@ -108,6 +127,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
int tags = 0;
int rc;
const char *repo = NULL; /* default repository */
+ int delete = 0;
struct option options[] = {
OPT__VERBOSE(&verbose),
@@ -118,6 +138,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"),
OPT_BOOLEAN('f', "force", &force, "force updates"),
OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
+ OPT_BOOLEAN('d', "delete", &delete, "delete remote branch"),
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"),
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
OPT_END()
@@ -125,6 +146,18 @@ int cmd_push(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, options, push_usage, 0);
+ if (delete) {
+ if (all || mirror || tags || force || repo)
+ die("--delete cannot be used with --all, --mirror, --tags, --farce or --repo");
+
+ if (argc == 0)
+ die("Need a remote on which to delete a branch");
+ if (argc == 1)
+ die("Need a branch on the remote to delete");
+ repo = argv[0];
+ set_delete_refspecs(argv + 1, argc - 1);
+ }
+
if (force)
flags |= TRANSPORT_PUSH_FORCE;
if (dry_run)
@@ -138,7 +171,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
if (mirror)
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
- if (argc > 0) {
+ if (!delete && argc > 0) {
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 6805032..42fe89c 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -361,6 +361,19 @@ test_expect_success 'push with HEAD nonexisting at remote' '
git push testrepo HEAD &&
check_push_result $the_commit heads/local
'
+test_expect_success 'delete with --delete syntax' '
+
+ git push testrepo master:test1 &&
+ git push --delete testrepo test1 &&
+ git push testrepo master:test1 master:test2 &&
+ check_push_result $the_commit heads/test1 &&
+ check_push_result $the_commit heads/test2 &&
+ git push --delete testrepo test1 test2 &&
+ !(check_push_result $the_commit heads/test1) &&
+ !(check_push_result $the_commit heads/test2) &&
+ test_must_fail git push --delete testrepo test1
+
+'
test_expect_success 'push with +HEAD' '
--
1.5.6.rc1.153.gc1d96
^ permalink raw reply related
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