From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v4 4/4] Accept tags in HEAD or MERGE_HEAD
Date: Sat, 20 Aug 2011 23:37:11 +0700 [thread overview]
Message-ID: <CACsJy8CLb-PrMdt05HEV-sHWwWbsu9MaC7-khAoT43O8vfkSDg@mail.gmail.com> (raw)
In-Reply-To: <7vaab52m2r.fsf@alter.siamese.dyndns.org>
2011/8/20 Junio C Hamano <gitster@pobox.com>:
> That's de-reference, not deference ;-). You may want to be more explicit
> about what kind of de-reference you are talking about.
>
> /*
> * Get a commit object for the given sha1, unwrapping a tag object that
> * point at a commit while at it. ref_name is only used when the result
> * is not a commit in the error message to report where we got the sha1
> * from.
> */
>
> I actually was hoping that you would have this comment in commit.h to help
> people who want to add callers of this function, not next to the
> implementation.
OK. It's because I tend to go straight to implementation instead of
the declaration when I want to know how to use it.
> As I said earlier, I do not think updating sha1[] here is necessary. The
> caller should be updated to use c->object.sha1 instead.
The usual pattern is
get_sha1(ref, sha1);
commit = lookup_commit_or_die(sha1, ref);
From a quick look, it's very easy to assume "sha1" is safe to use
afterwards while it may be different from commit->object.sha1. I'm
tempted to make lookup_commit_or_die() resolve ref to sha1 internally,
no temporary sha1 variable will be hanging around, the pattern becomes
commit = lookup_commit_or_die(ref);
The only problem is MERGE_HEAD is not usual ref and cannot be treated this way.
--
Duy
next prev parent reply other threads:[~2011-08-20 16:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-15 15:38 [PATCH] commit: check return value of lookup_commit() Nguyễn Thái Ngọc Duy
2011-08-15 17:46 ` Junio C Hamano
2011-08-16 13:22 ` Nguyen Thai Ngoc Duy
2011-08-16 18:02 ` Junio C Hamano
2011-08-17 1:32 ` Nguyen Thai Ngoc Duy
2011-08-17 1:42 ` [PATCH v2] commit: accept tag objects in HEAD/MERGE_HEAD Nguyễn Thái Ngọc Duy
2011-08-17 17:59 ` Junio C Hamano
2011-08-18 2:10 ` Nguyen Thai Ngoc Duy
2011-08-18 13:43 ` [PATCH v3] Accept tags in HEAD or MERGE_HEAD Nguyễn Thái Ngọc Duy
2011-08-18 18:54 ` Junio C Hamano
2011-08-19 12:53 ` Nguyen Thai Ngoc Duy
2011-08-19 14:50 ` [PATCH v4 1/4] commit: remove global variable head_sha1[] Nguyễn Thái Ngọc Duy
2011-08-19 14:50 ` [PATCH v4 2/4] merge: keep stash[] a local variable Nguyễn Thái Ngọc Duy
2011-08-19 22:59 ` Junio C Hamano
2011-08-19 14:50 ` [PATCH v4 3/4] merge: remove global variable head[] Nguyễn Thái Ngọc Duy
2011-08-23 18:46 ` Junio C Hamano
2011-08-19 14:50 ` [PATCH v4 4/4] Accept tags in HEAD or MERGE_HEAD Nguyễn Thái Ngọc Duy
2011-08-19 20:17 ` Junio C Hamano
2011-08-20 16:37 ` Nguyen Thai Ngoc Duy [this message]
2011-08-19 18:57 ` [PATCH v4 1/4] commit: remove global variable head_sha1[] Junio C Hamano
2011-08-20 12:03 ` Nguyen Thai Ngoc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACsJy8CLb-PrMdt05HEV-sHWwWbsu9MaC7-khAoT43O8vfkSDg@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).