Skip to content
Snippets Groups Projects
Select Git revision
  • v1.0rc3
  • passt default
  • master
  • pu
  • todo
  • next
  • maint
  • v2.8.0-rc1
  • v2.8.0-rc0
  • v2.7.2
  • v2.7.1
  • v2.7.0
  • v2.6.5
  • v2.7.0-rc3
  • v2.7.0-rc2
  • v2.7.0-rc1
  • v2.7.0-rc0
  • v2.6.4
  • v2.6.3
  • v2.6.2
  • v2.6.1
  • v2.3.10
  • v2.5.4
  • v2.4.10
  • v2.6.0
  • v2.6.0-rc3
  • v2.5.3
27 results

git-parse-remote.sh

Blame
  • git-mv.perl 4.58 KiB
    #!/usr/bin/perl
    #
    # Copyright 2005, Ryan Anderson <ryan@michonline.com>
    #                 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
    #
    # This file is licensed under the GPL v2, or a later version
    # at the discretion of Linus Torvalds.
    
    
    use warnings;
    use strict;
    use Getopt::Std;
    
    sub usage() {
    	print <<EOT;
    $0 [-f] [-n] <source> <dest>
    $0 [-f] [-k] [-n] <source> ... <dest directory>
    
    In the first form, source must exist and be either a file,
    symlink or directory, dest must not exist. It renames source to dest.
    In the second form, the last argument has to be an existing
    directory; the given sources will be moved into this directory.
    
    Updates the git cache to reflect the change.
    Use "git commit" to make the change permanently.
    
    Options:
      -f   Force renaming/moving, even if target exists
      -k   Continue on error by skipping
           not-existing or not revision-controlled source
      -n   Do nothing; show what would happen
    EOT
    	exit(1);
    }
    
    # Sanity checks:
    my $GIT_DIR = $ENV{'GIT_DIR'} || ".git";
    
    unless ( -d $GIT_DIR && -d $GIT_DIR . "/objects" && 
    	-d $GIT_DIR . "/objects/" && -d $GIT_DIR . "/refs") {
        print "Git repository not found.";
        usage();
    }
    
    
    our ($opt_n, $opt_f, $opt_h, $opt_k, $opt_v);
    getopts("hnfkv") || usage;
    usage() if $opt_h;
    @ARGV >= 1 or usage;
    
    my (@srcArgs, @dstArgs, @srcs, @dsts);
    my ($src, $dst, $base, $dstDir);
    
    my $argCount = scalar @ARGV;
    if (-d $ARGV[$argCount-1]) {
    	$dstDir = $ARGV[$argCount-1];
    	# remove any trailing slash
    	$dstDir =~ s/\/$//;
    	@srcArgs = @ARGV[0..$argCount-2];
    	
    	foreach $src (@srcArgs) {
    		$base = $src;
    		$base =~ s/^.*\///;
    		$dst = "$dstDir/". $base;
    		push @dstArgs, $dst;
    	}
    }
    else {
        if ($argCount != 2) {
    	print "Error: moving to directory '"