Skip to content

running the script outside of git #10

@geoffhart

Description

@geoffhart

I wouldn't call this an "issue", but for me it's handy to run the script directly, without changing the .gitconfig. Like:

.../git-meld.pl HEAD^^ -- $PWD

all that was needed was:

@@ -157,13 +158,15 @@ sub copy_files_named_tree($$$) {
 # diff viewer
 sub link_files_working_dir($$) {
     (my $file_list, my $out_dir) = @_;
+    my $git_root = cwd();
+    $git_root =~ s!/[^/]+$!! while (! -d $git_root."/.git");
     # Because we're diffing against the working directory we wish to create a
     # tree of links in the dest folder mirroring that in the repo.
     # TODO: Fix this so we don't have to loop over each filename somehow
     foreach my $filename (@$file_list) {
         my $dir = $filename;
         safe_system("mkdir", "-p", dirname("$out_dir/$filename"));
-        safe_system("ln", "-s", cwd() . "/$filename", "$out_dir/$filename");
+        safe_system("ln", "-s", $git_root . "/$filename", "$out_dir/$filename")
     }
 }

I'm not sure if that's the correct way to detect the git root, but you get the idea.

Also, something you might consider:

@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl

a little more flexible....

BTW - awesome script - exactly what I was looking for :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions