Merge branch 'rs/archive-excluded-directory' into next
authorJunio C Hamano <gitster@pobox.com>
Tue, 19 Sep 2017 03:52:27 +0000 (12:52 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Sep 2017 03:52:28 +0000 (12:52 +0900)
"git archive", especially when used with pathspec, stored an empty
directory in its output, even though Git itself never does so.
This has been fixed.

* rs/archive-excluded-directory:
archive: don't add empty directories to archives

1  2 
archive.c
diff --combined archive.c
index 1ab8d3a1d7cc9c3e55465fbadf899e8a267de689,f81bd3649a1f4bf20bc03100d12fc157401bdc14..1e41f4bbeb1d8730da83aad12bc8987abedcad8a
+++ b/archive.c
@@@ -121,11 -121,6 +121,6 @@@ static int check_attr_export_subst(cons
        return check && ATTR_TRUE(check->items[1].value);
  }
  
- static int should_queue_directories(const struct archiver_args *args)
- {
-       return args->pathspec.has_wildcard;
- }
  static int write_archive_entry(const unsigned char *sha1, const char *base,
                int baselen, const char *filename, unsigned mode, int stage,
                void *context)
                strbuf_addch(&path, '/');
        path_without_prefix = path.buf + args->baselen;
  
-       if (!S_ISDIR(mode) || !should_queue_directories(args)) {
+       if (!S_ISDIR(mode)) {
                const struct attr_check *check;
                check = get_archive_attrs(path_without_prefix);
                if (check_attr_export_ignore(check))
        return write_entry(args, sha1, path.buf, path.len, mode);
  }
  
- static int write_archive_entry_buf(const unsigned char *sha1, struct strbuf *base,
-               const char *filename, unsigned mode, int stage,
-               void *context)
- {
-       return write_archive_entry(sha1, base->buf, base->len,
-                                    filename, mode, stage, context);
- }
  static void queue_directory(const unsigned char *sha1,
                struct strbuf *base, const char *filename,
                unsigned mode, int stage, struct archiver_context *c)
@@@ -290,9 -277,7 +277,7 @@@ int write_archive_entries(struct archiv
        }
  
        err = read_tree_recursive(args->tree, "", 0, 0, &args->pathspec,
-                                 should_queue_directories(args) ?
-                                 queue_or_write_archive_entry :
-                                 write_archive_entry_buf,
+                                 queue_or_write_archive_entry,
                                  &context);
        if (err == READ_TREE_RECURSIVE)
                err = 0;
@@@ -391,7 -376,7 +376,7 @@@ static void parse_treeish_arg(const cha
                free(ref);
        }
  
 -      if (get_sha1(name, oid.hash))
 +      if (get_oid(name, &oid))
                die("Not a valid object name");
  
        commit = lookup_commit_reference_gently(&oid, 1);