chiark
/
gitweb
/
~ianmdlvl
/
dgit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
badcommit-fixup: reorganise arg parsing
[dgit.git]
/
badcommit-fixup
diff --git
a/badcommit-fixup
b/badcommit-fixup
index 1fa95d5fc31009f9a2ffd22e155d3e282abe43f9..ca2e0dfbdd28a8f02db50d38cd45244c06464d1b 100755
(executable)
--- a/
badcommit-fixup
+++ b/
badcommit-fixup
@@
-1,7
+1,7
@@
#!/usr/bin/perl -w
# usage:
#!/usr/bin/perl -w
# usage:
-# .../badcommit-fixup --test
+# .../badcommit-fixup
[--
--test
# .../badcommit-fixup --real
use strict;
# .../badcommit-fixup --real
use strict;
@@
-10,10
+10,19
@@
use POSIX;
use IPC::Open2;
use Data::Dumper;
use IPC::Open2;
use Data::Dumper;
-
die unless "@ARGV" eq "--test" or "@ARGV" eq "--real"
;
+
my $real
;
-my ($modeopt) = @ARGV;
-my $real = ($modeopt eq '--real');
+foreach my $a (@ARGV) {
+ if ($a eq '--test') {
+ $real = 0;
+ } elsif ($a eq '--real') {
+ $real = 1;
+ } else {
+ die "$a ?";
+ }
+}
+
+die unless defined $real;
my $gcfpid = open2 \*GCFO, \*GCFI, 'git cat-file --batch' or die $!;
my $gcfpid = open2 \*GCFO, \*GCFI, 'git cat-file --batch' or die $!;
@@
-132,8
+141,13
@@
foreach my $rline (split /\n/, $refs) {
open U, "|git update-ref -m 'dgit bad commit fixup' --stdin" or die $!;
if ($real) {
open U, "|git update-ref -m 'dgit bad commit fixup' --stdin" or die $!;
if ($real) {
- print "detaching your HEAD\n" or die $!;
- system 'git checkout --detach' and die "$! $?";
+ $!=0; $?=0;
+ my $bare = `git rev-parse --is-bare-repository`;
+ die "$? $!" if $?;
+ if ($bare eq 'false') {
+ print "detaching your HEAD\n" or die $!;
+ system 'git checkout --detach' and die "$! $?";
+ }
}
for my $up (@updates) {
}
for my $up (@updates) {