git-p4: Unset P4DIFF environment variable when using 'p4 -du diff'
[gitweb.git] / git-filter-branch.sh
index 49e13f0bb1ed2bcb6e85455f24dffa912927d67a..010353ad82881886b9739cc5f8de595acc9273ef 100755 (executable)
@@ -252,7 +252,16 @@ while read commit parents; do
                git read-tree -i -m $commit
                ;;
        *)
-               git read-tree -i -m $commit:"$filter_subdir"
+               # The commit may not have the subdirectory at all
+               err=$(git read-tree -i -m $commit:"$filter_subdir" 2>&1) || {
+                       if ! git rev-parse --verify $commit:"$filter_subdir" 2>/dev/null
+                       then
+                               rm -f "$GIT_INDEX_FILE"
+                       else
+                               echo >&2 "$err"
+                               false
+                       fi
+               }
        esac || die "Could not initialize the index"
 
        GIT_COMMIT=$commit