]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'fc/at-head'
authorJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2013 20:31:23 +0000 (13:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2013 20:31:23 +0000 (13:31 -0700)
Instead of typing four capital letters "HEAD", you can say "@"
instead.

* fc/at-head:
  sha1_name: compare variable with constant, not constant with variable
  Add new @ shortcut for HEAD
  sha1_name: refactor reinterpret()
  sha1_name: check @{-N} errors sooner
  sha1_name: reorganize get_sha1_basic()
  sha1_name: don't waste cycles in the @-parsing loop
  sha1_name: remove unnecessary braces
  sha1_name: remove no-op
  tests: at-combinations: @{N} versus HEAD@{N}
  tests: at-combinations: increase coverage
  tests: at-combinations: improve nonsense()
  tests: at-combinations: check ref names directly
  tests: at-combinations: simplify setup

1  2 
Documentation/git-check-ref-format.txt
refs.c
sha1_name.c

diff --cc refs.c
Simple merge
diff --cc sha1_name.c
index a695d16d8c244700e28d220061818e59ee187000,5a58720d85be0af90a32490e31831df5bc7f1ae8..90419efe1052406381af3e35b70dc996fe8533ce
@@@ -435,31 -436,12 +436,31 @@@ static int interpret_nth_prior_checkout
  static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
  {
        static const char *warn_msg = "refname '%.*s' is ambiguous.";
 +      static const char *object_name_msg = N_(
 +      "Git normally never creates a ref that ends with 40 hex characters\n"
 +      "because it will be ignored when you just specify 40-hex. These refs\n"
 +      "may be created by mistake. For example,\n"
 +      "\n"
 +      "  git checkout -b $br $(git rev-parse ...)\n"
 +      "\n"
 +      "where \"$br\" is somehow empty and a 40-hex ref is created. Please\n"
 +      "examine these refs and maybe delete them. Turn this message off by\n"
 +      "running \"git config advice.object_name_warning false\"");
 +      unsigned char tmp_sha1[20];
        char *real_ref = NULL;
        int refs_found = 0;
-       int at, reflog_len;
+       int at, reflog_len, nth_prior = 0;
  
 -      if (len == 40 && !get_sha1_hex(str, sha1))
 +      if (len == 40 && !get_sha1_hex(str, sha1)) {
 +              refs_found = dwim_ref(str, len, tmp_sha1, &real_ref);
 +              if (refs_found > 0 && warn_ambiguous_refs) {
 +                      warning(warn_msg, len, str);
 +                      if (advice_object_name_warning)
 +                              fprintf(stderr, "%s\n", _(object_name_msg));
 +              }
 +              free(real_ref);
                return 0;
 +      }
  
        /* basic@{time or number or -number} format to query ref-log */
        reflog_len = at = 0;