Merge commit '74359821' into js/reflog-delete
authorJunio C Hamano <gitster@pobox.com>
Mon, 3 Mar 2008 09:20:19 +0000 (01:20 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Mar 2008 09:20:19 +0000 (01:20 -0800)
* commit '74359821': (128 commits)
tests: introduce test_must_fail
Fix builtin checkout crashing when given an invalid path
templates/Makefile: don't depend on local umask setting
Correct name of diff_flush() in API documentation
Start preparing for 1.5.4.4
format-patch: remove a leftover debugging message
completion: support format-patch's --cover-letter option
Eliminate confusing "won't bisect on seeked tree" failure
builtin-reflog.c: don't install new reflog on write failure
send-email: fix In-Reply-To regression
git-svn: Don't prompt for client cert password everytime.
git.el: Do not display empty directories.
Fix 'git cvsexportcommit -w $cvsdir ...' when used with relative $GIT_DIR
Add testcase for 'git cvsexportcommit -w $cvsdir ...' with relative $GIT_DIR
Prompt to continue when editing during rebase --interactive
Documentation/git svn log: add a note about timezones.
git-p4: Support usage of perforce client spec
git-p4: git-p4 submit cleanups.
git-p4: Removed git-p4 submit --direct.
git-p4: Clean up git-p4 submit's log message handling.
...

1  2 
refs.c
diff --combined refs.c
index bc654299c9b5d7ab143c138e7f4e825691f2b12b,c979fb1d9507309785909a8d714ab28b1efd2e88..1b0050eee4e037aec8396edd0ff6c14bda5985a2
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -157,6 -157,7 +157,7 @@@ static struct cached_refs 
        struct ref_list *loose;
        struct ref_list *packed;
  } cached_refs;
+ static struct ref_list *current_ref;
  
  static void free_ref_list(struct ref_list *list)
  {
@@@ -476,6 -477,7 +477,7 @@@ static int do_one_ref(const char *base
                error("%s does not point to a valid object!", entry->name);
                return 0;
        }
+       current_ref = entry;
        return fn(entry->name + trim, entry->sha1, entry->flag, cb_data);
  }
  
@@@ -485,6 -487,16 +487,16 @@@ int peel_ref(const char *ref, unsigned 
        unsigned char base[20];
        struct object *o;
  
+       if (current_ref && (current_ref->name == ref
+               || !strcmp(current_ref->name, ref))) {
+               if (current_ref->flag & REF_KNOWS_PEELED) {
+                       hashcpy(sha1, current_ref->peeled);
+                       return 0;
+               }
+               hashcpy(base, current_ref->sha1);
+               goto fallback;
+       }
        if (!resolve_ref(ref, base, 1, &flag))
                return -1;
  
                }
        }
  
-       /* fallback - callers should not call this for unpacked refs */
+ fallback:
        o = parse_object(base);
-       if (o->type == OBJ_TAG) {
+       if (o && o->type == OBJ_TAG) {
                o = deref_tag(o, ref, 0);
                if (o) {
                        hashcpy(sha1, o->sha1);
  static int do_for_each_ref(const char *base, each_ref_fn fn, int trim,
                           void *cb_data)
  {
-       int retval;
+       int retval = 0;
        struct ref_list *packed = get_packed_refs();
        struct ref_list *loose = get_loose_refs();
  
                }
                retval = do_one_ref(base, fn, trim, cb_data, entry);
                if (retval)
-                       return retval;
+                       goto end_each;
        }
  
        for (packed = packed ? packed : loose; packed; packed = packed->next) {
                retval = do_one_ref(base, fn, trim, cb_data, packed);
                if (retval)
-                       return retval;
+                       goto end_each;
        }
-       return 0;
+ end_each:
+       current_ref = NULL;
+       return retval;
  }
  
  int head_ref(each_ref_fn fn, void *cb_data)
@@@ -1018,7 -1033,7 +1033,7 @@@ int rename_ref(const char *oldref, cons
        return 1;
  }
  
 -static int close_ref(struct ref_lock *lock)
 +int close_ref(struct ref_lock *lock)
  {
        if (close_lock_file(lock->lk))
                return -1;
        return 0;
  }
  
 -static int commit_ref(struct ref_lock *lock)
 +int commit_ref(struct ref_lock *lock)
  {
        if (commit_lock_file(lock->lk))
                return -1;