* [PATCH] Make 'cvs -n commit ...' not to commit
@ 2012-03-22 20:57 ericc
2012-03-23 18:39 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: ericc @ 2012-03-22 20:57 UTC (permalink / raw)
Actually, doing a 'cvs -n commit' will _do_ the commit...
With this patch, it now goes through the code, but don't do the commit.
A further progress would be to do the pre-commit hook is possible...
Eric Chamberland <Eric.Chamberland@giref.ulaval.ca>
---
git-cvsserver.perl | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index b8eddab..67ec4d0 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -1395,6 +1395,9 @@ sub req_ci
push @committedfiles, $committedfile;
$log->info("Committing $filename");
+ # Don't want to actually _DO_ the update if -n specified
+ unless ( $state->{globaloptions}{-n} )
+ {
system("mkdir","-p",$dirpart) unless ( -d $dirpart );
unless ( $rmflag )
@@ -1424,6 +1427,7 @@ sub req_ci
$log->info("Updating file '$filename'");
system("git", "update-index", $filename);
}
+ }
}
unless ( scalar(@committedfiles) > 0 )
@@ -1434,6 +1438,9 @@ sub req_ci
return;
}
+ # Don't want to actually _DO_ the update if -n specified
+ unless ( $state->{globaloptions}{-n} )
+ {
my $treehash = `git write-tree`;
chomp $treehash;
@@ -1537,7 +1544,7 @@ sub req_ci
print "/$filepart/1.$meta->{revision}//$kopts/\n";
}
}
-
+ }
cleanupWorkTree();
print "ok\n";
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Make 'cvs -n commit ...' not to commit
2012-03-22 20:57 [PATCH] Make 'cvs -n commit ...' not to commit ericc
@ 2012-03-23 18:39 ` Junio C Hamano
2012-03-23 19:02 ` Eric Chamberland
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2012-03-23 18:39 UTC (permalink / raw)
To: ericc; +Cc: git
ericc <eric.chamberland@giref.ulaval.ca> writes:
> Actually, doing a 'cvs -n commit' will _do_ the commit...
> With this patch, it now goes through the code, but don't do the commit.
OK.
> A further progress would be to do the pre-commit hook is possible...
It is not clear what you meant here.
> Eric Chamberland <Eric.Chamberland@giref.ulaval.ca>
> ---
> git-cvsserver.perl | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/git-cvsserver.perl b/git-cvsserver.perl
> index b8eddab..67ec4d0 100755
> --- a/git-cvsserver.perl
> +++ b/git-cvsserver.perl
> @@ -1395,6 +1395,9 @@ sub req_ci
> push @committedfiles, $committedfile;
> $log->info("Committing $filename");
>
> + # Don't want to actually _DO_ the update if -n specified
> + unless ( $state->{globaloptions}{-n} )
> + {
> system("mkdir","-p",$dirpart) unless ( -d $dirpart );
>
> unless ( $rmflag )
> @@ -1424,6 +1427,7 @@ sub req_ci
> $log->info("Updating file '$filename'");
> system("git", "update-index", $filename);
> }
> + }
> }
I understand that you tried to make the patch smaller by avoiding
re-indenting, but this is *yucky*.
It looks to me that the above part could be solved with:
unless (...) {
next;
}
I think the function being patched is too big. Wouldn't it be better to
have a refactoring patch to move the above per-path logic to a helper
function that deals with a single path, and then insert the "omit call to
that helper when run with -n" code in a separate patch?
The same comment applies to the other hunk.
Also I notice that the indentation used throughout the file is somewhat
broken (e.g. "Emulate by running hooks/update" part is indented to 8
columns, but earlier parts use 4 space indent). The right structure for
this change may be:
Patch 1: Fix indentation (and do nothing else) to uniformly indent with
HT;
Patch 2: Refactor this big funciton using a handful of helper functions
(and do nothing else);
Patch 3: Omit calls to these helper functions under -n option.
> @@ -1434,6 +1438,9 @@ sub req_ci
> return;
> }
>
> + # Don't want to actually _DO_ the update if -n specified
> + unless ( $state->{globaloptions}{-n} )
> + {
> my $treehash = `git write-tree`;
> chomp $treehash;
>
> @@ -1537,7 +1544,7 @@ sub req_ci
> print "/$filepart/1.$meta->{revision}//$kopts/\n";
> }
> }
> -
> + }
> cleanupWorkTree();
> print "ok\n";
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Make 'cvs -n commit ...' not to commit
2012-03-23 18:39 ` Junio C Hamano
@ 2012-03-23 19:02 ` Eric Chamberland
0 siblings, 0 replies; 3+ messages in thread
From: Eric Chamberland @ 2012-03-23 19:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On 03/23/2012 02:39 PM, Junio C Hamano wrote:
> ericc<eric.chamberland@giref.ulaval.ca> writes:
>
>> Actually, doing a 'cvs -n commit' will _do_ the commit...
>> With this patch, it now goes through the code, but don't do the commit.
>
> OK.
>
>> A further progress would be to do the pre-commit hook is possible...
Sorry, I wanted to write:
"A further progress would be to do the pre-commit hook *if* possible..."
here, we are used to do "cvs -n commit" just to check if the "hooks" on
the cvs server will fail or not...
>
> I understand that you tried to make the patch smaller by avoiding
> re-indenting, but this is *yucky*.
>
> It looks to me that the above part could be solved with:
>
> unless (...) {
> next;
> }
>
> I think the function being patched is too big. Wouldn't it be better to
> have a refactoring patch to move the above per-path logic to a helper
> function that deals with a single path, and then insert the "omit call to
> that helper when run with -n" code in a separate patch?
>
> The same comment applies to the other hunk.
>
> Also I notice that the indentation used throughout the file is somewhat
> broken (e.g. "Emulate by running hooks/update" part is indented to 8
> columns, but earlier parts use 4 space indent). The right structure for
> this change may be:
>
> Patch 1: Fix indentation (and do nothing else) to uniformly indent with
> HT;
>
> Patch 2: Refactor this big funciton using a handful of helper functions
> (and do nothing else);
>
> Patch 3: Omit calls to these helper functions under -n option.
>
>
Ok you are right... These were my very first lines in Perl... I just
wanted to catch the attention of someone who is able to do the changes
correctly... and in a more clean way than I...
Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-23 19:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-22 20:57 [PATCH] Make 'cvs -n commit ...' not to commit ericc
2012-03-23 18:39 ` Junio C Hamano
2012-03-23 19:02 ` Eric Chamberland
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.