Merge branch 'maint-1.6.5' into maint-1.6.6
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Feb 2010 23:04:55 +0000 (15:04 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Feb 2010 23:04:55 +0000 (15:04 -0800)
* maint-1.6.5:
dwim_ref: fix dangling symref warning
stash pop: remove 'apply' options during 'drop' invocation
diff: make sure --output=/bad/path is caught

1  2 
diff.c
git-stash.sh
sha1_name.c
diff --combined diff.c
index 6da52e0c49bc5646594ab47cba3971fd156e021d,8d8405aba29a4240f6a68c5fb1e3f0ad15050318..7a321f4254cf25101f9c9ed5df1621e3bf4b2e29
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -13,7 -13,6 +13,7 @@@
  #include "utf8.h"
  #include "userdiff.h"
  #include "sigchain.h"
 +#include "submodule.h"
  
  #ifdef NO_FAST_WORKING_DIRECTORY
  #define FAST_WORKING_DIRECTORY 0
@@@ -39,7 -38,6 +39,7 @@@ static char diff_colors[][COLOR_MAXLEN
        GIT_COLOR_GREEN,        /* NEW */
        GIT_COLOR_YELLOW,       /* COMMIT */
        GIT_COLOR_BG_RED,       /* WHITESPACE */
 +      GIT_COLOR_NORMAL,       /* FUNCINFO */
  };
  
  static void diff_filespec_load_driver(struct diff_filespec *one);
@@@ -61,8 -59,6 +61,8 @@@ static int parse_diff_color_slot(const 
                return DIFF_COMMIT;
        if (!strcasecmp(var+ofs, "whitespace"))
                return DIFF_WHITESPACE;
 +      if (!strcasecmp(var+ofs, "func"))
 +              return DIFF_FUNCINFO;
        return -1;
  }
  
@@@ -300,13 -296,12 +300,13 @@@ static void emit_line_0(FILE *file, con
                nofirst = 0;
        }
  
 -      fputs(set, file);
 -
 -      if (!nofirst)
 -              fputc(first, file);
 -      fwrite(line, len, 1, file);
 -      fputs(reset, file);
 +      if (len || !nofirst) {
 +              fputs(set, file);
 +              if (!nofirst)
 +                      fputc(first, file);
 +              fwrite(line, len, 1, file);
 +              fputs(reset, file);
 +      }
        if (has_trailing_carriage_return)
                fputc('\r', file);
        if (has_trailing_newline)
@@@ -350,42 -345,6 +350,42 @@@ static void emit_add_line(const char *r
        }
  }
  
 +static void emit_hunk_header(struct emit_callback *ecbdata,
 +                           const char *line, int len)
 +{
 +      const char *plain = diff_get_color(ecbdata->color_diff, DIFF_PLAIN);
 +      const char *frag = diff_get_color(ecbdata->color_diff, DIFF_FRAGINFO);
 +      const char *func = diff_get_color(ecbdata->color_diff, DIFF_FUNCINFO);
 +      const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
 +      static const char atat[2] = { '@', '@' };
 +      const char *cp, *ep;
 +
 +      /*
 +       * As a hunk header must begin with "@@ -<old>, +<new> @@",
 +       * it always is at least 10 bytes long.
 +       */
 +      if (len < 10 ||
 +          memcmp(line, atat, 2) ||
 +          !(ep = memmem(line + 2, len - 2, atat, 2))) {
 +              emit_line(ecbdata->file, plain, reset, line, len);
 +              return;
 +      }
 +      ep += 2; /* skip over @@ */
 +
 +      /* The hunk header in fraginfo color */
 +      emit_line(ecbdata->file, frag, reset, line, ep - line);
 +
 +      /* blank before the func header */
 +      for (cp = ep; ep - line < len; ep++)
 +              if (*ep != ' ' && *ep != '\t')
 +                      break;
 +      if (ep != cp)
 +              emit_line(ecbdata->file, plain, reset, cp, ep - cp);
 +
 +      if (ep < line + len)
 +              emit_line(ecbdata->file, func, reset, ep, line + len - ep);
 +}
 +
  static struct diff_tempfile *claim_diff_tempfile(void) {
        int i;
        for (i = 0; i < ARRAY_SIZE(diff_temp); i++)
@@@ -823,7 -782,9 +823,7 @@@ static void fn_out_consume(void *priv, 
                        diff_words_flush(ecbdata);
                len = sane_truncate_line(ecbdata, line, len);
                find_lno(line, ecbdata);
 -              emit_line(ecbdata->file,
 -                        diff_get_color(ecbdata->color_diff, DIFF_FRAGINFO),
 -                        reset, line, len);
 +              emit_hunk_header(ecbdata, line, len);
                if (line[len-1] != '\n')
                        putc('\n', ecbdata->file);
                return;
@@@ -1155,7 -1116,7 +1155,7 @@@ static void show_stats(struct diffstat_
               total_files, adds, dels);
  }
  
 -static void show_shortstats(struct diffstat_tdata, struct diff_options *options)
 +static void show_shortstats(struct diffstat_t *data, struct diff_options *options)
  {
        int i, adds = 0, dels = 0, total_files = data->nr;
  
@@@ -1602,17 -1563,6 +1602,17 @@@ static void builtin_diff(const char *na
        const char *a_prefix, *b_prefix;
        const char *textconv_one = NULL, *textconv_two = NULL;
  
 +      if (DIFF_OPT_TST(o, SUBMODULE_LOG) &&
 +                      (!one->mode || S_ISGITLINK(one->mode)) &&
 +                      (!two->mode || S_ISGITLINK(two->mode))) {
 +              const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
 +              const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
 +              show_submodule_summary(o->file, one ? one->path : two->path,
 +                              one->sha1, two->sha1,
 +                              del, add, reset);
 +              return;
 +      }
 +
        if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
                textconv_one = get_textconv(one);
                textconv_two = get_textconv(two);
@@@ -2813,12 -2763,6 +2813,12 @@@ int diff_opt_parse(struct diff_options 
                DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
        else if (!strcmp(arg, "--ignore-submodules"))
                DIFF_OPT_SET(options, IGNORE_SUBMODULES);
 +      else if (!strcmp(arg, "--submodule"))
 +              DIFF_OPT_SET(options, SUBMODULE_LOG);
 +      else if (!prefixcmp(arg, "--submodule=")) {
 +              if (!strcmp(arg + 12, "log"))
 +                      DIFF_OPT_SET(options, SUBMODULE_LOG);
 +      }
  
        /* misc options */
        else if (!strcmp(arg, "-z"))
                ;
        else if (!prefixcmp(arg, "--output=")) {
                options->file = fopen(arg + strlen("--output="), "w");
+               if (!options->file)
+                       die_errno("Could not open '%s'", arg + strlen("--output="));
                options->close_file = 1;
        } else
                return 0;
diff --combined git-stash.sh
index 3a0685f1893098e8f5c877f509183c8434e7c028,79b277109975cbda46f91de3bdcabbf98e084d53..2d691963934c31242512bd4dd349d970c0350243
@@@ -7,7 -7,7 +7,7 @@@ USAGE="list [<options>
     or: $dashless drop [-q|--quiet] [<stash>]
     or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
     or: $dashless branch <branchname> [<stash>]
 -   or: $dashless [save [-k|--keep-index] [-q|--quiet] [<message>]]
 +   or: $dashless [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] [<message>]]
     or: $dashless clear"
  
  SUBDIRECTORY_OK=Yes
@@@ -205,7 -205,8 +205,7 @@@ have_stash () 
  
  list_stash () {
        have_stash || return 0
 -      git log --no-color --pretty=oneline -g "$@" $ref_stash -- |
 -      sed -n -e 's/^[.0-9a-f]* refs\///p'
 +      git log --format="%gd: %gs" -g "$@" $ref_stash --
  }
  
  show_stash () {
  }
  
  apply_stash () {
+       applied_stash=
        unstash_index=
  
        while test $# != 0
        if test $# = 0
        then
                have_stash || die 'Nothing to apply'
+               applied_stash="$ref_stash@{0}"
+       else
+               applied_stash="$*"
        fi
  
        # stash records the work tree, and is a merge between the
@@@ -382,6 -387,11 +386,6 @@@ test -n "$seen_non_option" || set "save
  case "$1" in
  list)
        shift
 -      if test $# = 0
 -      then
 -              set x -n 10
 -              shift
 -      fi
        list_stash "$@"
        ;;
  show)
@@@ -415,8 -425,7 +419,7 @@@ pop
        shift
        if apply_stash "$@"
        then
-               test -z "$unstash_index" || shift
-               drop_stash "$@"
+               drop_stash "$applied_stash"
        fi
        ;;
  branch)
diff --combined sha1_name.c
index 04fb3b8fed2970bf7fde83e0dc38cea9485ca3d2,9677afdadb337fd8d4f69307aebe8b0186a4e7c8..7013c53ca6f083b6887f2d8567c72c5a63054c1c
@@@ -278,8 -278,7 +278,7 @@@ int dwim_ref(const char *str, int len, 
                                *ref = xstrdup(r);
                        if (!warn_ambiguous_refs)
                                break;
-               } else if ((flag & REF_ISSYMREF) &&
-                          (len != 4 || strcmp(str, "HEAD")))
+               } else if ((flag & REF_ISSYMREF) && strcmp(fullref, "HEAD"))
                        warning("ignoring dangling symref %s.", fullref);
        }
        free(last_branch);
@@@ -395,12 -394,9 +394,12 @@@ static int get_sha1_basic(const char *s
                } else if (0 <= nth)
                        at_time = 0;
                else {
 +                      int errors = 0;
                        char *tmp = xstrndup(str + at + 2, reflog_len);
 -                      at_time = approxidate(tmp);
 +                      at_time = approxidate_careful(tmp, &errors);
                        free(tmp);
 +                      if (errors)
 +                              return -1;
                }
                if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
                                &co_time, &co_tz, &co_cnt)) {