# HG changeset patch
# User Olaf Wintermann <olaf.wintermann@gmail.com>
# Date 1505663762 -7200
# Node ID 8a474d2ad209b73e7f607fb3deedd5d3693d6df2
# Parent  82275f589d8dc3a89a69b33154330b92ce3a4f53
adds option to dav get for downloading only the directory structure

this is an undocumented feature and may be replaced in the future

diff -r 82275f589d8d -r 8a474d2ad209 dav/main.c
--- a/dav/main.c	Sun Sep 17 16:36:45 2017 +0200
+++ b/dav/main.c	Sun Sep 17 17:56:02 2017 +0200
@@ -705,12 +705,10 @@
 
 int get_resource(Repository *repo, DavResource *res, CmdArgs *a, char *out) {
     size_t outlen = strlen(out);
-    // print some status message in recursive mode
-    if(cmd_getoption(a, "recursive")) {
-        printf("get: %s\n", res->path);
-    }
     
     if(res->iscollection) {
+        printf("get: %s\n", res->path);
+        
         // create directory
         if(outlen != 0) {
             mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
@@ -735,6 +733,15 @@
         }
         
         return 0;
+    } else if(cmd_getoption(a, "structure")) {
+        // download only directory structure
+        // this is a hidden feature and will be replaced in the future
+        return 0;
+    }
+    
+    // print some status message in recursive mode
+    if(cmd_getoption(a, "recursive")) {
+        printf("get: %s\n", res->path);
     }
      
     FILE *fout = !strcmp(out, "-") ? stdout : fopen(out, "wb");
diff -r 82275f589d8d -r 8a474d2ad209 dav/optparser.c
--- a/dav/optparser.c	Sun Sep 17 16:36:45 2017 +0200
+++ b/dav/optparser.c	Sun Sep 17 17:56:02 2017 +0200
@@ -123,6 +123,11 @@
                         ucx_map_cstr_put(a->options, "extended", NOARG);
                         break;
                     }
+                    case 'S': {
+                        // undocumented hidden feature
+                        ucx_map_cstr_put(a->options, "structure", NOARG);
+                        break;
+                    }
                     case 'o': {
                         if(!option) {
                             option = "output";