chiark / gitweb /
dgit: unrepres. changes: Prepare to tolerate symlinks
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 16 Jul 2017 10:19:29 +0000 (11:19 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 16 Jul 2017 11:46:25 +0000 (12:46 +0100)
Permit symlinks (which have mode 120000 in git) to make their way
through for more detailed checks.

No functional change except to error messages, because:

 * If neither thing was a symlink, then the existing regexps
   still match and the new "modified symlink" clause will not,
   so the flow is unchanged.

 * Otherwise, if both $oldmode and $newmode match [^0], ie,
   this is a modification rather than deletion or removal,
   we insist that $oldmode=$newmode, and then, fail the
   new "modified symlink" check.

 * Otherwise, we fail the check for default mode.

So in the case we are allowing to proceed further, we fail as before.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit
tests/tests/unrepresentable

diff --git a/dgit b/dgit
index dd3b31c717a60ab0562420f3fce5f3a439a8d929..8b9934b807c020233bc9f90d76487988460e2b30 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -4910,14 +4910,15 @@ sub quiltify_trees_differ ($$;$$$) {
 
        if ($unrepres) {
            eval {
-               die "not a plain file\n"
-                   unless $newmode =~ m/^10\d{4}$/ ||
-                          $oldmode =~ m/^10\d{4}$/;
+               die "not a plain file or symlink\n"
+                   unless $newmode =~ m/^(?:10|12)\d{4}$/ ||
+                          $oldmode =~ m/^(?:10|12)\d{4}$/;
                if ($oldmode =~ m/[^0]/ &&
                    $newmode =~ m/[^0]/) {
-                   die "mode changed\n" if $oldmode ne $newmode;
+                   die "mode or type changed\n" if $oldmode ne $newmode;
+                   die "modified symlink\n" unless $newmode =~ m/^10/;
                } else {
-                   die "non-default mode\n"
+                   die "non-default mode or type\n"
                        unless $newmode =~ m/^100644$/ ||
                               $oldmode =~ m/^100644$/;
                }
index fa71bd38b6e4ca7492ea2eb8eb4832d1c4c2109b..206af866b5c6eb7a63bd93318c756e8058cbde51 100755 (executable)
@@ -25,12 +25,12 @@ badly-2 () {
        attempt
 }
 
-badly-1 orig-symlink 'not a plain file'
+badly-1 orig-symlink 'modified symlink'
        ln -sf NEWTARGET orig-symlink
        git add orig-symlink
 badly-2
 
-badly-1 orig-symlink 'not a plain file'
+badly-1 orig-symlink 'non-default mode or type'
        git rm -f orig-symlink
 badly-2
 
@@ -39,7 +39,7 @@ start
        git commit -m deleted
 attempt
 
-badly-1 src.c 'mode changed'
+badly-1 src.c 'mode or type changed'
        chmod +x src.c
        git add src.c
 badly-2