Re: Where can I find the MD5 or SHA1 of git preview client.

2016-04-17 Thread Johannes Schindelin
Hi Wu,

On Sun, 17 Apr 2016, bin wu wrote:

> There is still a question.Why not just post the the MD5 and SHA1 on
> the download page?

We do: https://github.com/git-for-windows/git/releases

Ciao,
Johannes
--
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 3/6] match-trees: convert shift_tree and shift_tree_by to object_id

2016-04-17 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 cache.h|  4 ++--
 match-trees.c  | 44 ++--
 merge-recursive.c  |  4 ++--
 test-match-trees.c |  2 +-
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/cache.h b/cache.h
index 22b73646..70091e73 100644
--- a/cache.h
+++ b/cache.h
@@ -1768,8 +1768,8 @@ int add_files_to_cache(const char *prefix, const struct 
pathspec *pathspec, int
 extern int diff_auto_refresh_index;
 
 /* match-trees.c */
-void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, 
int);
-void shift_tree_by(const unsigned char *, const unsigned char *, unsigned char 
*, const char *);
+void shift_tree(const struct object_id *, const struct object_id *, struct 
object_id *, int);
+void shift_tree_by(const struct object_id *, const struct object_id *, struct 
object_id *, const char *);
 
 /*
  * whitespace rules.
diff --git a/match-trees.c b/match-trees.c
index 1ce0954a..9977752a 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -229,9 +229,9 @@ static int splice_tree(const unsigned char *hash1,
  * other hand, it could cover tree one and we might need to pick a
  * subtree of it.
  */
-void shift_tree(const unsigned char *hash1,
-   const unsigned char *hash2,
-   unsigned char *shifted,
+void shift_tree(const struct object_id *hash1,
+   const struct object_id *hash2,
+   struct object_id *shifted,
int depth_limit)
 {
char *add_prefix;
@@ -245,7 +245,7 @@ void shift_tree(const unsigned char *hash1,
if (!depth_limit)
depth_limit = 2;
 
-   add_score = del_score = score_trees(hash1, hash2);
+   add_score = del_score = score_trees(hash1->hash, hash2->hash);
add_prefix = xcalloc(1, 1);
del_prefix = xcalloc(1, 1);
 
@@ -253,16 +253,16 @@ void shift_tree(const unsigned char *hash1,
 * See if one's subtree resembles two; if so we need to prefix
 * two with a few fake trees to match the prefix.
 */
-   match_trees(hash1, hash2, _score, _prefix, "", depth_limit);
+   match_trees(hash1->hash, hash2->hash, _score, _prefix, "", 
depth_limit);
 
/*
 * See if two's subtree resembles one; if so we need to
 * pick only subtree of two.
 */
-   match_trees(hash2, hash1, _score, _prefix, "", depth_limit);
+   match_trees(hash2->hash, hash1->hash, _score, _prefix, "", 
depth_limit);
 
/* Assume we do not have to do any shifting */
-   hashcpy(shifted, hash2);
+   oidcpy(shifted, hash2);
 
if (add_score < del_score) {
/* We need to pick a subtree of two */
@@ -271,16 +271,16 @@ void shift_tree(const unsigned char *hash1,
if (!*del_prefix)
return;
 
-   if (get_tree_entry(hash2, del_prefix, shifted, ))
+   if (get_tree_entry(hash2->hash, del_prefix, shifted->hash, 
))
die("cannot find path %s in tree %s",
-   del_prefix, sha1_to_hex(hash2));
+   del_prefix, oid_to_hex(hash2));
return;
}
 
if (!*add_prefix)
return;
 
-   splice_tree(hash1, add_prefix, hash2, shifted);
+   splice_tree(hash1->hash, add_prefix, hash2->hash, shifted->hash);
 }
 
 /*
@@ -288,44 +288,44 @@ void shift_tree(const unsigned char *hash1,
  * Unfortunately we cannot fundamentally tell which one to
  * be prefixed, as recursive merge can work in either direction.
  */
-void shift_tree_by(const unsigned char *hash1,
-  const unsigned char *hash2,
-  unsigned char *shifted,
+void shift_tree_by(const struct object_id *hash1,
+  const struct object_id *hash2,
+  struct object_id *shifted,
   const char *shift_prefix)
 {
-   unsigned char sub1[20], sub2[20];
+   struct object_id sub1, sub2;
unsigned mode1, mode2;
unsigned candidate = 0;
 
/* Can hash2 be a tree at shift_prefix in tree hash1? */
-   if (!get_tree_entry(hash1, shift_prefix, sub1, ) &&
+   if (!get_tree_entry(hash1->hash, shift_prefix, sub1.hash, ) &&
S_ISDIR(mode1))
candidate |= 1;
 
/* Can hash1 be a tree at shift_prefix in tree hash2? */
-   if (!get_tree_entry(hash2, shift_prefix, sub2, ) &&
+   if (!get_tree_entry(hash2->hash, shift_prefix, sub2.hash, ) &&
S_ISDIR(mode2))
candidate |= 2;
 
if (candidate == 3) {
/* Both are plausible -- we need to evaluate the score */
-   int best_score = score_trees(hash1, hash2);
+   int best_score = score_trees(hash1->hash, hash2->hash);
int score;
 
candidate = 0;
-   score = score_trees(sub1, hash2);
+   score = 

Re: Default authentication over https?

2016-04-17 Thread brian m. carlson
On Fri, Apr 15, 2016 at 06:43:35PM -0400, Jeff King wrote:
> Hmm. Looks like we already pull this out of the curl result for other
> reasons, but we never feed it back in to the next request. So if I do
> this:
> 
> diff --git a/http.c b/http.c
> index 9bedad7..add9bf2 100644
> --- a/http.c
> +++ b/http.c
> @@ -1132,6 +1132,8 @@ static int handle_curl_result(struct slot_results 
> *results)
>   return HTTP_NOAUTH;
>   } else {
>  #ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
> + if (results->auth_avail)
> + http_auth_methods = results->auth_avail;
>   http_auth_methods &= ~CURLAUTH_GSSNEGOTIATE;
>  #endif
>   return HTTP_REAUTH;
> 
> that drops my test case down to two requests: once to find out that we
> need auth via the 401, and then we feed curl sufficient information to
> do the followup in a single request (the GSSNEGOTIATE thing there is a
> hack from 4dbe664, which we can ignore for now).
> 
> Interestingly, curl _does_ reuse the connection this time. I'm still not
> sure why it didn't in the original case. But this means the whole thing
> is happening over a single TCP session, which is good (and I didn't have
> to change my config at all).

This looks fine from my point of view.  GSS-Negotiate and Digest are
going to require at least one round-trip because they need the token or
nonce to authenticate.  Basic shouldn't, though.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204


signature.asc
Description: PGP signature


[PATCH 1/6] Introduce a get_oid function.

2016-04-17 Thread brian m. carlson
The get_oid function is equivalent to the get_sha1 function, but uses a
struct object_id instead.

Signed-off-by: brian m. carlson 
---
 cache.h | 2 ++
 sha1_name.c | 9 +
 2 files changed, 11 insertions(+)

diff --git a/cache.h b/cache.h
index 2711048c..22b73646 100644
--- a/cache.h
+++ b/cache.h
@@ -1156,6 +1156,8 @@ extern int get_sha1_blob(const char *str, unsigned char 
*sha1);
 extern void maybe_die_on_misspelt_object_name(const char *name, const char 
*prefix);
 extern int get_sha1_with_context(const char *str, unsigned flags, unsigned 
char *sha1, struct object_context *orc);
 
+extern int get_oid(const char *str, struct object_id *oid);
+
 typedef int each_abbrev_fn(const unsigned char *sha1, void *);
 extern int for_each_abbrev(const char *prefix, each_abbrev_fn, void *);
 
diff --git a/sha1_name.c b/sha1_name.c
index 776101e8..ca7ddd6f 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1215,6 +1215,15 @@ int get_sha1(const char *name, unsigned char *sha1)
 }
 
 /*
+ * This is like "get_sha1()", but for struct object_id.
+ */
+int get_oid(const char *name, struct object_id *oid)
+{
+   return get_sha1(name, oid->hash);
+}
+
+
+/*
  * Many callers know that the user meant to name a commit-ish by
  * syntactical positions where the object name appears.  Calling this
  * function allows the machinery to disambiguate shorter-than-unique
-- 
2.8.0.rc3.226.g39d4020

--
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: Migrating away from SHA-1?

2016-04-17 Thread brian m. carlson
On Tue, Apr 12, 2016 at 06:58:10PM -0700, H. Peter Anvin wrote:
> On April 12, 2016 6:51:12 PM PDT, Duy Nguyen  wrote:
> >On Wed, Apr 13, 2016 at 5:38 AM, H. Peter Anvin  wrote:
> >> OK, I'm going to open this can of worms...
> >>
> >> At what point do we migrate from SHA-1?
> >
> >Brian Carlson has been slowly refactoring git code base, abstracting
> >SHA-1 away. Once that work is done, I think we can talk about moving
> >away from SHA-1. The process is slow because it likely causes
> >conflicts with in-flight topics. A quick grep shows we still have
> >about 300 SHA-1 references, so it'll be quite some time.
> 
> Well, at least it sounds like work is underway.  That is a big deal.

Yes, it's a bunch of slow manual refactoring, and I've been busy as
we've been doing house- and car-related things recently.  I'll try to
spend a little more time on it this weekend.

The first step is to convert all of the individual places that use
unsigned char [20] to use struct object_id, which can then be extended
to use different hash algorithms.  There are also constants,
GIT_SHA1_RAWSZ and GIT_SHA1_HEXSZ, that abstract the 20 and 40 values in
the codebase so they can be changed in the future.

While this is a project I've been mostly working on, I have no objection
to other people sending in a patch or series as they feel like it.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204


signature.asc
Description: PGP signature


[PATCH 2/6] test-match-trees: convert to use struct object_id

2016-04-17 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 test-match-trees.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/test-match-trees.c b/test-match-trees.c
index 4dad7095..41aff841 100644
--- a/test-match-trees.c
+++ b/test-match-trees.c
@@ -3,24 +3,24 @@
 
 int main(int ac, char **av)
 {
-   unsigned char hash1[20], hash2[20], shifted[20];
+   struct object_id hash1, hash2, shifted;
struct tree *one, *two;
 
setup_git_directory();
 
-   if (get_sha1(av[1], hash1))
+   if (get_oid(av[1], ))
die("cannot parse %s as an object name", av[1]);
-   if (get_sha1(av[2], hash2))
+   if (get_oid(av[2], ))
die("cannot parse %s as an object name", av[2]);
-   one = parse_tree_indirect(hash1);
+   one = parse_tree_indirect(hash1.hash);
if (!one)
die("not a tree-ish %s", av[1]);
-   two = parse_tree_indirect(hash2);
+   two = parse_tree_indirect(hash2.hash);
if (!two)
die("not a tree-ish %s", av[2]);
 
-   shift_tree(one->object.oid.hash, two->object.oid.hash, shifted, -1);
-   printf("shifted: %s\n", sha1_to_hex(shifted));
+   shift_tree(one->object.oid.hash, two->object.oid.hash, shifted.hash, 
-1);
+   printf("shifted: %s\n", oid_to_hex());
 
exit(0);
 }
-- 
2.8.0.rc3.226.g39d4020

--
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 0/6] object_id Part 3

2016-04-17 Thread brian m. carlson
This is the third of a series of patches to convert instances of
unsigned char[20] to struct object_id.  The focus in this series was to
convert test-match-trees, related functions, and some dependencies.
struct name_entry was converted as part of these dependencies.

The riskiest part of this series is the conversion of struct name_entry.
Compatibility with unconverted code requires dereferencing the new oid
member, but there are at least some places where we explicitly check
that it is not NULL.  These seem to be limited to empty entries in
merge-tree.c, and it doesn't appear that we ever pass an empty entry to
a function which might dereference it.

This series rebases onto next cleanly and is not likely to conflict with
other topics in flight.  My intention is to send smaller series more
frequently, with the goal of avoiding or minimizing conflicts where
possible.

brian m. carlson (6):
  Introduce a get_oid function.
  test-match-trees: convert to use struct object_id
  match-trees: convert shift_tree and shift_tree_by to object_id
  Convert struct name_entry to use struct object_id.
  tree-walk: convert tree_entry_extract to struct object_id
  match-trees: convert several leaf functions to struct object_id

 builtin/grep.c |  6 ++---
 builtin/merge-tree.c   | 18 +++
 builtin/pack-objects.c |  4 ++--
 builtin/reflog.c   |  4 ++--
 cache-tree.c   |  4 ++--
 cache.h|  6 +++--
 fsck.c | 10 -
 http-push.c|  4 ++--
 list-objects.c |  6 ++---
 match-trees.c  | 60 +-
 merge-recursive.c  |  4 ++--
 notes.c|  4 ++--
 revision.c |  4 ++--
 sha1_name.c|  9 
 test-match-trees.c | 14 ++--
 tree-diff.c|  8 +++
 tree-walk.c| 16 +++---
 tree-walk.h|  8 +++
 tree.c | 10 -
 unpack-trees.c |  4 ++--
 walker.c   |  4 ++--
 21 files changed, 109 insertions(+), 98 deletions(-)

-- 
2.8.0.rc3.226.g39d4020

--
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 4/6] Convert struct name_entry to use struct object_id.

2016-04-17 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 builtin/grep.c |  6 +++---
 builtin/merge-tree.c   | 18 +-
 builtin/pack-objects.c |  4 ++--
 builtin/reflog.c   |  4 ++--
 cache-tree.c   |  4 ++--
 fsck.c |  4 ++--
 http-push.c|  4 ++--
 list-objects.c |  6 +++---
 match-trees.c  |  2 +-
 notes.c|  4 ++--
 revision.c |  4 ++--
 tree-diff.c|  6 +++---
 tree-walk.c|  6 +++---
 tree-walk.h|  6 +++---
 tree.c | 10 +-
 unpack-trees.c |  4 ++--
 walker.c   |  4 ++--
 17 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index 111b6f6c..462e6079 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -438,7 +438,7 @@ static int grep_tree(struct grep_opt *opt, const struct 
pathspec *pathspec,
strbuf_add(base, entry.path, te_len);
 
if (S_ISREG(entry.mode)) {
-   hit |= grep_sha1(opt, entry.sha1, base->buf, tn_len,
+   hit |= grep_sha1(opt, entry.oid->hash, base->buf, 
tn_len,
 check_attr ? base->buf + tn_len : 
NULL);
}
else if (S_ISDIR(entry.mode)) {
@@ -447,10 +447,10 @@ static int grep_tree(struct grep_opt *opt, const struct 
pathspec *pathspec,
void *data;
unsigned long size;
 
-   data = lock_and_read_sha1_file(entry.sha1, , 
);
+   data = lock_and_read_sha1_file(entry.oid->hash, , 
);
if (!data)
die(_("unable to read tree (%s)"),
-   sha1_to_hex(entry.sha1));
+   oid_to_hex(entry.oid));
 
strbuf_addch(base, '/');
init_tree_desc(, data, size);
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index ca570041..81cced50 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -150,15 +150,15 @@ static void show_result(void)
 /* An empty entry never compares same, not even to another empty entry */
 static int same_entry(struct name_entry *a, struct name_entry *b)
 {
-   return  a->sha1 &&
-   b->sha1 &&
-   !hashcmp(a->sha1, b->sha1) &&
+   return  a->oid &&
+   b->oid &&
+   !oidcmp(a->oid, b->oid) &&
a->mode == b->mode;
 }
 
 static int both_empty(struct name_entry *a, struct name_entry *b)
 {
-   return !(a->sha1 || b->sha1);
+   return !(a->oid || b->oid);
 }
 
 static struct merge_list *create_entry(unsigned stage, unsigned mode, const 
unsigned char *sha1, const char *path)
@@ -188,8 +188,8 @@ static void resolve(const struct traverse_info *info, 
struct name_entry *ours, s
return;
 
path = traverse_path(info, result);
-   orig = create_entry(2, ours->mode, ours->sha1, path);
-   final = create_entry(0, result->mode, result->sha1, path);
+   orig = create_entry(2, ours->mode, ours->oid->hash, path);
+   final = create_entry(0, result->mode, result->oid->hash, path);
 
final->link = orig;
 
@@ -213,7 +213,7 @@ static void unresolved_directory(const struct traverse_info 
*info,
 
newbase = traverse_path(info, p);
 
-#define ENTRY_SHA1(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->sha1 : NULL)
+#define ENTRY_SHA1(e) (((e)->mode && S_ISDIR((e)->mode)) ? (e)->oid->hash : 
NULL)
buf0 = fill_tree_descriptor(t+0, ENTRY_SHA1(n + 0));
buf1 = fill_tree_descriptor(t+1, ENTRY_SHA1(n + 1));
buf2 = fill_tree_descriptor(t+2, ENTRY_SHA1(n + 2));
@@ -239,7 +239,7 @@ static struct merge_list *link_entry(unsigned stage, const 
struct traverse_info
path = entry->path;
else
path = traverse_path(info, n);
-   link = create_entry(stage, n->mode, n->sha1, path);
+   link = create_entry(stage, n->mode, n->oid->hash, path);
link->link = entry;
return link;
 }
@@ -314,7 +314,7 @@ static int threeway_callback(int n, unsigned long mask, 
unsigned long dirmask, s
}
 
if (same_entry(entry+0, entry+1)) {
-   if (entry[2].sha1 && !S_ISDIR(entry[2].mode)) {
+   if (entry[2].oid->hash && !S_ISDIR(entry[2].mode)) {
/* We did not touch, they modified -- take theirs */
resolve(info, entry+1, entry+2);
return mask;
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index a27de5b3..d56b2c2d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1186,7 +1186,7 @@ static void add_pbase_object(struct tree_desc *tree,
if (cmp < 0)
return;
if (name[cmplen] != '/') {
-   

[PATCH 5/6] tree-walk: convert tree_entry_extract to struct object_id

2016-04-17 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 fsck.c|  6 +++---
 match-trees.c | 12 ++--
 tree-diff.c   |  2 +-
 tree-walk.c   | 10 +-
 tree-walk.h   |  4 ++--
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/fsck.c b/fsck.c
index 606eba8c..92b17f5d 100644
--- a/fsck.c
+++ b/fsck.c
@@ -450,11 +450,11 @@ static int fsck_tree(struct tree *item, struct 
fsck_options *options)
while (desc.size) {
unsigned mode;
const char *name;
-   const unsigned char *sha1;
+   const struct object_id *oid;
 
-   sha1 = tree_entry_extract(, , );
+   oid = tree_entry_extract(, , );
 
-   has_null_sha1 |= is_null_sha1(sha1);
+   has_null_sha1 |= is_null_oid(oid);
has_full_path |= !!strchr(name, '/');
has_empty_name |= !*name;
has_dot |= !strcmp(name, ".");
diff --git a/match-trees.c b/match-trees.c
index 751f8f20..8ca7c68f 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -131,14 +131,14 @@ static void match_trees(const unsigned char *hash1,
 
while (one.size) {
const char *path;
-   const unsigned char *elem;
+   const struct object_id *elem;
unsigned mode;
int score;
 
elem = tree_entry_extract(, , );
if (!S_ISDIR(mode))
goto next;
-   score = score_trees(elem, hash2);
+   score = score_trees(elem->hash, hash2);
if (*best_score < score) {
free(*best_match);
*best_match = xstrfmt("%s%s", base, path);
@@ -146,7 +146,7 @@ static void match_trees(const unsigned char *hash1,
}
if (recurse_limit) {
char *newbase = xstrfmt("%s%s/", base, path);
-   match_trees(elem, hash2, best_score, best_match,
+   match_trees(elem->hash, hash2, best_score, best_match,
newbase, recurse_limit - 1);
free(newbase);
}
@@ -191,15 +191,15 @@ static int splice_tree(const unsigned char *hash1,
while (desc.size) {
const char *name;
unsigned mode;
-   const unsigned char *sha1;
+   const struct object_id *oid;
 
-   sha1 = tree_entry_extract(, , );
+   oid = tree_entry_extract(, , );
if (strlen(name) == toplen &&
!memcmp(name, prefix, toplen)) {
if (!S_ISDIR(mode))
die("entry %s in tree %s is not a tree",
name, sha1_to_hex(hash1));
-   rewrite_here = (unsigned char *) sha1;
+   rewrite_here = (unsigned char *) oid->hash;
break;
}
update_tree_entry();
diff --git a/tree-diff.c b/tree-diff.c
index 402f9ff2..ff4e0d3c 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -183,7 +183,7 @@ static struct combine_diff_path *emit_path(struct 
combine_diff_path *p,
 
if (t) {
/* path present in resulting tree */
-   sha1 = tree_entry_extract(t, , );
+   sha1 = tree_entry_extract(t, , )->hash;
pathlen = tree_entry_len(>entry);
isdir = S_ISDIR(mode);
} else {
diff --git a/tree-walk.c b/tree-walk.c
index fab57dd5..ce278424 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -433,10 +433,10 @@ static int find_tree_entry(struct tree_desc *t, const 
char *name, unsigned char
int namelen = strlen(name);
while (t->size) {
const char *entry;
-   const unsigned char *sha1;
+   const struct object_id *oid;
int entrylen, cmp;
 
-   sha1 = tree_entry_extract(t, , mode);
+   oid = tree_entry_extract(t, , mode);
entrylen = tree_entry_len(>entry);
update_tree_entry(t);
if (entrylen > namelen)
@@ -447,7 +447,7 @@ static int find_tree_entry(struct tree_desc *t, const char 
*name, unsigned char
if (cmp < 0)
break;
if (entrylen == namelen) {
-   hashcpy(result, sha1);
+   hashcpy(result, oid->hash);
return 0;
}
if (name[entrylen] != '/')
@@ -455,10 +455,10 @@ static int find_tree_entry(struct tree_desc *t, const 
char *name, unsigned char
if (!S_ISDIR(*mode))
break;
if (++entrylen == namelen) {
-   hashcpy(result, sha1);
+   hashcpy(result, oid->hash);
return 0;
}
- 

[PATCH 6/6] match-trees: convert several leaf functions to struct object_id

2016-04-17 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 match-trees.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/match-trees.c b/match-trees.c
index 8ca7c68f..396b7338 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -48,17 +48,17 @@ static int score_matches(unsigned mode1, unsigned mode2, 
const char *path)
 }
 
 static void *fill_tree_desc_strict(struct tree_desc *desc,
-  const unsigned char *hash)
+  const struct object_id *hash)
 {
void *buffer;
enum object_type type;
unsigned long size;
 
-   buffer = read_sha1_file(hash, , );
+   buffer = read_sha1_file(hash->hash, , );
if (!buffer)
-   die("unable to read tree (%s)", sha1_to_hex(hash));
+   die("unable to read tree (%s)", oid_to_hex(hash));
if (type != OBJ_TREE)
-   die("%s is not a tree", sha1_to_hex(hash));
+   die("%s is not a tree", oid_to_hex(hash));
init_tree_desc(desc, buffer, size);
return buffer;
 }
@@ -73,7 +73,7 @@ static int base_name_entries_compare(const struct name_entry 
*a,
 /*
  * Inspect two trees, and give a score that tells how similar they are.
  */
-static int score_trees(const unsigned char *hash1, const unsigned char *hash2)
+static int score_trees(const struct object_id *hash1, const struct object_id 
*hash2)
 {
struct tree_desc one;
struct tree_desc two;
@@ -119,8 +119,8 @@ static int score_trees(const unsigned char *hash1, const 
unsigned char *hash2)
 /*
  * Match one itself and its subtrees with two and pick the best match.
  */
-static void match_trees(const unsigned char *hash1,
-   const unsigned char *hash2,
+static void match_trees(const struct object_id *hash1,
+   const struct object_id *hash2,
int *best_score,
char **best_match,
const char *base,
@@ -138,7 +138,7 @@ static void match_trees(const unsigned char *hash1,
elem = tree_entry_extract(, , );
if (!S_ISDIR(mode))
goto next;
-   score = score_trees(elem->hash, hash2);
+   score = score_trees(elem, hash2);
if (*best_score < score) {
free(*best_match);
*best_match = xstrfmt("%s%s", base, path);
@@ -146,7 +146,7 @@ static void match_trees(const unsigned char *hash1,
}
if (recurse_limit) {
char *newbase = xstrfmt("%s%s/", base, path);
-   match_trees(elem->hash, hash2, best_score, best_match,
+   match_trees(elem, hash2, best_score, best_match,
newbase, recurse_limit - 1);
free(newbase);
}
@@ -245,7 +245,7 @@ void shift_tree(const struct object_id *hash1,
if (!depth_limit)
depth_limit = 2;
 
-   add_score = del_score = score_trees(hash1->hash, hash2->hash);
+   add_score = del_score = score_trees(hash1, hash2);
add_prefix = xcalloc(1, 1);
del_prefix = xcalloc(1, 1);
 
@@ -253,13 +253,13 @@ void shift_tree(const struct object_id *hash1,
 * See if one's subtree resembles two; if so we need to prefix
 * two with a few fake trees to match the prefix.
 */
-   match_trees(hash1->hash, hash2->hash, _score, _prefix, "", 
depth_limit);
+   match_trees(hash1, hash2, _score, _prefix, "", depth_limit);
 
/*
 * See if two's subtree resembles one; if so we need to
 * pick only subtree of two.
 */
-   match_trees(hash2->hash, hash1->hash, _score, _prefix, "", 
depth_limit);
+   match_trees(hash2, hash1, _score, _prefix, "", depth_limit);
 
/* Assume we do not have to do any shifting */
oidcpy(shifted, hash2);
@@ -309,16 +309,16 @@ void shift_tree_by(const struct object_id *hash1,
 
if (candidate == 3) {
/* Both are plausible -- we need to evaluate the score */
-   int best_score = score_trees(hash1->hash, hash2->hash);
+   int best_score = score_trees(hash1, hash2);
int score;
 
candidate = 0;
-   score = score_trees(sub1.hash, hash2->hash);
+   score = score_trees(, hash2);
if (score > best_score) {
candidate = 1;
best_score = score;
}
-   score = score_trees(sub2.hash, hash1->hash);
+   score = score_trees(, hash1);
if (score > best_score)
candidate = 2;
}
-- 
2.8.0.rc3.226.g39d4020

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More 

Re: git merge branch --no-commit does commit fast forward merges

2016-04-17 Thread Jacob Keller
On Sun, Apr 17, 2016 at 2:10 PM, Christoph Paulik  wrote:
>
> Hi Git Mailinglist,
> git merge branch --no-commit does commit fast forward merges leaving users
> no way to change the merge results. The command only works as expected when
> also adding the --no-ff flag. Looking at the help text of the --no-commit
> flag I think that this might be a unintended.
> I've tested this on git 2.8.0.
>
> This bug was first reported to magit
> (https://github.com/magit/magit/issues/2620) whose maintainer then suggested
> that it might be a git bug.
>
> Best regards,
> Christoph
>


To be fair, the user can undo it with "git reset HEAD@{1}" I believe?

Thanks,
Jake
--
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


Important Message.

2016-04-17 Thread Itsuki
Business proposal therefor you are required to send an email to: 
itsuki_kaito2...@qq.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


[PATCH v6 2/6] t7030: test verifying multiple tags

2016-04-17 Thread santiago
From: Santiago Torres 

The verify-tag command supports multiple tag names to verify, but
existing tests only test for invocation with a single tag.

Add a test invoking it with multiple tags.

Helped-by: Jeff King 
Signed-off-by: Santiago Torres 
Reviewed-by: Eric Sunshine 
Signed-off-by: Junio C Hamano 
---
 t/t7030-verify-tag.sh | 13 +
 1 file changed, 13 insertions(+)

diff --git a/t/t7030-verify-tag.sh b/t/t7030-verify-tag.sh
index 4608e71..07079a4 100755
--- a/t/t7030-verify-tag.sh
+++ b/t/t7030-verify-tag.sh
@@ -112,4 +112,17 @@ test_expect_success GPG 'verify signatures with --raw' '
)
 '
 
+test_expect_success GPG 'verify multiple tags' '
+   tags="fourth-signed sixth-signed seventh-signed" &&
+   for i in $tags
+   do
+   git verify-tag -v --raw $i || return 1
+   done >expect.stdout 2>expect.stderr.1 &&
+   grep "^.GNUPG:." expect.stderr &&
+   git verify-tag -v --raw $tags >actual.stdout 2>actual.stderr.1 &&
+   grep "^.GNUPG:." actual.stderr &&
+   test_cmp expect.stdout actual.stdout &&
+   test_cmp expect.stderr actual.stderr
+'
+
 test_done
-- 
2.8.0

--
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 4/6] verify-tag: add sha1 argument to verify_tag()

2016-04-17 Thread santiago
From: Santiago Torres 

The current interface of verify_tag() resolves reference names to SHA1,
which might be redundant as future callers may resolve the refname to
SHA1 beforehand.

Add a SHA1 parameter to use instead of the name parameter. We also
replace the name argument to report_name and use it for error reporting
only.

Helped-by: Junio C Hamano 
Signed-off-by: Santiago Torres 
---
 builtin/verify-tag.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 010353c..1d1c5c2 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -42,25 +42,24 @@ static int run_gpg_verify(const char *buf, unsigned long 
size, unsigned flags)
return ret;
 }
 
-static int verify_tag(const char *name, unsigned flags)
+static int verify_tag(const unsigned char *sha1, const char *report_name,
+   unsigned flags)
 {
enum object_type type;
-   unsigned char sha1[20];
char *buf;
unsigned long size;
int ret;
 
-   if (get_sha1(name, sha1))
-   return error("tag '%s' not found.", name);
-
type = sha1_object_info(sha1, NULL);
if (type != OBJ_TAG)
return error("%s: cannot verify a non-tag object of type %s.",
-   name, typename(type));
+   report_name ? report_name : 
find_unique_abbrev(sha1, DEFAULT_ABBREV),
+   typename(type));
 
buf = read_sha1_file(sha1, , );
if (!buf)
-   return error("%s: unable to read file.", name);
+   return error("%s: unable to read file.",
+   report_name ? report_name : 
find_unique_abbrev(sha1, DEFAULT_ABBREV));
 
ret = run_gpg_verify(buf, size, flags);
 
@@ -80,6 +79,8 @@ int cmd_verify_tag(int argc, const char **argv, const char 
*prefix)
 {
int i = 1, verbose = 0, had_error = 0;
unsigned flags = 0;
+   unsigned char sha1[20];
+   const char *name;
const struct option verify_tag_options[] = {
OPT__VERBOSE(, N_("print tag contents")),
OPT_BIT(0, "raw", , N_("print raw gpg status output"), 
GPG_VERIFY_RAW),
@@ -96,8 +97,14 @@ int cmd_verify_tag(int argc, const char **argv, const char 
*prefix)
if (verbose)
flags |= GPG_VERIFY_VERBOSE;
 
-   while (i < argc)
-   if (verify_tag(argv[i++], flags))
+   while (i < argc) {
+   name = argv[i++];
+   if (get_sha1(name, sha1)) {
+   error("tag '%s' not found.", name);
had_error = 1;
+   }
+   else if (verify_tag(sha1, name, flags))
+   had_error = 1;
+   }
return had_error;
 }
-- 
2.8.0

--
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 6/6] tag -v: verfy directly rather than exec-ing verify-tag

2016-04-17 Thread santiago
From: Santiago Torres 

tag -v forks into verify-tag, which only calls gpg_verify_tag().

Instead of forking to verify-tag, call gpg_verify_tag directly().

Helped-by: Eric Sunshine 
Signed-off-by: Santiago Torres 
---
 builtin/tag.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/builtin/tag.c b/builtin/tag.c
index 1705c94..7b2918e 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -104,13 +104,7 @@ static int delete_tag(const char *name, const char *ref,
 static int verify_tag(const char *name, const char *ref,
const unsigned char *sha1)
 {
-   const char *argv_verify_tag[] = {"verify-tag",
-   "-v", "SHA1_HEX", NULL};
-   argv_verify_tag[2] = sha1_to_hex(sha1);
-
-   if (run_command_v_opt(argv_verify_tag, RUN_GIT_CMD))
-   return error(_("could not verify the tag '%s'"), name);
-   return 0;
+   return gpg_verify_tag(sha1, name, GPG_VERIFY_VERBOSE);
 }
 
 static int do_sign(struct strbuf *buffer)
-- 
2.8.0

--
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/6] Move PGP verification out of verify-tag

2016-04-17 Thread santiago
From: Santiago Torres 

This is a follow up of [1], [2], [3], [4], and [5]. patches 1/6, 2/6 and 3/6
are the same as the corresponding commits in pu.

v6: 
 * As Junio suggested, updated 4/6, to include the name argument and the
   ternary operator to provide more descriptive error messages. I propagated
   these changes to 5/6 and 6/6 as well. I'm unsure about the 80-column
   on 4/6, the ternary operator is rather long.
 * Updated and reviewed the commit messages based on Eric and Junio's
   feedback

v5:
Added helpful feedback by Eric

 * Reordering of the patches, to avoid temporal inclusion of a regression
 * Fix typos here and there.
 * Review commit messages, as some weren't representative of what the patches
   were doing anymore.
 * Updated t7030 to include Peff's suggestion, and added a helped-by line here
   as it was mostly Peff's code.
 * Updated the error-handling/printing issues that were introduced when.
   libifying the verify_tag function.

v4:

Thanks Eric, Jeff, and Hannes for the feedback.

 * I relocated the sigchain_push call so it comes after the error on
   gpg-interface (thanks Hannnes for catching this).
 * I updated the unit test to match the discussion on [3]. Now it generates
   the expected output of the tag on the fly for comparison. (This is just
   copy and paste from [3], but I verified that it works by breaking the
   while)
 * I split moving the code and renaming the variables into two patches so
   these are easier to review.
 * I used an adapter on builtin/tag.c instead of redefining all the fn*
   declarations everywhere. This introduces an issue with the way git tag -v
   resolves refnames though. I added a new commit to restore the previous
   behavior of git-tag. I'm not sure if I should've split this into two commits
   though.

v3:
Thanks Eric, Jeff, for the feedback.

 * I separated the patch in multiple sub-patches.
 * I compared the behavior of previous git tag -v and git verify-tag 
   invocations to make sure the behavior is the same
 * I dropped the multi-line comment, as suggested.
 * I fixed the issue with the missing brackets in the while (this is 
   now detected by the test).

v2:

 * I moved the pgp-verification code to tag.c 
 * I added extra arguments so git tag -v and git verify-tag both work
   with the same function
 * Relocated the SIGPIPE handling code in verify-tag to gpg-interface

v1:
 
The verify tag function is just a thin wrapper around the verify-tag
command. We can avoid one fork call by doing the verification inside
the tag builtin instead.


This applies on v2.8.0. 
Thanks!
-Santiago

[1] http://thread.gmane.org/gmane.comp.version-control.git/287649
[2] http://thread.gmane.org/gmane.comp.version-control.git/289836
[3] http://thread.gmane.org/gmane.comp.version-control.git/290608
[4] http://thread.gmane.org/gmane.comp.version-control.git/290731
[5] http://thread.gmane.org/gmane.comp.version-control.git/290790

Santiago Torres (6):
  builtin/verify-tag.c: ignore SIGPIPE in gpg-interface
  t7030: test verifying multiple tags
  verify-tag: change variable name for readability
  verify-tag: add sha1 argument to verify_tag()
  verify-tag: move verification code to tag.c
  tag -v: verfy directly rather than exec-ing verify-tag

 builtin/tag.c |  8 +--
 builtin/verify-tag.c  | 64 ---
 gpg-interface.c   |  2 ++
 t/t7030-verify-tag.sh | 13 +++
 tag.c | 49 +++
 tag.h |  3 ++-
 6 files changed, 77 insertions(+), 62 deletions(-)

-- 
2.8.0

--
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/6] builtin/verify-tag.c: ignore SIGPIPE in gpg-interface

2016-04-17 Thread santiago
From: Santiago Torres 

The verify_signed_buffer() function may trigger a SIGPIPE when the
GPG child process terminates early (due to a bad keyid, for example)
and Git tries to write to it afterwards.  Previously, ignoring
SIGPIPE was done in builtin/verify-tag.c to avoid this issue.

However, any other caller who wants to call verify_signed_buffer()
would have to do the same.

Use sigchain_push(SIGPIPE, SIG_IGN) in verify_signed_buffer(),
pretty much like in sign_buffer(), so that any caller is not
required to perform this task.

This will avoid possible mistakes by further developers using
verify_signed_buffer().

Signed-off-by: Santiago Torres 
Reviewed-by: Eric Sunshine 
Signed-off-by: Junio C Hamano 
---
 builtin/verify-tag.c | 3 ---
 gpg-interface.c  | 2 ++
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 00663f6..77f070a 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -95,9 +95,6 @@ int cmd_verify_tag(int argc, const char **argv, const char 
*prefix)
if (verbose)
flags |= GPG_VERIFY_VERBOSE;
 
-   /* sometimes the program was terminated because this signal
-* was received in the process of writing the gpg input: */
-   signal(SIGPIPE, SIG_IGN);
while (i < argc)
if (verify_tag(argv[i++], flags))
had_error = 1;
diff --git a/gpg-interface.c b/gpg-interface.c
index 3dc2fe3..2259938 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -237,6 +237,7 @@ int verify_signed_buffer(const char *payload, size_t 
payload_size,
return error(_("could not run gpg."));
}
 
+   sigchain_push(SIGPIPE, SIG_IGN);
write_in_full(gpg.in, payload, payload_size);
close(gpg.in);
 
@@ -250,6 +251,7 @@ int verify_signed_buffer(const char *payload, size_t 
payload_size,
close(gpg.out);
 
ret = finish_command();
+   sigchain_pop(SIGPIPE);
 
unlink_or_warn(path);
 
-- 
2.8.0

--
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/6] verify-tag: change variable name for readability

2016-04-17 Thread santiago
From: Santiago Torres 

The run_gpg_verify() function has two variables, size and len.

This may come off as confusing when reading the code.  Clarify which
one pertains to the length of the tag headers by renaming len to
payload_length.

Signed-off-by: Santiago Torres 
Reviewed-by: Eric Sunshine 
Signed-off-by: Junio C Hamano 
---
 builtin/verify-tag.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 77f070a..010353c 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -21,20 +21,21 @@ static const char * const verify_tag_usage[] = {
 static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
 {
struct signature_check sigc;
-   int len;
+   int payload_size;
int ret;
 
memset(, 0, sizeof(sigc));
 
-   len = parse_signature(buf, size);
+   payload_size = parse_signature(buf, size);
 
-   if (size == len) {
+   if (size == payload_size) {
if (flags & GPG_VERIFY_VERBOSE)
-   write_in_full(1, buf, len);
+   write_in_full(1, buf, payload_size);
return error("no signature found");
}
 
-   ret = check_signature(buf, len, buf + len, size - len, );
+   ret = check_signature(buf, payload_size, buf + payload_size,
+   size - payload_size, );
print_signature_buffer(, flags);
 
signature_check_clear();
-- 
2.8.0

--
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 5/6] verify-tag: move verification code to tag.c

2016-04-17 Thread santiago
From: Santiago Torres 

The PGP verification routine for tags could be accessed by other modules
that require to do so.

Publish the verify_tag function in tag.c and rename it to gpg_verify_tag
so it does not conflict with builtin/mktag's static function.

Helped-by: Junio C Hamano 
Signed-off-by: Santiago Torres 
---
 builtin/verify-tag.c | 51 +--
 tag.c| 49 +
 tag.h|  3 ++-
 3 files changed, 52 insertions(+), 51 deletions(-)

diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 1d1c5c2..4e3b643 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -18,55 +18,6 @@ static const char * const verify_tag_usage[] = {
NULL
 };
 
-static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
-{
-   struct signature_check sigc;
-   int payload_size;
-   int ret;
-
-   memset(, 0, sizeof(sigc));
-
-   payload_size = parse_signature(buf, size);
-
-   if (size == payload_size) {
-   if (flags & GPG_VERIFY_VERBOSE)
-   write_in_full(1, buf, payload_size);
-   return error("no signature found");
-   }
-
-   ret = check_signature(buf, payload_size, buf + payload_size,
-   size - payload_size, );
-   print_signature_buffer(, flags);
-
-   signature_check_clear();
-   return ret;
-}
-
-static int verify_tag(const unsigned char *sha1, const char *report_name,
-   unsigned flags)
-{
-   enum object_type type;
-   char *buf;
-   unsigned long size;
-   int ret;
-
-   type = sha1_object_info(sha1, NULL);
-   if (type != OBJ_TAG)
-   return error("%s: cannot verify a non-tag object of type %s.",
-   report_name ? report_name : 
find_unique_abbrev(sha1, DEFAULT_ABBREV),
-   typename(type));
-
-   buf = read_sha1_file(sha1, , );
-   if (!buf)
-   return error("%s: unable to read file.",
-   report_name ? report_name : 
find_unique_abbrev(sha1, DEFAULT_ABBREV));
-
-   ret = run_gpg_verify(buf, size, flags);
-
-   free(buf);
-   return ret;
-}
-
 static int git_verify_tag_config(const char *var, const char *value, void *cb)
 {
int status = git_gpg_config(var, value, cb);
@@ -103,7 +54,7 @@ int cmd_verify_tag(int argc, const char **argv, const char 
*prefix)
error("tag '%s' not found.", name);
had_error = 1;
}
-   else if (verify_tag(sha1, name, flags))
+   else if (gpg_verify_tag(sha1, name, flags))
had_error = 1;
}
return had_error;
diff --git a/tag.c b/tag.c
index d72f742..e7f22c6 100644
--- a/tag.c
+++ b/tag.c
@@ -6,6 +6,55 @@
 
 const char *tag_type = "tag";
 
+static int run_gpg_verify(const char *buf, unsigned long size, unsigned flags)
+{
+   struct signature_check sigc;
+   int payload_size;
+   int ret;
+
+   memset(, 0, sizeof(sigc));
+
+   payload_size = parse_signature(buf, size);
+
+   if (size == payload_size) {
+   if (flags & GPG_VERIFY_VERBOSE)
+   write_in_full(1, buf, payload_size);
+   return error("no signature found");
+   }
+
+   ret = check_signature(buf, payload_size, buf + payload_size,
+   size - payload_size, );
+   print_signature_buffer(, flags);
+
+   signature_check_clear();
+   return ret;
+}
+
+int gpg_verify_tag(const unsigned char *sha1, const char *report_name,
+   unsigned flags)
+{
+   enum object_type type;
+   char *buf;
+   unsigned long size;
+   int ret;
+
+   type = sha1_object_info(sha1, NULL);
+   if (type != OBJ_TAG)
+   return error("%s: cannot verify a non-tag object of type %s.",
+   report_name ? report_name : 
find_unique_abbrev(sha1, DEFAULT_ABBREV),
+   typename(type));
+
+   buf = read_sha1_file(sha1, , );
+   if (!buf)
+   return error("%s: unable to read file.",
+   report_name ? report_name : 
find_unique_abbrev(sha1, DEFAULT_ABBREV));
+
+   ret = run_gpg_verify(buf, size, flags);
+
+   free(buf);
+   return ret;
+}
+
 struct object *deref_tag(struct object *o, const char *warn, int warnlen)
 {
while (o && o->type == OBJ_TAG)
diff --git a/tag.h b/tag.h
index f4580ae..1a8d123 100644
--- a/tag.h
+++ b/tag.h
@@ -17,5 +17,6 @@ extern int parse_tag_buffer(struct tag *item, const void 
*data, unsigned long si
 extern int parse_tag(struct tag *item);
 extern struct object *deref_tag(struct object *, const char *, int);
 extern struct object 

git merge branch --no-commit does commit fast forward merges

2016-04-17 Thread Christoph Paulik


Hi Git Mailinglist, 

git merge branch --no-commit does commit fast forward merges 
leaving users no way to change the merge results. The command only 
works as expected when also adding the --no-ff flag. Looking at 
the help text of the --no-commit flag I think that this might be a 
unintended. 


I've tested this on git 2.8.0.

This bug was first reported to magit 
(https://github.com/magit/magit/issues/2620) whose maintainer then 
suggested that it might be a git bug.


Best regards,
Christoph


--

---
Christoph Paulik
Twitter, Github: @cpaulik
PGP: 8CFC D7DF 2867 B2DC 749B  1B0A 6E3B A262 5186 A0AC


signature.asc
Description: PGP signature


Re: Where can I find the MD5 or SHA1 of git preview client.

2016-04-17 Thread Philip Oakley

From: "bin wu" 

Thanks a lot! It's my version!
There is still a question.Why not just post the the MD5 and SHA1 on
the download page?

I've created a page on the FAQ wiki 
https://github.com/git-for-windows/git/wiki/Release-Hashes


@dscho may have a better reference but adding this page is a start as it 
avoids overloading @dscho with any more work. We 'lurkers' can contribute!


PS the list prefers bottom posting, so that context is seen before the 
answers and comments.



2016-04-16 23:19 GMT+08:00 Philip Oakley :

From: "bin wu" 


Hi,
  When I download git client from https://git-scm.com/download/win ,
I want to check the MD5 and SHA1 after finished downloading. But I can
not find them. Where can I find them?

BR.
--


Try
http://article.gmane.org/gmane.comp.version-control.git/290684/match=announce

If that isn't your version, try searching the list for other 
announcements.

--
Philip

--
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



--
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 v4 15/16] branch: use ref-filter printing APIs

2016-04-17 Thread Karthik Nayak
On Sat, Apr 16, 2016 at 5:41 AM, Stefan Beller  wrote:
>>  static int calc_maxwidth(struct ref_array *refs, int remote_bonus)
>>  {
>> int i, max = 0;
>> @@ -432,7 +281,10 @@ static int calc_maxwidth(struct ref_array *refs, int 
>> remote_bonus)
>>
>> skip_prefix(it->refname, "refs/heads/", );
>> skip_prefix(it->refname, "refs/remotes/", );
>> -   w = utf8_strwidth(desc);
>> +   if (it->kind == FILTER_REFS_DETACHED_HEAD)
>> +   w = strlen(get_head_description());
>
> get_head_description returns memory, which needs to be free'd.
> (found by catching up on reading the coverity scan log. I see
> you deleted get_head_description in another part of the patch;
> nevertheless would you like to take care of this memleak?)

Seems like an easy fix. Will take care of it, Thanks :)

-- 
Regards,
Karthik Nayak
--
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


Important Message.

2016-04-17 Thread Itsuki
Business proposal therefor you are required to send an email to: 
itsuki_kaito2...@qq.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


[git-gui: Chinese (TW) translation] git-gui: added New Chinese (Taiwan) translation.

2016-04-17 Thread Mingye Wang (Arthur2e5)

This translation is based on some zh_CN strings, in repo and/or
three-clause-BSD-licensed on Launchpad. All contributors whose
strings got into this submission have their names added to the PO
header. For those whose email addresses are not available on LP,
the LP user page link is added instead.

Thanks-to: vdragon.tai...@gmail.com, for pointing me to the
_Pro Git 2_ zh_TW translation group word list (link included in po).

Signed-off-by: Mingye Wang (Arthur2e5) 
---
 po/glossary/zh_tw.po |  169 
 po/zh_tw.po  | 2558 ++
 2 files changed, 2727 insertions(+)
 create mode 100644 po/glossary/zh_tw.po
 create mode 100644 po/zh_tw.po


diff --git a/po/glossary/zh_tw.po b/po/glossary/zh_tw.po
new file mode 100644
index 000..5fc4b7f
--- /dev/null
+++ b/po/glossary/zh_tw.po
@@ -0,0 +1,169 @@
+# zh_TW git glossary.
+# Copyright (C) 2007 Shawn Pearce, et al.
+# Mingye Wang (Arthur2e5) , 2016. 
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"POT-Creation-Date: 2008-01-07 21:20+0100\n"
+"PO-Revision-Date: 2016-04-11 13:14-0400\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Last-Translator: Mingye Wang (Arthur2e5) \n"
+"Language-Team:  Traditional Chinese \n"
+"Language: zh_TW\n"
+"X-Generator: Poedit 1.8.7\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#. "English Definition (Dear translator: This file will never be visible to the user! It should only serve as a tool for you, the translator. Nothing more.)"
+msgid "English Term (Dear translator: This file will never be visible to the user!)"
+msgstr "Fetched from https://nchueecsec.hackpad.com/Pro-Git-hdsV2m1i7ab.;
+
+#. ""
+msgid "amend"
+msgstr "修訂"
+
+#. ""
+msgid "annotate"
+msgstr "加註"
+
+#. "A 'branch' is an active line of development."
+msgid "branch [noun]"
+msgstr "分支"
+
+#. ""
+msgid "branch [verb]"
+msgstr "分支"
+
+#. ""
+msgid "checkout [noun]"
+msgstr "檢出"
+
+#. "The action of updating the working tree to a revision which was stored in the object database."
+msgid "checkout [verb]"
+msgstr "檢出"
+
+#. ""
+msgid "clone [verb]"
+msgstr "克隆"
+
+#. "A single point in the git history."
+msgid "commit [noun]"
+msgstr "提交"
+
+#. "The action of storing a new snapshot of the project's state in the git history."
+msgid "commit [verb]"
+msgstr "提交"
+
+#. ""
+msgid "diff [noun]"
+msgstr "差異"
+
+#. ""
+msgid "diff [verb]"
+msgstr "對比"
+
+#. "A fast-forward is a special type of merge where you have a revision and you are merging another branch's changes that happen to be a descendant of what you have."
+msgid "fast forward merge"
+msgstr "快進合併"
+
+#. "Fetching a branch means to get the branch's head from a remote repository, to find out which objects are missing from the local object database, and to get them, too."
+msgid "fetch"
+msgstr "獲取"
+
+#. "One context of consecutive lines in a whole patch, which consists of many such hunks"
+msgid "hunk"
+msgstr "修改塊"
+
+#. "A collection of files. The index is a stored version of your working tree."
+msgid "index (in git-gui: staging area)"
+msgstr "索引"
+
+#. "A successful merge results in the creation of a new commit representing the result of the merge."
+msgid "merge [noun]"
+msgstr "合併"
+
+#. "To bring the contents of another branch into the current branch."
+msgid "merge [verb]"
+msgstr "合併"
+
+#. ""
+msgid "message"
+msgstr "訊息"
+
+#. "Deletes all stale tracking branches under . These stale branches have already been removed from the remote repository referenced by , but are still locally available in 'remotes/'."
+msgid "prune"
+msgstr "翦除"
+
+#. "Pulling a branch means to fetch it and merge it."
+msgid "pull"
+msgstr "拉取"
+
+#. "Pushing a branch means to get the branch's head ref from a remote repository, and ... (well, can someone please explain it for mere mortals?)"
+msgid "push"
+msgstr "推送"
+
+#. ""
+msgid "redo"
+msgstr "重做"
+
+#. "An other repository ('remote'). One might have a set of remotes whose branches one tracks."
+msgid "remote"
+msgstr "遠端"
+
+#. "A collection of refs (?) together with an object database containing all objects which are reachable from the refs... (oops, you've lost me here. Again, please an explanation for mere mortals?)"
+msgid "repository"
+msgstr "版本庫"
+
+#. ""
+msgid "reset"
+msgstr "重置"
+
+#. ""
+msgid "revert"
+msgstr "反轉"
+
+#. "A particular state of files and directories which was stored in the object database."
+msgid "revision"
+msgstr "修訂"
+
+#. ""
+msgid "sign off"
+msgstr "簽名"
+
+#. ""
+msgid "staging area"
+msgstr "預存區"
+
+#. ""
+msgid "status"
+msgstr "状态"
+
+#. "A ref pointing to a tag or commit object"
+msgid "tag [noun]"
+msgstr "標籤"
+
+#. ""
+msgid "tag [verb]"
+msgstr "加標"
+
+#. "A regular git branch that is 

Re: [PATCH v5 2/6] t7030-verify-tag: Adds validation for multiple tags

2016-04-17 Thread Eric Sunshine
On Sun, Apr 17, 2016 at 2:38 PM, Santiago Torres  wrote:
> On Sun, Apr 17, 2016 at 02:19:00PM -0400, Eric Sunshine wrote:
>> Junio already made this correction and others in the three patches he
>> queued on his 'pu' branch. It's possible that he also made other
>> tweaks not mentioned in the reviews, so it's a good idea to compare
>> what he queued against what you plan to send for the re-roll to ensure
>> that nothing is missed. Thanks.
>
> Oh, I'm looking at the patches in pu, I didn't know they were there yet.
> Thanks for the heads up.
>
> Also, would it make sense to copy the commit messages as they are on the pu
> branch? for consistency? Or should ommit those three patches and work
> on 4+ for the re-roll instead?

I just re-read the commit messages as Junio queued them on 'pu', and
they are all good, so yes it would be plenty sensible to copy the
commit messages from the three queued patches (along with whatever
other tweaks he made).

Since the patches are only in 'pu' (but not in 'next'), when you
re-roll, resubmit the entire series, not just the patches he didn't
queue.
--
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 v5 2/6] t7030-verify-tag: Adds validation for multiple tags

2016-04-17 Thread Santiago Torres
On Sun, Apr 17, 2016 at 02:19:00PM -0400, Eric Sunshine wrote:
> On Sun, Apr 17, 2016 at 1:31 PM, Santiago Torres  wrote:
> >> +   grep "^.GNUPG" expect.stderr &&
> >>
> >> Hmm, is there a reason you didn't stick with the more strict regex
> >> Peff suggested?
> >>
> >> ^.GNUPG:.
> >>
> >> (Genuine question: I'm not saying your choice is wrong, I'm just
> >> interested in the reasoning behind the decision.)
> >
> > I actually had missed the ":". I read the email and tried to internalize
> > what the new test was actually doing, then I rewrote the test.
> >
> > I think I could add it for completeness though.
> 
> Junio already made this correction and others in the three patches he
> queued on his 'pu' branch. It's possible that he also made other
> tweaks not mentioned in the reviews, so it's a good idea to compare
> what he queued against what you plan to send for the re-roll to ensure
> that nothing is missed. Thanks.

Oh, I'm looking at the patches in pu, I didn't know they were there yet.
Thanks for the heads up. 

Also, would it make sense to copy the commit messages as they are on the pu
branch? for consistency? Or should ommit those three patches and work
on 4+ for the re-roll instead?
--
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 v5 2/6] t7030-verify-tag: Adds validation for multiple tags

2016-04-17 Thread Eric Sunshine
On Sun, Apr 17, 2016 at 1:31 PM, Santiago Torres  wrote:
>> +   grep "^.GNUPG" expect.stderr &&
>>
>> Hmm, is there a reason you didn't stick with the more strict regex
>> Peff suggested?
>>
>> ^.GNUPG:.
>>
>> (Genuine question: I'm not saying your choice is wrong, I'm just
>> interested in the reasoning behind the decision.)
>
> I actually had missed the ":". I read the email and tried to internalize
> what the new test was actually doing, then I rewrote the test.
>
> I think I could add it for completeness though.

Junio already made this correction and others in the three patches he
queued on his 'pu' branch. It's possible that he also made other
tweaks not mentioned in the reviews, so it's a good idea to compare
what he queued against what you plan to send for the re-roll to ensure
that nothing is missed. Thanks.
--
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 v5 0/6] tag: move PGP verification code to tag.c

2016-04-17 Thread Eric Sunshine
On Sun, Apr 17, 2016 at 1:34 PM, Santiago Torres  wrote:
> On Thu, Apr 07, 2016 at 12:19:37PM -0400, Eric Sunshine wrote:
>> If you make any changes beyond the minor ones mentioned in my reviews
>> or beyond plagiarizing commit message enhancements offered by my or
>> Junio's reviews, then you'd also probably want to hold off adding my
>> Reviewed-by: since I wouldn't yet have reviewed whatever new changes
>> you're making.
>
> Speaking of which, would it make sense to add "helped-by" to the patches
> in which I'm plagiarizing the commit messages?

Yes, that would be quite sensible.
--
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 v5 0/6] tag: move PGP verification code to tag.c

2016-04-17 Thread Santiago Torres
On Thu, Apr 07, 2016 at 12:19:37PM -0400, Eric Sunshine wrote:
> On Wed, Apr 6, 2016 at 11:40 PM, Santiago Torres  wrote:
> >> > v5 (this):
> >> > Added helpful feedback by Eric
> >> >
> >> >  * Reordering of the patches, to avoid temporal inclusion of a regression
> >> >  * Fix typos here and there.
> >> >  * Review commit messages, as some weren't representative of what the 
> >> > patches
> >> >were doing anymore.
> >> >  * Updated t7030 to include Peff's suggestion, and added a helped-by 
> >> > line here
> >> >as it was mostly Peff's code.
> >> >  * Updated the error-handling/printing issues that were introduced when.
> >> >libifying the verify_tag function.
> >>
> >> This version is a more pleasant read, easier to digest and understand.
> >> All of my review comments were minor; nothing demanding a re-roll. As
> >> such, this version is:
> >>
> >> Reviewed-by: Eric Sunshine 
> >>
> >> If you do happen to re-roll based upon the review comments, feel free
> >> to add my Reviewed-by: (but not if you make larger changes).
> >
> > Thanks! I'll add your and Junio's in another re-roll.
> 
> I don't think Junio explicitly gave his Reviewed-by: (indicating his
> approval of the patches as-is), so you wouldn't want to include his
> Reviewed-by:.

Yeah, I didn't mean to imply that. I'm rewriting the commit messages and
testing out patches 3+/6, so I'm not going to assume there's any
reviewed-by.

> 
> If you make any changes beyond the minor ones mentioned in my reviews
> or beyond plagiarizing commit message enhancements offered by my or
> Junio's reviews, then you'd also probably want to hold off adding my
> Reviewed-by: since I wouldn't yet have reviewed whatever new changes
> you're making.

Speaking of which, would it make sense to add "helped-by" to the patches
in which I'm plagiarizing the commit messages?

> (And, if you do make changes beyond ones I mentioned, and if I review
> them and consider them issue-free, I can always re-extend my
> Reviewed-by:.)

Thanks!
-Santiago.
--
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 v5 2/6] t7030-verify-tag: Adds validation for multiple tags

2016-04-17 Thread Santiago Torres
Sorry for the delay! I just realized I had missed the second comment.

> +   grep "^.GNUPG" expect.stderr &&
> 
> Hmm, is there a reason you didn't stick with the more strict regex
> Peff suggested?
> 
> ^.GNUPG:.
> 
> (Genuine question: I'm not saying your choice is wrong, I'm just
> interested in the reasoning behind the decision.)
> 
I actually had missed the ":". I read the email and tried to internalize
what the new test was actually doing, then I rewrote the test. 

I think I could add it for completeness though.

Thanks again for the reviews!
-Santiago.

--
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 1/2] test-lib: add a function to compare an expection with stdout from a command

2016-04-17 Thread Eric Sunshine
On Sun, Apr 17, 2016 at 11:19 AM, Johannes Sixt  wrote:
> Am 17.04.2016 um 05:07 schrieb Eric Sunshine:
>> Hmm, considering that $(...) collapses each whitespace run (including
>> newlines) down to a single space, I don't see how you could get a
>> multi-line result.
>
> No, it doesn't. It only removes trailing newlines:
>
> ~:1004> frotz=$(echo 1; echo; echo 2; echo; echo; echo); echo "$frotz"
> 1
>
> 2
> ~:1005>

Thanks for the correction.
--
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 2/2] t1500-rev-parse: rewrite each test to run in isolation

2016-04-17 Thread Eric Sunshine
On Sun, Apr 17, 2016 at 5:42 AM, SZEDER Gábor  wrote:
> Quoting Michael Rappazzo :
>> +test_expect_success 'GIT_DIR=../.git, core.bare = false:
>> is-bare-repository' '
>> +   mkdir work &&
>> +   test_when_finished "rm -rf work" &&
>> +   test_config -C "$(pwd)"/.git core.bare false &&
>> +   GIT_DIR=../.git test_stdout false git -C work rev-parse
>> --is-bare-repository
>> +'
>
> Here and in the following tests as well: some shells don't cope that well
> with a one-shot environmental variable set in front of a shell function.
> See commit 512477b17528:
>
> tests: use "env" to run commands with temporary env-var settings

While reviewing the patch, I stared at that code for a good while
thinking that there was something about it I ought to remember but
couldn't, so thanks for the reminder (and j6t's too).

Considering that this patch is probably going in the wrong direction
and that if, when re-rolled, it takes a systematic approach testing
that the original code uses, then the "need" for test_stdout
effectively disappears, so this issue should go away too (but it's
good to remember, nevertheless).
--
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] git rev-parse :/ "regex" syntax not really regex?

2016-04-17 Thread Andreas Mohr
On Sun, Apr 17, 2016 at 04:10:28PM +0200, Andreas Schwab wrote:
> Andreas Mohr  writes:
> 
> > Unless I happened to misunderstand git's regex flavour, or something else...
> > (hmm, perhaps it's a try-match-single-line vs. multi-line content issue,
> > which perhaps does not work by specifying the trailing $)
> 
> This is exactly the difference.  git log --grep matches individual lines
> (like grep), whereas :/ matches against the whole commit message
> including embedded (and trailing) newlines, and $ doesn't match an
> embedded newline.  Thus to address the second commit in your example you
> have to use $':/^My commit\n' (using bash's ANSI-C quoting feature).

At first I thought "no way, I already did try trailing \n",
but then I realized that
it's exactly use of that ANSI-C quoting feature
which makes that \n newline be (non-)interpreted correctly here,
and it truly works.

Thank you for a fast and well-inform{ed|ing} response!

Now there's only one question remaining:
do we simply take this as a documentation-supplied-by-mailing-list item ;-),
or should certain parts of the parse-rev :/ documentation
be improved in a certain manner?


No, there's another one:
this syntax seems to be (as indicated) indeed bash-specific,
since a short dash test script (POSIX):
#!/usr/bin/dash

git rev-parse $':/^My commit\n'

simply prints a
$:/^My commit\n
result,
and no amount of syntax fiddling
succeeded in getting the correct commit result on dash.

Well, since that \n simply *is* a newline
(see also
http://unix.stackexchange.com/questions/155367/when-to-use-bash-ansi-c-style-escape-e-g-n
 ),
a successful way to encode it in dash (all non-bash shells?) is:

git rev-parse :/'^My commit
'

i.e. with an *actual* newline.


BTW, as a (albeit weak) former m68k architecture user,
thank you for your efforts!

Andreas Mohr
--
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 1/2] test-lib: add a function to compare an expection with stdout from a command

2016-04-17 Thread Johannes Sixt

Am 17.04.2016 um 05:07 schrieb Eric Sunshine:

Hmm, considering that $(...) collapses each whitespace run (including
newlines) down to a single space, I don't see how you could get a
multi-line result.


No, it doesn't. It only removes trailing newlines:

~:1004> frotz=$(echo 1; echo; echo 2; echo; echo; echo); echo "$frotz"
1

2
~:1005>

-- Hannes

--
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 2/2] t1500-rev-parse: rewrite each test to run in isolation

2016-04-17 Thread Johannes Sixt

Am 17.04.2016 um 07:59 schrieb Eric Sunshine:

On Sat, Apr 16, 2016 at 12:13:50PM -0400, Michael Rappazzo wrote:

+test_expect_success 'GIT_DIR=../.git, core.bare = false: prefix' '
+   mkdir work &&
+   test_when_finished "rm -rf work" &&
+   test_config -C "$(pwd)"/.git core.bare false &&
+   GIT_DIR=../.git test_stdout "" git -C work rev-parse --show-prefix 
>actual


Drop the unnecessary '>actual' redirection.


Not only that: setting an environment variable in front of a shell 
function invocation keeps the variable's value in some (most?) shells. 
This occurs frequently in the new code. I don't know whether we have a 
shorter pattern than


(
GIT_DIR=../.git &&
export GIT_DIR &&
test_stdout "" git -C work rev-parse --show-prefix
)

-- Hannes

--
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] git rev-parse :/ "regex" syntax not really regex?

2016-04-17 Thread Andreas Schwab
Andreas Mohr  writes:

> Unless I happened to misunderstand git's regex flavour, or something else...
> (hmm, perhaps it's a try-match-single-line vs. multi-line content issue,
> which perhaps does not work by specifying the trailing $)

This is exactly the difference.  git log --grep matches individual lines
(like grep), whereas :/ matches against the whole commit message
including embedded (and trailing) newlines, and $ doesn't match an
embedded newline.  Thus to address the second commit in your example you
have to use $':/^My commit\n' (using bash's ANSI-C quoting feature).

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
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


[BUG] git rev-parse :/ "regex" syntax not really regex?

2016-04-17 Thread Andreas Mohr
Hello all,

I just wanted to shortly mention that to me it seems
that while
git help rev-parse
says
   :/, e.g. :/fix nasty bug
   A colon, followed by a slash, followed by a text, names a commit 
whose commit message matches the specified regular expression. This name 
returns the
   youngest matching commit which is reachable from any ref. If the 
commit message starts with a !  you have to repeat that; the special sequence 
:/!, followed
   by something else than !, is reserved for now. The regular 
expression can match any part of the commit message. To match messages starting 
with a string, one
   can use e.g.  :/^foo.
, the supported syntax seems to be decidedly not really regex,
as opposed to
git log --grep

Creating a minimal reproducing repo sample
with e.g. a dummy commit series of the following commit titles:

My commit last
My commit
My commit first

and doing searches via
  git rev-parse :/'^My commi\w'
  git rev-parse :/'^My commit$'
  git rev-parse :/'^My commit'
  git log --grep='^My commit$' --format=%H < that one seems to work fully 
reliably

will yield surprising results
(returning most recent commit rather than commit title exact-match one),
and no amount of fiddling with various regex flavour syntax deviations
managed to fix it for me.

Unless I happened to misunderstand git's regex flavour, or something else...
(hmm, perhaps it's a try-match-single-line vs. multi-line content issue,
which perhaps does not work by specifying the trailing $)


$ git --version
git version 2.5.5

(same irritating behaviour also encountered on some older version, perhaps 
2.0/2.1 range)


If this bug is confirmed, then I could suggest two variants:
- fix rev-parse's handling of :/ to actually do the correct thing, if easily 
possible
- simply fix rev-parse's docs to correctly indicate
  that unfortunately it is NOT fully regex capable,
  and ensure also having added a reference to the (much?) more reliably working
  git log --grep.

If this bug is not confirmed, then the question would be
what kind of potential documentation / usability weaknesses
successfully managed to lead me astray
and thus would need to be fixed.

Thanks,

Andreas Mohr
--
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


企业培训师

2016-04-17 Thread 企业培训师
你的老朋友邀你来Q群:343257759 抢红包 抢秒杀 抢vip 什么都要抢。太刺激了。不靠手气只拼手速


[PATCH 7/7] checkout: prevent checking out a branch being rebased in another worktree

2016-04-17 Thread Nguyễn Thái Ngọc Duy
We failed to detect this case because the rebase-in-progress worktree
has HEAD in detached state. Some more poking around is needed to
determine if a rebase is in progress.

Note that even though bisect can also put a worktree in detached state
and hide the real branch, we allow to checkout anyway. This is because
unlike rebase, bisect does not update the branch. Yes it's still a bit
confusing when the user doing the bisecting realizes that the branch is
updated elsewhere, but at least we do not lose any valuable ref update.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 worktree.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/worktree.c b/worktree.c
index 3b7c6f2..6dc40c2 100644
--- a/worktree.c
+++ b/worktree.c
@@ -2,6 +2,7 @@
 #include "refs.h"
 #include "strbuf.h"
 #include "worktree.h"
+#include "wt-status.h"
 
 void free_worktrees(struct worktree **worktrees)
 {
@@ -202,6 +203,28 @@ char *find_shared_symref(const char *symref, const char 
*target)
for (i = 0; worktrees[i]; i++) {
struct worktree *wt = worktrees[i];
 
+   if (wt->is_detached) {
+   struct wt_status_state wss;
+   int found;
+
+   memset(, 0, sizeof(wss));
+   wss.wt = wt;
+   wt_status_get_state(, 0);
+   found = (wss.rebase_in_progress ||
+wss.rebase_interactive_in_progress) &&
+   wss.branch &&
+   starts_with(target, "refs/heads/") &&
+   !strcmp(wss.branch,
+   target + strlen("refs/heads/"));
+   free(wss.branch);
+   free(wss.onto);
+   free(wss.detached_from);
+   if (found) {
+   existing = xstrdup(wt->path);
+   break;
+   }
+   }
+
strbuf_reset();
strbuf_reset();
strbuf_addf(, "%s/%s",
-- 
2.8.0.rc0.210.gd302cd2

--
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 6/7] worktree.c: avoid referencing to worktrees[i] multiple times

2016-04-17 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 worktree.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/worktree.c b/worktree.c
index c5bf583..3b7c6f2 100644
--- a/worktree.c
+++ b/worktree.c
@@ -200,10 +200,12 @@ char *find_shared_symref(const char *symref, const char 
*target)
int i = 0;
 
for (i = 0; worktrees[i]; i++) {
+   struct worktree *wt = worktrees[i];
+
strbuf_reset();
strbuf_reset();
strbuf_addf(, "%s/%s",
-   get_worktree_git_dir(worktrees[i]),
+   get_worktree_git_dir(wt),
symref);
 
if (parse_ref(path.buf, , NULL)) {
@@ -211,7 +213,7 @@ char *find_shared_symref(const char *symref, const char 
*target)
}
 
if (!strcmp(sb.buf, target)) {
-   existing = xstrdup(worktrees[i]->path);
+   existing = xstrdup(wt->path);
break;
}
}
-- 
2.8.0.rc0.210.gd302cd2

--
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 4/7] worktree.c: add worktree_git_path_..._head()

2016-04-17 Thread Nguyễn Thái Ngọc Duy
These are a variant of git_path_..._head(), defined with GIT_PATH_FUNC
macro but they takes worktree into account. To be used when
wt_status_get_state() is converted to be worktree-aware.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 worktree.c |  4 
 worktree.h | 13 +
 2 files changed, 17 insertions(+)

diff --git a/worktree.c b/worktree.c
index 5ae54f0..c5bf583 100644
--- a/worktree.c
+++ b/worktree.c
@@ -222,3 +222,7 @@ char *find_shared_symref(const char *symref, const char 
*target)
 
return existing;
 }
+
+WORKTREE_GIT_PATH_FUNC(merge_head, "MERGE_HEAD")
+WORKTREE_GIT_PATH_FUNC(cherry_pick_head, "CHERRY_PICK_HEAD")
+WORKTREE_GIT_PATH_FUNC(revert_head, "REVERT_HEAD")
diff --git a/worktree.h b/worktree.h
index 9ae2028..b7c5da0 100644
--- a/worktree.h
+++ b/worktree.h
@@ -52,4 +52,17 @@ extern char *worktree_git_pathdup(const struct worktree *wt,
  const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
 
+#define WORKTREE_GIT_PATH_FUNC(func, filename) \
+   const char *worktree_git_path_ ## func(const struct worktree *wt) \
+   { \
+   static char *ret; \
+   if (!ret) \
+   ret = worktree_git_pathdup(wt, filename); \
+   return ret; \
+   }
+
+const char *worktree_git_path_merge_head(const struct worktree *);
+const char *worktree_git_path_cherry_pick_head(const struct worktree *);
+const char *worktree_git_path_revert_head(const struct worktree *);
+
 #endif
-- 
2.8.0.rc0.210.gd302cd2

--
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 5/7] wt-status.c: make wt_status_get_state() support worktree

2016-04-17 Thread Nguyễn Thái Ngọc Duy
The function is to be used to detect if a ref is checked out in another
worktree. In some cases, parsing "HEAD" alone is not enough because the
worktree may be under rebase or bisect.

Note that because get_sha1() cannot take a worktree (and of course will
not, we need something like worktree_get_sha1), cherry-pick and revert
detection will not work when the examined worktree is not the current
one. The same for get_detached_from.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 wt-status.c | 42 +-
 wt-status.h |  3 +++
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 1ea2ebe..6cca3a6 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -15,6 +15,7 @@
 #include "column.h"
 #include "strbuf.h"
 #include "utf8.h"
+#include "worktree.h"
 
 static const char cut_line[] =
 " >8 \n";
@@ -1262,13 +1263,13 @@ static void show_bisect_in_progress(struct wt_status *s,
 /*
  * Extract branch information from rebase/bisect
  */
-static char *read_and_strip_branch(const char *path)
+static char *read_and_strip_branch(const struct worktree *wt, const char *path)
 {
struct strbuf sb = STRBUF_INIT;
unsigned char sha1[20];
const char *branch_name;
 
-   if (strbuf_read_file(, git_path("%s", path), 0) <= 0)
+   if (strbuf_read_file(, worktree_git_path(wt, "%s", path), 0) <= 0)
goto got_nothing;
 
while (sb.len && sb.buf[sb.len - 1] == '\n')
@@ -1363,45 +1364,52 @@ static void wt_status_get_detached_from(struct 
wt_status_state *state)
 void wt_status_get_state(struct wt_status_state *state,
 int get_detached_from)
 {
+   const struct worktree *wt = state->wt;
struct stat st;
unsigned char sha1[20];
 
-   if (!stat(git_path_merge_head(), )) {
+   if (!stat(worktree_git_path_merge_head(wt), )) {
state->merge_in_progress = 1;
-   } else if (!stat(git_path("rebase-apply"), )) {
-   if (!stat(git_path("rebase-apply/applying"), )) {
+   } else if (!stat(worktree_git_path(wt, "rebase-apply"), )) {
+   if (!stat(worktree_git_path(wt, "rebase-apply/applying"), )) 
{
state->am_in_progress = 1;
-   if (!stat(git_path("rebase-apply/patch"), ) && 
!st.st_size)
+   if (!stat(worktree_git_path(wt, "rebase-apply/patch"), 
) && !st.st_size)
state->am_empty_patch = 1;
} else {
state->rebase_in_progress = 1;
-   state->branch = 
read_and_strip_branch("rebase-apply/head-name");
-   state->onto = 
read_and_strip_branch("rebase-apply/onto");
+   state->branch = read_and_strip_branch(wt, 
"rebase-apply/head-name");
+   state->onto = read_and_strip_branch(wt, 
"rebase-apply/onto");
}
-   } else if (!stat(git_path("rebase-merge"), )) {
-   if (!stat(git_path("rebase-merge/interactive"), ))
+   } else if (!stat(worktree_git_path(wt, "rebase-merge"), )) {
+   if (!stat(worktree_git_path(wt, "rebase-merge/interactive"), 
))
state->rebase_interactive_in_progress = 1;
else
state->rebase_in_progress = 1;
-   state->branch = read_and_strip_branch("rebase-merge/head-name");
-   state->onto = read_and_strip_branch("rebase-merge/onto");
-   } else if (!stat(git_path_cherry_pick_head(), ) &&
+   state->branch = read_and_strip_branch(wt, 
"rebase-merge/head-name");
+   state->onto = read_and_strip_branch(wt, "rebase-merge/onto");
+   } else if (!wt && /* TODO: get_sha1() cannot select worktree yet */
+  !stat(worktree_git_path_cherry_pick_head(wt), ) &&
!get_sha1("CHERRY_PICK_HEAD", sha1)) {
state->cherry_pick_in_progress = 1;
hashcpy(state->cherry_pick_head_sha1, sha1);
}
-   if (!stat(git_path("BISECT_LOG"), )) {
+   if (!stat(worktree_git_path(wt, "BISECT_LOG"), )) {
state->bisect_in_progress = 1;
-   state->branch = read_and_strip_branch("BISECT_START");
+   state->branch = read_and_strip_branch(wt, "BISECT_START");
}
-   if (!stat(git_path_revert_head(), ) &&
+   if (!wt &&  /* TODO: get_sha1() cannot select worktree yet */
+   !stat(worktree_git_path_revert_head(wt), ) &&
!get_sha1("REVERT_HEAD", sha1)) {
state->revert_in_progress = 1;
hashcpy(state->revert_head_sha1, sha1);
}
 
-   if (get_detached_from)
+   if (get_detached_from) {
+   if (wt)
+   die("BUG: %s:%d: non-zero get_detached_from is not 
supported",
+   

[PATCH 3/7] path.c: refactor and add worktree_git_path()

2016-04-17 Thread Nguyễn Thái Ngọc Duy
do_git_path(), which is the common code for all git_path* functions, is
modified to take a worktree struct and can produce paths for any
worktree.

worktree_git_path() is the first function that makes use of this. It can
be used to write code that can examine any worktree. For example,
wt_status_get_state() will be converted using this to take
am/rebase/... state of any worktree.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 path.c | 34 --
 worktree.h | 11 +++
 2 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/path.c b/path.c
index 2ebb23d..c421d37 100644
--- a/path.c
+++ b/path.c
@@ -5,6 +5,7 @@
 #include "strbuf.h"
 #include "string-list.h"
 #include "dir.h"
+#include "worktree.h"
 
 static int get_st_mode_bits(const char *path, int *mode)
 {
@@ -383,10 +384,11 @@ static void adjust_git_path(struct strbuf *buf, int 
git_dir_len)
update_common_dir(buf, git_dir_len, NULL);
 }
 
-static void do_git_path(struct strbuf *buf, const char *fmt, va_list args)
+static void do_git_path(const struct worktree *wt, struct strbuf *buf,
+   const char *fmt, va_list args)
 {
int gitdir_len;
-   strbuf_addstr(buf, get_git_dir());
+   strbuf_addstr(buf, get_worktree_git_dir(wt));
if (buf->len && !is_dir_sep(buf->buf[buf->len - 1]))
strbuf_addch(buf, '/');
gitdir_len = buf->len;
@@ -400,7 +402,7 @@ char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
va_list args;
strbuf_reset(buf);
va_start(args, fmt);
-   do_git_path(buf, fmt, args);
+   do_git_path(NULL, buf, fmt, args);
va_end(args);
return buf->buf;
 }
@@ -409,7 +411,7 @@ void strbuf_git_path(struct strbuf *sb, const char *fmt, 
...)
 {
va_list args;
va_start(args, fmt);
-   do_git_path(sb, fmt, args);
+   do_git_path(NULL, sb, fmt, args);
va_end(args);
 }
 
@@ -418,7 +420,7 @@ const char *git_path(const char *fmt, ...)
struct strbuf *pathname = get_pathname();
va_list args;
va_start(args, fmt);
-   do_git_path(pathname, fmt, args);
+   do_git_path(NULL, pathname, fmt, args);
va_end(args);
return pathname->buf;
 }
@@ -428,7 +430,7 @@ char *git_pathdup(const char *fmt, ...)
struct strbuf path = STRBUF_INIT;
va_list args;
va_start(args, fmt);
-   do_git_path(, fmt, args);
+   do_git_path(NULL, , fmt, args);
va_end(args);
return strbuf_detach(, NULL);
 }
@@ -454,6 +456,26 @@ const char *mkpath(const char *fmt, ...)
return cleanup_path(pathname->buf);
 }
 
+const char *worktree_git_path(const struct worktree *wt, const char *fmt, ...)
+{
+   struct strbuf *pathname = get_pathname();
+   va_list args;
+   va_start(args, fmt);
+   do_git_path(wt, pathname, fmt, args);
+   va_end(args);
+   return pathname->buf;
+}
+
+char *worktree_git_pathdup(const struct worktree *wt, const char *fmt, ...)
+{
+   struct strbuf path = STRBUF_INIT;
+   va_list args;
+   va_start(args, fmt);
+   do_git_path(wt, , fmt, args);
+   va_end(args);
+   return strbuf_detach(, NULL);
+}
+
 static void do_submodule_path(struct strbuf *buf, const char *path,
  const char *fmt, va_list args)
 {
diff --git a/worktree.h b/worktree.h
index 3198c8d..9ae2028 100644
--- a/worktree.h
+++ b/worktree.h
@@ -41,4 +41,15 @@ extern void free_worktrees(struct worktree **);
  */
 extern char *find_shared_symref(const char *symref, const char *target);
 
+/*
+ * Similar to git_path() and git_pathdup() but can produce paths for a
+ * specified worktree instead of current one
+ */
+extern const char *worktree_git_path(const struct worktree *wt,
+const char *fmt, ...)
+   __attribute__((format (printf, 2, 3)));
+extern char *worktree_git_pathdup(const struct worktree *wt,
+ const char *fmt, ...)
+   __attribute__((format (printf, 2, 3)));
+
 #endif
-- 
2.8.0.rc0.210.gd302cd2

--
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/7] worktree.c: store "id" instead of "git_dir"

2016-04-17 Thread Nguyễn Thái Ngọc Duy
We can reconstruct git_dir from id quite easily. It's a bit hackier to
do the reverse.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 worktree.c | 31 ++-
 worktree.h |  8 +++-
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/worktree.c b/worktree.c
index 6181a66..5ae54f0 100644
--- a/worktree.c
+++ b/worktree.c
@@ -9,7 +9,7 @@ void free_worktrees(struct worktree **worktrees)
 
for (i = 0; worktrees[i]; i++) {
free(worktrees[i]->path);
-   free(worktrees[i]->git_dir);
+   free(worktrees[i]->id);
free(worktrees[i]->head_ref);
free(worktrees[i]);
}
@@ -74,13 +74,11 @@ static struct worktree *get_main_worktree(void)
struct worktree *worktree = NULL;
struct strbuf path = STRBUF_INIT;
struct strbuf worktree_path = STRBUF_INIT;
-   struct strbuf gitdir = STRBUF_INIT;
struct strbuf head_ref = STRBUF_INIT;
int is_bare = 0;
int is_detached = 0;
 
-   strbuf_addf(, "%s", absolute_path(get_git_common_dir()));
-   strbuf_addbuf(_path, );
+   strbuf_addstr(_path, absolute_path(get_git_common_dir()));
is_bare = !strbuf_strip_suffix(_path, "/.git");
if (is_bare)
strbuf_strip_suffix(_path, "/.");
@@ -92,7 +90,7 @@ static struct worktree *get_main_worktree(void)
 
worktree = xmalloc(sizeof(struct worktree));
worktree->path = strbuf_detach(_path, NULL);
-   worktree->git_dir = strbuf_detach(, NULL);
+   worktree->id = NULL;
worktree->is_bare = is_bare;
worktree->head_ref = NULL;
worktree->is_detached = is_detached;
@@ -100,7 +98,6 @@ static struct worktree *get_main_worktree(void)
 
 done:
strbuf_release();
-   strbuf_release();
strbuf_release(_path);
strbuf_release(_ref);
return worktree;
@@ -111,16 +108,13 @@ static struct worktree *get_linked_worktree(const char 
*id)
struct worktree *worktree = NULL;
struct strbuf path = STRBUF_INIT;
struct strbuf worktree_path = STRBUF_INIT;
-   struct strbuf gitdir = STRBUF_INIT;
struct strbuf head_ref = STRBUF_INIT;
int is_detached = 0;
 
if (!id)
die("Missing linked worktree name");
 
-   strbuf_addf(, "%s/worktrees/%s",
-   absolute_path(get_git_common_dir()), id);
-   strbuf_addf(, "%s/gitdir", gitdir.buf);
+   strbuf_git_common_path(, "worktrees/%s/gitdir", id);
if (strbuf_read_file(_path, path.buf, 0) <= 0)
/* invalid gitdir file */
goto done;
@@ -140,7 +134,7 @@ static struct worktree *get_linked_worktree(const char *id)
 
worktree = xmalloc(sizeof(struct worktree));
worktree->path = strbuf_detach(_path, NULL);
-   worktree->git_dir = strbuf_detach(, NULL);
+   worktree->id = xstrdup(id);
worktree->is_bare = 0;
worktree->head_ref = NULL;
worktree->is_detached = is_detached;
@@ -148,7 +142,6 @@ static struct worktree *get_linked_worktree(const char *id)
 
 done:
strbuf_release();
-   strbuf_release();
strbuf_release(_path);
strbuf_release(_ref);
return worktree;
@@ -188,6 +181,16 @@ struct worktree **get_worktrees(void)
return list;
 }
 
+const char *get_worktree_git_dir(const struct worktree *wt)
+{
+   if (!wt)
+   return get_git_dir();
+   else if (!wt->id)
+   return get_git_common_dir();
+   else
+   return git_common_path("worktrees/%s", wt->id);
+}
+
 char *find_shared_symref(const char *symref, const char *target)
 {
char *existing = NULL;
@@ -199,7 +202,9 @@ char *find_shared_symref(const char *symref, const char 
*target)
for (i = 0; worktrees[i]; i++) {
strbuf_reset();
strbuf_reset();
-   strbuf_addf(, "%s/%s", worktrees[i]->git_dir, symref);
+   strbuf_addf(, "%s/%s",
+   get_worktree_git_dir(worktrees[i]),
+   symref);
 
if (parse_ref(path.buf, , NULL)) {
continue;
diff --git a/worktree.h b/worktree.h
index b4b3dda..3198c8d 100644
--- a/worktree.h
+++ b/worktree.h
@@ -3,7 +3,7 @@
 
 struct worktree {
char *path;
-   char *git_dir;
+   char *id;
char *head_ref;
unsigned char head_sha1[20];
int is_detached;
@@ -23,6 +23,12 @@ struct worktree {
 extern struct worktree **get_worktrees(void);
 
 /*
+ * Return git dir of the worktree. Note that the path may be relative.
+ * If wt is NULL, git dir of current worktree is returned.
+ */
+extern const char *get_worktree_git_dir(const struct worktree *wt);
+
+/*
  * Free up the memory for worktree(s)
  */
 extern void free_worktrees(struct worktree **);
-- 
2.8.0.rc0.210.gd302cd2

--
To unsubscribe from this list: send the line 

[PATCH 1/7] path.c: add git_common_path() and strbuf_git_common_path()

2016-04-17 Thread Nguyễn Thái Ngọc Duy
These are mostly convenient functions to reduce code duplication. Most
of the time, we should be able to get by with git_path() which handles
$GIT_COMMON_DIR internally. However there are a few cases where we need
to construct paths manually, for example some paths from a specific
worktree. These functions will enable that.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 cache.h |  3 +++
 path.c  | 29 +
 2 files changed, 32 insertions(+)

diff --git a/cache.h b/cache.h
index 2711048..c04a17f 100644
--- a/cache.h
+++ b/cache.h
@@ -799,11 +799,14 @@ extern void check_repository_format(void);
  */
 extern const char *mkpath(const char *fmt, ...) __attribute__((format (printf, 
1, 2)));
 extern const char *git_path(const char *fmt, ...) __attribute__((format 
(printf, 1, 2)));
+extern const char *git_common_path(const char *fmt, ...) __attribute__((format 
(printf, 1, 2)));
 
 extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
 extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
+extern void strbuf_git_common_path(struct strbuf *sb, const char *fmt, ...)
+   __attribute__((format (printf, 2, 3)));
 extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
__attribute__((format (printf, 2, 3)));
 extern void strbuf_git_path_submodule(struct strbuf *sb, const char *path,
diff --git a/path.c b/path.c
index bbaea5a..2ebb23d 100644
--- a/path.c
+++ b/path.c
@@ -503,6 +503,35 @@ void strbuf_git_path_submodule(struct strbuf *buf, const 
char *path,
va_end(args);
 }
 
+static void do_git_common_path(struct strbuf *buf,
+  const char *fmt,
+  va_list args)
+{
+   strbuf_addstr(buf, get_git_common_dir());
+   if (buf->len && !is_dir_sep(buf->buf[buf->len - 1]))
+   strbuf_addch(buf, '/');
+   strbuf_vaddf(buf, fmt, args);
+   strbuf_cleanup_path(buf);
+}
+
+const char *git_common_path(const char *fmt, ...)
+{
+   struct strbuf *pathname = get_pathname();
+   va_list args;
+   va_start(args, fmt);
+   do_git_common_path(pathname, fmt, args);
+   va_end(args);
+   return pathname->buf;
+}
+
+void strbuf_git_common_path(struct strbuf *sb, const char *fmt, ...)
+{
+   va_list args;
+   va_start(args, fmt);
+   do_git_common_path(sb, fmt, args);
+   va_end(args);
+}
+
 int validate_headref(const char *path)
 {
struct stat st;
-- 
2.8.0.rc0.210.gd302cd2

--
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 0/7] fix checking out a being-rebased branch

2016-04-17 Thread Nguyễn Thái Ngọc Duy
First cut. I need opinions on 05/07, which converts
wt_status_get_state() to support selecting any worktree. I'm not super
happy with leaving "TODO: not supported yet" comments, even though
strictly speaking this series does not need it.

The reason it's left unsupported is, in order to add
worktree_get_sha1() or similar, resolve_ref() will be touched. But
that function is going under some changes for quite some time now, for
lmdb backend support, and I don't want to create more code conflicts
there, potentially delaying lmdb backend further.

Another option is leave wt_status_get_state() alone, factor out the
rebase-detection code and use that for worktree/checkout. We save a
few syscalls this way too.

Comments?

  [01/07] path.c: add git_common_path() and strbuf_git_common_path()
  [02/07] worktree.c: store "id" instead of "git_dir"
  [03/07] path.c: refactor and add worktree_git_path()
  [04/07] worktree.c: add worktree_git_path_..._head()
  [05/07] wt-status.c: make wt_status_get_state() support worktree
  [06/07] worktree.c: avoid referencing to worktrees[i] multiple times
  [07/07] checkout: prevent checking out a branch being rebased in another 
worktree

Total 6 files changed, 167 insertions(+), 38 deletions(-)
--
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 2/2] t1500-rev-parse: rewrite each test to run in isolation

2016-04-17 Thread SZEDER Gábor


Quoting Michael Rappazzo :

+test_expect_success 'GIT_DIR=../.git, core.bare = false:  
is-bare-repository' '

+   mkdir work &&
+   test_when_finished "rm -rf work" &&
+   test_config -C "$(pwd)"/.git core.bare false &&
+	GIT_DIR=../.git test_stdout false git -C work rev-parse  
--is-bare-repository

+'


Here and in the following tests as well: some shells don't cope that well
with a one-shot environmental variable set in front of a shell function.
See commit 512477b17528:

tests: use "env" to run commands with temporary env-var settings

Ordinarily, we would say "VAR=VAL command" to execute a tested
command with environment variable(s) set only for that command.
This however does not work if 'command' is a shell function (most
notably 'test_must_fail'); the result of the assignment is retained
and affects later commands.

To avoid this, we used to assign and export environment variables
and run such a test in a subshell, like so:

(
VAR=VAL && export VAR &&
test_must_fail git command to be tested
)

But with "env" utility, we should be able to say:

test_must_fail env VAR=VAL git command to be tested

which is much shorter and easier to read.


--
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 1/2] test-lib: add a function to compare an expection with stdout from a command

2016-04-17 Thread Jeff King
On Sun, Apr 17, 2016 at 02:36:24AM -0400, Eric Sunshine wrote:

> Agreed. I wouldn't mind the version where test_stdout grabs "expected"
> from < prepared test_cmp version.
> 
> I suppose that the one-liner form of test_stdout could have its uses,
> however, it bothers me for a couple reasons: (1) it's not generally
> useful like the version which grabs "expected" from < squats on a nice concise name which would better suit the < version.

I think you could get around your second objection by making "-" a magic
token, like:

  test_stdout - = git rev-parse ... <<-\EOF
  false
  EOF

Though I admit the combination of "-" and "=" is pretty ugly to read.

I'm OK with abandoning this line of inquiry, too. This may be a case
where a little repetition makes things a lot less magical to a reader,
and it's not worth trying to devise the perfect helper.

> Anyhow, this may all be moot (for now) since I think this patch series
> is going in the wrong direction entirely by abandoning the systematic
> approach taken by the original t1500 code, as explained in my
> review[1]. If modernization of t1500 retains a systematic approach,
> then the repetitive code which prompted the suggestion of test_stdout
> won't exist in the first place.

Fair enough. I haven't really followed the other part of the series very
closely.

-Peff
--
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 1/2] test-lib: add a function to compare an expection with stdout from a command

2016-04-17 Thread Eric Sunshine
On Sat, Apr 16, 2016 at 11:54 PM, Jeff King  wrote:
> On Sat, Apr 16, 2016 at 11:07:02PM -0400, Eric Sunshine wrote:
>> > test_stdout accepts an expection and a command to execute.  It will execute
>> > the command and then compare the stdout from that command to an 
>> > expectation.
>> > If the expectation is not met, a mock diff output is written to stderr.
>>
>> I wonder if this deserves more flexibility by accepting a comparison
>> operator, such as = and !=, similar to test_line_count()? Although, I
>> suppose such functionality could be added later if deemed useful.
>
> [...] Though I do actually find that:
>
>   test_stdout false git rev-parse --whatever
>
> isn't great, because there's no syntactic separator between the expected
> output and the actual command to run. So I dunno, maybe it would be
> better as:
>
>   test_stdout false = git rev-parse --whatever
>
> [...] We could also do:
>
>   test_stdout git rev-parse --whatever <<-\EOF
>   false
>   EOF
>
> which is more robust for multi-line output, but I think part of the
> point is to keep these as simple one-liners. You're not buying all that
> much over:
>
>   cat >expect <<-\EOF &&
>   false
>   EOF
>   git rev-parse --whatever >actual &&
>   test_cmp expect actual
>
> Though I do admit I've considered such a helper for some tests where
> that pattern is repeated ad nauseam.

Agreed. I wouldn't mind the version where test_stdout grabs "expected"
from <

Draft of Git Rev News edition 14

2016-04-17 Thread Christian Couder
Hi,

A draft of Git Rev News edition 14 is available here:

  https://github.com/git/git.github.io/blob/master/rev_news/drafts/edition-14.md

Everyone is welcome to contribute in any section either by editing the
above page on GitHub and sending a pull request, or by commenting on
this GitHub issue:

  https://github.com/git/git.github.io/issues/147

You can also reply to this email.

I tried to cc everyone who appears in this edition but maybe I missed
some people, sorry about that.

Thomas, Nicola and myself plan to publish this edition on Wednesday
the 20th of April.

Thanks,
Christian.
--
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 2/2] t1500-rev-parse: rewrite each test to run in isolation

2016-04-17 Thread Eric Sunshine
On Sat, Apr 16, 2016 at 12:13:50PM -0400, Michael Rappazzo wrote:
> t1500-rev-parse has many tests which change directories and leak
> environment variables.  This makes it difficult to add new tests without
> minding the environment variables and current directory.
> 
> Each test is now setup, executed, and cleaned up without leaving anything
> behind.  Test comparisons been converted to use test_cmp or test_stdout.

Overall, I'm not enthused about how this patch unrolls the systematic
function-driven approach taken by the original code and turns it into
a series of highly repetitive individual tests. Not only does it make
the patch mind-numbing to review, but it is far too easy for errors
to creep into the conversion which simply wouldn't exist if a
systematic approach was used (whether via function, table, or
for-loops).

The very fact that you missed several test_stdout conversion
opportunities and didn't notice a bit of gunk (an unnecessary
">actual") or several bogus and misspelled "test_config care.bar ="
invocations, makes a good argument that this patch's approach is
undesirable.

The fact that I also missed these problems when reading through the
patch hammers the point home. It wasn't until I started actually
changing the patch in order to present you with a "here's a diff atop
your patch which fixes the issues" as a convenience, that I noticed
the more serious problems.

> Signed-off-by: Michael Rappazzo 
> ---
> diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
> @@ -3,85 +3,320 @@
> +test_expect_success '.git/objects/: git-dir' '
> + echo $(pwd)/.git >expect &&
> + git -C .git/objects rev-parse --git-dir >actual &&
> + test_cmp expect actual
> +'

You forgot to convert this test_cmp to test_stdout.

> +test_expect_success 'subdirectory: prefix' '
> + mkdir -p sub/dir &&
> + test_when_finished "rm -rf sub" &&
> + test sub/dir/ = "$(git -C sub/dir rev-parse --show-prefix)"
> +'

You forgot to convert this 'test' to test_stdout.

> -git config core.bare true
> -test_rev_parse 'GIT_DIR=../repo.git, core.bare = true' true false false ''
> +test_expect_success 'subdirectory: git-dir' '
> + mkdir -p sub/dir &&
> + test_when_finished "rm -rf sub" &&
> + echo $(pwd)/.git >expect &&

Nit: Here and one other place, you could quote this: "$(pwd)/.git"

> + git -C sub/dir rev-parse --git-dir >actual &&
> + test_cmp expect actual
> +'

Ditto: test_cmp => test_stdout

> +test_expect_success 'core.bare = true: is-bare-repository' '
> + test_config core.bare true &&
> + test_stdout true git rev-parse --is-bare-repository
> +'

Is there a reason you chose to use test_config rather than the more
concise '-c foo=bar' as suggested by the review[1]?

[1]: http://article.gmane.org/gmane.comp.version-control.git/291368

> +test_expect_success 'core.bare undefined: is-bare-repository' '
> + test_config core.bare "" &&

Is setting core.bare to "" really the same as undefining it, or is
the effect the same only as an accident of implementation? (Genuine
question; I haven't checked.)

> + test_stdout false git rev-parse --is-bare-repository
> +'
> +test_expect_success 'GIT_DIR=../.git, core.bare = false: is-bare-repository' 
> '
> + mkdir work &&
> + test_when_finished "rm -rf work" &&
> + test_config -C "$(pwd)"/.git core.bare false &&

Drop the unnecessary "$(pwd)"/ here and elsewhere.

> + GIT_DIR=../.git test_stdout false git -C work rev-parse 
> --is-bare-repository
> +'
> +
> +test_expect_success 'GIT_DIR=../.git, core.bare = false: prefix' '
> + mkdir work &&
> + test_when_finished "rm -rf work" &&
> + test_config -C "$(pwd)"/.git core.bare false &&
> + GIT_DIR=../.git test_stdout "" git -C work rev-parse --show-prefix 
> >actual

Drop the unnecessary '>actual' redirection.

> +'
> +
> +test_expect_success 'GIT_DIR=../.git, core.bare undefined: 
> is-bare-repository' '
> + mkdir work &&
> + test_when_finished "rm -rf work" &&
> + test_config -C "$(pwd)"/.git core.bar = &&

What is "core.bar =" (here and elsewhere)?

> + GIT_DIR=../.git test_stdout false git -C work rev-parse 
> --is-bare-repository
> +'
> +
> +test_expect_success 'GIT_DIR=../repo.git, core.bare = false: 
> is-bare-repository' '
> + mkdir work &&
> + test_when_finished "rm -rf work" &&
> + cp -r .git repo.git &&
> + test_when_finished "rm -r repo.git" &&

You could coalesce these two test_when_finished invocations:

test_when_finished "rm -rf work repo.git" &&

Windows folk might appreciate it since process spawning is expensive
and slow there.

> + test_config -C "$(pwd)"/repo.git core.bare false &&
> + GIT_DIR=../repo.git test_stdout false git -C work rev-parse 
> --is-bare-repository
> +'

For convenience, here's a diff atop your patch which addresses the
above issues (except the question about core.bare set to "" versus
being undefined). However, as noted above, I think this patch's