Merge branch 'cb/maint-ls-files-error-report' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 23 Sep 2011 21:30:49 +0000 (14:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 Sep 2011 21:30:49 +0000 (14:30 -0700)
* cb/maint-ls-files-error-report:
t3005: do not assume a particular order of stdout and stderr of git-ls-files
ls-files: fix pathspec display on error

1  2 
builtin/checkout.c
cache.h
diff --combined builtin/checkout.c
index ca855d716ccab1d1209638193e2f52e901acfba0,a5717f1637d9a018ba5f953bc356e84341b612cd..4c20dae34d2fc095195d91adae0af26087306277
@@@ -201,7 -201,7 +201,7 @@@ static int checkout_merged(int pos, str
  }
  
  static int checkout_paths(struct tree *source_tree, const char **pathspec,
-                         struct checkout_opts *opts)
+                         const char *prefix, struct checkout_opts *opts)
  {
        int pos;
        struct checkout state;
                match_pathspec(pathspec, ce->name, ce_namelen(ce), 0, ps_matched);
        }
  
-       if (report_path_error(ps_matched, pathspec, 0))
+       if (report_path_error(ps_matched, pathspec, prefix))
                return 1;
  
        /* "checkout -m path" to recreate conflicted state */
@@@ -715,12 -715,10 +715,12 @@@ static int switch_branches(struct check
        unsigned char rev[20];
        int flag;
        memset(&old, 0, sizeof(old));
 -      old.path = resolve_ref("HEAD", rev, 0, &flag);
 +      old.path = xstrdup(resolve_ref("HEAD", rev, 0, &flag));
        old.commit = lookup_commit_reference_gently(rev, 1);
 -      if (!(flag & REF_ISSYMREF))
 +      if (!(flag & REF_ISSYMREF)) {
 +              free((char *)old.path);
                old.path = NULL;
 +      }
  
        if (old.path && !prefixcmp(old.path, "refs/heads/"))
                old.name = old.path + strlen("refs/heads/");
        update_refs_for_switch(opts, &old, new);
  
        ret = post_checkout_hook(old.commit, new->commit, 1);
 +      free((char *)old.path);
        return ret || opts->writeout_error;
  }
  
@@@ -1063,7 -1060,7 +1063,7 @@@ int cmd_checkout(int argc, const char *
                if (1 < !!opts.writeout_stage + !!opts.force + !!opts.merge)
                        die(_("git checkout: --ours/--theirs, --force and --merge are incompatible when\nchecking out of the index."));
  
-               return checkout_paths(source_tree, pathspec, &opts);
+               return checkout_paths(source_tree, pathspec, prefix, &opts);
        }
  
        if (patch_mode)
                if (strbuf_check_branch_ref(&buf, opts.new_branch))
                        die(_("git checkout: we do not like '%s' as a branch name."),
                            opts.new_branch);
 -              if (!get_sha1(buf.buf, rev)) {
 +              if (ref_exists(buf.buf)) {
                        opts.branch_exists = 1;
                        if (!opts.new_branch_force)
                                die(_("git checkout: branch %s already exists"),
diff --combined cache.h
index e494bdcda77678c971ab810151e0d5ecfe89c447,d55a6bbe37a1c2174738cc22a88ca259b4924852..6b24c252ef5c8d56b06cf0f00934fc79e46f022c
+++ b/cache.h
  #endif
  
  #include <zlib.h>
 -#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
 -#define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
 -#endif
 -
 -void git_inflate_init(z_streamp strm);
 -void git_inflate_end(z_streamp strm);
 -int git_inflate(z_streamp strm, int flush);
 +typedef struct git_zstream {
 +      z_stream z;
 +      unsigned long avail_in;
 +      unsigned long avail_out;
 +      unsigned long total_in;
 +      unsigned long total_out;
 +      unsigned char *next_in;
 +      unsigned char *next_out;
 +} git_zstream;
 +
 +void git_inflate_init(git_zstream *);
 +void git_inflate_init_gzip_only(git_zstream *);
 +void git_inflate_end(git_zstream *);
 +int git_inflate(git_zstream *, int flush);
 +
 +void git_deflate_init(git_zstream *, int level);
 +void git_deflate_init_gzip(git_zstream *, int level);
 +void git_deflate_end(git_zstream *);
 +int git_deflate_end_gently(git_zstream *);
 +int git_deflate(git_zstream *, int flush);
 +unsigned long git_deflate_bound(git_zstream *, unsigned long);
  
  #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
  #define DTYPE(de)     ((de)->d_type)
@@@ -434,7 -420,7 +434,7 @@@ extern char *get_index_file(void)
  extern char *get_graft_file(void);
  extern int set_git_dir(const char *path);
  extern const char *get_git_work_tree(void);
 -extern const char *read_gitfile_gently(const char *path);
 +extern const char *read_gitfile(const char *path);
  extern void set_git_work_tree(const char *tree);
  
  #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
@@@ -1023,7 -1009,7 +1023,7 @@@ extern struct packed_git *find_sha1_pac
  extern void pack_report(void);
  extern int open_pack_index(struct packed_git *);
  extern void close_pack_index(struct packed_git *);
 -extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *);
 +extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
  extern void close_pack_windows(struct packed_git *);
  extern void unuse_pack(struct pack_window **);
  extern void free_pack_by_name(const char *);
@@@ -1189,7 -1175,7 +1189,7 @@@ extern int ws_blank_line(const char *li
  #define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
  
  /* ls-files */
- int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset);
+ int report_path_error(const char *ps_matched, const char **pathspec, const char *prefix);
  void overlay_tree_on_cache(const char *tree_name, const char *prefix);
  
  char *alias_lookup(const char *alias);