Sources of pandora sale For Kids, Bags For girls
Making a decision to buy gifts for teenage girls can be very difficult. When you want to give them something special, you might consider * pandora uk http://www.buycheappandorarings.co.uk/ * for kids. These options are great options for that gift that you want to be extra special. Whether you are buying a gift for a special occasion or just because, there are a wide range of choices that can be found. Deciding on the piece you might choose is going to be influenced by things such as the girl, the occasion and the cost. Making these choices might be something that you do based on the individuality of the girl. * http://www.buycheappandorarings.co.uk/ * -- View this message in context: http://git.661346.n2.nabble.com/Sources-of-pandora-sale-For-Kids-Bags-For-girls-tp7581102.html Sent from the git mailing list archive at Nabble.com. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Bug in git rev-parse --verify
Michael Haggerty mhag...@alum.mit.edu writes: On 03/30/2013 05:09 AM, Junio C Hamano wrote: So why not verify arguments while making sure of their type early with 'rev-parse --verify $userinput^{desiredtype}? Yes, that's a better solution in almost all cases. Thanks for the tip. (It doesn't change my opinion that the documentation for rev-parse --verify is misleading, but given that you don't appear to want to change its behavior I will submit a documentation patch.) It does not matter what I want. What matters is that changing the definition is a _wrong_ thing to do, as --verify is designed to be usable for objects you may not yet have. What we may want is another type peeling operator, ^{object}. makes sure it is an object, that lets you say: rev-parse --verify 572a535454612a046e7dd7404dcca94d6243c788^{object} It asks I have this 40-hex; I want an object out of it, just like frotz^{tree} is I have 'frotz'; I want a tree-ish for any value of 'frotz'. With that, a use case that it wants to see _any_ object can safely use 'rev-parse --verify $userinput^{object}' without an annotated tag getting in the way. How does that sound? -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] rev-parse: clarify documentation for the --verify option
The old version could be read to mean that the argument has to refer to a valid object, but that is incorrect: * the object is not necessarily read (e.g., to check for corruption) * if the argument is a 40-digit string of hex digits, then it is accepted whether or not is is the name of an existing object. So reword the explanation to be less ambiguous. Also fix the examples involving --verify: to be sure that the argument refers to a commit (rather than some other kind of object), the argument has to be suffixed with ^{commit}. This trick is not possible in the example involving --default, so don't imply that it is exactly the same as the previous example. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu --- This was discussed in the following thread: http://thread.gmane.org/gmane.comp.version-control.git/219409 Please note that the second example already reveals a fly in the ointment: $ git rev-parse --default master --verify $REV Following Junio's advice, we would like to change this to $ git rev-parse --default master --verify $REV^{commit} but that defeats the purpose of the --default option. Doing $ git rev-parse --verify $(git rev-parse --default master $REV)^{commit} is just plain ugly. Though honestly, I don't see the point of using --default as opposed to $ git rev-parse --verify ${REV:-master}^{commit} So maybe the second example should be removed entirely or converted to use ${REV:-master} rather than --default. Documentation/git-rev-parse.txt | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt index 10a116f..6095227 100644 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@ -60,8 +60,10 @@ OPTIONS instead. --verify:: - The parameter given must be usable as a single, valid - object name. Otherwise barf and abort. + If the parameter can be used as a single object name, output + that name; otherwise, emit an error message and exit with a + non-zero status. Please note that the existence and validity + of the named object itself are not checked. -q:: --quiet:: @@ -308,12 +310,12 @@ $ git rev-parse --verify HEAD * Print the commit object name from the revision in the $REV shell variable: + -$ git rev-parse --verify $REV +$ git rev-parse --verify $REV^{commit} + This will error out if $REV is empty or not a valid revision. -* Same as above: +* Similar to above: + $ git rev-parse --default master --verify $REV -- 1.8.2 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
tiffany jewellery uk Making you Appealing Ladies
Speaking of ladies, elegance as well as love is going to be regarded as their own alternatives. Within their whole life, these people go after the beauty as well as style. Jewellery is actually their own required item. Tiffany jewellery is among the most widely used styles amongst a lot of types of jewellery. Because of its esteemed title and also the fine quality, * http://www.tiffanyandcocharmsstore.co.uk/ tiffany uk* includes a excellent need. The actual styles associated with Tiffany jewellery had been usually various as well as stunning which makes it uniquely well-known. The look associated with tiffany jewellery is simple as well as stylish. * http://www.tiffanyandcocharmsstore.co.uk/ * -- View this message in context: http://git.661346.n2.nabble.com/tiffany-jewellery-uk-Making-you-Appealing-Ladies-tp7581105.html Sent from the git mailing list archive at Nabble.com. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Bug in git rev-parse --verify
Junio C Hamano gits...@pobox.com writes: What we may want is another type peeling operator, ^{object}. that makes sure it is an object, like this: rev-parse --verify 572a535454612a046e7dd7404dcca94d6243c788^{object} It asks I have this 40-hex; I want an object out of it, just like frotz^{tree} is I have 'frotz'; I want a tree-ish for any value of 'frotz'. With that, a use case that it wants to see _any_ object can safely use 'rev-parse --verify $userinput^{object}' without an annotated tag getting in the way. How does that sound? Perhaps something like this. Note that the last hunk is unrelated thinko-fix I noticed while browsing the code. -- 8 -- Subject: sha1_name.c: ^{object} peeler A string that names an object can be suffixed with ^{type} peeler to say I have this object name; peel it until you get this type. If you cannot do so, it is an error. v1.8.2^{commit} asks for a commit that is pointed at an annotated tag v1.8.2; v1.8.2^{tree} unwraps it further to the top-level tree object. A special suffix ^{} (i.e. no type specified) means I do not care what it unwraps to; just peel annotated tag until you get something that is not a tag. When you have a random user-supplied string, you can turn it to a bare 40-hex object name, and cause it to error out if such an object does not exist, with: git rev-parse --verify $userstring^{} for most objects, but this does not yield the tag object name when $userstring refers to an annotated tag. Introduce a new suffix, ^{object}, that only makes sure the given name refers to an existing object. Then git rev-parse --verify $userstring^{object} becomes a way to make sure $userstring refers to an existing object. Signed-off-by: Junio C Hamano gits...@pobox.com --- sha1_name.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sha1_name.c b/sha1_name.c index c50630a..85b6e75 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -594,7 +594,7 @@ struct object *peel_to_type(const char *name, int namelen, while (1) { if (!o || (!o-parsed !parse_object(o-sha1))) return NULL; - if (o-type == expected_type) + if (expected_type == OBJ_ANY || o-type == expected_type) return o; if (o-type == OBJ_TAG) o = ((struct tag*) o)-tagged; @@ -645,6 +645,8 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) expected_type = OBJ_TREE; else if (!strncmp(blob_type, sp, 4) sp[4] == '}') expected_type = OBJ_BLOB; + else if (!prefixcmp(sp, object})) + expected_type = OBJ_ANY; else if (sp[0] == '}') expected_type = OBJ_NONE; else if (sp[0] == '/') @@ -654,6 +656,8 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) if (expected_type == OBJ_COMMIT) lookup_flags = GET_SHA1_COMMITTISH; + else if (expected_type == OBJ_TREE) + lookup_flags = GET_SHA1_TREEISH; if (get_sha1_1(name, sp - name - 2, outer, lookup_flags)) return -1; -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
pandora bracelet charms is usually like all other expensive jewelry at a sens
You should be hunting for pandora bracelet charms http://www.pndoracharmonlineshop.ca on Connecticut, notably that ever in your life well known enchantment rings. It's a distinct and even classic variety of expensive jewelry which will started in Denmark. You can get an electric in Pandora expensive jewelry in addition rings. You will also find neck laces, diamond rings and even jewels. Those things causes any such expensive jewelry as a result distinct is without a doubt that you really have the capability to model ones own expensive jewelry chunk as a result of merging several drops and even bracelets mutually. Because of this each individual chunk develops into personalised. It is easy to choose to order it expensive jewelry definitely create on whole collections and you may choose to go for design ones own distinct piece of expensive jewelry as a result of purchasing the drops on an individual basis and even personalizing ones own chunk. http://www.pndoracharmonlineshop.ca -- View this message in context: http://git.661346.n2.nabble.com/pandora-bracelet-charms-is-usually-like-all-other-expensive-jewelry-at-a-sens-tp7581108.html Sent from the git mailing list archive at Nabble.com. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Bug in git rev-parse --verify
On 03/30/2013 08:05 AM, Junio C Hamano wrote: Junio C Hamano gits...@pobox.com writes: What we may want is another type peeling operator, ^{object}. that makes sure it is an object, like this: rev-parse --verify 572a535454612a046e7dd7404dcca94d6243c788^{object} It asks I have this 40-hex; I want an object out of it, just like frotz^{tree} is I have 'frotz'; I want a tree-ish for any value of 'frotz'. With that, a use case that it wants to see _any_ object can safely use 'rev-parse --verify $userinput^{object}' without an annotated tag getting in the way. How does that sound? Perhaps something like this. Note that the last hunk is unrelated thinko-fix I noticed while browsing the code. Sounds reasonable to me. I'm not familiar with this code, but your change looks simple enough. Plus documentation change in Documentation/revisions.txt, of course. Thanks, Michael -- Michael Haggerty mhag...@alum.mit.edu http://softwareswirl.blogspot.com/ -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Bug in git rev-parse --verify
Fwiw, look very a sound idea for me. Best 2013/3/30, Junio C Hamano gits...@pobox.com: Junio C Hamano gits...@pobox.com writes: What we may want is another type peeling operator, ^{object}. that makes sure it is an object, like this: rev-parse --verify 572a535454612a046e7dd7404dcca94d6243c788^{object} It asks I have this 40-hex; I want an object out of it, just like frotz^{tree} is I have 'frotz'; I want a tree-ish for any value of 'frotz'. With that, a use case that it wants to see _any_ object can safely use 'rev-parse --verify $userinput^{object}' without an annotated tag getting in the way. How does that sound? Perhaps something like this. Note that the last hunk is unrelated thinko-fix I noticed while browsing the code. -- 8 -- Subject: sha1_name.c: ^{object} peeler A string that names an object can be suffixed with ^{type} peeler to say I have this object name; peel it until you get this type. If you cannot do so, it is an error. v1.8.2^{commit} asks for a commit that is pointed at an annotated tag v1.8.2; v1.8.2^{tree} unwraps it further to the top-level tree object. A special suffix ^{} (i.e. no type specified) means I do not care what it unwraps to; just peel annotated tag until you get something that is not a tag. When you have a random user-supplied string, you can turn it to a bare 40-hex object name, and cause it to error out if such an object does not exist, with: git rev-parse --verify $userstring^{} for most objects, but this does not yield the tag object name when $userstring refers to an annotated tag. Introduce a new suffix, ^{object}, that only makes sure the given name refers to an existing object. Then git rev-parse --verify $userstring^{object} becomes a way to make sure $userstring refers to an existing object. Signed-off-by: Junio C Hamano gits...@pobox.com --- sha1_name.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sha1_name.c b/sha1_name.c index c50630a..85b6e75 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -594,7 +594,7 @@ struct object *peel_to_type(const char *name, int namelen, while (1) { if (!o || (!o-parsed !parse_object(o-sha1))) return NULL; - if (o-type == expected_type) + if (expected_type == OBJ_ANY || o-type == expected_type) return o; if (o-type == OBJ_TAG) o = ((struct tag*) o)-tagged; @@ -645,6 +645,8 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) expected_type = OBJ_TREE; else if (!strncmp(blob_type, sp, 4) sp[4] == '}') expected_type = OBJ_BLOB; + else if (!prefixcmp(sp, object})) + expected_type = OBJ_ANY; else if (sp[0] == '}') expected_type = OBJ_NONE; else if (sp[0] == '/') @@ -654,6 +656,8 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) if (expected_type == OBJ_COMMIT) lookup_flags = GET_SHA1_COMMITTISH; + else if (expected_type == OBJ_TREE) + lookup_flags = GET_SHA1_TREEISH; if (get_sha1_1(name, sp - name - 2, outer, lookup_flags)) return -1; -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Inviato dal mio dispositivo mobile -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/12] pretty: support % that steal trailing spaces
On Sun, Mar 17, 2013 at 4:06 PM, Eric Sunshine sunsh...@sunshineco.com wrote: On Fri, Mar 15, 2013 at 10:24 PM, Nguyễn Thái Ngọc Duy pclo...@gmail.com wrote: This is pretty useful in `%(100)%s%Cred%(20)% an' where %s does not s/% an/%an/ No. The space after '%' is intentional. And thanks for proofreading in all my patches. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 00/12] Layout control placeholders for pretty format
The only difference in v2 is typo fixes (mostly in commit messages, but some in pretty-formats.txt). Also resend as a reminder to Junio if he forgot to pick it up. Nguyễn Thái Ngọc Duy (12): pretty-formats.txt: wrap long lines pretty: share code between format_decoration and show_decorations utf8.c: move display_mode_esc_sequence_len() for use by other functions utf8.c: add utf8_strnwidth() with the ability to skip ansi sequences pretty: save commit encoding from logmsg_reencode if the caller needs it pretty: get the correct encoding for --pretty:format=%e utf8: keep NULs in reencode_string() pretty: two phase conversion for non utf-8 commits pretty: add %C(auto) for auto-coloring on the next placeholder pretty: support padding placeholders, % % and % pretty: support truncating in %, % and % pretty: support % that steal trailing spaces Documentation/pretty-formats.txt | 34 - builtin/blame.c | 2 +- builtin/commit.c | 2 +- builtin/fast-export.c| 3 +- builtin/mailinfo.c | 3 +- commit.h | 1 + compat/precompose_utf8.c | 2 +- log-tree.c | 60 + log-tree.h | 3 + notes.c | 4 +- pretty.c | 282 ++- revision.c | 2 +- sequencer.c | 5 +- t/t4207-log-decoration-colors.sh | 8 +- t/t6006-rev-list-format.sh | 12 +- utf8.c | 104 +++ utf8.h | 14 +- 17 files changed, 434 insertions(+), 107 deletions(-) -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 01/12] pretty-formats.txt: wrap long lines
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- Documentation/pretty-formats.txt | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 105f18a..66345d1 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -106,18 +106,22 @@ The placeholders are: - '%P': parent hashes - '%p': abbreviated parent hashes - '%an': author name -- '%aN': author name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +- '%aN': author name (respecting .mailmap, see linkgit:git-shortlog[1] + or linkgit:git-blame[1]) - '%ae': author email -- '%aE': author email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +- '%aE': author email (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) - '%ad': author date (format respects --date= option) - '%aD': author date, RFC2822 style - '%ar': author date, relative - '%at': author date, UNIX timestamp - '%ai': author date, ISO 8601 format - '%cn': committer name -- '%cN': committer name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +- '%cN': committer name (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) - '%ce': committer email -- '%cE': committer email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +- '%cE': committer email (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) - '%cd': committer date - '%cD': committer date, RFC2822 style - '%cr': committer date, relative @@ -136,9 +140,11 @@ The placeholders are: - '%gD': reflog selector, e.g., `refs/stash@{1}` - '%gd': shortened reflog selector, e.g., `stash@{1}` - '%gn': reflog identity name -- '%gN': reflog identity name (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +- '%gN': reflog identity name (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) - '%ge': reflog identity email -- '%gE': reflog identity email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +- '%gE': reflog identity email (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) - '%gs': reflog subject - '%Cred': switch color to red - '%Cgreen': switch color to green -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 02/12] pretty: share code between format_decoration and show_decorations
This also adds color support to format_decoration() Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- log-tree.c | 60 +--- log-tree.h | 3 ++ pretty.c | 19 + t/t4207-log-decoration-colors.sh | 8 +++--- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/log-tree.c b/log-tree.c index 5dc45c4..7467a1d 100644 --- a/log-tree.c +++ b/log-tree.c @@ -174,36 +174,50 @@ static void show_children(struct rev_info *opt, struct commit *commit, int abbre } } -void show_decorations(struct rev_info *opt, struct commit *commit) +void format_decoration(struct strbuf *sb, + const struct commit *commit, + int use_color) { - const char *prefix; - struct name_decoration *decoration; + const char *prefix = (; + struct name_decoration *d; const char *color_commit = - diff_get_color_opt(opt-diffopt, DIFF_COMMIT); + diff_get_color(use_color, DIFF_COMMIT); const char *color_reset = - decorate_get_color_opt(opt-diffopt, DECORATION_NONE); + decorate_get_color(use_color, DECORATION_NONE); + + load_ref_decorations(DECORATE_SHORT_REFS); + d = lookup_decoration(name_decoration, commit-object); + if (!d) + return; + while (d) { + strbuf_addstr(sb, color_commit); + strbuf_addstr(sb, prefix); + strbuf_addstr(sb, decorate_get_color(use_color, d-type)); + if (d-type == DECORATION_REF_TAG) + strbuf_addstr(sb, tag: ); + strbuf_addstr(sb, d-name); + strbuf_addstr(sb, color_reset); + prefix = , ; + d = d-next; + } + if (prefix[0] == ',') { + strbuf_addstr(sb, color_commit); + strbuf_addch(sb, ')'); + strbuf_addstr(sb, color_reset); + } +} + +void show_decorations(struct rev_info *opt, struct commit *commit) +{ + struct strbuf sb = STRBUF_INIT; if (opt-show_source commit-util) printf(\t%s, (char *) commit-util); if (!opt-show_decorations) return; - decoration = lookup_decoration(name_decoration, commit-object); - if (!decoration) - return; - prefix = (; - while (decoration) { - printf(%s, prefix); - fputs(decorate_get_color_opt(opt-diffopt, decoration-type), - stdout); - if (decoration-type == DECORATION_REF_TAG) - fputs(tag: , stdout); - printf(%s, decoration-name); - fputs(color_reset, stdout); - fputs(color_commit, stdout); - prefix = , ; - decoration = decoration-next; - } - putchar(')'); + format_decoration(sb, commit, opt-diffopt.use_color); + fputs(sb.buf, stdout); + strbuf_release(sb); } /* @@ -625,8 +639,8 @@ void show_log(struct rev_info *opt) printf( (from %s), find_unique_abbrev(parent-object.sha1, abbrev_commit)); + fputs(diff_get_color_opt(opt-diffopt, DIFF_RESET), stdout); show_decorations(opt, commit); - printf(%s, diff_get_color_opt(opt-diffopt, DIFF_RESET)); if (opt-commit_format == CMIT_FMT_ONELINE) { putchar(' '); } else { diff --git a/log-tree.h b/log-tree.h index 9140f48..e6a2da5 100644 --- a/log-tree.h +++ b/log-tree.h @@ -13,6 +13,9 @@ int log_tree_diff_flush(struct rev_info *); int log_tree_commit(struct rev_info *, struct commit *); int log_tree_opt_parse(struct rev_info *, const char **, int); void show_log(struct rev_info *opt); +void format_decoration(struct strbuf *sb, + const struct commit *commit, + int use_color); void show_decorations(struct rev_info *opt, struct commit *commit); void log_write_email_headers(struct rev_info *opt, struct commit *commit, const char **subject_p, diff --git a/pretty.c b/pretty.c index eae57ad..79784be 100644 --- a/pretty.c +++ b/pretty.c @@ -898,23 +898,6 @@ static void parse_commit_message(struct format_commit_context *c) c-commit_message_parsed = 1; } -static void format_decoration(struct strbuf *sb, const struct commit *commit) -{ - struct name_decoration *d; - const char *prefix = (; - - load_ref_decorations(DECORATE_SHORT_REFS); - d = lookup_decoration(name_decoration, commit-object); - while (d) { - strbuf_addstr(sb, prefix); - prefix = , ; - strbuf_addstr(sb, d-name); - d = d-next; - } - if
[PATCH v2 03/12] utf8.c: move display_mode_esc_sequence_len() for use by other functions
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- utf8.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/utf8.c b/utf8.c index 1087870..82c2ddf 100644 --- a/utf8.c +++ b/utf8.c @@ -9,6 +9,20 @@ struct interval { int last; }; +static size_t display_mode_esc_sequence_len(const char *s) +{ + const char *p = s; + if (*p++ != '\033') + return 0; + if (*p++ != '[') + return 0; + while (isdigit(*p) || *p == ';') + p++; + if (*p++ != 'm') + return 0; + return p - s; +} + /* auxiliary function for binary search in interval table */ static int bisearch(ucs_char_t ucs, const struct interval *table, int max) { @@ -303,20 +317,6 @@ static void strbuf_add_indented_text(struct strbuf *buf, const char *text, } } -static size_t display_mode_esc_sequence_len(const char *s) -{ - const char *p = s; - if (*p++ != '\033') - return 0; - if (*p++ != '[') - return 0; - while (isdigit(*p) || *p == ';') - p++; - if (*p++ != 'm') - return 0; - return p - s; -} - /* * Wrap the text, if necessary. The variable indent is the indent for the * first line, indent2 is the indent for all other lines. -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 04/12] utf8.c: add utf8_strnwidth() with the ability to skip ansi sequences
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- utf8.c | 20 ++-- utf8.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/utf8.c b/utf8.c index 82c2ddf..38322a1 100644 --- a/utf8.c +++ b/utf8.c @@ -266,18 +266,26 @@ int utf8_width(const char **start, size_t *remainder_p) * string, assuming that the string is utf8. Returns strlen() instead * if the string does not look like a valid utf8 string. */ -int utf8_strwidth(const char *string) +int utf8_strnwidth(const char *string, int len, int skip_ansi) { int width = 0; const char *orig = string; - while (1) { - if (!string) - return strlen(orig); - if (!*string) - return width; + if (len == -1) + len = strlen(string); + while (string string orig + len) { + int skip; + while (skip_ansi + (skip = display_mode_esc_sequence_len(string))) + string += skip; width += utf8_width(string, NULL); } + return string ? width : len; +} + +int utf8_strwidth(const char *string) +{ + return utf8_strnwidth(string, -1, 0); } int is_utf8(const char *text) diff --git a/utf8.h b/utf8.h index 501b2bd..a556932 100644 --- a/utf8.h +++ b/utf8.h @@ -4,6 +4,7 @@ typedef unsigned int ucs_char_t; /* assuming 32bit int */ int utf8_width(const char **start, size_t *remainder_p); +int utf8_strnwidth(const char *string, int len, int skip_ansi); int utf8_strwidth(const char *string); int is_utf8(const char *text); int is_encoding_utf8(const char *name); -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 05/12] pretty: save commit encoding from logmsg_reencode if the caller needs it
The commit encoding is parsed by logmsg_reencode, there's no need for the caller to re-parse it again. The reencoded message now has the new encoding, not the original one. The caller would need to read commit object again before parsing. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/blame.c | 2 +- builtin/commit.c | 2 +- commit.h | 1 + pretty.c | 16 revision.c | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index 86100e9..104a948 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1425,7 +1425,7 @@ static void get_commit_info(struct commit *commit, commit_info_init(ret); encoding = get_log_output_encoding(); - message = logmsg_reencode(commit, encoding); + message = logmsg_reencode(commit, NULL, encoding); get_ac_line(message, \nauthor , ret-author, ret-author_mail, ret-author_time, ret-author_tz); diff --git a/builtin/commit.c b/builtin/commit.c index 3348aa1..beead44 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -953,7 +953,7 @@ static const char *read_commit_message(const char *name) if (!commit) die(_(could not lookup commit %s), name); out_enc = get_commit_output_encoding(); - return logmsg_reencode(commit, out_enc); + return logmsg_reencode(commit, NULL, out_enc); } static int parse_and_validate_options(int argc, const char *argv[], diff --git a/commit.h b/commit.h index 4138bb4..085349a 100644 --- a/commit.h +++ b/commit.h @@ -100,6 +100,7 @@ struct userformat_want { extern int has_non_ascii(const char *text); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ extern char *logmsg_reencode(const struct commit *commit, +char **commit_encoding, const char *output_encoding); extern void logmsg_free(char *msg, const struct commit *commit); extern void get_commit_format(const char *arg, struct rev_info *); diff --git a/pretty.c b/pretty.c index 79784be..ab5d70f 100644 --- a/pretty.c +++ b/pretty.c @@ -584,6 +584,7 @@ static char *replace_encoding_header(char *buf, const char *encoding) } char *logmsg_reencode(const struct commit *commit, + char **commit_encoding, const char *output_encoding) { static const char *utf8 = UTF-8; @@ -605,9 +606,15 @@ char *logmsg_reencode(const struct commit *commit, sha1_to_hex(commit-object.sha1), typename(type)); } - if (!output_encoding || !*output_encoding) + if (!output_encoding || !*output_encoding) { + if (commit_encoding) + *commit_encoding = + get_header(commit, msg, encoding); return msg; + } encoding = get_header(commit, msg, encoding); + if (commit_encoding) + *commit_encoding = encoding; use_encoding = encoding ? encoding : utf8; if (same_encoding(use_encoding, output_encoding)) { /* @@ -648,7 +655,8 @@ char *logmsg_reencode(const struct commit *commit, if (out) out = replace_encoding_header(out, output_encoding); - free(encoding); + if (!commit_encoding) + free(encoding); /* * If the re-encoding failed, out might be NULL here; in that * case we just return the commit message verbatim. @@ -1313,7 +1321,7 @@ void format_commit_message(const struct commit *commit, context.commit = commit; context.pretty_ctx = pretty_ctx; context.wrap_start = sb-len; - context.message = logmsg_reencode(commit, output_enc); + context.message = logmsg_reencode(commit, NULL, output_enc); strbuf_expand(sb, format, format_commit_item, context); rewrap_message_tail(sb, context, 0, 0, 0); @@ -1476,7 +1484,7 @@ void pretty_print_commit(const struct pretty_print_context *pp, } encoding = get_log_output_encoding(); - msg = reencoded = logmsg_reencode(commit, encoding); + msg = reencoded = logmsg_reencode(commit, NULL, encoding); if (pp-fmt == CMIT_FMT_ONELINE || pp-fmt == CMIT_FMT_EMAIL) indent = 0; diff --git a/revision.c b/revision.c index ef60205..c6ff560 100644 --- a/revision.c +++ b/revision.c @@ -2290,7 +2290,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) * in it. */ encoding = get_log_output_encoding(); - message = logmsg_reencode(commit, encoding); + message = logmsg_reencode(commit, NULL, encoding); /* Copy the commit to temporary if we are using fake headers */ if (buf.len) -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More
[PATCH v2 06/12] pretty: get the correct encoding for --pretty:format=%e
parse_commit_header() provides the commit encoding for '%e' and it reads it from the re-encoded message, which contains the new encoding, not the original one in the commit object. Get the commit encoding from logmsg_reencode() instead. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- pretty.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pretty.c b/pretty.c index ab5d70f..e2241e5 100644 --- a/pretty.c +++ b/pretty.c @@ -771,12 +771,12 @@ struct format_commit_context { char *signer; } signature; char *message; + char *commit_encoding; size_t width, indent1, indent2; /* These offsets are relative to the start of the commit message. */ struct chunk author; struct chunk committer; - struct chunk encoding; size_t message_off; size_t subject_off; size_t body_off; @@ -823,9 +823,6 @@ static void parse_commit_header(struct format_commit_context *context) } else if (!prefixcmp(msg + i, committer )) { context-committer.off = i + 10; context-committer.len = eol - i - 10; - } else if (!prefixcmp(msg + i, encoding )) { - context-encoding.off = i + 9; - context-encoding.len = eol - i - 9; } i = eol; } @@ -1210,7 +1207,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, msg + c-committer.off, c-committer.len, c-pretty_ctx-date_mode); case 'e': /* encoding */ - strbuf_add(sb, msg + c-encoding.off, c-encoding.len); + if (c-commit_encoding) + strbuf_addstr(sb, c-commit_encoding); return 1; case 'B': /* raw body */ /* message_off is always left at the initial newline */ @@ -1321,11 +1319,14 @@ void format_commit_message(const struct commit *commit, context.commit = commit; context.pretty_ctx = pretty_ctx; context.wrap_start = sb-len; - context.message = logmsg_reencode(commit, NULL, output_enc); + context.message = logmsg_reencode(commit, + context.commit_encoding, + output_enc); strbuf_expand(sb, format, format_commit_item, context); rewrap_message_tail(sb, context, 0, 0, 0); + free(context.commit_encoding); logmsg_free(context.message, commit); free(context.signature.gpg_output); free(context.signature.signer); -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 07/12] utf8: keep NULs in reencode_string()
reencode_string() will be used in the next patch for re-encoding pretty output, which can contain NULs. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/fast-export.c| 3 ++- builtin/mailinfo.c | 3 ++- compat/precompose_utf8.c | 2 +- notes.c | 4 +++- pretty.c | 3 ++- sequencer.c | 5 +++-- utf8.c | 10 +++--- utf8.h | 10 +++--- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 77dffd1..7ba9f3b 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -316,7 +316,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev) mark_next_object(commit-object); if (!is_encoding_utf8(encoding)) - reencoded = reencode_string(message, UTF-8, encoding); + reencoded = reencode_string(message, strlen(message), + UTF-8, encoding, NULL); if (!commit-parents) printf(reset %s\n, (const char*)commit-util); printf(commit %s\nmark :%PRIu32\n%.*s\n%.*s\ndata %u\n%s, diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 24a772d..129e7dc 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -486,7 +486,8 @@ static void convert_to_utf8(struct strbuf *line, const char *charset) if (same_encoding(metainfo_charset, charset)) return; - out = reencode_string(line-buf, metainfo_charset, charset); + out = reencode_string(line-buf, line-len, + metainfo_charset, charset, NULL); if (!out) die(cannot convert from %s to %s, charset, metainfo_charset); diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c index 8cf5955..d9203d0 100644 --- a/compat/precompose_utf8.c +++ b/compat/precompose_utf8.c @@ -78,7 +78,7 @@ void precompose_argv(int argc, const char **argv) size_t namelen; oldarg = argv[i]; if (has_non_ascii(oldarg, (size_t)-1, namelen)) { - newarg = reencode_string_iconv(oldarg, namelen, ic_precompose); + newarg = reencode_string_iconv(oldarg, namelen, ic_precompose, NULL); if (newarg) argv[i] = newarg; } diff --git a/notes.c b/notes.c index f63fd57..4ae3b25 100644 --- a/notes.c +++ b/notes.c @@ -1222,7 +1222,9 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1, if (output_encoding *output_encoding !is_encoding_utf8(output_encoding)) { - char *reencoded = reencode_string(msg, output_encoding, utf8); + char *reencoded = reencode_string(msg, strlen(msg), + output_encoding, utf8, + NULL); if (reencoded) { free(msg); msg = reencoded; diff --git a/pretty.c b/pretty.c index e2241e5..092dd1d 100644 --- a/pretty.c +++ b/pretty.c @@ -643,7 +643,8 @@ char *logmsg_reencode(const struct commit *commit, * this point, we are done with msg. If we allocated a fresh * copy, we can free it. */ - out = reencode_string(msg, output_encoding, use_encoding); + out = reencode_string(msg, strlen(msg), + output_encoding, use_encoding, NULL); if (out msg != commit-buffer) free(msg); } diff --git a/sequencer.c b/sequencer.c index aef5e8a..bf15531 100644 --- a/sequencer.c +++ b/sequencer.c @@ -61,8 +61,9 @@ static int get_message(struct commit *commit, struct commit_message *out) out-reencoded_message = NULL; out-message = commit-buffer; if (same_encoding(encoding, git_commit_encoding)) - out-reencoded_message = reencode_string(commit-buffer, - git_commit_encoding, encoding); + out-reencoded_message = + reencode_string(commit-buffer, strlen(commit-buffer), + git_commit_encoding, encoding, NULL); if (out-reencoded_message) out-message = out-reencoded_message; diff --git a/utf8.c b/utf8.c index 38322a1..9d98043 100644 --- a/utf8.c +++ b/utf8.c @@ -468,7 +468,7 @@ int utf8_fprintf(FILE *stream, const char *format, ...) #else typedef char * iconv_ibp; #endif -char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv) +char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, int *outsz_p) { size_t outsz, outalloc; char *out, *outpos; @@ -502,13 +502,17 @@ char *reencode_string_iconv(const char *in, size_t insz,
[PATCH v2 08/12] pretty: two phase conversion for non utf-8 commits
Always assume format_commit_item() takes an utf-8 string for string handling simplicity (we can handle utf-8 strings, but can't with other encodings). If commit message is in non-utf8, or output encoding is not, then the commit is first converted to utf-8, processed, then output converted to output encoding. This of course only works with encodings that are compatible with Unicode. This also fixes the iso8859-1 test in t6006. It's supposed to create an iso8859-1 commit, but the commit content in t6006 is in UTF-8. t6006 is now converted back in UTF-8 (the downside is we can't put utf-8 strings there anymore). Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- pretty.c | 24 ++-- t/t6006-rev-list-format.sh | 12 ++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/pretty.c b/pretty.c index 092dd1d..3f4809a 100644 --- a/pretty.c +++ b/pretty.c @@ -1003,7 +1003,8 @@ static int format_reflog_person(struct strbuf *sb, return format_person_part(sb, part, ident, strlen(ident), dmode); } -static size_t format_commit_one(struct strbuf *sb, const char *placeholder, +static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ + const char *placeholder, void *context) { struct format_commit_context *c = context; @@ -1235,7 +1236,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, return 0; /* unknown placeholder */ } -static size_t format_commit_item(struct strbuf *sb, const char *placeholder, +static size_t format_commit_item(struct strbuf *sb, /* in UTF-8 */ +const char *placeholder, void *context) { int consumed; @@ -1315,6 +1317,7 @@ void format_commit_message(const struct commit *commit, { struct format_commit_context context; const char *output_enc = pretty_ctx-output_encoding; + const char *utf8 = UTF-8; memset(context, 0, sizeof(context)); context.commit = commit; @@ -1327,6 +1330,23 @@ void format_commit_message(const struct commit *commit, strbuf_expand(sb, format, format_commit_item, context); rewrap_message_tail(sb, context, 0, 0, 0); + if (output_enc) { + if (same_encoding(utf8, output_enc)) + output_enc = NULL; + } else { + if (context.commit_encoding + !same_encoding(context.commit_encoding, utf8)) + output_enc = context.commit_encoding; + } + + if (output_enc) { + int outsz; + char *out = reencode_string(sb-buf, sb-len, + output_enc, utf8, outsz); + if (out) + strbuf_attach(sb, out, outsz, outsz + 1); + } + free(context.commit_encoding); logmsg_free(context.message, commit); free(context.signature.gpg_output); diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index 3fc3b74..0393c9f 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -184,7 +184,7 @@ Test printing of complex bodies This commit message is much longer than the others, and it will be encoded in iso8859-1. We should therefore -include an iso8859 character: ¡bueno! +include an iso8859 character: �bueno! EOF test_expect_success 'setup complex body' ' git config i18n.commitencoding iso8859-1 @@ -192,14 +192,14 @@ git config i18n.commitencoding iso8859-1 ' test_format complex-encoding %e 'EOF' -commit f58db70b055c5718631e5c61528b28b12090cdea +commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 iso8859-1 commit 131a310eb913d107dd3c09a65d1651175898735d commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 EOF test_format complex-subject %s 'EOF' -commit f58db70b055c5718631e5c61528b28b12090cdea +commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 Test printing of complex bodies commit 131a310eb913d107dd3c09a65d1651175898735d changed foo @@ -208,17 +208,17 @@ added foo EOF test_format complex-body %b 'EOF' -commit f58db70b055c5718631e5c61528b28b12090cdea +commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 This commit message is much longer than the others, and it will be encoded in iso8859-1. We should therefore -include an iso8859 character: ¡bueno! +include an iso8859 character: �bueno! commit 131a310eb913d107dd3c09a65d1651175898735d commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873 EOF test_expect_success '%x00 shows NUL' ' - echo expect commit f58db70b055c5718631e5c61528b28b12090cdea + echo expect commit 1ed88da4a5b5ed8c449114ac131efc62178734c3 echo expect fooQbar git rev-list -1 --format=foo%x00bar HEAD actual.nul nul_to_q actual.nul actual -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to
[PATCH v2 09/12] pretty: add %C(auto) for auto-coloring on the next placeholder
This is not simply convenient over %C(auto,xxx). Some placeholders (actually only one, %d) do multi coloring and we can't emit a multiple colors with %C(auto,xxx). Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- Documentation/pretty-formats.txt | 3 ++- pretty.c | 15 +-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 66345d1..8734224 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -154,7 +154,8 @@ The placeholders are: adding `auto,` at the beginning will emit color only when colors are enabled for log output (by `color.diff`, `color.ui`, or `--color`, and respecting the `auto` settings of the former if we are going to a - terminal) + terminal). `auto` alone (i.e. `%C(auto)`) will turn on auto coloring + on the following placeholder. - '%m': left, right or boundary mark - '%n': newline - '%%': a raw '%' diff --git a/pretty.c b/pretty.c index 3f4809a..c333fd6 100644 --- a/pretty.c +++ b/pretty.c @@ -774,6 +774,7 @@ struct format_commit_context { char *message; char *commit_encoding; size_t width, indent1, indent2; + int auto_color; /* These offsets are relative to the start of the commit message. */ struct chunk author; @@ -1011,7 +1012,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ const struct commit *commit = c-commit; const char *msg = c-message; struct commit_list *p; - int h1, h2; + int h1, h2, use_color; /* these are independent of the commit */ switch (placeholder[0]) { @@ -1023,6 +1024,10 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ if (!end) return 0; + if (!prefixcmp(begin, auto))) { + c-auto_color = 1; + return end - placeholder + 1; + } if (!prefixcmp(begin, auto,)) { if (!want_color(c-pretty_ctx-color)) return end - placeholder + 1; @@ -1090,16 +1095,22 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ /* these depend on the commit */ if (!commit-object.parsed) parse_object(commit-object.sha1); + use_color = c-auto_color; + c-auto_color = 0; switch (placeholder[0]) { case 'H': /* commit hash */ + strbuf_addstr(sb, diff_get_color(use_color, DIFF_COMMIT)); strbuf_addstr(sb, sha1_to_hex(commit-object.sha1)); + strbuf_addstr(sb, diff_get_color(use_color, DIFF_RESET)); return 1; case 'h': /* abbreviated commit hash */ + strbuf_addstr(sb, diff_get_color(use_color, DIFF_COMMIT)); if (add_again(sb, c-abbrev_commit_hash)) return 1; strbuf_addstr(sb, find_unique_abbrev(commit-object.sha1, c-pretty_ctx-abbrev)); + strbuf_addstr(sb, diff_get_color(use_color, DIFF_RESET)); c-abbrev_commit_hash.len = sb-len - c-abbrev_commit_hash.off; return 1; case 'T': /* tree hash */ @@ -1136,7 +1147,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ strbuf_addstr(sb, get_revision_mark(NULL, commit)); return 1; case 'd': - format_decoration(sb, commit, 0); + format_decoration(sb, commit, use_color); return 1; case 'g': /* reflog info */ switch(placeholder[1]) { -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 10/12] pretty: support padding placeholders, % % and %
Either %, % or % standing before a placeholder specifies how many columns (at least as the placeholder can exceed it) it takes. Each differs on how spaces are padded: % pads on the right (aka left alignment) % pads on the left (aka right alignment) % pads both ways equally (aka centered) The (N) follows them, e.g. `%(100)', to specify the number of columns the next placeholder takes. However, if '|' stands before (N), e.g. `%|(100)', then the number of columns is calculated so that it reaches the Nth column on screen. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- Documentation/pretty-formats.txt | 8 +++ pretty.c | 117 ++- 2 files changed, 124 insertions(+), 1 deletion(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 8734224..0ab1233 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -162,6 +162,14 @@ The placeholders are: - '%x00': print a byte from a hex code - '%w([w[,i1[,i2]]])': switch line wrapping, like the -w option of linkgit:git-shortlog[1]. +- '%(N)': make the next placeholder take at least N columns, + padding spaces on the right if necessary +- '%|(N)': make the next placeholder take at least until Nth + columns, padding spaces on the right if necessary +- '%(N)', '%|(N)': similar to '%(N)', '%|(N)' + respectively, but padding spaces on the left +- '%(N)', '%|(N)': similar to '%(N)', '%|(N)' + respectively, but padding both sides (i.e. the text is centered) NOTE: Some placeholders may depend on other options given to the revision traversal engine. For example, the `%g*` reflog options will diff --git a/pretty.c b/pretty.c index c333fd6..233d69c 100644 --- a/pretty.c +++ b/pretty.c @@ -760,12 +760,20 @@ struct chunk { size_t len; }; +enum flush_type { + no_flush, + flush_right, + flush_left, + flush_both +}; + struct format_commit_context { const struct commit *commit; const struct pretty_print_context *pretty_ctx; unsigned commit_header_parsed:1; unsigned commit_message_parsed:1; unsigned commit_signature_parsed:1; + enum flush_type flush_type; struct { char *gpg_output; char good_bad; @@ -775,6 +783,7 @@ struct format_commit_context { char *commit_encoding; size_t width, indent1, indent2; int auto_color; + int padding; /* These offsets are relative to the start of the commit message. */ struct chunk author; @@ -1004,6 +1013,52 @@ static int format_reflog_person(struct strbuf *sb, return format_person_part(sb, part, ident, strlen(ident), dmode); } +static size_t parse_padding_placeholder(struct strbuf *sb, + const char *placeholder, + struct format_commit_context *c) +{ + const char *ch = placeholder; + enum flush_type flush_type; + int to_column = 0; + + switch (*ch++) { + case '': + flush_type = flush_right; + break; + case '': + if (*ch == '') { + flush_type = flush_both; + ch++; + } else + flush_type = flush_left; + break; + default: + return 0; + } + + /* the next value means wide enough to that column */ + if (*ch == '|') { + to_column = 1; + ch++; + } + + if (*ch == '(') { + const char *start = ch + 1; + const char *end = strchr(start, ')'); + char *next; + int width; + if (!end || end == start) + return 0; + width = strtoul(start, next, 10); + if (next == start || width == 0) + return 0; + c-padding = to_column ? -width : width; + c-flush_type = flush_type; + return end - placeholder + 1; + } + return 0; +} + static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ const char *placeholder, void *context) @@ -1090,6 +1145,10 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ return end - placeholder + 1; } else return 0; + + case '': + case '': + return parse_padding_placeholder(sb, placeholder, c); } /* these depend on the commit */ @@ -1247,6 +1306,59 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ return 0; /* unknown placeholder */ } +static size_t format_and_pad_commit(struct strbuf *sb, /* in UTF-8 */ + const char *placeholder, +
Re: [PATCH 2/2] optimize set_shared_perm()
On 29.03.13 22:20, Junio C Hamano wrote: [snip] The last two points can become a separate preparation step. The result would be easier to read. Your updated adjust_shared_perm() does not begin with: if (!shared_repository) return 0; as the original, but it always first calls to get_st_mode_bits() which makes a call to lstat(2). That smells like a huge regression for !shared_repository case, unless you have updated the existing callers of adjust_shared_perm() not to call it when !shared_repository. Thanks for carefull review: The achieved effect of the code is the same, but the developer is to blame. I send a new patch of 2/2 in a minute, splitted into 2 commits. Highlights of part 2: a) move if (!shared_repository) to the right place b) Simplify calc_shared_perm() even more: Remove the variable int shared c) Remove calc_shared_perm_dir(), the functionality is baked into adjust_shared_perm() -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] optimize set_shared_perm() in path.c:
All calls to set_shared_perm() use mode == 0, so simplify the function. All callers use the macro adjust_shared_perm(path) from cache.h, convert adjust_shared_perm() from a macro into a function prototype Since path.c has much more functions than just mkpath(), improve a stale comment about path.c Signed-off-by: Torsten Bögershausen tbo...@web.de --- cache.h | 3 +-- path.c | 27 +++ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/cache.h b/cache.h index c12957b..e1e8ce8 100644 --- a/cache.h +++ b/cache.h @@ -719,8 +719,7 @@ enum sharedrepo { PERM_EVERYBODY = 0664 }; int git_config_perm(const char *var, const char *value); -int set_shared_perm(const char *path, int mode); -#define adjust_shared_perm(path) set_shared_perm((path), 0) +int adjust_shared_perm(const char *path); int safe_create_leading_directories(char *path); int safe_create_leading_directories_const(const char *path); int mkdir_in_gitdir(const char *path); diff --git a/path.c b/path.c index 2fdccc2..427312e 100644 --- a/path.c +++ b/path.c @@ -1,14 +1,5 @@ /* - * I'm tired of doing vsnprintf() etc just to open a - * file, so here's a return static buffer with printf - * interface for paths. - * - * It's obviously not thread-safe. Sue me. But it's quite - * useful for doing things like - * - * f = open(mkpath(%s/%s.git, base, name), O_RDONLY); - * - * which is what it's designed for. + * Different utilitiy functions for path and path names */ #include cache.h #include strbuf.h @@ -405,21 +396,17 @@ const char *enter_repo(const char *path, int strict) return NULL; } -int set_shared_perm(const char *path, int mode) +int adjust_shared_perm(const char *path) { - int tweak, shared, orig_mode; + int tweak, shared, orig_mode, mode; if (!shared_repository) { - if (mode) - return chmod(path, mode ~S_IFMT); return 0; } - if (!mode) { - if (get_st_mode_bits(path, mode) 0) - return -1; - orig_mode = mode; - } else - orig_mode = 0; + if (get_st_mode_bits(path, mode) 0) + return -1; + + orig_mode = mode; if (shared_repository 0) shared = -shared_repository; else -- 1.8.2.341.g543621f -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] optimize adjust_shared_perm() in path.c:
sometimes the chown() function is called even when not needed. (This can be provoced by running t1301, and adding some debug code) Save a chmod from 400 to 400, or from 600-600 on these files: .git/info/refs+ .git/objects/info/packs+ Save chmod on directories from 2770 to 2770: .git/refs .git/refs/heads .git/refs/tags Signed-off-by: Torsten Bögershausen tbo...@web.de --- path.c | 42 +++--- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/path.c b/path.c index 427312e..33fa880 100644 --- a/path.c +++ b/path.c @@ -396,22 +396,14 @@ const char *enter_repo(const char *path, int strict) return NULL; } -int adjust_shared_perm(const char *path) +static int calc_shared_perm(int mode) { - int tweak, shared, orig_mode, mode; + int tweak; - if (!shared_repository) { - return 0; - } - if (get_st_mode_bits(path, mode) 0) - return -1; - - orig_mode = mode; if (shared_repository 0) - shared = -shared_repository; + tweak = -shared_repository; else - shared = shared_repository; - tweak = shared; + tweak = shared_repository; if (!(mode S_IWUSR)) tweak = ~0222; @@ -423,16 +415,28 @@ int adjust_shared_perm(const char *path) else mode |= tweak; - if (S_ISDIR(mode)) { + return mode; +} + + +int adjust_shared_perm(const char *path) +{ + int old_mode, new_mode; + + if (!shared_repository) + return 0; + if (get_st_mode_bits(path, old_mode) 0) + return -1; + + new_mode = calc_shared_perm(old_mode); + if (S_ISDIR(old_mode)) { /* Copy read bits to execute bits */ - mode |= (shared 0444) 2; - mode |= FORCE_DIR_SET_GID; + new_mode |= (new_mode 0444) 2; + new_mode |= FORCE_DIR_SET_GID; } - if (((shared_repository 0 - ? (orig_mode (FORCE_DIR_SET_GID | 0777)) - : (orig_mode mode)) != mode) - chmod(path, (mode ~S_IFMT)) 0) + if (((old_mode ^ new_mode) ~S_IFMT) + chmod(path, (new_mode ~S_IFMT)) 0) return -2; return 0; } -- 1.8.2.341.g543621f -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] checkout: add --no-widen for restoring files in sparse checkout mode
git checkout -- paths is usually used to restore all modified files in paths. In sparse checkout mode, this command is overloaded with another meaning: to add back all files in paths that are excluded by sparse patterns. Add --no-widen option to do what normal mode does: restore all modified files and nothing else. The user can make it default by putting it to an alias (e.g. co = checkout --no-widen) and get back to the original behavior with git co --widen. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- --sparse - --no-widen and git-checkout does not error out when the option is specified but has no effects. Let's see how it works out. We could change the default from --widen to --no-widen later. Documentation/git-checkout.txt | 11 +++ builtin/checkout.c | 7 +++ t/t1011-read-tree-sparse-checkout.sh | 12 3 files changed, 30 insertions(+) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 8edcdca..538b8b8 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -180,6 +180,17 @@ branch by running git rm -rf . from the top level of the working tree. Afterwards you will be ready to prepare your new files, repopulating the working tree, by copying them from elsewhere, extracting a tarball, etc. +--no-widen:: + In sparse checkout mode, `git checkout -- paths` would + update all entries matched by paths regardless of sparse + patterns. This option only updates entries matched by paths + and sparse patterns. + +--widen:: + Revert the effect of `--no-widen` if specified and make + `git checkout -- paths` update all entries matched by + paths regardless of sparse patterns. + -m:: --merge:: When switching branches, diff --git a/builtin/checkout.c b/builtin/checkout.c index a9c1b5a..246de33 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -35,6 +35,7 @@ struct checkout_opts { int force_detach; int writeout_stage; int overwrite_ignore; + int widen_sparse; const char *new_branch; const char *new_branch_force; @@ -275,6 +276,8 @@ static int checkout_paths(const struct checkout_opts *opts, struct cache_entry *ce = active_cache[pos]; if (opts-source_tree !(ce-ce_flags CE_UPDATE)) continue; + if (!opts-widen_sparse ce_skip_worktree(ce)) + continue; match_pathspec(opts-pathspec, ce-name, ce_namelen(ce), 0, ps_matched); } @@ -315,6 +318,8 @@ static int checkout_paths(const struct checkout_opts *opts, struct cache_entry *ce = active_cache[pos]; if (opts-source_tree !(ce-ce_flags CE_UPDATE)) continue; + if (!opts-widen_sparse ce_skip_worktree(ce)) + continue; if (match_pathspec(opts-pathspec, ce-name, ce_namelen(ce), 0, NULL)) { if (!ce_stage(ce)) { errs |= checkout_entry(ce, state, NULL); @@ -1029,6 +1034,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) OPT_STRING(0, conflict, conflict_style, N_(style), N_(conflict style (merge or diff3))), OPT_BOOLEAN('p', patch, opts.patch_mode, N_(select hunks interactively)), + OPT_BOOL(0, widen, opts.widen_sparse, N_(do not limit pathspecs to sparse entries only (default))), { OPTION_BOOLEAN, 0, guess, dwim_new_local_branch, NULL, N_(second guess 'git checkout no-such-branch'), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN }, @@ -1039,6 +1045,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) memset(new, 0, sizeof(new)); opts.overwrite_ignore = 1; opts.prefix = prefix; + opts.widen_sparse = 1; gitmodules_config(); git_config(git_checkout_config, opts); diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh index 5c0053a..4a45714 100755 --- a/t/t1011-read-tree-sparse-checkout.sh +++ b/t/t1011-read-tree-sparse-checkout.sh @@ -250,4 +250,16 @@ EOF test_cmp expected actual ' +test_expect_success 'checkout --no-widen' ' + echo * .git/info/sparse-checkout + git checkout -f top + test -f init.t + echo sub .git/info/sparse-checkout + git checkout + echo modified sub/added + git checkout --no-widen . + ! test -f init.t + git diff --exit-code HEAD +' + test_done -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
check-attr doesn't respect recursive definitions
Hi, I am trying to write a custom archiving script that checks the export-ignore attribute to know which files from an ls-files output it should skip. Through this I noticed that for files in directories for which the export-ignore (or any other) attribute is set, check-attr still reports 'unspecified'. More precisely: $ git init test Initialized empty Git repository in /home/jan/test/.git/ $ cd test $ mkdir foo $ touch foo/bar $ echo foo export-ignore .gitattributes $ git check-attr export-ignore foo foo: export-ignore: set $ git check-attr export-ignore foo/bar foo/bar: export-ignore: unspecified I would expect the last command to also report 'set'. I've also tried other patterns like 'foo/' and 'foo*', but it didn't make any difference. Is this expected behaviour? It does make checking the attributes of single files somewhat more difficult. git-archive ignores the directory as expected, but unfortunately it doesn't have an option to just list the files it would archive instead of actually archiving them. This is with git version 1.7.10.4. -Jan -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 0/5] Verify GPG signatures when merging and extend %G? pretty string
Yuck. That termination condition is horrible. Ok, I reverted it to your suggestion. In this case, a much more elegant termination condition (foo == 1) is not possible without casts because foo is a pointer. +switch(signature_check.check_result){ +case 'G': +if (verbosity = 0) +printf(_(Commit %s has a good GPG signature by %s (key fingerprint %s)\n), hex, signature_check.signer, signature_check.key); +break; +case 'B': +die(_(Commit %s has a bad GPG signature allegedly by %s (key fingerprint %s).), hex, signature_check.signer, signature_check.key); +default: /* 'N' */ +die(_(Commit %s does not have a good GPG signature. In fact, commit %s does not have a GPG signature at all.), hex, hex); +} Style. I moved that verbose printf outside the switch(foo). Also avoid overlong lines, both in the source, but pay extra attention to what we show the user. For example: Commit %s has a bad GPG signature allegedly by %s (key fingerprint %s). The first %s will expand to 40 places, the other two are likely to be around 20-30 places. The first %s is the output of find_unique_abbrev, so though it will be 40 places worst-case, it will usually be *much* shorter (more like 7-8 places). Commit %s does not have a good GPG signature. In fact, commit %s does not have a GPG signature at all. Drop everything from the beginning up to In fact, , perhaps: Commit '%s' does not have any GPG signature. is sufficient? You may also want to consider die(_(Commit '%.*s...' does not have any GPG signature.), 8, hex); I shortened these messages and removed the key fingerprint output. Anybody interested can use git log --show-signature to get these. Sebastian Götte (5): Move commit GPG signature verification to commit.c commit.c/GPG signature verification: Also look at the first GPG status line merge/pull: verify GPG signatures of commits being merged merge/pull Check for untrusted good GPG signatures pretty printing: extend %G? to include 'N' and 'U' Documentation/merge-options.txt| 5 ++ Documentation/pretty-formats.txt | 3 +- builtin/merge.c| 34 +- commit.c | 68 +++ commit.h | 10 git-pull.sh| 10 +++- gpg-interface.h| 12 + pretty.c | 93 ++--- t/lib-gpg/pubring.gpg | Bin 1164 - 2359 bytes t/lib-gpg/random_seed | Bin 600 - 600 bytes t/lib-gpg/secring.gpg | Bin 1237 - 3734 bytes t/lib-gpg/trustdb.gpg | Bin 1280 - 1360 bytes t/t7612-merge-verify-signatures.sh | 61 13 files changed, 214 insertions(+), 82 deletions(-) create mode 100755 t/t7612-merge-verify-signatures.sh -- 1.8.1.5 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 1/5] Move commit GPG signature verification to commit.c
Signed-off-by: Sebastian Götte ja...@physik-pool.tu-berlin.de --- commit.c| 59 + commit.h| 10 +++ gpg-interface.h | 11 +++ pretty.c| 91 + 4 files changed, 93 insertions(+), 78 deletions(-) diff --git a/commit.c b/commit.c index e8eb0ae..eb645af 100644 --- a/commit.c +++ b/commit.c @@ -1023,6 +1023,65 @@ free_return: free(buf); } +static struct { + char result; + const char *check; +} sigcheck_gpg_status[] = { + { 'G', \n[GNUPG:] GOODSIG }, + { 'B', \n[GNUPG:] BADSIG }, +}; + +static void parse_gpg_output(struct signature_check *sigc) +{ + const char *buf = sigc-gpg_status; + int i; + + for (i = 0; i ARRAY_SIZE(sigcheck_gpg_status); i++) { + const char *found = strstr(buf, sigcheck_gpg_status[i].check); + const char *next; + if (!found) + continue; + sigc-result = sigcheck_gpg_status[i].result; + found += strlen(sigcheck_gpg_status[i].check); + sigc-key = xmemdupz(found, 16); + found += 17; + next = strchrnul(found, '\n'); + sigc-signer = xmemdupz(found, next - found); + break; + } +} + +void check_commit_signature(const struct commit* commit, struct signature_check *sigc) +{ + struct strbuf payload = STRBUF_INIT; + struct strbuf signature = STRBUF_INIT; + struct strbuf gpg_output = STRBUF_INIT; + struct strbuf gpg_status = STRBUF_INIT; + int status; + + sigc-result = 'N'; + + if (parse_signed_commit(commit-object.sha1, + payload, signature) = 0) + goto out; + status = verify_signed_buffer(payload.buf, payload.len, + signature.buf, signature.len, + gpg_output, gpg_status); + if (status !gpg_output.len) + goto out; + sigc-gpg_output = strbuf_detach(gpg_output, NULL); + sigc-gpg_status = strbuf_detach(gpg_status, NULL); + parse_gpg_output(sigc); + + out: + strbuf_release(gpg_status); + strbuf_release(gpg_output); + strbuf_release(payload); + strbuf_release(signature); +} + + + void append_merge_tag_headers(struct commit_list *parents, struct commit_extra_header ***tail) { diff --git a/commit.h b/commit.h index 4138bb4..8bbcf13 100644 --- a/commit.h +++ b/commit.h @@ -5,6 +5,7 @@ #include tree.h #include strbuf.h #include decorate.h +#include gpg-interface.h struct commit_list { struct commit *item; @@ -230,4 +231,13 @@ extern void print_commit_list(struct commit_list *list, const char *format_cur, const char *format_last); +/* + * Check the signature of the given commit. The result of the check is stored in + * sig-result, 'G' for a good signature, 'B' for a bad signature and 'N' + * for no signature at all. + * This may allocate memory for sig-gpg_output, sig-gpg_status, sig-signer + * and sig-key. + */ +extern void check_commit_signature(const struct commit* commit, struct signature_check *sigc); + #endif /* COMMIT_H */ diff --git a/gpg-interface.h b/gpg-interface.h index cf99021..5884aa4 100644 --- a/gpg-interface.h +++ b/gpg-interface.h @@ -1,6 +1,17 @@ #ifndef GPG_INTERFACE_H #define GPG_INTERFACE_H +struct signature_check { + char *gpg_output; + char *gpg_status; + char result; /* 0 (not checked), + * N (checked but no further result), + * G (good) + * B (bad) */ + char *signer; + char *key; +}; + extern int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key); extern int verify_signed_buffer(const char *payload, size_t payload_size, const char *signature, size_t signature_size, struct strbuf *gpg_output, struct strbuf *gpg_status); extern int git_gpg_config(const char *, const char *, void *); diff --git a/pretty.c b/pretty.c index b57adef..cf84d3a 100644 --- a/pretty.c +++ b/pretty.c @@ -756,14 +756,7 @@ struct format_commit_context { const struct pretty_print_context *pretty_ctx; unsigned commit_header_parsed:1; unsigned commit_message_parsed:1; - unsigned commit_signature_parsed:1; - struct { - char *gpg_output; - char *gpg_status; - char good_bad; - char *signer; - char *key; - } signature; + struct signature_check signature_check; char *message; size_t width, indent1, indent2; @@ -946,64 +939,6 @@ static void rewrap_message_tail(struct strbuf *sb, c-indent2 = new_indent2; } -static struct { - char result; - const char *check; -}
[PATCH v6 2/5] commit.c/GPG signature verification: Also look at the first GPG status line
Signed-off-by: Sebastian Götte ja...@physik-pool.tu-berlin.de --- commit.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/commit.c b/commit.c index eb645af..ca11919 100644 --- a/commit.c +++ b/commit.c @@ -1027,8 +1027,8 @@ static struct { char result; const char *check; } sigcheck_gpg_status[] = { - { 'G', \n[GNUPG:] GOODSIG }, - { 'B', \n[GNUPG:] BADSIG }, + { 'G', [GNUPG:] GOODSIG }, + { 'B', [GNUPG:] BADSIG }, }; static void parse_gpg_output(struct signature_check *sigc) @@ -1036,13 +1036,20 @@ static void parse_gpg_output(struct signature_check *sigc) const char *buf = sigc-gpg_status; int i; + /* Iterate over all search strings */ for (i = 0; i ARRAY_SIZE(sigcheck_gpg_status); i++) { - const char *found = strstr(buf, sigcheck_gpg_status[i].check); - const char *next; - if (!found) - continue; + const char *found, *next; + + if (!prefixcmp(buf, sigcheck_gpg_status[i].check + 1)) { + /* At the very beginning of the buffer */ + found = buf + strlen(sigcheck_gpg_status[i].check + 1); + } else { + found = strstr(buf, sigcheck_gpg_status[i].check); + if (!found) + continue; + found += strlen(sigcheck_gpg_status[i].check); + } sigc-result = sigcheck_gpg_status[i].result; - found += strlen(sigcheck_gpg_status[i].check); sigc-key = xmemdupz(found, 16); found += 17; next = strchrnul(found, '\n'); -- 1.8.1.5 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 3/5] merge/pull: verify GPG signatures of commits being merged
When --verify-signatures is specified on the command-line of git-merge or git-pull, check whether the commits being merged have good gpg signatures and abort the merge in case they do not. This allows e.g. auto-deployment from untrusted repo hosts. Signed-off-by: Sebastian Götte ja...@physik-pool.tu-berlin.de --- Documentation/merge-options.txt| 5 builtin/merge.c| 32 ++- git-pull.sh| 10 ++-- t/t7612-merge-verify-signatures.sh | 52 ++ 4 files changed, 96 insertions(+), 3 deletions(-) diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index 0bcbe0a..31f1067 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -83,6 +83,11 @@ option can be used to override --squash. Pass merge strategy specific option through to the merge strategy. +--verify-signatures:: +--no-verify-signatures:: + Verify that the commits being merged have good GPG signatures and abort the + merge in case they do not. + --summary:: --no-summary:: Synonyms to --stat and --no-stat; these are deprecated and will be diff --git a/builtin/merge.c b/builtin/merge.c index 7c8922c..7a33d03 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -49,7 +49,7 @@ static const char * const builtin_merge_usage[] = { static int show_diffstat = 1, shortlog_len = -1, squash; static int option_commit = 1, allow_fast_forward = 1; static int fast_forward_only, option_edit = -1; -static int allow_trivial = 1, have_message; +static int allow_trivial = 1, have_message, verify_signatures; static int overwrite_ignore = 1; static struct strbuf merge_msg = STRBUF_INIT; static struct strategy **use_strategies; @@ -199,6 +199,8 @@ static struct option builtin_merge_options[] = { OPT_BOOLEAN(0, ff-only, fast_forward_only, N_(abort if fast-forward is not possible)), OPT_RERERE_AUTOUPDATE(allow_rerere_auto), + OPT_BOOL(0, verify-signatures, verify_signatures, + N_(Verify that the named commit has a valid GPG signature)), OPT_CALLBACK('s', strategy, use_strategies, N_(strategy), N_(merge strategy to use), option_parse_strategy), OPT_CALLBACK('X', strategy-option, xopts, N_(option=value), @@ -1233,6 +1235,34 @@ int cmd_merge(int argc, const char **argv, const char *prefix) usage_with_options(builtin_merge_usage, builtin_merge_options); + if (verify_signatures) { + for (p = remoteheads; p; p = p-next) { + struct commit *commit = p-item; + char hex[41]; + struct signature_check signature_check; + memset(signature_check, 0, sizeof(signature_check)); + + check_commit_signature(commit, signature_check); + + strcpy(hex, find_unique_abbrev(commit-object.sha1, DEFAULT_ABBREV)); + switch(signature_check.result){ + case 'G': + break; + case 'B': + die(_(Commit %s has a bad GPG signature allegedly by %s.), hex, signature_check.signer); + default: /* 'N' */ + die(_(Commit %s does not have a GPG signature.), hex, hex); + } + if (verbosity = 0 signature_check.result == 'G') + printf(_(Commit %s has a good GPG signature by %s\n), hex, signature_check.signer); + + free(signature_check.gpg_output); + free(signature_check.gpg_status); + free(signature_check.signer); + free(signature_check.key); + } + } + strbuf_addstr(buf, merge); for (p = remoteheads; p; p = p-next) strbuf_addf(buf, %s, merge_remote_util(p-item)-name); diff --git a/git-pull.sh b/git-pull.sh index 266e682..705940d 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -39,7 +39,7 @@ test -z $(git ls-files -u) || die_conflict test -f $GIT_DIR/MERGE_HEAD die_merge strategy_args= diffstat= no_commit= squash= no_ff= ff_only= -log_arg= verbosity= progress= recurse_submodules= +log_arg= verbosity= progress= recurse_submodules= verify_signatures= merge_args= edit= curr_branch=$(git symbolic-ref -q HEAD) curr_branch_short=${curr_branch#refs/heads/} @@ -125,6 +125,12 @@ do --no-recurse-submodules) recurse_submodules=--no-recurse-submodules ;; + --verify-signatures) + verify_signatures=--verify-signatures + ;; + --no-verify-signatures) + verify_signatures=--no-verify-signatures + ;;
[PATCH v6 4/5] merge/pull Check for untrusted good GPG signatures
When --verify-signatures is specified, abort the merge in case a good GPG signature from an untrusted key is encountered. Signed-off-by: Sebastian Götte ja...@physik-pool.tu-berlin.de --- Documentation/merge-options.txt| 4 ++-- builtin/merge.c| 2 ++ commit.c | 2 ++ commit.h | 10 +- gpg-interface.h| 1 + t/lib-gpg/pubring.gpg | Bin 1164 - 2359 bytes t/lib-gpg/random_seed | Bin 600 - 600 bytes t/lib-gpg/secring.gpg | Bin 1237 - 3734 bytes t/lib-gpg/trustdb.gpg | Bin 1280 - 1360 bytes t/t7612-merge-verify-signatures.sh | 9 + 10 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index 31f1067..a0f022b 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -85,8 +85,8 @@ option can be used to override --squash. --verify-signatures:: --no-verify-signatures:: - Verify that the commits being merged have good GPG signatures and abort the - merge in case they do not. + Verify that the commits being merged have good and trusted GPG signatures + and abort the merge in case they do not. --summary:: --no-summary:: diff --git a/builtin/merge.c b/builtin/merge.c index 7a33d03..752e3a9 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1248,6 +1248,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) switch(signature_check.result){ case 'G': break; + case 'U': + die(_(Commit %s has a good, untrusted GPG signature allegedly by %s.), hex, signature_check.signer); case 'B': die(_(Commit %s has a bad GPG signature allegedly by %s.), hex, signature_check.signer); default: /* 'N' */ diff --git a/commit.c b/commit.c index ca11919..0a49e2b 100644 --- a/commit.c +++ b/commit.c @@ -1027,6 +1027,8 @@ static struct { char result; const char *check; } sigcheck_gpg_status[] = { + { 'U', [GNUPG:] TRUST_UNDEFINED }, + { 'U', [GNUPG:] TRUST_NEVER }, { 'G', [GNUPG:] GOODSIG }, { 'B', [GNUPG:] BADSIG }, }; diff --git a/commit.h b/commit.h index 8bbcf13..27d9b36 100644 --- a/commit.h +++ b/commit.h @@ -232,11 +232,11 @@ extern void print_commit_list(struct commit_list *list, const char *format_last); /* - * Check the signature of the given commit. The result of the check is stored in - * sig-result, 'G' for a good signature, 'B' for a bad signature and 'N' - * for no signature at all. - * This may allocate memory for sig-gpg_output, sig-gpg_status, sig-signer - * and sig-key. + * Check the signature of the given commit. The result of the check is stored + * in sig-check_result, 'G' for a good signature, 'U' for a good signature + * from an untrusted signer, 'B' for a bad signature and 'N' for no signature + * at all. This may allocate memory for sig-gpg_output, sig-gpg_status, + * sig-signer and sig-key. */ extern void check_commit_signature(const struct commit* commit, struct signature_check *sigc); diff --git a/gpg-interface.h b/gpg-interface.h index 5884aa4..a85cb5b 100644 --- a/gpg-interface.h +++ b/gpg-interface.h @@ -6,6 +6,7 @@ struct signature_check { char *gpg_status; char result; /* 0 (not checked), * N (checked but no further result), + * U (untrusted good), * G (good) * B (bad) */ char *signer; diff --git a/t/lib-gpg/pubring.gpg b/t/lib-gpg/pubring.gpg index 83855fa4e1c6c37afe550c17afa1e7971042ded5..1a3c2d487c2fda9169751a3068fa51e853a1e519 100644 GIT binary patch delta 1212 zcmV;t1Vj6b3AYlkj0As~0SyFEOqNFh2mr~8{AU1PG9!Ku9w|}@vpZJPg*#s86v-*O zhafj(DLlFA0)`tvC$E@WHJ2r~0{0ZCh1kHo$b9ih^aD*~)oVvKyC1(yi)6x_y zF8V3JpbIY^ZYQUk#j*ja0`;jw^J+5~!h3qc)ej%g1;Wb0U8cXSuLKdXkx2PUtB4 zzqQO;r+6QaVFd?ZkA#8Ch(2p+QaoKR;K0{BU;l_DqGU2YCt6Fr4psgB*tPou z8C@tnj=CqkffSLs=a-5G+h;Y8bkws-iIgT{$f^j!)l`hmkz}$nZPxBoPmwU;zIH^ zLN~K=bOhGBes9{Fcqzh%Wj2h^{ZjI01*KI0kkAVa%poQL}_zlZ*pX5VIVwYX((5 za%4bdcwudDY-KKPWpqA?0XPH`0RjLb1p-k_mPY~`0|pBT2nPcK1{DYb2?`4Y76JnS z0v-VZ7k~f?2@qikE`_%uafw)?2m1%-{uDP0Rs1|(F{OVhOSKoH$k!o)x3CO5Z^@El zxGq=+xQGRr@3$S0@SUu@@UuxUH%pD3Q-D`?37Vg*xmo%+KD)(U~kXU^b+=70V zFr?b3DvlFq^B*d%lz=lr!ch6nQbvcwWCD}n2DT3`r?RDkq=7r}qFvEhdfApA7yR; z8`OB;$TEKm@jkwG=8vlcKFdrcM8+9eP66QueaUSz6NhphD3O@E(iX7T@2kxV(dXd zxG_$z;qqdhNp6*{J!OD7b;8M6otxRi0UUN|OngZ4NdYbeU0hneiVEwY2h5xZ4z{ zsXL4UkGxJ?Pc}MK(eQlV@oumS)Bxd9CXQA~f9M*#=`sXI#Mh|Ll%uxJqK}$ zc)VOU|M7H$nU~Bd(!9WlLk)V)zUY~vSc_rVFe1JAY7ThlG1IzE9z6ly;9WIe zrW+EU|2KpxZ$0rq-Jn9T{vsi6Qh0j42I3_PLQ5$)qa$}3etj89nJkr^3#KD!xh9*
[PATCH v6 5/5] pretty printing: extend %G? to include 'N' and 'U'
Expand %G? in pretty format strings to 'N' in case of no GPG signature and 'U' in case of a good but untrusted GPG signature in addition to the previous 'G'ood and 'B'ad. This eases writing anyting parsing git-log output. Signed-off-by: Sebastian Götte ja...@physik-pool.tu-berlin.de --- Documentation/pretty-formats.txt | 3 ++- pretty.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt index 2939655..afac703 100644 --- a/Documentation/pretty-formats.txt +++ b/Documentation/pretty-formats.txt @@ -131,7 +131,8 @@ The placeholders are: - '%B': raw body (unwrapped subject and body) - '%N': commit notes - '%GG': raw verification message from GPG for a signed commit -- '%G?': show either G for Good or B for Bad for a signed commit +- '%G?': show G for a Good signature, B for a Bad signature, U for a good, + untrusted signature and N for no signature - '%GS': show the name of the signer for a signed commit - '%GK': show the key used to sign a signed commit - '%gD': reflog selector, e.g., `refs/stash@{1}` diff --git a/pretty.c b/pretty.c index cf84d3a..840c41f 100644 --- a/pretty.c +++ b/pretty.c @@ -1135,6 +1135,8 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder, switch (c-signature_check.result) { case 'G': case 'B': + case 'U': + case 'N': strbuf_addch(sb, c-signature_check.result); } break; -- 1.8.1.5 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 07/12] utf8: keep NULs in reencode_string()
On 30.03.13 10:35, Nguyễn Thái Ngọc Duy wrote: [...] The short version of a review: Would it make sense to leave reencode_string() as it is, and add a new function reencode_string_len() +char *reencode_string_len(const char *in, int insz, + const char *out_encoding, const char *in_encoding, + int *outsz) And I didn't manage to apply the patch on master (631bc94e67383b66da190550866566f09d32) is there a specific commitID it should be applied on ? /Torsten pretty output, which can contain NULs. - reencoded = reencode_string(message, UTF-8, encoding); + reencoded = reencode_string(message, strlen(message), + UTF-8, encoding, NULL); - out = reencode_string(line-buf, metainfo_charset, charset); + out = reencode_string(line-buf, line-len, + metainfo_charset, charset, NULL); - newarg = reencode_string_iconv(oldarg, namelen, ic_precompose); + newarg = reencode_string_iconv(oldarg, namelen, ic_precompose, NULL); - char *reencoded = reencode_string(msg, output_encoding, utf8); + char *reencoded = reencode_string(msg, strlen(msg), + output_encoding, utf8, + NULL); - out = reencode_string(msg, output_encoding, use_encoding); + out = reencode_string(msg, strlen(msg), + output_encoding, use_encoding, NULL); - out-reencoded_message = reencode_string(commit-buffer, - git_commit_encoding, encoding); + out-reencoded_message = + reencode_string(commit-buffer, strlen(commit-buffer), + git_commit_encoding, encoding, NULL); +char *reencode_string_len(const char *in, int insz, + const char *out_encoding, const char *in_encoding, + int *outsz) -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] fixup! pathspec: support :(glob) syntax
A formatting fix for a patch currently cooking on nd/magic-pathspecs (cc3d8045ec1e2323c5654e2af834e887f26deb7e). --- The latest version of this wasn't posted to the list in full, so I'm not sure about the recommended way to provide feedback. Hopefully this is easy to squash in. Documentation/git.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git.txt b/Documentation/git.txt index f423cd6..d6eb0d3 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -443,13 +443,13 @@ help ...`. This is equivalent to setting the `GIT_LITERAL_PATHSPECS` environment variable to `1`. ---glob-pathspecs: +--glob-pathspecs:: Add glob magic to all pathspec. This is equivalent to setting the `GIT_GLOB_PATHSPECS` environment variable to `1`. Disabling globbing on individual pathspecs can be done using pathspec magic :(literal) ---noglob-pathspecs: +--noglob-pathspecs:: Add literal magic to all pathspec. This is equivalent to setting the `GIT_NOGLOB_PATHSPECS` environment variable to `1`. Enabling globbing on individual pathspecs can be done using pathspec -- 1.8.2.515.g52d783d -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] Add posibility to preload stat information.
On Thu, Mar 21, 2013 at 10:44 AM, Junio C Hamano gits...@pobox.com wrote: Thomas Rast tr...@student.ethz.ch writes: I think it would actually be a somewhat interesting feature if it interacted with GIT_PS1_SHOW*. If you use these settings (I personally use SHOWDIRTYSTATE but not SHOWUNTRACKEDFILES), the prompt hangs while __git_ps1 runs git-status. It should be possible to run a git-status process in the background when entering a repository, and displaying some marker ('??' maybe) in the prompt instead of the dirty-state info until git-status has finished. This is somewhat interesting. Perhaps we can introduce a helper binary that does what __git_ps1() does, with a --timeout=500ms option to say I dunno (yet), and keep priming the well in the background when it takes more than the specified amount of time? That would be nice. My fork-fu is weak, so I cheated and relied on kill/timeout instead. I have had this code below in my zsh git prompt (based on oh-my-zsh) for more than a year. It uses $(timeout) to kill the status command if it does not complete in 1 second. It's dumb in several ways, but it does show me four different flags fairly reliably indicating whether I have changed files, untracked files, clean workdir, or I timed out trying to find out. git_dirty_timeout () { #-- Modified files xx=$(timeout 1s git status -s $@ 2 /dev/null) test $? -eq 124 return 124 test -n ${xx} return 50 #-- Untracked files (only) xx=$(timeout 1s git status -s -uno $@ 2 /dev/null) test $? -eq 124 return 124 test -n ${xx} return 51 return 0 } parse_git_dirty () { git_dirty_timeout case $? in '50') echo $ZSH_THEME_GIT_PROMPT_DIRTY ;; '51') echo $ZSH_THEME_GIT_PROMPT_UNTRACKED ;; '124') echo $ZSH_THEME_GIT_PROMPT_TIMEOUT ;; *) echo [$?]$ZSH_THEME_GIT_PROMPT_CLEAN ;; esac } -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: stuck and need unstuck (git checkout)
On Mon, Mar 25, 2013 at 1:57 PM, J.V. jvsr...@gmail.com wrote: I was on a branch (local tracked with remote), and I wanted to checkout a remote branch so did: $git co myRemoteBranch and got a message that a lot of jar files were being untracked (files were locked). I had a server running that had some of the jar files locked, so it could not update and untracked them all. What I want to do now is: 1. switch branches 2. delete this locally created branch 3. re-check out again so all will be well. I cannot switch branches because it says my untracked files will be overwritten. How do I switch branches? I have no commits to make and simply want to go back. git reset and git stash do not get me there. Does 'git checkout --force yourLocalBranch' help? Phil -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] git-svn: avoid self-referencing mergeinfo
When svn.pushmergeinfo is set, the target branch is included in the mergeinfo if it was previously merged into one of the source branches. SVN does not do this. Remove merge target branch path from resulting mergeinfo when svn.pushmergeinfo is set to better match the behavior of SVN. Update the svn-mergeinfo-push test. Signed-off-by: Michael Contreras mich...@inetric.com Reported-by: Avishay Lavie avishay.la...@gmail.com --- Avishay's original patch was never applied. http://thread.gmane.org/gmane.comp.version-control.git/193123 git-svn.perl | 9 ++--- t/t9161-git-svn-mergeinfo-push.sh | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index b46795f..bd4388d 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -669,12 +669,14 @@ sub merge_revs_into_hash { } sub merge_merge_info { - my ($mergeinfo_one, $mergeinfo_two) = @_; + my ($mergeinfo_one, $mergeinfo_two, $ignore_branch) = @_; my %result_hash = (); merge_revs_into_hash(\%result_hash, $mergeinfo_one); merge_revs_into_hash(\%result_hash, $mergeinfo_two); + delete $result_hash{$ignore_branch} if $ignore_branch; + my $result = ''; # Sort below is for consistency's sake for my $branchname (sort keys(%result_hash)) { @@ -695,6 +697,7 @@ sub populate_merge_info { my $all_parents_ok = 1; my $aggregate_mergeinfo = ''; my $rooturl = $gs-repos_root; + my ($target_branch) = $gs-full_pushurl =~ /^\Q$rooturl\E(.*)/; if (defined($rewritten_parent)) { # Replace first parent with newly-rewritten version @@ -726,7 +729,7 @@ sub populate_merge_info { # Merge previous mergeinfo values $aggregate_mergeinfo = merge_merge_info($aggregate_mergeinfo, - $par_mergeinfo, 0); + $par_mergeinfo, $target_branch); next if $parent eq $parents[0]; # Skip first parent # Add new changes being placed in tree by merge @@ -769,7 +772,7 @@ sub populate_merge_info { my $newmergeinfo = $branchpath: . join(',', @revsin); $aggregate_mergeinfo = merge_merge_info($aggregate_mergeinfo, -$newmergeinfo, 1); +$newmergeinfo, $target_branch); } if ($all_parents_ok and $aggregate_mergeinfo) { return $aggregate_mergeinfo; diff --git a/t/t9161-git-svn-mergeinfo-push.sh b/t/t9161-git-svn-mergeinfo-push.sh index 6ef0c0b..1eab701 100755 --- a/t/t9161-git-svn-mergeinfo-push.sh +++ b/t/t9161-git-svn-mergeinfo-push.sh @@ -88,7 +88,6 @@ test_expect_success 'check reintegration mergeinfo' ' test $mergeinfo = /branches/svnb1:2-4,7-9,13-18 /branches/svnb2:3,8,16-17 /branches/svnb3:4,9 -/branches/svnb4:5-6,10-12 /branches/svnb5:6,11 ' -- 1.8.2 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 07/12] utf8: keep NULs in reencode_string()
On Sun, Mar 31, 2013 at 12:06 AM, Torsten Bögershausen tbo...@web.de wrote: On 30.03.13 10:35, Nguyễn Thái Ngọc Duy wrote: [...] The short version of a review: Would it make sense to leave reencode_string() as it is, and add a new function reencode_string_len() Hmm.. yeah. +char *reencode_string_len(const char *in, int insz, + const char *out_encoding, const char *in_encoding, + int *outsz) And I didn't manage to apply the patch on master (631bc94e67383b66da190550866566f09d32) is there a specific commitID it should be applied on ? v1.8.2 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] bash: teach __git_ps1 about REVERT_HEAD
Signed-off-by: Robin Rosenberg robin.rosenb...@dewire.com --- contrib/completion/git-prompt.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 341422a..756a951 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -282,6 +282,8 @@ __git_ps1 () r=|MERGING elif [ -f $g/CHERRY_PICK_HEAD ]; then r=|CHERRY-PICKING + elif [ -f $g/REVERT_HEAD ]; then + r=|REVERTING elif [ -f $g/BISECT_LOG ]; then r=|BISECTING fi -- 1.8.1.337.gf3f86a8 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] branch: give better message when no names specified for rename
Signed-off-by: Jonathon Mah m...@jonathonmah.com --- The previous message was incorrect when not enough arguments were specified: $ git branch -m fatal: too many branches for a rename operation I changed to branch name required instead of new branch name required in the hope that existing translations can be used. builtin/branch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/branch.c b/builtin/branch.c index 00d17d2..580107f 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -880,7 +880,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (edit_branch_description(branch_name)) return 1; } else if (rename) { - if (argc == 1) + if (!argc) + die(_(branch name required)); + else if (argc == 1) rename_branch(head, argv[0], rename 1); else if (argc == 2) rename_branch(argv[0], argv[1], rename 1); -- 1.8.2.279.g631bc94 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] branch: give better message when no names specified for rename
On Sun, Mar 31, 2013 at 8:27 AM, Jonathon Mah m...@jonathonmah.com wrote: - if (argc == 1) + if (!argc) + die(_(branch name required)); + else if (argc == 1) rename_branch(head, argv[0], rename 1); else if (argc == 2) rename_branch(argv[0], argv[1], rename 1); This makes four branches based on argc. Maybe we should convert if/else chain to switch/case. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html