summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5c7721)
raw | patch | inline | side by side (parent: d5c7721)
author | Petr Baudis <pasky@suse.cz> | |
Sat, 24 Jun 2006 02:34:53 +0000 (04:34 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 3 Jul 2006 00:14:41 +0000 (17:14 -0700) |
Fairly straightforward.
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git-mv.perl | patch | blob | history |
diff --git a/git-mv.perl b/git-mv.perl
index 75aa8feeb6201c54e55bfaca0cc178c53891e776..f1bde4307ba719ce0e78ad360aa2ce1f4b7c6958 100755 (executable)
--- a/git-mv.perl
+++ b/git-mv.perl
use warnings;
use strict;
use Getopt::Std;
+use Git;
sub usage() {
print <<EOT;
usage() if $opt_h;
@ARGV >= 1 or usage;
-my $GIT_DIR = `git rev-parse --git-dir`;
-exit 1 if $?; # rev-parse would have given "not a git dir" message.
-chomp($GIT_DIR);
+my $repo = Git->repository();
my (@srcArgs, @dstArgs, @srcs, @dsts);
my ($src, $dst, $base, $dstDir);
$dstDir = "";
}
-my $subdir_prefix = `git rev-parse --show-prefix`;
-chomp($subdir_prefix);
+my $subdir_prefix = $repo->wc_subdir();
# run in git base directory, so that git-ls-files lists all revisioned files
-chdir "$GIT_DIR/..";
+chdir $repo->wc_path();
+$repo->wc_chdir('');
# normalize paths, needed to compare against versioned files and update-index
# also, this is nicer to end-users by doing ".//a/./b/.//./c" ==> "a/b/c"
my $safesrc;
my (%overwritten, %srcForDst);
-$/ = "\0";
-open(F, 'git-ls-files -z |')
- or die "Failed to open pipe from git-ls-files: " . $!;
-
-@allfiles = map { chomp; $_; } <F>;
-close(F);
+{
+ local $/ = "\0";
+ @allfiles = $repo->command('ls-files', '-z');
+}
my ($i, $bad);
}
else {
if (@changedfiles) {
- open(H, "| git-update-index -z --stdin")
- or die "git-update-index failed to update changed files with code $!\n";
+ my ($fd, $ctx) = $repo->command_input_pipe('update-index', '-z', '--stdin');
foreach my $fileName (@changedfiles) {
- print H "$fileName\0";
+ print $fd "$fileName\0";
}
- close(H);
+ git_cmd_try { $repo->command_close_pipe($fd, $ctx); }
+ 'git-update-index failed to update changed files with code %d';
}
if (@addedfiles) {
- open(H, "| git-update-index --add -z --stdin")
- or die "git-update-index failed to add new names with code $!\n";
+ my ($fd, $ctx) = $repo->command_input_pipe('update-index', '--add', '-z', '--stdin');
foreach my $fileName (@addedfiles) {
- print H "$fileName\0";
+ print $fd "$fileName\0";
}
- close(H);
+ git_cmd_try { $repo->command_close_pipe($fd, $ctx); }
+ 'git-update-index failed to add new files with code %d';
}
if (@deletedfiles) {
- open(H, "| git-update-index --remove -z --stdin")
- or die "git-update-index failed to remove old names with code $!\n";
+ my ($fd, $ctx) = $repo->command_input_pipe('update-index', '--remove', '-z', '--stdin');
foreach my $fileName (@deletedfiles) {
- print H "$fileName\0";
+ print $fd "$fileName\0";
}
- close(H);
+ git_cmd_try { $repo->command_close_pipe($fd, $ctx); }
+ 'git-update-index failed to remove old files with code %d';
}
}