[PATCH 4/3] sha1_file.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 Since jk/pack-idx-corruption-safety is already in 'next', can we add
 this patch on top? Surrounding strings are handled separately [1] by
 another series.

 [1] http://thread.gmane.org/gmane.comp.version-control.git/287661/focus=287678

 sha1_file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 4a3a032..b8da68b 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1042,7 +1042,7 @@ unsigned char *use_pack(struct packed_git *p,
if (offset > (p->pack_size - 20))
die("offset beyond end of packfile (truncated pack?)");
if (offset < 0)
-   die("offset before end of packfile (broken .idx?)");
+   die(_("offset before end of packfile (broken .idx?)"));
 
if (!win || !in_window(win, offset)) {
if (win)
@@ -2367,11 +2367,11 @@ void check_pack_index_ptr(const struct packed_git *p, 
const void *vptr)
const unsigned char *start = p->index_data;
const unsigned char *end = start + p->index_size;
if (ptr < start)
-   die("offset before start of pack index for %s (corrupt index?)",
+   die(_("offset before start of pack index for %s (corrupt 
index?)"),
p->pack_name);
/* No need to check for underflow; .idx files must be at least 8 bytes 
*/
if (ptr >= end - 8)
-   die("offset beyond end of pack index for %s (truncated index?)",
+   die(_("offset beyond end of pack index for %s (truncated 
index?)"),
p->pack_name);
 }
 
-- 
2.8.0.rc0.205.g7ec8cf1

--
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: What's cooking in git.git (Feb 2016, #07; Thu, 25)

2016-02-26 Thread Torsten Bögershausen


On 27.02.16 04:29, Jeff King wrote:
> On Fri, Feb 26, 2016 at 03:35:10PM -0800, Junio C Hamano wrote:
>
>>> Digging means:
>>> run git bisect and report the commit.
>>> And this makes the compiler happy:
>>>   Revert "tree-diff: catch integer overflow in combine_diff_path allocation"
>> So?
>>
>> Identifying two versions of the same C file, for one of which the
>> Apple compiler does not give you "internal compiler error" and for
>> the other it does, may help Apple engineers to debug their compiler.
>>
>> But we cannot and will not revert any of our code only because some
>> vendor compiler is broken.  It would be a different story if we were
>> throwing an invalid C at compilers and relying on a bug in GCC that
>> accepts an invalid code, but I do not think that is the case here.
> I think knowing the commit that causes the problem is interesting for
> us, because it lets us see whether we are throwing invalid C at the
> compiler or not (the compiler should never segfault, obviously, but I
> can believe that it is more likely to if you throw garbage at it).
>
> But that commit is one of the tamest, I think; it just seems like a
> boring compiler bug.  I'd be curious to reduce it to a minimal change
> that causes the bug, just to be sure.
>
> Torsten, what is the compiler version (I don't have Apple compilers, but
> it seems plausible that older clang might have the same problem).
>
> -Peff
That's machine is running Mac OS X 10.6, which is no longer supported
with updates.

 gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

There seems to be a clang as well:
clang --version
Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)
Target: x86_64-apple-darwin10
Thread model: posix



If that information is helpful:
On later versions of Mac OS X (and/or Xcode) gcc is a wrapper to clang,
and this is what I see under Mac OS 10.9:
gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr 
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix








--
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 21/22] transport.c: mark strings for translating

2016-02-26 Thread Nguyễn Thái Ngọc Duy
More strings can be translated in print_ref_status() at least, but we
need to deal with utf-8 string length there. Let's stick with a safe
subset for now.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 transport.c | 41 ++---
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/transport.c b/transport.c
index ca3cfa4..93be900 100644
--- a/transport.c
+++ b/transport.c
@@ -83,7 +83,7 @@ static struct ref *get_refs_from_bundle(struct transport 
*transport, int for_pus
close(data->fd);
data->fd = read_bundle_header(transport->url, >header);
if (data->fd < 0)
-   die ("Could not read bundle '%s'.", transport->url);
+   die(_("Could not read bundle '%s'."), transport->url);
for (i = 0; i < data->header.references.nr; i++) {
struct ref_list_entry *e = data->header.references.list + i;
struct ref *ref = alloc_ref(e->name);
@@ -148,7 +148,7 @@ static int set_git_option(struct git_transport_options 
*opts,
char *end;
opts->depth = strtol(value, , 0);
if (*end)
-   die("transport: invalid depth option '%s'", 
value);
+   die(_("transport: invalid depth option '%s'"), 
value);
}
return 0;
}
@@ -285,7 +285,7 @@ void transport_update_tracking_ref(struct remote *remote, 
struct ref *ref, int v
 
if (!remote_find_tracking(remote, )) {
if (verbose)
-   fprintf(stderr, "updating local tracking ref '%s'\n", 
rs.dst);
+   fprintf_ln(stderr, _("updating local tracking ref 
'%s'"), rs.dst);
if (ref->deletion) {
delete_ref(rs.dst, NULL, 0);
} else
@@ -480,8 +480,8 @@ void transport_verify_remote_names(int nr_heads, const char 
**heads)
remote = remote ? (remote + 1) : local;
if (check_refname_format(remote,
REFNAME_ALLOW_ONELEVEL|REFNAME_REFSPEC_PATTERN))
-   die("remote part of refspec is not a valid name in %s",
-   heads[i]);
+   die(_("remote part of refspec is not a valid name in 
%s"),
+   heads[i]);
}
 }
 
@@ -626,7 +626,7 @@ int is_transport_allowed(const char *type)
 void transport_check_allowed(const char *type)
 {
if (!is_transport_allowed(type))
-   die("transport '%s' not allowed", type);
+   die(_("transport '%s' not allowed"), type);
 }
 
 int transport_restrict_protocols(void)
@@ -665,7 +665,7 @@ struct transport *transport_get(struct remote *remote, 
const char *url)
if (helper) {
transport_helper_init(ret, helper);
} else if (starts_with(url, "rsync:")) {
-   die("git-over-rsync is no longer supported");
+   die(_("git-over-rsync is no longer supported"));
} else if (url_is_local_not_ssh(url) && is_file(url) && is_bundle(url, 
1)) {
struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
transport_check_allowed("file");
@@ -766,19 +766,22 @@ static void die_with_unpushed_submodules(struct 
string_list *needs_pushing)
 {
int i;
 
-   fprintf(stderr, "The following submodule paths contain changes that 
can\n"
-   "not be found on any remote:\n");
+   fprintf_ln(stderr, _("The following submodule paths contain changes 
that can\n"
+"not be found on any remote:"));
for (i = 0; i < needs_pushing->nr; i++)
printf("  %s\n", needs_pushing->items[i].string);
-   fprintf(stderr, "\nPlease try\n\n"
-   "   git push --recurse-submodules=on-demand\n\n"
-   "or cd to the path and use\n\n"
-   "   git push\n\n"
-   "to push them to a remote.\n\n");
+   fputc('\n', stderr);
+   fprintf_ln(stderr,
+  _("Please try\n\n"
+"  git push --recurse-submodules=on-demand\n\n"
+"or cd to the path and use\n\n"
+"  git push\n\n"
+"to push them to a remote."));
+   fprintf(stderr, "\n\n");
 
string_list_clear(needs_pushing, 0);
 
-   die("Aborting.");
+   die(_("Aborting."));
 }
 
 static int run_pre_push_hook(struct transport *transport,
@@ -853,7 +856,7 @@ int transport_push(struct transport *transport,
if (transport->push) {
/* Maybe FIXME. But no important transport uses this case. */
if (flags & TRANSPORT_PUSH_SET_UPSTREAM)
-   die("This transport does not support using 
--set-upstream");
+   die(_("This transport does not 

[PATCH 20/22] transport-helper.c: mark strings for translating

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Debug printing is kept in English to reduce workload for
translators. Those rare who actually debug this can read English
anyway.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 transport-helper.c | 84 +++---
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index b934183..fa5c077 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -46,7 +46,7 @@ static void sendline(struct helper_data *helper, struct 
strbuf *buffer)
fprintf(stderr, "Debug: Remote helper: -> %s", buffer->buf);
if (write_in_full(helper->helper->in, buffer->buf, buffer->len)
!= buffer->len)
-   die_errno("Full write to remote helper failed");
+   die_errno(_("Full write to remote helper failed"));
 }
 
 static int recvline_fh(FILE *helper, struct strbuf *buffer, const char *name)
@@ -75,7 +75,7 @@ static void write_constant(int fd, const char *str)
if (debug)
fprintf(stderr, "Debug: Remote helper: -> %s", str);
if (write_in_full(fd, str, strlen(str)) != strlen(str))
-   die_errno("Full write to remote helper failed");
+   die_errno(_("Full write to remote helper failed"));
 }
 
 static const char *remove_ext_force(const char *url)
@@ -129,7 +129,7 @@ static struct child_process *get_helper(struct transport 
*transport)
 
code = start_command(helper);
if (code < 0 && errno == ENOENT)
-   die("Unable to find remote helper for '%s'", data->name);
+   die(_("Unable to find remote helper for '%s'"), data->name);
else if (code != 0)
exit(code);
 
@@ -144,7 +144,7 @@ static struct child_process *get_helper(struct transport 
*transport)
 */
duped = dup(helper->out);
if (duped < 0)
-   die_errno("Can't dup helper output fd");
+   die_errno(_("Can't dup helper output fd"));
data->out = xfdopen(duped, "r");
 
write_constant(helper->in, "capabilities\n");
@@ -196,8 +196,8 @@ static struct child_process *get_helper(struct transport 
*transport)
} else if (starts_with(capname, "no-private-update")) {
data->no_private_update = 1;
} else if (mandatory) {
-   die("Unknown mandatory capability %s. This remote "
-   "helper probably needs newer version of Git.",
+   die(_("Unknown mandatory capability %s. This remote "
+ "helper probably needs newer version of Git."),
capname);
}
}
@@ -209,7 +209,7 @@ static struct child_process *get_helper(struct transport 
*transport)
free((char *)refspecs[i]);
free(refspecs);
} else if (data->import || data->bidi_import || data->export) {
-   warning("This remote helper should implement refspec 
capability.");
+   warning(_("This remote helper should implement refspec 
capability."));
}
strbuf_release();
if (debug)
@@ -302,7 +302,7 @@ static int set_helper_option(struct transport *transport,
} else if (!strcmp(buf.buf, "unsupported"))
ret = 1;
else {
-   warning("%s unexpectedly said: '%s'", data->name, buf.buf);
+   warning(_("%s unexpectedly said: '%s'"), data->name, buf.buf);
ret = 1;
}
strbuf_release();
@@ -319,7 +319,7 @@ static void standard_options(struct transport *t)
 
n = snprintf(buf, sizeof(buf), "%d", v + 1);
if (n >= sizeof(buf))
-   die("impossibly large verbosity value");
+   die(_("impossibly large verbosity value"));
set_helper_option(t, "verbosity", buf);
 
switch (t->family) {
@@ -376,7 +376,7 @@ static int fetch_with_fetch(struct transport *transport,
if (starts_with(buf.buf, "lock ")) {
const char *name = buf.buf + 5;
if (transport->pack_lockfile)
-   warning("%s also locked %s", data->name, name);
+   warning(_("%s also locked %s"), data->name, 
name);
else
transport->pack_lockfile = xstrdup(name);
}
@@ -387,7 +387,7 @@ static int fetch_with_fetch(struct transport *transport,
else if (!buf.len)
break;
else
-   warning("%s unexpectedly said: '%s'", data->name, 
buf.buf);
+   warning(_("%s unexpectedly said: '%s'"), data->name, 
buf.buf);
}
strbuf_release();
return 0;
@@ -454,7 +454,7 @@ static int fetch_with_import(struct transport *transport,
get_helper(transport);
 
if 

[PATCH 22/22] wrapper.c: mark strings for translation

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

diff --git a/wrapper.c b/wrapper.c
index 9afc1a0..d2e3068 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -91,10 +91,10 @@ static void *do_xmallocz(size_t size, int gentle)
void *ret;
if (unsigned_add_overflows(size, 1)) {
if (gentle) {
-   error("Data too large to fit into virtual memory 
space.");
+   error(_("Data too large to fit into virtual memory 
space."));
return NULL;
} else
-   die("Data too large to fit into virtual memory space.");
+   die(_("Data too large to fit into virtual memory 
space."));
}
ret = do_xmalloc(size + 1, gentle);
if (ret)
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 19/22] trailer.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 trailer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/trailer.c b/trailer.c
index 94b387b..8e48a5c 100644
--- a/trailer.c
+++ b/trailer.c
@@ -234,7 +234,7 @@ static const char *apply_command(const char *command, const 
char *arg)
cp.use_shell = 1;
 
if (capture_command(, , 1024)) {
-   error("running trailer command '%s' failed", cmd.buf);
+   error(_("running trailer command '%s' failed"), cmd.buf);
strbuf_release();
result = xstrdup("");
} else {
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 17/22] sha1_file.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 sha1_file.c | 189 ++--
 1 file changed, 96 insertions(+), 93 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 0251700..f669499 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -194,7 +194,7 @@ const char *sha1_file_name(const unsigned char *sha1)
 
/* '/' + sha1(2) + '/' + sha1(38) + '\0' */
if (len + 43 > PATH_MAX)
-   die("insanely long object directory %s", objdir);
+   die(_("insanely long object directory %s"), objdir);
memcpy(buf, objdir, len);
buf[len] = '/';
buf[len+3] = '/';
@@ -284,8 +284,8 @@ static int link_alt_odb_entry(const char *entry, const char 
*relative_base,
 
/* Detect cases where alternate disappeared */
if (!is_directory(ent->base)) {
-   error("object directory %s does not exist; "
- "check .git/objects/info/alternates.",
+   error(_("object directory %s does not exist; "
+   "check .git/objects/info/alternates."),
  ent->base);
free(ent);
return -1;
@@ -328,8 +328,8 @@ static void link_alt_odb_entries(const char *alt, int len, 
int sep,
struct strbuf objdirbuf = STRBUF_INIT;
 
if (depth > 5) {
-   error("%s: ignoring alternate object stores, nesting too deep.",
-   relative_base);
+   error(_("%s: ignoring alternate object stores, nesting too 
deep."),
+ relative_base);
return;
}
 
@@ -343,8 +343,8 @@ static void link_alt_odb_entries(const char *alt, int len, 
int sep,
if (entry[0] == '\0' || entry[0] == '#')
continue;
if (!is_absolute_path(entry) && depth) {
-   error("%s: ignoring relative alternate object store %s",
-   relative_base, entry);
+   error(_("%s: ignoring relative alternate object store 
%s"),
+ relative_base, entry);
} else {
link_alt_odb_entry(entry, relative_base, depth, 
objdirbuf.buf);
}
@@ -389,7 +389,7 @@ void add_to_alternates_file(const char *reference)
hold_lock_file_for_update(lock, alts, LOCK_DIE_ON_ERROR);
out = fdopen_lock_file(lock, "w");
if (!out)
-   die_errno("unable to fdopen alternates lockfile");
+   die_errno(_("unable to fdopen alternates lockfile"));
 
in = fopen(alts, "r");
if (in) {
@@ -413,12 +413,12 @@ void add_to_alternates_file(const char *reference)
}
}
else if (errno != ENOENT)
-   die_errno("unable to read alternates file");
+   die_errno(_("unable to read alternates file"));
 
if (lock) {
fprintf_or_die(out, "%s\n", reference);
if (commit_lock_file(lock))
-   die_errno("unable to move new alternates file into 
place");
+   die_errno(_("unable to move new alternates file into 
place"));
if (alt_odb_tail)
link_alt_odb_entries(reference, strlen(reference), 
'\n', NULL, 0);
}
@@ -566,7 +566,7 @@ static int check_packed_git_idx(const char *path, struct 
packed_git *p)
idx_size = xsize_t(st.st_size);
if (idx_size < 4 * 256 + 20 + 20) {
close(fd);
-   return error("index file %s is too small", path);
+   return error(_("index file %s is too small"), path);
}
idx_map = xmmap(NULL, idx_size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
@@ -576,9 +576,9 @@ static int check_packed_git_idx(const char *path, struct 
packed_git *p)
version = ntohl(hdr->idx_version);
if (version < 2 || version > 2) {
munmap(idx_map, idx_size);
-   return error("index file %s is version %"PRIu32
-" and is not supported by this binary"
-" (try upgrading GIT to a newer version)",
+   return error(_("index file %s is version %" PRIu32
+  " and is not supported by this binary"
+  " (try upgrading GIT to a newer 
version)"),
 path, version);
}
} else
@@ -592,7 +592,7 @@ static int check_packed_git_idx(const char *path, struct 
packed_git *p)
uint32_t n = ntohl(index[i]);
if (n < nr) {
munmap(idx_map, idx_size);
-   return error("non-monotonic index %s", path);
+   return error(_("non-monotonic index %s"), path);
 

[PATCH 18/22] submodule.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 submodule.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/submodule.c b/submodule.c
index 24fb81a..4dd6ab3 100644
--- a/submodule.c
+++ b/submodule.c
@@ -187,7 +187,7 @@ void gitmodules_config(void)
strbuf_addstr(_path, work_tree);
strbuf_addstr(_path, "/.gitmodules");
if (read_cache() < 0)
-   die("index file corrupt");
+   die(_("index file corrupt"));
pos = cache_name_pos(".gitmodules", 11);
if (pos < 0) { /* .gitmodules not found or isn't merged */
pos = -1 - pos;
@@ -224,7 +224,7 @@ void handle_ignore_submodules_arg(struct diff_options 
*diffopt,
else if (!strcmp(arg, "dirty"))
DIFF_OPT_SET(diffopt, IGNORE_DIRTY_SUBMODULES);
else if (strcmp(arg, "none"))
-   die("bad --ignore-submodules argument: %s", arg);
+   die(_("bad --ignore-submodules argument: %s"), arg);
 }
 
 static int prepare_submodule_summary(struct rev_info *rev, const char *path,
@@ -372,7 +372,7 @@ static int submodule_needs_pushing(const char *path, const 
unsigned char sha1[20
cp.out = -1;
cp.dir = path;
if (start_command())
-   die("Could not run 'git rev-list %s --not --remotes -n 
1' command in submodule %s",
+   die(_("Could not run 'git rev-list %s --not --remotes 
-n 1' command in submodule %s"),
sha1_to_hex(sha1), path);
if (strbuf_read(, cp.out, 41))
needs_pushing = 1;
@@ -431,7 +431,7 @@ int find_unpushed_submodules(unsigned char new_sha1[20],
argv[3] = remotes_arg.buf;
setup_revisions(argc, argv, , NULL);
if (prepare_revision_walk())
-   die("revision walk setup failed");
+   die(_("revision walk setup failed"));
 
while ((commit = get_revision()) != NULL)
find_unpushed_submodule_commits(commit, needs_pushing);
@@ -583,7 +583,7 @@ static void calculate_changed_submodule_paths(void)
   add_sha1_to_argv, );
setup_revisions(argv.argc, argv.argv, , NULL);
if (prepare_revision_walk())
-   die("revision walk setup failed");
+   die(_("revision walk setup failed"));
 
/*
 * Collect all submodules (whether checked out or not) for which new
@@ -685,7 +685,7 @@ static int get_next_submodule(struct child_process *cp,
cp->env = local_repo_env;
cp->git_cmd = 1;
if (!spf->quiet)
-   strbuf_addf(err, "Fetching submodule %s%s\n",
+   strbuf_addf(err, _("Fetching submodule %s%s\n"),
spf->prefix, ce->name);
argv_array_init(>args);
argv_array_pushv(>args, spf->args.argv);
@@ -743,7 +743,7 @@ int fetch_populated_submodules(const struct argv_array 
*options,
goto out;
 
if (read_cache() < 0)
-   die("index file corrupt");
+   die(_("index file corrupt"));
 
argv_array_push(, "fetch");
for (i = 0; i < options->argc; i++)
@@ -801,7 +801,7 @@ unsigned is_submodule_modified(const char *path, int 
ignore_untracked)
cp.out = -1;
cp.dir = path;
if (start_command())
-   die("Could not run 'git status --porcelain' in submodule %s", 
path);
+   die(_("Could not run 'git status --porcelain' in submodule 
%s"), path);
 
len = strbuf_read(, cp.out, 1024);
line = buf.buf;
@@ -826,7 +826,7 @@ unsigned is_submodule_modified(const char *path, int 
ignore_untracked)
close(cp.out);
 
if (finish_command())
-   die("'git status --porcelain' failed in submodule %s", path);
+   die(_("'git status --porcelain' failed in submodule %s"), path);
 
strbuf_release();
return dirty_submodule;
@@ -895,7 +895,7 @@ int ok_to_remove_submodule(const char *path)
cp.out = -1;
cp.dir = path;
if (start_command())
-   die("Could not run 'git status --porcelain -uall 
--ignore-submodules=none' in submodule %s", path);
+   die(_("Could not run 'git status --porcelain -uall 
--ignore-submodules=none' in submodule %s"), path);
 
len = strbuf_read(, cp.out, 1024);
if (len > 2)
@@ -903,7 +903,7 @@ int ok_to_remove_submodule(const char *path)
close(cp.out);
 
if (finish_command())
-   die("'git status --porcelain -uall --ignore-submodules=none' 
failed in submodule %s", path);
+   die(_("'git status --porcelain -uall --ignore-submodules=none' 
failed in submodule %s"), 

[PATCH 16/22] run-command.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 run-command.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/run-command.c b/run-command.c
index 863dad5..1ee2357 100644
--- a/run-command.c
+++ b/run-command.c
@@ -909,7 +909,7 @@ static int default_start_failure(struct child_process *cp,
 {
int i;
 
-   strbuf_addstr(err, "Starting a child failed:");
+   strbuf_addstr(err, _("Starting a child failed:"));
for (i = 0; cp->argv[i]; i++)
strbuf_addf(err, " %s", cp->argv[i]);
 
@@ -927,7 +927,7 @@ static int default_task_finished(int result,
if (!result)
return 0;
 
-   strbuf_addf(err, "A child failed with return code %d:", result);
+   strbuf_addf(err, _("A child failed with return code %d:"), result);
for (i = 0; cp->argv[i]; i++)
strbuf_addf(err, " %s", cp->argv[i]);
 
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 15/22] remote-curl.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 remote-curl.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index 15e48e2..d5b33aa 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -177,7 +177,7 @@ static struct ref *parse_info_refs(struct discovery *heads)
mid = [i];
if (data[i] == '\n') {
if (mid - start != 40)
-   die("%sinfo/refs not valid: is this a git 
repository?",
+   die(_("%sinfo/refs not valid: is this a git 
repository?"),
url.buf);
data[i] = 0;
ref_name = mid + 1;
@@ -285,13 +285,13 @@ static struct discovery *discover_refs(const char 
*service, int for_push)
break;
case HTTP_MISSING_TARGET:
show_http_message(, , );
-   die("repository '%s' not found", url.buf);
+   die(_("repository '%s' not found"), url.buf);
case HTTP_NOAUTH:
show_http_message(, , );
-   die("Authentication failed for '%s'", url.buf);
+   die(_("Authentication failed for '%s'"), url.buf);
default:
show_http_message(, , );
-   die("unable to access '%s': %s", url.buf, curl_errorstr);
+   die(_("unable to access '%s': %s"), url.buf, curl_errorstr);
}
 
last= xcalloc(1, sizeof(*last_discovery));
@@ -314,7 +314,7 @@ static struct discovery *discover_refs(const char *service, 
int for_push)
strbuf_reset();
strbuf_addf(, "# service=%s", service);
if (strcmp(line, exp.buf))
-   die("invalid server response; got '%s'", line);
+   die(_("invalid server response; got '%s'"), line);
strbuf_release();
 
/* The header can include additional metadata lines, up
@@ -422,7 +422,7 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void 
*clientp)
rpc->pos = 0;
return CURLIOE_OK;
}
-   error("unable to rewind rpc post data - try increasing 
http.postBuffer");
+   error(_("unable to rewind rpc post data - try increasing 
http.postBuffer"));
return CURLIOE_FAILRESTART;
 
default:
@@ -604,11 +604,11 @@ retry:
 
ret = git_deflate(, Z_FINISH);
if (ret != Z_STREAM_END)
-   die("cannot deflate request; zlib deflate error %d", 
ret);
+   die(_("cannot deflate request; zlib deflate error %d"), 
ret);
 
ret = git_deflate_end_gently();
if (ret != Z_OK)
-   die("cannot deflate request; zlib end error %d", ret);
+   die(_("cannot deflate request; zlib end error %d"), 
ret);
 
gzip_size = stream.total_out;
 
@@ -726,7 +726,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
 
ALLOC_ARRAY(targets, nr_heads);
if (options.depth)
-   die("dumb http transport does not support --depth");
+   die(_("dumb http transport does not support --depth"));
for (i = 0; i < nr_heads; i++)
targets[i] = xstrdup(oid_to_hex(_fetch[i]->old_oid));
 
@@ -743,7 +743,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
free(targets[i]);
free(targets);
 
-   return ret ? error("fetch failed.") : 0;
+   return ret ? error(_("fetch failed.")) : 0;
 }
 
 static int fetch_git(struct discovery *heads,
@@ -787,7 +787,7 @@ static int fetch_git(struct discovery *heads,
for (i = 0; i < nr_heads; i++) {
struct ref *ref = to_fetch[i];
if (!*ref->name)
-   die("cannot fetch by sha1 over smart http");
+   die(_("cannot fetch by sha1 over smart http"));
packet_buf_write(, "%s %s\n",
 oid_to_hex(>old_oid), ref->name);
}
@@ -832,13 +832,13 @@ static void parse_fetch(struct strbuf *buf)
struct object_id old_oid;
 
if (get_oid_hex(p, _oid))
-   die("protocol error: expected sha/ref, got 
%s'", p);
+   die(_("protocol error: expected sha/ref, got 
%s'"), p);
if (p[GIT_SHA1_HEXSZ] == ' ')
name = p + GIT_SHA1_HEXSZ + 1;
else if (!p[GIT_SHA1_HEXSZ])
name = "";
else
-   die("protocol error: expected sha/ref, got 
%s'", p);
+   die(_("protocol error: expected sha/ref, got 
%s'"), p);
 
   

[PATCH 13/22] ref-filter.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 ref-filter.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/ref-filter.c b/ref-filter.c
index bb79d6b..bc551a7 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -74,14 +74,14 @@ static void remote_ref_atom_parser(struct used_atom *atom, 
const char *arg)
 static void body_atom_parser(struct used_atom *atom, const char *arg)
 {
if (arg)
-   die("%%(body) does not take arguments");
+   die(_("%%(body) does not take arguments"));
atom->u.contents.option = C_BODY_DEP;
 }
 
 static void subject_atom_parser(struct used_atom *atom, const char *arg)
 {
if (arg)
-   die("%%(subject) does not take arguments");
+   die(_("%%(subject) does not take arguments"));
atom->u.contents.option = C_SUB;
 }
 
@@ -241,7 +241,7 @@ int parse_ref_filter_atom(const char *atom, const char *ep)
if (*sp == '*' && sp < ep)
sp++; /* deref */
if (ep <= sp)
-   die("malformed field name: %.*s", (int)(ep-atom), atom);
+   die(_("malformed field name: %.*s"), (int)(ep-atom), atom);
 
/* Do we have the atom already used elsewhere? */
for (i = 0; i < used_atom_cnt; i++) {
@@ -267,7 +267,7 @@ int parse_ref_filter_atom(const char *atom, const char *ep)
}
 
if (ARRAY_SIZE(valid_atom) <= i)
-   die("unknown field name: %.*s", (int)(ep-atom), atom);
+   die(_("unknown field name: %.*s"), (int)(ep-atom), atom);
 
/* Add it in, including the deref prefix */
at = used_atom_cnt;
@@ -421,7 +421,7 @@ int verify_ref_format(const char *format)
int at;
 
if (!ep)
-   return error("malformed format string %s", sp);
+   return error(_("malformed format string %s"), sp);
/* sp points at "%(" and ep points at the closing ")" */
at = parse_ref_filter_atom(sp + 2, ep);
cp = ep + 1;
@@ -875,12 +875,12 @@ static const char *strip_ref_components(const char 
*refname, const char *nr_arg)
const char *start = refname;
 
if (nr < 1 || *end != '\0')
-   die(":strip= requires a positive integer argument");
+   die(_(":strip= requires a positive integer argument"));
 
while (remaining) {
switch (*start++) {
case '\0':
-   die("ref '%s' does not have %ld components to :strip",
+   die(_("ref '%s' does not have %ld components to 
:strip"),
refname, nr);
case '/':
remaining--;
@@ -1043,7 +1043,7 @@ static void populate_value(struct ref_array_item *ref)
else if (skip_prefix(formatp, "strip=", ))
refname = strip_ref_components(refname, arg);
else
-   die("unknown %.*s format %s",
+   die(_("unknown %.*s format %s"),
(int)(formatp - name), name, formatp);
}
 
@@ -1063,10 +1063,10 @@ static void populate_value(struct ref_array_item *ref)
  need_obj:
buf = get_obj(ref->objectname, , , );
if (!buf)
-   die("missing object %s for %s",
+   die(_("missing object %s for %s"),
sha1_to_hex(ref->objectname), ref->refname);
if (!obj)
-   die("parse_object_buffer failed on %s for %s",
+   die(_("parse_object_buffer failed on %s for %s"),
sha1_to_hex(ref->objectname), ref->refname);
 
grab_values(ref->value, 0, obj, buf, size);
@@ -1094,10 +1094,10 @@ static void populate_value(struct ref_array_item *ref)
 */
buf = get_obj(tagged, , , );
if (!buf)
-   die("missing object %s for %s",
+   die(_("missing object %s for %s"),
sha1_to_hex(tagged), ref->refname);
if (!obj)
-   die("parse_object_buffer failed on %s for %s",
+   die(_("parse_object_buffer failed on %s for %s"),
sha1_to_hex(tagged), ref->refname);
grab_values(ref->value, 1, obj, buf, size);
if (!eaten)
@@ -1370,12 +1370,12 @@ static int ref_filter_handler(const char *refname, 
const struct object_id *oid,
unsigned int kind;
 
if (flag & REF_BAD_NAME) {
-   warning("ignoring ref with broken name %s", refname);
+   warning(_("ignoring ref with broken name %s"), refname);
return 0;
}
 
if (flag & REF_ISBROKEN) {
-   warning("ignoring broken ref %s", refname);
+   warning(_("ignoring broken ref %s"), refname);
return 0;
}
 
-- 
2.8.0.rc0.205.g7ec8cf1

--
To unsubscribe 

[PATCH 14/22] refs/files-backend.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 refs/files-backend.c | 86 ++--
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index 81f68f8..bf76094 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -203,7 +203,7 @@ static struct ref_entry *create_ref_entry(const char 
*refname,
 
if (check_name &&
check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))
-   die("Reference has invalid format: '%s'", refname);
+   die(_("Reference has invalid format: '%s'"), refname);
FLEX_ALLOC_STR(ref, name, refname);
hashcpy(ref->u.value.oid.hash, sha1);
oidclr(>u.value.peeled);
@@ -475,12 +475,12 @@ static int is_dup_ref(const struct ref_entry *ref1, const 
struct ref_entry *ref2
 
if ((ref1->flag & REF_DIR) || (ref2->flag & REF_DIR))
/* This is impossible by construction */
-   die("Reference directory conflict: %s", ref1->name);
+   die(_("Reference directory conflict: %s"), ref1->name);
 
if (oidcmp(>u.value.oid, >u.value.oid))
-   die("Duplicated ref, and SHA1s don't match: %s", ref1->name);
+   die(_("Duplicated ref, and SHA1s don't match: %s"), ref1->name);
 
-   warning("Duplicated ref: %s", ref1->name);
+   warning(_("Duplicated ref: %s"), ref1->name);
return 1;
 }
 
@@ -526,7 +526,7 @@ static int ref_resolves_to_object(struct ref_entry *entry)
if (entry->flag & REF_ISBROKEN)
return 0;
if (!has_sha1_file(entry->u.value.oid.hash)) {
-   error("%s does not point to a valid object!", entry->name);
+   error(_("%s does not point to a valid object!"), entry->name);
return 0;
}
return 1;
@@ -653,7 +653,7 @@ static int do_for_each_entry_in_dirs(struct ref_dir *dir1,
i1++;
i2++;
} else {
-   die("conflict between reference and directory: 
%s",
+   die(_("conflict between reference and 
directory: %s"),
e1->name);
}
} else {
@@ -914,7 +914,7 @@ static void clear_packed_ref_cache(struct ref_cache *refs)
struct packed_ref_cache *packed_refs = refs->packed;
 
if (packed_refs->lock)
-   die("internal error: packed-ref cache cleared while 
locked");
+   die(_("internal error: packed-ref cache cleared while 
locked"));
refs->packed = NULL;
release_packed_ref_cache(packed_refs);
}
@@ -1069,7 +1069,7 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)
 
if (check_refname_format(refname, 
REFNAME_ALLOW_ONELEVEL)) {
if (!refname_is_safe(refname))
-   die("packed refname is dangerous: %s", 
refname);
+   die(_("packed refname is dangerous: 
%s"), refname);
hashclr(sha1);
flag |= REF_BAD_NAME | REF_ISBROKEN;
}
@@ -1239,7 +1239,7 @@ static void read_loose_refs(const char *dirname, struct 
ref_dir *dir)
if (check_refname_format(refname.buf,
 REFNAME_ALLOW_ONELEVEL)) {
if (!refname_is_safe(refname.buf))
-   die("loose refname is dangerous: %s", 
refname.buf);
+   die(_("loose refname is dangerous: 
%s"), refname.buf);
hashclr(sha1);
flag |= REF_BAD_NAME | REF_ISBROKEN;
}
@@ -2099,7 +2099,7 @@ static int commit_packed_refs(void)
 
out = fdopen_lock_file(packed_ref_cache->lock, "w");
if (!out)
-   die_errno("unable to fdopen packed-refs descriptor");
+   die_errno(_("unable to fdopen packed-refs descriptor"));
 
fprintf_or_die(out, "%s", PACKED_REFS_HEADER);
do_for_each_entry_in_dir(get_packed_ref_dir(packed_ref_cache),
@@ -2275,7 +2275,7 @@ int pack_refs(unsigned int flags)
 pack_if_possible_fn, );
 
if (commit_packed_refs())
-   die_errno("unable to overwrite old ref-pack file");
+   die_errno(_("unable to overwrite old ref-pack file"));
 
prune_refs(cbdata.ref_to_prune);
return 0;
@@ -2417,7 +2417,7 @@ static int rename_tmp_log(const char *newrefname)
goto retry;
/* fall through */
default:
-   error("unable to create directory for %s", newrefname);
+  

[PATCH 11/22] ident.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 ident.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/ident.c b/ident.c
index 6e12582..367a5dc 100644
--- a/ident.c
+++ b/ident.c
@@ -75,13 +75,13 @@ static int add_mailname_host(struct strbuf *buf)
mailname = fopen("/etc/mailname", "r");
if (!mailname) {
if (errno != ENOENT)
-   warning("cannot open /etc/mailname: %s",
+   warning(_("cannot open /etc/mailname: %s"),
strerror(errno));
return -1;
}
if (strbuf_getline(, mailname) == EOF) {
if (ferror(mailname))
-   warning("cannot read /etc/mailname: %s",
+   warning(_("cannot read /etc/mailname: %s"),
strerror(errno));
strbuf_release();
fclose(mailname);
@@ -125,7 +125,7 @@ static void add_domainname(struct strbuf *out, int 
*is_bogus)
char buf[1024];
 
if (gethostname(buf, sizeof(buf))) {
-   warning("cannot get host name: %s", strerror(errno));
+   warning(_("cannot get host name: %s"), strerror(errno));
strbuf_addstr(out, "(none)");
*is_bogus = 1;
return;
@@ -355,18 +355,18 @@ const char *fmt_ident(const char *name, const char *email,
using_default = 1;
if (strict && default_name_is_bogus) {
fputs(env_hint, stderr);
-   die("unable to auto-detect name (got '%s')", 
name);
+   die(_("unable to auto-detect name (got '%s')"), 
name);
}
if (strict && ident_use_config_only
&& !(ident_config_given & IDENT_NAME_GIVEN))
-   die("user.useConfigOnly set but no name given");
+   die(_("user.useConfigOnly set but no name 
given"));
}
if (!*name) {
struct passwd *pw;
if (strict) {
if (using_default)
fputs(env_hint, stderr);
-   die("empty ident name (for <%s>) not allowed", 
email);
+   die(_("empty ident name (for <%s>) not 
allowed"), email);
}
pw = xgetpwuid_self(NULL);
name = pw->pw_name;
@@ -377,11 +377,11 @@ const char *fmt_ident(const char *name, const char *email,
email = ident_default_email();
if (strict && default_email_is_bogus) {
fputs(env_hint, stderr);
-   die("unable to auto-detect email address (got '%s')", 
email);
+   die(_("unable to auto-detect email address (got 
'%s')"), email);
}
if (strict && ident_use_config_only
&& !(ident_config_given & IDENT_MAIL_GIVEN))
-   die("user.useConfigOnly set but no mail given");
+   die(_("user.useConfigOnly set but no mail given"));
}
 
strbuf_reset();
@@ -396,7 +396,7 @@ const char *fmt_ident(const char *name, const char *email,
strbuf_addch(, ' ');
if (date_str && date_str[0]) {
if (parse_date(date_str, ) < 0)
-   die("invalid date format: %s", date_str);
+   die(_("invalid date format: %s"), date_str);
}
else
strbuf_addstr(, ident_default_date());
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 12/22] notes.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 notes.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/notes.c b/notes.c
index 88cf474..0f03f77 100644
--- a/notes.c
+++ b/notes.c
@@ -422,7 +422,7 @@ static void load_subtree(struct notes_tree *t, struct 
leaf_node *subtree,
 
buf = fill_tree_descriptor(, subtree->val_sha1);
if (!buf)
-   die("Could not read %s for notes-index",
+   die(_("Could not read %s for notes-index"),
 sha1_to_hex(subtree->val_sha1));
 
prefix_len = subtree->key_sha1[19];
@@ -455,8 +455,8 @@ static void load_subtree(struct notes_tree *t, struct 
leaf_node *subtree,
}
if (note_tree_insert(t, node, n, l, type,
 combine_notes_concatenate))
-   die("Failed to load %s %s into notes tree "
-   "from %s",
+   die(_("Failed to load %s %s into notes tree "
+ "from %s"),
type == PTR_TYPE_NOTE ? "note" : "subtree",
sha1_to_hex(l->key_sha1), t->ref);
}
@@ -942,7 +942,7 @@ void string_list_add_refs_by_glob(struct string_list *list, 
const char *glob)
} else {
unsigned char sha1[20];
if (get_sha1(glob, sha1))
-   warning("notes ref %s is invalid", glob);
+   warning(_("notes ref %s is invalid"), glob);
if (!unsorted_string_list_has_string(list, glob))
string_list_append(list, glob);
}
@@ -1020,9 +1020,9 @@ void init_notes(struct notes_tree *t, const char 
*notes_ref,
get_sha1_treeish(notes_ref, object_sha1))
return;
if (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, object_sha1))
-   die("Cannot use notes ref %s", notes_ref);
+   die(_("Cannot use notes ref %s"), notes_ref);
if (get_tree_entry(object_sha1, "", sha1, ))
-   die("Failed to read notes tree referenced by %s (%s)",
+   die(_("Failed to read notes tree referenced by %s (%s)"),
notes_ref, sha1_to_hex(object_sha1));
 
hashclr(root_tree.key_sha1);
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 10/22] http.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 http.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/http.c b/http.c
index 1d5e3bb..d56cb52 100644
--- a/http.c
+++ b/http.c
@@ -404,7 +404,7 @@ static void init_curl_proxy_auth(CURL *result)
}
}
if (i == ARRAY_SIZE(proxy_authmethods)) {
-   warning("unsupported proxy authentication method %s: 
using anyauth",
+   warning(_("unsupported proxy authentication method %s: 
using anyauth"),
http_proxy_authmethod);
curl_easy_setopt(result, CURLOPT_PROXYAUTH, 
CURLAUTH_ANY);
}
@@ -445,7 +445,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, 
curlsocktype type)
 
rc = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (void *), len);
if (rc < 0)
-   warning("unable to set SO_KEEPALIVE on socket %s",
+   warning(_("unable to set SO_KEEPALIVE on socket %s"),
strerror(errno));
 
return 0; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
@@ -469,7 +469,7 @@ static CURL *get_curl_handle(void)
long allowed_protocols = 0;
 
if (!result)
-   die("curl_easy_init failed");
+   die(_("curl_easy_init failed"));
 
if (!curl_ssl_verify) {
curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);
@@ -503,7 +503,7 @@ static CURL *get_curl_handle(void)
}
}
if (i == ARRAY_SIZE(sslversions))
-   warning("unsupported ssl version %s: using default",
+   warning(_("unsupported ssl version %s: using default"),
ssl_version);
}
 
@@ -558,8 +558,8 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS, allowed_protocols);
 #else
if (transport_restrict_protocols())
-   warning("protocol restrictions not applied to curl redirects 
because\n"
-   "your curl version is too old (>= 7.19.4)");
+   warning(_("protocol restrictions not applied to curl redirects 
because\n"
+ "your curl version is too old (>= 7.19.4)"));
 #endif
 
if (getenv("GIT_CURL_VERBOSE"))
@@ -659,7 +659,7 @@ void http_init(struct remote *remote, const char *url, int 
proactive_auth)
free(normalized_url);
 
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
-   die("curl_global_init failed");
+   die(_("curl_global_init failed"));
 
http_proactive_auth = proactive_auth;
 
@@ -681,7 +681,7 @@ void http_init(struct remote *remote, const char *url, int 
proactive_auth)
 
curlm = curl_multi_init();
if (!curlm)
-   die("curl_multi_init failed");
+   die(_("curl_multi_init failed"));
 #endif
 
if (getenv("GIT_SSL_NO_VERIFY"))
@@ -1544,7 +1544,7 @@ static int http_get_file(const char *url, const char 
*filename,
strbuf_addf(, "%s.temp", filename);
result = fopen(tmpfile.buf, "a");
if (!result) {
-   error("Unable to open local file %s", tmpfile.buf);
+   error(_("Unable to open local file %s"), tmpfile.buf);
ret = HTTP_ERROR;
goto cleanup;
}
@@ -1601,7 +1601,7 @@ static char *fetch_pack_index(unsigned char *sha1, const 
char *base_url)
tmp = strbuf_detach(, NULL);
 
if (http_get_file(url, tmp, NULL) != HTTP_OK) {
-   error("Unable to get pack index %s", url);
+   error(_("Unable to get pack index %s"), url);
free(tmp);
tmp = NULL;
}
@@ -1778,7 +1778,7 @@ struct http_pack_request *new_http_pack_request(
sha1_pack_name(target->sha1));
preq->packfile = fopen(preq->tmpfile, "a");
if (!preq->packfile) {
-   error("Unable to open local file %s for pack",
+   error(_("Unable to open local file %s for pack"),
  preq->tmpfile);
goto abort;
}
@@ -1866,7 +1866,7 @@ struct http_object_request *new_http_object_request(const 
char *base_url,
unlink_or_warn(freq->tmpfile);
 
if (freq->localfile != -1)
-   error("fd leakage in start: %d", freq->localfile);
+   error(_("fd leakage in start: %d"), freq->localfile);
freq->localfile = open(freq->tmpfile,
   O_WRONLY | O_CREAT | O_EXCL, 0666);
/*
@@ -1885,7 +1885,7 @@ struct http_object_request *new_http_object_request(const 
char *base_url,
}
 
if (freq->localfile < 0) {
-   error("Couldn't create temporary file %s: %s",
+   error(_("Couldn't create temporary file %s: %s"),
  

[PATCH 05/22] builtin/config.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 builtin/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/config.c b/builtin/config.c
index ca9f834..98ca43d 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -378,7 +378,7 @@ static int get_colorbool(const char *var, int print)
 static void check_write(void)
 {
if (!given_config_source.file && !startup_info->have_repository)
-   die("not in a git directory");
+   die(_("not in a git directory"));
 
if (given_config_source.use_stdin)
die("writing to stdin is not supported");
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 08/22] convert.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 convert.c | 30 +-
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/convert.c b/convert.c
index f524b8d..59d03b0 100644
--- a/convert.c
+++ b/convert.c
@@ -199,9 +199,11 @@ static void check_safe_crlf(const char *path, enum 
crlf_action crlf_action,
 */
if (stats->crlf) {
if (checksafe == SAFE_CRLF_WARN)
-   warning("CRLF will be replaced by LF in 
%s.\nThe file will have its original line endings in your working directory.", 
path);
+   warning(_("CRLF will be replaced by LF in %s.\n"
+ "The file will have its original line 
"
+ "endings in your working 
directory."), path);
else /* i.e. SAFE_CRLF_FAIL */
-   die("CRLF would be replaced by LF in %s.", 
path);
+   die(_("CRLF would be replaced by LF in %s."), 
path);
}
} else if (output_eol(crlf_action) == EOL_CRLF) {
/*
@@ -210,9 +212,11 @@ static void check_safe_crlf(const char *path, enum 
crlf_action crlf_action,
 */
if (stats->lonelf) {
if (checksafe == SAFE_CRLF_WARN)
-   warning("LF will be replaced by CRLF in 
%s.\nThe file will have its original line endings in your working directory.", 
path);
+   warning(_("LF will be replaced by CRLF in %s.\n"
+ "The file will have its original line 
"
+ "endings in your working 
directory."), path);
else /* i.e. SAFE_CRLF_FAIL */
-   die("LF would be replaced by CRLF in %s", path);
+   die(_("LF would be replaced by CRLF in %s"), 
path);
}
}
 }
@@ -397,7 +401,7 @@ static int filter_buffer_or_fd(int in, int out, void *data)
child_process.out = out;
 
if (start_command(_process))
-   return error("cannot fork to run external filter %s", 
params->cmd);
+   return error(_("cannot fork to run external filter %s"), 
params->cmd);
 
sigchain_push(SIGPIPE, SIG_IGN);
 
@@ -415,13 +419,13 @@ static int filter_buffer_or_fd(int in, int out, void 
*data)
if (close(child_process.in))
write_err = 1;
if (write_err)
-   error("cannot feed the input to external filter %s", 
params->cmd);
+   error(_("cannot feed the input to external filter %s"), 
params->cmd);
 
sigchain_pop(SIGPIPE);
 
status = finish_command(_process);
if (status)
-   error("external filter %s failed %d", params->cmd, status);
+   error(_("external filter %s failed %d"), params->cmd, status);
 
strbuf_release();
return (write_err || status);
@@ -462,15 +466,15 @@ static int apply_filter(const char *path, const char 
*src, size_t len, int fd,
return 0;   /* error was already reported */
 
if (strbuf_read(, async.out, len) < 0) {
-   error("read from external filter %s failed", cmd);
+   error(_("read from external filter %s failed"), cmd);
ret = 0;
}
if (close(async.out)) {
-   error("read from external filter %s failed", cmd);
+   error(_("read from external filter %s failed"), cmd);
ret = 0;
}
if (finish_async()) {
-   error("external filter %s failed", cmd);
+   error(_("external filter %s failed"), cmd);
ret = 0;
}
 
@@ -868,7 +872,7 @@ int convert_to_git(const char *path, const char *src, 
size_t len,
 
ret |= apply_filter(path, src, len, -1, dst, filter);
if (!ret && required)
-   die("%s: clean filter '%s' failed", path, ca.drv->name);
+   die(_("%s: clean filter '%s' failed"), path, ca.drv->name);
 
if (ret && dst) {
src = dst->buf;
@@ -892,7 +896,7 @@ void convert_to_git_filter_fd(const char *path, int fd, 
struct strbuf *dst,
assert(ca.drv->clean);
 
if (!apply_filter(path, NULL, 0, fd, dst, ca.drv->clean))
-   die("%s: clean filter '%s' failed", path, ca.drv->name);
+   die(_("%s: clean filter '%s' failed"), path, ca.drv->name);
 
crlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);
ident_to_git(path, dst->buf, dst->len, dst, ca.ident);
@@ -932,7 +936,7 @@ static int convert_to_working_tree_internal(const char 
*path, const char *src,
 
ret_filter = apply_filter(path, src, len, -1, dst, filter);
if (!ret_filter && required)
-   die("%s: 

[PATCH 02/22] builtin/blame.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 builtin/blame.c | 58 -
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index e982fb8..988a38a 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -196,7 +196,7 @@ static void fill_origin_blob(struct diff_options *opt,
file->size = file_size;
 
if (!file->ptr)
-   die("Cannot read blob %s for path %s",
+   die(_("Cannot read blob %s for path %s"),
sha1_to_hex(o->blob_sha1),
o->path);
o->file = *file;
@@ -981,7 +981,7 @@ static void pass_blame_to_parent(struct scoreboard *sb,
num_get_patch++;
 
if (diff_hunks(_p, _o, 0, blame_chunk_cb, ))
-   die("unable to generate diff (%s -> %s)",
+   die(_("unable to generate diff (%s -> %s)"),
oid_to_hex(>commit->object.oid),
oid_to_hex(>commit->object.oid));
/* The rest are the same as the parent */
@@ -1130,7 +1130,7 @@ static void find_copy_in_blob(struct scoreboard *sb,
 */
memset(split, 0, sizeof(struct blame_entry [3]));
if (diff_hunks(file_p, _o, 1, handle_split_cb, ))
-   die("unable to generate diff (%s)",
+   die(_("unable to generate diff (%s)"),
oid_to_hex(>commit->object.oid));
/* remainder, if any, all match the preimage */
handle_split(sb, ent, d.tlno, d.plno, ent->num_lines, parent, split);
@@ -2240,7 +2240,7 @@ static void verify_working_tree_path(struct commit 
*work_tree, const char *path)
sha1_object_info(blob_sha1, NULL) == OBJ_BLOB)
return;
}
-   die("no such path '%s' in HEAD", path);
+   die(_("no such path '%s' in HEAD"), path);
 }
 
 static struct commit_list **append_parent(struct commit_list **tail, const 
unsigned char *sha1)
@@ -2249,7 +2249,7 @@ static struct commit_list **append_parent(struct 
commit_list **tail, const unsig
 
parent = lookup_commit_reference(sha1);
if (!parent)
-   die("no such commit %s", sha1_to_hex(sha1));
+   die(_("no such commit %s"), sha1_to_hex(sha1));
return _list_insert(parent, tail)->next;
 }
 
@@ -2262,13 +2262,13 @@ static void append_merge_parents(struct commit_list 
**tail)
if (merge_head < 0) {
if (errno == ENOENT)
return;
-   die("cannot open '%s' for reading", git_path_merge_head());
+   die(_("cannot open '%s' for reading"), git_path_merge_head());
}
 
while (!strbuf_getwholeline_fd(, merge_head, '\n')) {
unsigned char sha1[20];
if (line.len < 40 || get_sha1_hex(line.buf, sha1))
-   die("unknown line in '%s': %s", git_path_merge_head(), 
line.buf);
+   die(_("unknown line in '%s': %s"), 
git_path_merge_head(), line.buf);
tail = append_parent(tail, sha1);
}
close(merge_head);
@@ -2314,7 +2314,7 @@ static struct commit *fake_working_tree_commit(struct 
diff_options *opt,
parent_tail = >parents;
 
if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_sha1, NULL))
-   die("no such ref: HEAD");
+   die(_("no such ref: HEAD"));
 
parent_tail = append_parent(parent_tail, head_sha1);
append_merge_parents(parent_tail);
@@ -2344,12 +2344,12 @@ static struct commit *fake_working_tree_commit(struct 
diff_options *opt,
 
if (contents_from) {
if (stat(contents_from, ) < 0)
-   die_errno("Cannot stat '%s'", contents_from);
+   die_errno(_("Cannot stat '%s'"), contents_from);
read_from = contents_from;
}
else {
if (lstat(path, ) < 0)
-   die_errno("Cannot lstat '%s'", path);
+   die_errno(_("Cannot lstat '%s'"), path);
read_from = path;
}
mode = canon_mode(st.st_mode);
@@ -2360,21 +2360,21 @@ static struct commit *fake_working_tree_commit(struct 
diff_options *opt,
textconv_object(read_from, mode, null_sha1, 0, 
_ptr, _len))
strbuf_attach(, buf_ptr, buf_len, buf_len + 
1);
else if (strbuf_read_file(, read_from, st.st_size) 
!= st.st_size)
-   die_errno("cannot open or read '%s'", 
read_from);
+   die_errno(_("cannot open or read '%s'"), 
read_from);
break;
case S_IFLNK:
if (strbuf_readlink(, read_from, 

[PATCH 03/22] builtin/checkout.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 builtin/checkout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index cfa66e2..efcbd8f 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -662,7 +662,7 @@ static void update_refs_for_switch(const struct 
checkout_opts *opts,
}
} else if (new->path) { /* Switch branches. */
if (create_symref("HEAD", new->path, msg.buf) < 0)
-   die("unable to update HEAD");
+   die(_("unable to update HEAD"));
if (!opts->quiet) {
if (old->path && !strcmp(new->path, old->path)) {
if (opts->new_branch_force)
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 09/22] credential-cache--daemon.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 credential-cache--daemon.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index 63ca7c8..ab33355 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -98,12 +98,12 @@ static int read_request(FILE *fh, struct credential *c,
 
strbuf_getline_lf(, fh);
if (!skip_prefix(item.buf, "action=", ))
-   return error("client sent bogus action line: %s", item.buf);
+   return error(_("client sent bogus action line: %s"), item.buf);
strbuf_addstr(action, p);
 
strbuf_getline_lf(, fh);
if (!skip_prefix(item.buf, "timeout=", ))
-   return error("client sent bogus timeout line: %s", item.buf);
+   return error(_("client sent bogus timeout line: %s"), item.buf);
*timeout = atoi(p);
 
if (credential_read(c, fh) < 0)
@@ -132,16 +132,16 @@ static void serve_one_client(FILE *in, FILE *out)
remove_credential();
else if (!strcmp(action.buf, "store")) {
if (timeout < 0)
-   warning("cache client didn't specify a timeout");
+   warning(_("cache client didn't specify a timeout"));
else if (!c.username || !c.password)
-   warning("cache client gave us a partial credential");
+   warning(_("cache client gave us a partial credential"));
else {
remove_credential();
cache_credential(, timeout);
}
}
else
-   warning("cache client sent unknown action: %s", action.buf);
+   warning(_("cache client sent unknown action: %s"), action.buf);
 
credential_clear();
strbuf_release();
@@ -160,7 +160,7 @@ static int serve_cache_loop(int fd)
pfd.events = POLLIN;
if (poll(, 1, 1000 * wakeup) < 0) {
if (errno != EINTR)
-   die_errno("poll failed");
+   die_errno(_("poll failed"));
return 1;
}
 
@@ -170,12 +170,12 @@ static int serve_cache_loop(int fd)
 
client = accept(fd, NULL, NULL);
if (client < 0) {
-   warning("accept failed: %s", strerror(errno));
+   warning(_("accept failed: %s"), strerror(errno));
return 1;
}
client2 = dup(client);
if (client2 < 0) {
-   warning("dup failed: %s", strerror(errno));
+   warning(_("dup failed: %s"), strerror(errno));
close(client);
return 1;
}
@@ -195,13 +195,13 @@ static void serve_cache(const char *socket_path, int 
debug)
 
fd = unix_stream_listen(socket_path);
if (fd < 0)
-   die_errno("unable to bind to '%s'", socket_path);
+   die_errno(_("unable to bind to '%s'"), socket_path);
 
printf("ok\n");
fclose(stdout);
if (!debug) {
if (!freopen("/dev/null", "w", stderr))
-   die_errno("unable to point stderr to /dev/null");
+   die_errno(_("unable to point stderr to /dev/null"));
}
 
while (serve_cache_loop(fd))
@@ -211,10 +211,10 @@ static void serve_cache(const char *socket_path, int 
debug)
 }
 
 static const char permissions_advice[] =
-"The permissions on your socket directory are too loose; other\n"
+N_("The permissions on your socket directory are too loose; other\n"
 "users may be able to read your cached credentials. Consider running:\n"
 "\n"
-"  chmod 0700 %s";
+"  chmod 0700 %s");
 static void init_socket_directory(const char *path)
 {
struct stat st;
@@ -223,7 +223,7 @@ static void init_socket_directory(const char *path)
 
if (!stat(dir, )) {
if (st.st_mode & 077)
-   die(permissions_advice, dir);
+   die(_(permissions_advice), dir);
} else {
/*
 * We must be sure to create the directory with the correct 
mode,
@@ -232,9 +232,9 @@ static void init_socket_directory(const char *path)
 * our protected socket.
 */
if (safe_create_leading_directories_const(dir) < 0)
-   die_errno("unable to create directories for '%s'", dir);
+   die_errno(_("unable to create directories for '%s'"), 
dir);
if (mkdir(dir, 0700) < 0)
-   die_errno("unable to mkdir '%s'", dir);
+   die_errno(_("unable to mkdir '%s'"), dir);
}
 
if (chdir(dir))
@@ -253,7 +253,7 @@ int main(int argc, const char **argv)
const 

[PATCH 06/22] builtin/config.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 builtin/config.c | 41 +
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/builtin/config.c b/builtin/config.c
index 98ca43d..b07df26 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -90,7 +90,7 @@ static struct option builtin_config_options[] = {
 static void check_argc(int argc, int min, int max) {
if (argc >= min && argc <= max)
return;
-   error("wrong number of arguments");
+   error(_("wrong number of arguments"));
usage_with_options(builtin_config_usage, builtin_config_options);
 }
 
@@ -213,7 +213,7 @@ static int get_value(const char *key_, const char *regex_)
 
key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
if (regcomp(key_regexp, key, REG_EXTENDED)) {
-   error("invalid key pattern: %s", key_);
+   error(_("invalid key pattern: %s"), key_);
free(key_regexp);
key_regexp = NULL;
ret = CONFIG_INVALID_PATTERN;
@@ -234,7 +234,7 @@ static int get_value(const char *key_, const char *regex_)
 
regexp = (regex_t*)xmalloc(sizeof(regex_t));
if (regcomp(regexp, regex_, REG_EXTENDED)) {
-   error("invalid pattern: %s", regex_);
+   error(_("invalid pattern: %s"), regex_);
free(regexp);
regexp = NULL;
ret = CONFIG_INVALID_PATTERN;
@@ -381,10 +381,10 @@ static void check_write(void)
die(_("not in a git directory"));
 
if (given_config_source.use_stdin)
-   die("writing to stdin is not supported");
+   die(_("writing to stdin is not supported"));
 
if (given_config_source.blob)
-   die("writing config blobs is not supported");
+   die(_("writing config blobs is not supported"));
 }
 
 struct urlmatch_current_candidate_value {
@@ -489,7 +489,7 @@ int cmd_config(int argc, const char **argv, const char 
*prefix)
 
if (use_global_config + use_system_config + use_local_config +
!!given_config_source.file + !!given_config_source.blob > 1) {
-   error("only one config file at a time.");
+   error(_("only one config file at a time."));
usage_with_options(builtin_config_usage, 
builtin_config_options);
}
 
@@ -510,7 +510,7 @@ int cmd_config(int argc, const char **argv, const char 
*prefix)
 * location; error out even if XDG_CONFIG_HOME
 * is set and points at a sane location.
 */
-   die("$HOME not set");
+   die(_("$HOME not set"));
 
if (access_or_warn(user_config, R_OK, 0) &&
xdg_config && !access_or_warn(xdg_config, R_OK, 0))
@@ -540,17 +540,17 @@ int cmd_config(int argc, const char **argv, const char 
*prefix)
}
 
if (HAS_MULTI_BITS(types)) {
-   error("only one type at a time.");
+   error(_("only one type at a time."));
usage_with_options(builtin_config_usage, 
builtin_config_options);
}
 
if ((actions & (ACTION_GET_COLOR|ACTION_GET_COLORBOOL)) && types) {
-   error("--get-color and variable type are incoherent");
+   error(_("--get-color and variable type are incoherent"));
usage_with_options(builtin_config_usage, 
builtin_config_options);
}
 
if (HAS_MULTI_BITS(actions)) {
-   error("only one action at a time.");
+   error(_("only one action at a time."));
usage_with_options(builtin_config_usage, 
builtin_config_options);
}
if (actions == 0)
@@ -563,7 +563,7 @@ int cmd_config(int argc, const char **argv, const char 
*prefix)
}
if (omit_values &&
!(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) {
-   error("--name-only is only applicable to --list or 
--get-regexp");
+   error(_("--name-only is only applicable to --list or 
--get-regexp"));
usage_with_options(builtin_config_usage, 
builtin_config_options);
}
 
@@ -580,10 +580,10 @@ int cmd_config(int argc, const char **argv, const char 
*prefix)
_config_source,
respect_includes) < 0) {
if (given_config_source.file)
-   die_errno("unable to read config file '%s'",
+   die_errno(_("unable to read config file '%s'"),
  given_config_source.file);
else
-   die("error processing config file(s)");
+  

[PATCH 07/22] builtin/update-index.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 builtin/update-index.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index 1c94ca5..21e38a8 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -1127,9 +1127,9 @@ int cmd_update_index(int argc, const char **argv, const 
char *prefix)
break;
case UC_DISABLE:
if (git_config_get_untracked_cache() == 1)
-   warning("core.untrackedCache is set to true; "
-   "remove or change it, if you really want to "
-   "disable the untracked cache");
+   warning(_("core.untrackedCache is set to true; "
+ "remove or change it, if you really want to "
+ "disable the untracked cache"));
remove_untracked_cache(_index);
report(_("Untracked cache disabled"));
break;
@@ -1139,9 +1139,9 @@ int cmd_update_index(int argc, const char **argv, const 
char *prefix)
case UC_ENABLE:
case UC_FORCE:
if (git_config_get_untracked_cache() == 0)
-   warning("core.untrackedCache is set to false; "
-   "remove or change it, if you really want to "
-   "enable the untracked cache");
+   warning(_("core.untrackedCache is set to false; "
+ "remove or change it, if you really want to "
+ "enable the untracked cache"));
add_untracked_cache(_index);
report(_("Untracked cache enabled for '%s'"), 
get_git_work_tree());
break;
@@ -1156,7 +1156,7 @@ int cmd_update_index(int argc, const char **argv, const 
char *prefix)
unable_to_lock_die(get_index_file(), lock_error);
}
if (write_locked_index(_index, lock_file, COMMIT_LOCK))
-   die("Unable to write new index file");
+   die(_("Unable to write new index file"));
}
 
rollback_lock_file(lock_file);
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 04/22] builtin/clone.c: mark strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 builtin/clone.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 9ac6c01..6616392 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -236,8 +236,8 @@ static char *guess_dir_name(const char *repo, int 
is_bundle, int is_bare)
strip_suffix_mem(start, , is_bundle ? ".bundle" : ".git");
 
if (!len || (len == 1 && *start == '/'))
-   die("No directory name could be guessed.\n"
-   "Please specify a directory on the command line");
+   die(_("No directory name could be guessed.\n"
+ "Please specify a directory on the command line"));
 
if (is_bare)
dir = xstrfmt("%.*s.git", (int)len, start);
@@ -644,7 +644,7 @@ static void update_remote_refs(const struct ref *refs,
if (create_symref(head_ref.buf,
  remote_head_points_at->peer_ref->name,
  msg) < 0)
-   die("unable to update %s", head_ref.buf);
+   die(_("unable to update %s"), head_ref.buf);
strbuf_release(_ref);
}
 }
@@ -656,7 +656,7 @@ static void update_head(const struct ref *our, const struct 
ref *remote,
if (our && skip_prefix(our->name, "refs/heads/", )) {
/* Local default branch link */
if (create_symref("HEAD", our->name, NULL) < 0)
-   die("unable to update HEAD");
+   die(_("unable to update HEAD"));
if (!option_bare) {
update_ref(msg, "HEAD", our->old_oid.hash, NULL, 0,
   UPDATE_REFS_DIE_ON_ERR);
@@ -750,7 +750,7 @@ static void write_config(struct string_list *config)
for (i = 0; i < config->nr; i++) {
if (git_config_parse_parameter(config->items[i].string,
   write_one_config, NULL) < 0)
-   die("unable to write parameters to config file");
+   die(_("unable to write parameters to config file"));
}
 }
 
-- 
2.8.0.rc0.205.g7ec8cf1

--
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 00/22] Mark more strings for translation

2016-02-26 Thread Nguyễn Thái Ngọc Duy
On Sat, Feb 27, 2016 at 6:41 AM, Junio C Hamano  wrote:
> In previous cycles, I often left many topics in 'next' when tagging
> this zero-th preview, but eventually merged them before the final.
> I decided to do things a bit differently for this cycle: a topic,
> once it hits 'next', will not be rewound and only refined and
> corrected with incremental updates, so the only effect such a late
> merge to 'master' before the final is that some topics are not as
> widely tested on 'master' before the final one is tagged.
>
> So this -rc0 is deliberately aggressive in that it includes all
> topics that have been cooking in 'next' that I think we can fix bugs
> that might still lurking in them before the final (it merges 25
> topics since the last batch to 'master').  The topics not merged to
> this preview, on the other hand, will not be considered for 2.8
> final, even though I might later succumb to the temptation to pick
> up ones that are in 'next' as of today ;-)

Beautiful. This allows me to fix up all i18n strings in a single
series instead of spreading them across many topics in 'next'. I'm not
sure if there's enough time for translators before release though. It
depends on how many rc- there are and how long it takes for this
series to graduate.

This series marks many strings for translation. It's a result of
looking for new strings between 1.7.2 and 'master', and sometimes
looking around touched files some more.

Most of these are wrapping _() around strings, except 01/22 (enable
gettext) and 20/22 and 21/22, which convert some more strings (they
have been in my queue for a year)

  [01/22] credential-cache--daemon: enable localized messages
  [02/22] builtin/blame.c: mark strings for translation
  [03/22] builtin/checkout.c: mark strings for translation
  [04/22] builtin/clone.c: mark strings for translation
  [05/22] builtin/config.c: mark strings for translation
  [06/22] builtin/config.c: mark strings for translation
  [07/22] builtin/update-index.c: mark strings for translation
  [08/22] convert.c: mark strings for translation
  [09/22] credential-cache--daemon.c: mark strings for translation
  [10/22] http.c: mark strings for translation
  [11/22] ident.c: mark strings for translation
  [12/22] notes.c: mark strings for translation
  [13/22] ref-filter.c: mark strings for translation
  [14/22] refs/files-backend.c: mark strings for translation
  [15/22] remote-curl.c: mark strings for translation
  [16/22] run-command.c: mark strings for translation
  [17/22] sha1_file.c: mark strings for translation
  [18/22] submodule.c: mark strings for translation
  [19/22] trailer.c: mark strings for translation
  [20/22] transport-helper.c: mark strings for translating
  [21/22] transport.c: mark strings for translating
  [22/22] wrapper.c: mark strings for translation

Total 20 files changed, 385 insertions(+), 372 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


[PATCH 01/22] credential-cache--daemon: enable localized messages

2016-02-26 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 credential-cache--daemon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index caef21e..63ca7c8 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -263,6 +263,8 @@ int main(int argc, const char **argv)
OPT_END()
};
 
+   git_setup_gettext();
+
git_config_get_bool("credentialcache.ignoresighup", _sighup);
 
argc = parse_options(argc, argv, NULL, options, usage, 0);
-- 
2.8.0.rc0.205.g7ec8cf1

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


Consulting for implementation

2016-02-26 Thread JOSE
good afternoon GIT Community

We are a group of people interested in using management software versions 
of GIT for the solution of social problems and citizen empowerment in 
smart cities.

I need to speak with a representative of the community, to explain the 
idea and have an advice of the feasibility of the proposal.

Thanks for your time, I´ll wait for your answer.

Sincerely

José from BioRed

[PATCH] add--interactive: allow custom diff highlighting programs

2016-02-26 Thread Jeff King
The patch hunk selector of add--interactive knows how ask
git for colorized diffs, and correlate them with the
uncolored diffs we apply. But there's not any way for
somebody who uses a diff-filter tool like contrib's
diff-highlight to see their normal highlighting.

This patch lets users define an arbitrary shell command to
pipe the colorized diff through. The exact output shouldn't
matter (since we just show the result to humans) as long as
it is line-compatible with the original diff (so that
hunk-splitting can split the colorized version, too).

I left two minor issues with the new system that I don't
think are worth fixing right now, but could be done later:

  1. We only filter colorized diffs. Theoretically a user
 could want to filter a non-colorized diff, but I find
 it unlikely in practice. Users who are doing things
 like diff-highlighting are likely to want color, too.

  2. add--interactive will re-colorize a diff which has been
 hand-edited, but it won't have run through the filter.
 Fixing this is conceptually easy (just pipe the diff
 through the filter), but practically hard to do without
 using tempfiles (it would need to feed data to and read
 the result from the filter without deadlocking; this
 raises portability questions with respect to Windows).

I've punted on both issues for now, and if somebody really
cares later, they can do a patch on top.

Signed-off-by: Jeff King 
---
This is a little hack I whipped up after the diff-so-fancy people asked
me about it in:

  https://github.com/so-fancy/diff-so-fancy/issues/35

It's something I've wanted for a while with diff-highlight. I made sure
it works (the final hunk of this patch was added via highlighted "add
-p". Woohoo!), but other than that it hasn't been exposed to a lot of
corner cases.

I'm actually not sure whether it will work well with diff-so-fancy or
not; they change the diff header around a bit, and there's not a
complete 1:1 correspondence in the lines. _But_ I think it might work OK
in practice, because their diff header remains 4 lines long, and the
hunks themselves have 1:1 line correspondence.

 Documentation/config.txt  |  8 
 git-add--interactive.perl | 12 ++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 2cd6bdd..f5834ec 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1886,6 +1886,14 @@ interactive.singleKey::
setting is silently ignored if portable keystroke input
is not available; requires the Perl module Term::ReadKey.
 
+interactive.diffFilter::
+   When an interactive command (such as `git add --patch`) shows
+   a colorized diff, git will pipe the diff through the shell
+   command defined by this configuration variable. The command may
+   mark up the diff further for human consumption, provided that it
+   retains a one-to-one correspondence with the lines in the
+   original diff. Defaults to disabled (no filtering).
+
 log.abbrevCommit::
If true, makes linkgit:git-log[1], linkgit:git-show[1], and
linkgit:git-whatchanged[1] assume `--abbrev-commit`. You may
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 77876d4..822f857 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -45,6 +45,7 @@ my ($diff_new_color) =
 my $normal_color = $repo->get_color("", "reset");
 
 my $diff_algorithm = $repo->config('diff.algorithm');
+my $diff_filter = $repo->config('interactive.difffilter');
 
 my $use_readkey = 0;
 my $use_termcap = 0;
@@ -754,7 +755,14 @@ sub parse_diff {
my @diff = run_cmd_pipe("git", @diff_cmd, "--", $path);
my @colored = ();
if ($diff_use_color) {
-   @colored = run_cmd_pipe("git", @diff_cmd, qw(--color --), 
$path);
+   my @display_cmd = ("git", @diff_cmd, qw(--color --), $path);
+   if (defined $diff_filter) {
+   # quotemeta is overkill, but sufficient for 
shell-quoting
+   my $diff = join(' ', map { quotemeta } @display_cmd);
+   @display_cmd = ("$diff | $diff_filter");
+   }
+
+   @colored = run_cmd_pipe(@display_cmd);
}
my (@hunk) = { TEXT => [], DISPLAY => [], TYPE => 'header' };
 
@@ -765,7 +773,7 @@ sub parse_diff {
}
push @{$hunk[-1]{TEXT}}, $diff[$i];
push @{$hunk[-1]{DISPLAY}},
-   ($diff_use_color ? $colored[$i] : $diff[$i]);
+   (@colored ? $colored[$i] : $diff[$i]);
}
return @hunk;
 }
-- 
2.7.2.767.g705917e
--
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/RFC] builtin/tag: Changes argument format for verify

2016-02-26 Thread Jeff King
On Fri, Feb 26, 2016 at 07:27:44PM -0500, santi...@nyu.edu wrote:

> From: Santiago Torres 
> 
> The verify tag function converts the commit sha1 to hex and passes it as
> a command-line argument to builtin/verify-tag. Given that builtin/verify-tag
> already resolves the ref name sha1 equivalent, the sha1 to
> hex_sha1 conversion is unnecessary and the ref-name can be used instead.

Hrm. This is potentially racy, if git-tag is going to say something
about the ref, but git-verify-tag may have actually verified another tag
entirely.

AFAICT, though, git-tag doesn't say anything, and is just purely
forwarding work to verify-tag. So I can't see a real downside to passing
in the ref name, except that it is slightly less efficient (because
verify_tag has to re-resolve it). But...

> diff --git a/builtin/tag.c b/builtin/tag.c
> index 1705c94..5de1161 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -105,8 +105,7 @@ 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);
> + "-v", name, NULL};

You are passing in "name" here, not "ref". git-tag knows it is operating
specifically on tags, and completes a name like "foo" to
"refs/tags/foo". Whereas verify-tag is plumbing that can operate on any
ref, and will do the usual lookup for "foo", "refs/heads/foo",
"refs/tags/foo", etc.

So by passing the unqualified name, we may end up finding something
entirely different, generating "ambiguous name" errors, etc. So if we
_were_ to go this route, I think we'd need to use "ref" here, not
"name".

But I'm not really sure I see the upside.

A much more interesting change in this area, I think, would be to skip
verify-tag entirely. Once upon a time it had a lot of logic itself, but
these days it is a thin wrapper over run_gpg_verify(), and we could
improve the efficiency quite a bit by eliminates the sub-process
entirely.

-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 v6 28/32] config: read ref storage config on startup

2016-02-26 Thread Jeff King
On Fri, Feb 26, 2016 at 10:56:34PM -0500, Jeff King wrote:

> My second confusion is why this is happening in git_config_early(). That
> function is called during the setup of check_repository_format_gently(),
> which is why I think you wanted to put the code here. But it's _also_
> called as part of a regular git_config(). Which means we're parsing the
> repo config and setting the ref backend all over again, every time we
> look at config for other reasons.
> 
> So I think this setup probably should be in
> check_repository_format_gently(), and should be able to trigger off of
> the existing ref_storage_backend string we've already saved (and we
> should bail immediately there if we don't know about the backend, as it
> means we _don't_ match the repo's extensions and cannot proceed).

By the way, I notice that the default value for the_refs_backend is
"_be_files". It might be safer to make this NULL (or some
_be_null that fills the vtable, but just returns an error for each
call).

Then in check_repository_format_gently(), do:

  if (!ref_storage_backend || !*ref_storage_backend)
refs_backend_storage = "files";
  set_ref_storage_backend(ref_storage_backend);

That way you could be sure that the backend has been initialized from
the config, and never blindly falls back to the "files" backend.  If
there is any code path where we try to access refs but the_refs_backend
is null, that's a bug that needs fixing. But it's a lot easier to find
such bugs if we die loudly in that case rather than silently using
"files".

-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 v6 05/32] refs: add a backend method structure with transaction functions

2016-02-26 Thread Jeff King
On Wed, Feb 24, 2016 at 05:58:37PM -0500, David Turner wrote:

> +int set_ref_storage_backend(const char *name)
> +{
> + struct ref_storage_be *be;
> +
> + for (be = refs_backends; be; be = be->next)
> + if (!strcmp(be->name, name)) {
> + the_refs_backend = be;
> + return 0;
> + }
> + return 1;
> +}

So we search through the list and assign the_refs_backend if we find
something, returning 0 for success, and 1 if we found nothing. OK
(though our usual convention is that if 0 is success, -1 is the error
case).

> +int ref_storage_backend_exists(const char *name)
> +{
> + struct ref_storage_be *be;
> +
> + for (be = refs_backends; be; be = be->next)
> + if (!strcmp(be->name, name)) {
> + the_refs_backend = be;
> + return 1;
> + }
> + return 0;
> +}

Here we do the same thing, but we get "1" for exists, and "0"
otherwise. That makes sense if this is about querying for existence. But
why does the query function still set the_refs_backend?

I'm guessing the assignment in the second one is just copy-pasta, but
maybe the whole thing would be simpler if they could share the
implementation, like:

  struct ref_storage_be *find_ref_storage_backend(const char *name)
  {
struct ref_storage *be;
for (be = refs_backends; be; be = be->next)
if (!strcmp(be->name, name))
return be;
return NULL;
  }

  int set_ref_storage_backend(const char *name)
  {
struct ref_storage *be = find_ref_storage_backend(name);
if (!be)
return -1;
the_refs_backend = be;
return 0;
  }

You don't really need an "exists", as you can check that "find" doesn't
return NULL, but you could wrap it, of course.

-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 v6 28/32] config: read ref storage config on startup

2016-02-26 Thread Jeff King
On Wed, Feb 24, 2016 at 05:59:00PM -0500, David Turner wrote:

> @@ -1207,6 +1208,29 @@ int git_config_early(config_fn_t fn, void *data, const 
> char *repo_config)
>   }
>  
>   if (repo_config && !access_or_die(repo_config, R_OK, 0)) {
> + char *storage = NULL;
> +
> + /*
> +  * make sure we always read the ref storage config
> +  * from the extensions section on startup
> +  */
> + ret += git_config_from_file(ref_storage_backend_config,
> + repo_config, );
> +
> + register_ref_storage_backends();
> + if (!storage)
> + storage = xstrdup("");
> +
> + if (!*storage ||
> + !strcmp(storage, "files")) {
> + /* default backend, nothing to do */
> + free(storage);
> + } else {
> + if (set_ref_storage_backend(ref_storage_backend))
> + die(_("Unknown ref storage backend %s"),
> + ref_storage_backend);
> + }
> +

Coverity complains that "storage" leaks here, and I think it does in the
case that we non-default storage, and we successfully set up the
backend. That's a pretty minor point.

However, after looking at this code, I'm rather confused about a few
things.

One is that we read the config and use ref_storage_backend_config[1] to
store the string value in "storage", and then we check whether that is
non-default, and if it is, I'd expect us to feed it to
set_ref_storage_backend. But we don't; we feed ref_storage_backend
instead!

What is that value? It looks like it is the string we set in
check_repo_format when we load the extensions list there. So why
are we re-reading the config here at all? Couldn't we just use
ref_storage_backend in the first place?

My second confusion is why this is happening in git_config_early(). That
function is called during the setup of check_repository_format_gently(),
which is why I think you wanted to put the code here. But it's _also_
called as part of a regular git_config(). Which means we're parsing the
repo config and setting the ref backend all over again, every time we
look at config for other reasons.

So I think this setup probably should be in
check_repository_format_gently(), and should be able to trigger off of
the existing ref_storage_backend string we've already saved (and we
should bail immediately there if we don't know about the backend, as it
means we _don't_ match the repo's extensions and cannot proceed).

-Peff

[1] The ref_storage_backend_config function uses xstrdup(), which I
think will segfault for a value-less boolean config, like:

  [extensions]
  # notice no "=" sign!
  refstorage

The same bug is in check_repo_format, where we assigned
ref_storage_backend. The normal way to do this is to use:

  return git_config_string(var, value, _backend_storage);

which checks for the boolean case and complains.
--
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: What's cooking in git.git (Feb 2016, #07; Thu, 25)

2016-02-26 Thread Jeff King
On Fri, Feb 26, 2016 at 03:35:10PM -0800, Junio C Hamano wrote:

> > Digging means:
> > run git bisect and report the commit.
> > And this makes the compiler happy:
> >   Revert "tree-diff: catch integer overflow in combine_diff_path allocation"
> 
> So?
> 
> Identifying two versions of the same C file, for one of which the
> Apple compiler does not give you "internal compiler error" and for
> the other it does, may help Apple engineers to debug their compiler.
> 
> But we cannot and will not revert any of our code only because some
> vendor compiler is broken.  It would be a different story if we were
> throwing an invalid C at compilers and relying on a bug in GCC that
> accepts an invalid code, but I do not think that is the case here.

I think knowing the commit that causes the problem is interesting for
us, because it lets us see whether we are throwing invalid C at the
compiler or not (the compiler should never segfault, obviously, but I
can believe that it is more likely to if you throw garbage at it).

But that commit is one of the tamest, I think; it just seems like a
boring compiler bug.  I'd be curious to reduce it to a minimal change
that causes the bug, just to be sure.

Torsten, what is the compiler version (I don't have Apple compilers, but
it seems plausible that older clang might have the same problem).

-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 2/2] Revert "rev-parse: remove restrictions on some options"

2016-02-26 Thread Jeff King
On Fri, Feb 26, 2016 at 03:44:01PM -0800, Junio C Hamano wrote:

> But why do you even need to run local-env-vars from outside a
> repository in the first place?

The short answer is: because it is about clearing the state to move into
a new repository, and we do not necessarily know what the old state was.

Here's a longer answer.

We (GitHub) have some scripts that preemptively clear the git env when
moving into another repository directory, so that the environment
doesn't lead to us operating in the wrong repository.

For example, we use alternates to share object storage between a series
of forks. So frequently in such scripts we may need to switch between
repositories (e.g., to sync a fork to the shared storage, and then go
back to the shared storage and run repack). To do so safely, we have to
clear the git env for each "cd" (otherwise things work fine when
$GIT_DIR is not set and we rely on auto-finding the repo, and break
horribly if the script is run with $GIT_DIR set).

There are a few corner cases where library code wants to "cd", but
doesn't know if it's coming from another repo or not.  So it clears the
git env to be on the safe side. We could fix it by always going to the
new repo and running "unset $(git rev-parse --local-env-vars)" there,
but I think that just has the opposite problem (you may be _leaving_ a
repository, and want to make sure you are no longer in one).

For us, it's mostly just an annoyance. rev-parse produces no output so
we don't clear any variables, and its stderr gets logged somewhere. We
really only care about $GIT_DIR, and if that is set to something valid,
then you are in a repo, rev-parse works, and we clear it. But you can
come up with cases where it does the wrong thing, like:

  # Work in some repo; set some git vars in the environment, but
  # rely on auto-discovery to find the actual repo.
  cd some-git-repo
  export GIT_WORK_TREE=/whatever
  git ...

  # Now go back to our root and do some work elsewhere.
  # We're no longer in a git repo.
  cd ..
  ... run some non-git commands ...

  # Now we want to go into a new repo. Clear the environment.
  unset $(git rev-parse --local-env-vars)
  cd ../another-git-repo
  git ...

In the third directory, you'd still have GIT_WORK_TREE set, even though
you asked to clear existing git state.

I don't think we have any scripts that do that, but it doesn't seem that
implausible to me.

-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/RFD 3/6] rev-list: list all heads with --all

2016-02-26 Thread Duy Nguyen
On Fri, Feb 26, 2016 at 11:39 PM, Michael J Gruber
 wrote:
> HEAD is a worktree specific sysmref, so that a repository with multiple
> worktrees can have multiple HEADs, or HEADs in a worktree different from
> the current worktree.
>
> So far, "rev-parse --all" adds only the HEAD from the current worktree
> to the list of refs (besides branches etc.). So, a detached HEAD from a
> different checkout would be missed unless a shared ref (or current HEAD)
> points to it (or descents from it). As a consequence, "git prune" can
> prune detached HEADs from worktrees and leave the repo in an
> inconsistent state.
>
> Make "rev-parse --all" add the HEADs from all worktrees. This results in
> a non-worktree-specific ref list and solves the pruning problem.
>
> Signed-off-by: Michael J Gruber 
> ---
>
> Notes:
> This patch solves the pruning problem with worktrees, but I feel quite
> uneasy about substituting the ref solving at the very heart of refs.c. So
> please consider this a mere poc and a request for discussion/input
> about how to do this the right way.
>
> In essence, I feel the worktree interface still has to evolve a bit: I'd
> rather for_each_worktree than loop myself, and if many call sites need to
> be aware of multiple heads or worktrees than get_worktrees() should be
> part of our init stuff, not here. [I may be out of sync of newer 
> progress.]

How about adding for_each_head_ref_submodule()  and make
handle_revision_pseudo_opt() use it with a new option, .e.g
--all-work-trees?

I looked over head_ref and head_ref_submodule call sites. I think
we're ok. Most of them only concern about "our head". for-each-ref may
need some improvement though.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] recursive submodules: paths are hard

2016-02-26 Thread Duy Nguyen
On Sat, Feb 27, 2016 at 3:51 AM, Stefan Beller  wrote:
> I think we may need to enable Git to pass in 'negative' pathes for the prefix,
> i.e.
>   Although operating on this repository, your reference for displaying paths
>   should be '../untracked' for the example above, when the submodule is in the
>   root directory of the superproject.
>
> This seems currently not possible with the standard way to pass down the 
> prefix.

The problem is, prefix is meant for inside worktree area only. Many
code paths are not ready for prefix "../". Worse, in some cases when
you launch outside worktree, prefix is empty and I think some builtin
commands rely on that. However, I think you can introduce "prefix v2"
that is used in parallel with "prefix v1".
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/3] pass credential.* to submodules

2016-02-26 Thread Jacob Keller
On Fri, Feb 26, 2016 at 4:13 PM, Jacob Keller  wrote:
> From: Jacob Keller 
>
> This version of the series fixes up a few issues and implements
> sq_quotef function to help make intent more clear in the code. I also
> chose to use Jeff's implementation for the test fix since I think it
> works better and I prefer the consistency of implementation.
>

Junio, I didn't use -4 when sending email so the patch which fixes
apache.conf is not here. I still need it myself for running the test,
so it should be queued somehow.

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


[PATCH/RFC] builtin/tag: Changes argument format for verify

2016-02-26 Thread santiago
From: Santiago Torres 

The verify tag function converts the commit sha1 to hex and passes it as
a command-line argument to builtin/verify-tag. Given that builtin/verify-tag
already resolves the ref name sha1 equivalent, the sha1 to
hex_sha1 conversion is unnecessary and the ref-name can be used instead.

Signed-off-by: Santiago Torres 
---
 builtin/tag.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/builtin/tag.c b/builtin/tag.c
index 1705c94..5de1161 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -105,8 +105,7 @@ 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);
+   "-v", name, NULL};
 
if (run_command_v_opt(argv_verify_tag, RUN_GIT_CMD))
return error(_("could not verify the tag '%s'"), name);
-- 
2.7.0.435.g70bd996.dirty

--
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 v5 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

Due to the way that the git-submodule code works, it clears all local
git environment variables before entering submodules. This is normally
a good thing since we want to clear settings such as GIT_WORKTREE and
other variables which would affect the operation of submodule commands.
However, GIT_CONFIG_PARAMETERS is special, and we actually do want to
preserve these settings. However, we do not want to preserve all
configuration as many things should be left specific to the parent
project.

Add a git submodule--helper function, sanitize-config, which shall be
used to sanitize GIT_CONFIG_PARAMETERS, removing all key/value pairs
except a small subset that are known to be safe and necessary.

Replace all the calls to clear_local_git_env with a wrapped function
that filters GIT_CONFIG_PARAMETERS using the new helper and then
restores it to the filtered subset after clearing the rest of the
environment.

Signed-off-by: Jacob Keller 
---

Notes:
- v2
* Clarify which paramaters are left after the sanitization, and don't seem 
to
  indicate it is our goal to extend the list.
* add a comment in the submodule_config_ok function indicating the same

- v3
* Remove extraneous comments
* add strbuf_release calls
* rename sanitize_local_git_env
* remove use of local
* add C equivalent of sanitize_config
* add a test for the credential passing

- v4
* use argc check instead of empty options check
* fix brain-melting quotes in t7412-submodule--helper.sh

- v5
* use new sq_quote_f
* fix test to use ${sq} style to prevent need of complex quotes or the use 
of
  double quotes on the test body

 builtin/submodule--helper.c  | 68 +++-
 git-submodule.sh | 36 ++-
 t/t5550-http-fetch-dumb.sh   | 17 +++
 t/t7412-submodule--helper.sh | 26 +
 4 files changed, 133 insertions(+), 14 deletions(-)
 create mode 100755 t/t7412-submodule--helper.sh

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 072d9bbd12a8..43943eef81b4 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -124,6 +124,55 @@ static int module_name(int argc, const char **argv, const 
char *prefix)
 
return 0;
 }
+
+/*
+ * Rules to sanitize configuration variables that are Ok to be passed into
+ * submodule operations from the parent project using "-c". Should only
+ * include keys which are both (a) safe and (b) necessary for proper
+ * operation.
+ */
+static int submodule_config_ok(const char *var)
+{
+   if (starts_with(var, "credential."))
+   return 1;
+   return 0;
+}
+
+static int sanitize_submodule_config(const char *var, const char *value, void 
*data)
+{
+   struct strbuf quoted = STRBUF_INIT;
+   struct strbuf *out = data;
+
+   if (submodule_config_ok(var)) {
+   if (out->len)
+   strbuf_addch(out, ' ');
+
+   sq_quotef(out, "%s=%s", var, value);
+   }
+
+   strbuf_release();
+
+   return 0;
+}
+
+static void prepare_submodule_repo_env(struct argv_array *out)
+{
+   const char * const *var;
+
+   for (var = local_repo_env; *var; var++) {
+   if (!strcmp(*var, CONFIG_DATA_ENVIRONMENT)) {
+   struct strbuf sanitized_config = STRBUF_INIT;
+   git_config_from_parameters(sanitize_submodule_config,
+  _config);
+   argv_array_pushf(out, "%s=%s", *var, 
sanitized_config.buf);
+   strbuf_release(_config);
+   } else {
+   argv_array_push(out, *var);
+   }
+   }
+
+}
+
 static int clone_submodule(const char *path, const char *gitdir, const char 
*url,
   const char *depth, const char *reference, int quiet)
 {
@@ -145,7 +194,7 @@ static int clone_submodule(const char *path, const char 
*gitdir, const char *url
argv_array_push(, path);
 
cp.git_cmd = 1;
-   cp.env = local_repo_env;
+   prepare_submodule_repo_env(_array);
cp.no_stdin = 1;
 
return run_command();
@@ -258,6 +307,22 @@ static int module_clone(int argc, const char **argv, const 
char *prefix)
return 0;
 }
 
+static int module_sanitize_config(int argc, const char **argv, const char 
*prefix)
+{
+   struct strbuf sanitized_config = STRBUF_INIT;
+
+   if (argc > 1)
+   usage(_("git submodule--helper sanitize-config"));
+
+   git_config_from_parameters(sanitize_submodule_config, 
_config);
+   if (sanitized_config.len)
+   printf("%s\n", sanitized_config.buf);
+
+   strbuf_release(_config);
+
+   return 0;
+}
+
 struct cmd_struct {
const char *cmd;
int (*fn)(int, const char **, const char *);
@@ 

[PATCH v5 2/3] quote: implement sq_quotef()

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

Signed-off-by: Jacob Keller 
---
 quote.c | 13 +
 quote.h |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/quote.c b/quote.c
index fe884d24521f..b281a8fe454e 100644
--- a/quote.c
+++ b/quote.c
@@ -43,6 +43,19 @@ void sq_quote_buf(struct strbuf *dst, const char *src)
free(to_free);
 }
 
+void sq_quotef(struct strbuf *dst, const char *fmt, ...)
+{
+   struct strbuf src = STRBUF_INIT;
+
+   va_list ap;
+   va_start(ap, fmt);
+   strbuf_vaddf(, fmt, ap);
+   va_end(ap);
+
+   sq_quote_buf(dst, src.buf);
+   strbuf_release();
+}
+
 void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
 {
int i;
diff --git a/quote.h b/quote.h
index 99e04d34bf22..6c53a2cc66c4 100644
--- a/quote.h
+++ b/quote.h
@@ -25,10 +25,13 @@ struct strbuf;
  * sq_quote_buf() writes to an existing buffer of specified size; it
  * will return the number of characters that would have been written
  * excluding the final null regardless of the buffer size.
+ *
+ * sq_quotef() quotes the entire formatted string as a single result.
  */
 
 extern void sq_quote_buf(struct strbuf *, const char *src);
 extern void sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
+extern void sq_quotef(struct strbuf *, const char *fmt, ...);
 
 /* This unwraps what sq_quote() produces in place, but returns
  * NULL if the input does not look like what sq_quote would have
-- 
2.7.1.429.g45cd78e

--
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 v5 0/3] pass credential.* to submodules

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

This version of the series fixes up a few issues and implements
sq_quotef function to help make intent more clear in the code. I also
chose to use Jeff's implementation for the test fix since I think it
works better and I prefer the consistency of implementation.

Interdiff between v4 and v5:

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c6c0a3b06e27..43943eef81b4 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -147,16 +147,7 @@ static int sanitize_submodule_config(const char *var, 
const char *value, void *d
if (out->len)
strbuf_addch(out, ' ');
 
-   /*
-* The GIT_CONFIG_PARAMETERS parser is a bit picky and
-* requires that each var=value pair be quoted as a single
-* unit.
-*/
-   strbuf_addstr(, var);
-   strbuf_addch(, '=');
-   strbuf_addstr(, value);
-
-   sq_quote_buf(out, quoted.buf);
+   sq_quotef(out, "%s=%s", var, value);
}
 
strbuf_release();
diff --git a/quote.c b/quote.c
index fe884d24521f..b281a8fe454e 100644
--- a/quote.c
+++ b/quote.c
@@ -43,6 +43,19 @@ void sq_quote_buf(struct strbuf *dst, const char *src)
free(to_free);
 }
 
+void sq_quotef(struct strbuf *dst, const char *fmt, ...)
+{
+   struct strbuf src = STRBUF_INIT;
+
+   va_list ap;
+   va_start(ap, fmt);
+   strbuf_vaddf(, fmt, ap);
+   va_end(ap);
+
+   sq_quote_buf(dst, src.buf);
+   strbuf_release();
+}
+
 void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
 {
int i;
diff --git a/quote.h b/quote.h
index 99e04d34bf22..6c53a2cc66c4 100644
--- a/quote.h
+++ b/quote.h
@@ -25,10 +25,13 @@ struct strbuf;
  * sq_quote_buf() writes to an existing buffer of specified size; it
  * will return the number of characters that would have been written
  * excluding the final null regardless of the buffer size.
+ *
+ * sq_quotef() quotes the entire formatted string as a single result.
  */
 
 extern void sq_quote_buf(struct strbuf *, const char *src);
 extern void sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
+extern void sq_quotef(struct strbuf *, const char *fmt, ...);
 
 /* This unwraps what sq_quote() produces in place, but returns
  * NULL if the input does not look like what sq_quote would have
diff --git a/t/t7412-submodule--helper.sh b/t/t7412-submodule--helper.sh
index 9d937de8b224..149d42864f29 100755
--- a/t/t7412-submodule--helper.sh
+++ b/t/t7412-submodule--helper.sh
@@ -16,12 +16,11 @@ test_expect_success 'sanitize-config clears configuration' '
test_must_be_empty actual
 '
 
-test_expect_success 'sanitize-config keeps credential.helper' "
+sq="'"
+test_expect_success 'sanitize-config keeps credential.helper' '
git -c credential.helper=helper submodule--helper sanitize-config 
>actual &&
-   cat >expect <<-EOF &&
-   'credential.helper=helper'
-   EOF
+   echo "${sq}credential.helper=helper${sq}" >expect &&
test_cmp expect actual
-"
+'
 
 test_done

Jacob Keller (3):
  sumodule--helper: fix submodule--helper clone usage and check argc
count
  quote: implement sq_quotef()
  git: submodule honor -c credential.* from command line

 builtin/submodule--helper.c  | 73 ++--
 git-submodule.sh | 40 +++-
 quote.c  | 13 
 quote.h  |  3 ++
 t/t5550-http-fetch-dumb.sh   | 17 +++
 t/t7412-submodule--helper.sh | 26 
 6 files changed, 155 insertions(+), 17 deletions(-)
 create mode 100755 t/t7412-submodule--helper.sh

-- 
2.7.1.429.g45cd78e

--
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 v5 1/3] sumodule--helper: fix submodule--helper clone usage and check argc count

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

git submodule--helper clone usage specified that paths come after the --
as a sequence. However, the actual implementation does not, and requires
only a single path passed in via --path. In addition, argc was
unchecked. (allowing arbitrary extra arguments that were silently
ignored).

Fix the usage description to match implementation. Add an argc check to
enforce no extra arguments. Fix a bug in the argument passing in
git-submodule.sh which would pass --reference and --depth as empty
strings when they were unused, resulting in extra argc after parsing
options.

Signed-off-by: Jacob Keller 
---
 builtin/submodule--helper.c | 5 -
 git-submodule.sh| 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index f4c3eff179b5..072d9bbd12a8 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -187,13 +187,16 @@ static int module_clone(int argc, const char **argv, 
const char *prefix)
const char *const git_submodule_helper_usage[] = {
N_("git submodule--helper clone [--prefix=] [--quiet] "
   "[--reference ] [--name ] [--url ]"
-  "[--depth ] [--] [...]"),
+  "[--depth ] [--path ]"),
NULL
};
 
argc = parse_options(argc, argv, prefix, module_clone_options,
 git_submodule_helper_usage, 0);
 
+   if (argc)
+   usage(*git_submodule_helper_usage);
+
strbuf_addf(, "%s/modules/%s", get_git_dir(), name);
sm_gitdir = strbuf_detach(, NULL);
 
diff --git a/git-submodule.sh b/git-submodule.sh
index 9bc5c5f94d1d..2dd29b3df0e6 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -347,7 +347,7 @@ Use -f if you really want to add it." >&2
echo "$(eval_gettext "Reactivating local git 
directory for submodule '\$sm_name'.")"
fi
fi
-   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
"$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" "$reference" 
"$depth" || exit
+   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
"$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" 
${reference:+"$reference"} ${depth:+"$depth"} || exit
(
clear_local_git_env
cd "$sm_path" &&
@@ -709,7 +709,7 @@ Maybe you want to use 'update --init'?")"
 
if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
then
-   git submodule--helper clone ${GIT_QUIET:+--quiet} 
--prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" "$reference" 
"$depth" || exit
+   git submodule--helper clone ${GIT_QUIET:+--quiet} 
--prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" 
${reference:+"$reference"} ${depth:+"$depth"} || exit
cloned_modules="$cloned_modules;$name"
subsha1=
else
-- 
2.7.1.429.g45cd78e

--
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 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Jacob Keller
On Fri, Feb 26, 2016 at 2:20 PM, Jacob Keller  wrote:
>> that is slightly more verbose, but it does let us keep the main body
>> inside single-quotes, without restoring to confusing backslash escaping.
>>
>
> I think I prefer the double quotes myself but will use this if people prefer?
>
>> -Peff

On second thought, I'd prefer consistency and I think using single
quotes is probably better, so I'll use this solution in v5.

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


Re: What's cooking in git.git (Feb 2016, #08; Fri, 26)

2016-02-26 Thread Stefan Beller
On Fri, Feb 26, 2016 at 3:41 PM, Junio C Hamano  wrote:

> * sb/submodule-parallel-update (2016-02-25) 11 commits
>  - clone: allow an explicit argument for parallel submodule clones
>  - submodule update: expose parallelism to the user
>  - git submodule update: have a dedicated helper for cloning
>  - run_processes_parallel: correctly terminate callbacks with an LF
>  - run_processes_parallel: rename parameters for the callbacks
>  - run-command: expose default_{start_failure, task_finished}
>  - run_processes_parallel: treat output of children as byte array
>  - submodule update: direct error message to stderr
>  - fetching submodules: respect `submodule.fetchJobs` config option
>  - submodule-config: drop check against NULL
>  - submodule-config: keep update strategy around
>  (this branch is used by dt/refs-backend-lmdb and sb/submodule-init.)
>
>  A major part of "git submodule update" has been ported to C to take
>  advantage of the recently added framework to run download tasks in
>  parallel.
>
>  Seems to break tests when merged to the tip of 'pu'.

There was a version (v17[1]) which broke tests,
v18 seemed fine by Jonathan except for a small nit (the prefix handling[2])
v19 reverted that nit to an earlier version, which Jonathan seemed fine with.
IIUC, v19[3] is reviewed by Jonathan, no complaints found.

Please pick that latest version.

Thanks,
Stefan


[1] http://thread.gmane.org/gmane.comp.version-control.git/287319/focus=287447
[2] http://thread.gmane.org/gmane.comp.version-control.git/287319/focus=287489
[3] http://thread.gmane.org/gmane.comp.version-control.git/287500
--
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 2/2] Revert "rev-parse: remove restrictions on some options"

2016-02-26 Thread Junio C Hamano
Jeff King  writes:

> On Fri, Feb 26, 2016 at 06:29:57PM -0500, Jeff King wrote:
>
>> The best solution here would be to have a full parsing loop
>> that handles all options, but only calls setup_git_directory
>> as appropriate. Unfortunately, that's a bit complicated to
>> implement. We _have_ to handle each option in the order it
>> appears on the command line. If the caller asked for:
>> 
>>   git rev-parse --resolve-git-dir foo/.git --show-toplevel
>> 
>> then it must receive the two lines of output in the correct
>> to know which is which. But asking for:
>> 
>>   git rev-parse --show-toplevel --resolve-git-dir foo/.git
>> 
>> is weird; we have to setup_git_directory() for the first
>> option.
>> 
>> So any implementation would probably have to either:
>> 
>>   - make two passes over the options, first figuring out
>> whether we need a git-dir, and then actually handling
>> the options. That's possible, but it's probably not
>> worth the trouble.
>> 
>>   - call setup_git_directory() on the fly when an option
>> needs it; that requires annotating all of the options,
>> and there are a considerable number of them.
>
> Having just sent this, of course, it occurs to me that a loop like:
>
>setup_git_directory_gently();
>for (i = 0; i < argc; i++) {
>   if (!strcmp(argv[i], "--local-env-vars"))
>   ... and other nongit-ok options ...
>   
>   if (nongit)
>   die("need a repo");
>   
>   if (!strcmp(argv[i], "--git-dir"))
>   ... and other options ...
>}
>
> would probably work. It does still leave things like --parseopt and
> --sq-quote as one-offs, though, because they consume the rest of the
> command line. And the fact remains that --local-repo-env isn't really
> suitable for use with other options.
>
> So I'm still tempted by this "lazy" approach.
>
> -Peff

Yup.

But why do you even need to run local-env-vars from outside a
repository in the first place?

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


[ANNOUNCE] Git v2.8.0-rc0

2016-02-26 Thread Junio C Hamano
An early preview release Git v2.8.0-rc0 is now available for
testing at the usual places.  It is comprised of 436 non-merge
commits since v2.7.0, contributed by 58 people, 19 of which are
new faces.

The tarballs are found at:

https://www.kernel.org/pub/software/scm/git/testing/

The following public repositories all have a copy of the
'v2.8.0-rc0' tag and the 'master' branch that the tag points at:

  url = https://kernel.googlesource.com/pub/scm/git/git
  url = git://repo.or.cz/alt-git.git
  url = git://git.sourceforge.jp/gitroot/git-core/git.git
  url = git://git-core.git.sourceforge.net/gitroot/git-core/git-core
  url = https://github.com/gitster/git

New contributors whose contributions weren't in v2.7.0 are as follows.
Welcome to the Git development community!

  마누엘, Andrew Wheeler, Changwoo Ryu, Christoph Egger,
  Dan Aloni, Dave Ware, David A. Wheeler, Dickson Wong, Felipe
  Gonçalves Assis, GyuYong Jung, Jon Griffiths, Kazutoshi Satoda,
  Lars Vogel, Martin Amdisen, Matthew Kraai, Paul Wagland, Rob
  Mayoff, Romain Picard, and Victor Leschuk.

Returning contributors who helped this release are as follows.
Thanks for your continued support.

  Alexander Kuleshov, Alex Henrie, brian m. carlson, Christian
  Couder, David A. Greene, David Turner, Dennis Kaarsemaker,
  Edmundo Carmona Antoranz, Elia Pinto, Eric Wong, Jacob Keller,
  Jeff King, Johannes Schindelin, Johannes Sixt, John Keeping,
  Jonathan Nieder, Junio C Hamano, Karsten Blees, Karthik Nayak,
  Knut Franke, Lars Schneider, Matthieu Moy, Matt McCutchen,
  Michael J Gruber, Mike Hommey, Nguyễn Thái Ngọc Duy,
  Øyvind A. Holm, Patrick Steinhardt, Pat Thoyts, Sebastian
  Schuberth, Shawn O. Pearce, Stefan Beller, Stephen P. Smith,
  SZEDER Gábor, Thomas Braun, Thomas Gummerer, Tobias Klauser,
  Torsten Bögershausen, and Will Palmer.



Git 2.8 Release Notes (draft)
=

Backward compatibility note
---

The rsync:// transport has been removed.


Updates since v2.7
--

UI, Workflows & Features

 * It turns out "git clone" over rsync transport has been broken when
   the source repository has packed references for a long time, and
   nobody noticed nor complained about it.

 * "branch --delete" has "branch -d" but "push --delete" does not.

 * "git blame" learned to produce the progress eye-candy when it takes
   too much time before emitting the first line of the result.

 * "git grep" can now be configured (or told from the command line)
   how many threads to use when searching in the working tree files.

 * Some "git notes" operations, e.g. "git log --notes=", should
   be able to read notes from any tree-ish that is shaped like a notes
   tree, but the notes infrastructure required that the argument must
   be a ref under refs/notes/.  Loosen it to require a valid ref only
   when the operation would update the notes (in which case we must
   have a place to store the updated notes tree, iow, a ref).

 * "git grep" by default does not fall back to its "--no-index"
   behaviour outside a directory under Git's control (otherwise the
   user may by mistake end up running a huge recursive search); with a
   new configuration (set in $HOME/.gitconfig--by definition this
   cannot be set in the config file per project), this safety can be
   disabled.

 * "git pull --rebase" has been extended to allow invoking
   "rebase -i".

 * "git p4" learned to cope with the type of a file getting changed.

 * "git format-patch" learned to notice format.outputDirectory
   configuration variable.  This allows "-o " option to be
   omitted on the command line if you always use the same directory in
   your workflow.

 * "interpret-trailers" has been taught to optionally update a file in
   place, instead of always writing the result to the standard output.

 * Many commands that read files that are expected to contain text
   that is generated (or can be edited) by the end user to control
   their behaviour (e.g. "git grep -f ") have been updated
   to be more tolerant to lines that are terminated with CRLF (they
   used to treat such a line to contain payload that ends with CR,
   which is usually not what the users expect).

 * "git notes merge" used to limit the source of the merged notes tree
   to somewhere under refs/notes/ hierarchy, which was too limiting
   when inventing a workflow to exchange notes with remote
   repositories using remote-tracking notes trees (located in e.g.
   refs/remote-notes/ or somesuch).

 * "git ls-files" learned a new "--eol" option to help diagnose
   end-of-line problems.

 * "ls-remote" learned an option to show which branch the remote
   repository advertises as its primary by pointing its HEAD at.

 * New http.proxyAuthMethod configuration variable can be used to
   specify what authentication method to use, as a way to work around
   proxies that do not give error response expected 

What's cooking in git.git (Feb 2016, #08; Fri, 26)

2016-02-26 Thread Junio C Hamano
Here are the topics that have been cooking.  Commits prefixed with
'-' are only in 'pu' (proposed updates) while commits prefixed with
'+' are in 'next'.  The ones marked with '.' do not appear in any of
the integration branches, but I am still holding onto them.

v2.8-rc0 has been tagged; this is a preview for the next release.

In previous cycles, I often left many topics in 'next' when tagging
this zero-th preview, but eventually merged them before the final.
I decided to do things a bit differently for this cycle: a topic,
once it hits 'next', will not be rewound and only refined and
corrected with incremental updates, so the only effect such a late
merge to 'master' before the final is that some topics are not as
widely tested on 'master' before the final one is tagged.

So this -rc0 is deliberately aggressive in that it includes all
topics that have been cooking in 'next' that I think we can fix bugs
that might still lurking in them before the final (it merges 25
topics since the last batch to 'master').  The topics not merged to
this preview, on the other hand, will not be considered for 2.8
final, even though I might later succumb to the temptation to pick
up ones that are in 'next' as of today ;-)

You can find the changes described here in the integration branches of the
repositories listed at

http://git-blame.blogspot.com/p/git-public-repositories.html

--
[Graduated to "master"]

* ak/extract-argv0-last-dir-sep (2016-02-19) 1 commit
  (merged to 'next' on 2016-02-24 at f590eb0)
 + exec_cmd.c: use find_last_dir_sep() for code simplification

 Code simplification.


* ak/git-strip-extension-from-dashed-command (2016-02-21) 1 commit
  (merged to 'next' on 2016-02-24 at 8a84f91)
 + git.c: simplify stripping extension of a file in handle_builtin()

 Code simplification.


* dt/initial-ref-xn-commit-doc (2016-02-25) 1 commit
  (merged to 'next' on 2016-02-25 at e32d0f6)
 + refs: document transaction semantics


* fa/merge-recursive-no-rename (2016-02-24) 7 commits
  (merged to 'next' on 2016-02-25 at 8f18cc1)
 + t3034: test deprecated interface
 + t3034: test option to disable renames
 + t3034: add rename threshold tests
 + merge-recursive: find-renames resets threshold
 + merge-strategies.txt: fix typo
  (merged to 'next' on 2016-02-18 at dd6125b)
 + merge-recursive: more consistent interface
 + merge-recursive: option to disable renames

 "git merge-recursive" learned "--no-renames" option to disable its
 rename detection logic.


* jg/credential-cache-chdir-to-sockdir (2016-02-23) 3 commits
  (merged to 'next' on 2016-02-25 at ad35811)
 + credential-cache--daemon: change to the socket dir on startup
 + credential-cache--daemon: disallow relative socket path
 + credential-cache--daemon: refactor check_socket_directory

 The "credential-cache" daemon process used to run in whatever
 directory it happened to start in, but this made umount(2)ing the
 filesystem that houses the repository harder; now the process
 chdir()s to the directory that house its own socket on startup.


* jk/epipe-in-async (2016-02-25) 4 commits
  (merged to 'next' on 2016-02-25 at 4482ddf)
 + t5504: handle expected output from SIGPIPE death
 + test_must_fail: report number of unexpected signal
 + fetch-pack: ignore SIGPIPE in sideband demuxer
 + write_or_die: handle EPIPE in async threads

 Handling of errors while writing into our internal asynchronous
 process has been made more robust, which reduces flakiness in our
 tests.


* jk/grep-binary-workaround-in-test (2016-02-23) 2 commits
  (merged to 'next' on 2016-02-25 at 0e96ae8)
 + t9200: avoid grep on non-ASCII data
 + t8005: avoid grep on non-ASCII data

 Recent versions of GNU grep are pickier when their input contains
 arbitrary binary data, which some of our tests uses.  Rewrite the
 tests to sidestep the problem.


* jk/more-comments-on-textconv (2016-02-22) 1 commit
  (merged to 'next' on 2016-02-24 at 4ccfdc5)
 + diff: clarify textconv interface

 The memory ownership rule of fill_textconv() API, which was a bit
 tricky, has been documented a bit better.


* jk/no-diff-emit-common (2016-02-22) 3 commits
  (merged to 'next' on 2016-02-24 at 72626ea)
 + xdiff: drop XDL_EMIT_COMMON
 + merge-tree: drop generate_common strategy
 + merge-one-file: use empty blob for add/add base

 "git merge-tree" used to mishandle "both sides added" conflict with
 its own "create a fake ancestor file that has the common parts of
 what both sides have added and do a 3-way merge" logic; this has
 been updated to use the usual "3-way merge with an empty blob as
 the fake common ancestor file" approach used in the rest of the
 system.


* jk/tighten-alloc (2016-02-22) 22 commits
  (merged to 'next' on 2016-02-24 at 78b3251)
 + ewah: convert to REALLOC_ARRAY, etc
 + convert ewah/bitmap code to use xmalloc
 + diff_populate_gitlink: use a strbuf
 + transport_anonymize_url: use xstrfmt
 + git-compat-util: drop mempcpy compat code
 + 

Re: What's cooking in git.git (Feb 2016, #07; Thu, 25)

2016-02-26 Thread Junio C Hamano
Torsten Bögershausen  writes:

> On 2016-02-26 19.29, Junio C Hamano wrote:
>> Torsten Bögershausen  writes:
>> 
>>> CC combine-diff.o
>>> combine-diff.c: In function ‘diff_tree_combined’:
>>> combine-diff.c:1391: internal compiler error: Segmentation fault
>>> Please submit a full bug report,
>>> with preprocessed source if appropriate.
>>> See  for instructions.
>>> make: *** [combine-diff.o] Error 1
>>>
>>> Revert "use st_add and st_mult for allocation size computation" didn't fix 
>>> it.
>>> I haven't digged deeper yet.
>> 
>> Hmph, I am not quite sure what you meant by "I haven't digged
>> deeper"; I do not think you should be debugging Apple's compiler
>> (unless you have the source to it and that is your job to do so,
>> that is).
>> 
>> In any case, merging the topic to 'master', and reverting that
>> commit will leave this only this change between 'master' and the
>> result.  I do not immediately spot anything trickier in the
>> postimage compared to the preimage that may trickle a compiler bug,
>> but what would I know without the source ;-)
>> 
> Digging means:
> run git bisect and report the commit.
> And this makes the compiler happy:
>   Revert "tree-diff: catch integer overflow in combine_diff_path allocation"

So?

Identifying two versions of the same C file, for one of which the
Apple compiler does not give you "internal compiler error" and for
the other it does, may help Apple engineers to debug their compiler.

But we cannot and will not revert any of our code only because some
vendor compiler is broken.  It would be a different story if we were
throwing an invalid C at compilers and relying on a bug in GCC that
accepts an invalid code, but I do not think that is the case here.



>
> This reverts commit 5b442c4f2723211ce0d862571e88ee206bfd51bf.
>
> Test suite passes,
> ( except t9115, the 2 new test cases "svn.pathnameencoding=cp932".
>   More info about that later)
--
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 2/2] Revert "rev-parse: remove restrictions on some options"

2016-02-26 Thread Jeff King
On Fri, Feb 26, 2016 at 06:29:57PM -0500, Jeff King wrote:

> The best solution here would be to have a full parsing loop
> that handles all options, but only calls setup_git_directory
> as appropriate. Unfortunately, that's a bit complicated to
> implement. We _have_ to handle each option in the order it
> appears on the command line. If the caller asked for:
> 
>   git rev-parse --resolve-git-dir foo/.git --show-toplevel
> 
> then it must receive the two lines of output in the correct
> to know which is which. But asking for:
> 
>   git rev-parse --show-toplevel --resolve-git-dir foo/.git
> 
> is weird; we have to setup_git_directory() for the first
> option.
> 
> So any implementation would probably have to either:
> 
>   - make two passes over the options, first figuring out
> whether we need a git-dir, and then actually handling
> the options. That's possible, but it's probably not
> worth the trouble.
> 
>   - call setup_git_directory() on the fly when an option
> needs it; that requires annotating all of the options,
> and there are a considerable number of them.

Having just sent this, of course, it occurs to me that a loop like:

   setup_git_directory_gently();
   for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "--local-env-vars"))
... and other nongit-ok options ...
  
if (nongit)
die("need a repo");
  
if (!strcmp(argv[i], "--git-dir"))
... and other options ...
   }

would probably work. It does still leave things like --parseopt and
--sq-quote as one-offs, though, because they consume the rest of the
command line. And the fact remains that --local-repo-env isn't really
suitable for use with other options.

So I'm still tempted by this "lazy" approach.

-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


Trouble Cloning Git remote repository

2016-02-26 Thread Fred's Personal
I am trying to set up a remote Git repository on my network server. 
I want to develop source on several desktops / laptops and want to have a
central repository to sync everything and maintain version control. 
Seems like a good fit for Git, but I cannot get it to work and would
appreciate advice on fixing the configuration or how to troubleshoot to
identify the root cause.
Please let me know what additional info you need to assist.

I have listed the machine configurations and the Git Bash lines from
attempting the git clone.

Configuration:
Local Machine (Host1)
o   Windows 10 - Git for Windows 2.7.1.2-64bit update
o   Git Repository = ~HOME/gitrepository
Remote Machine (Host2)
o   Ubuntu Server 14.04 LTS; Git version 2.7.2
o   Git repository = /srv/centralrepo.git ;created with -bare -shared
o  Owner= user1; group= developer
o   Created ~/.bashrc to ensure PATH is set correctly with 'interactive
non-login' session
o   After .bashrc runs there is a line from a bash script that causes a
bash error: "bash: user1@Host2: command not found" 

Clone to the remote repository always fails with:
  bash: user1@Host2: command not found
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.

All command line text shown here is executed from Local Machine(Host1) (from
Windows Git Bash) My comments preceded with ## 
## First cd into local repository and check status;
user1@Host1 MINGW64 ~
$ cd $HOME/gitrepository
user1@Host1 MINGW64 ~/gitrepository (master)
$ git status
On branch master
nothing to commit, working directory clean

## Now try to clone remote repository on Host2 (added set -x to ~/.bashrc
script)
user1@Host1 MINGW64 ~/gitrepository (master)
$ git clone -v ssh://user1@Host2/srv/centralrepo
Cloning into 'centralrepo'...
>>>Lines from $HOME/.bashrc
  + export
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
:/usr/local/games
  +
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
:/usr/local/games
  + PROMPT_COMMAND=
  + CDPATH=
  + '[' '' = yes ']'
  + PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
  + export GIT_TRACE_PACKET=1
  + GIT_TRACE_PACKET=1
  + export GIT_TRACE=1
  + GIT_TRACE=1
>>>End of Lines from $HOME/.bashrc
## WHERE DOES The following line COME FROMWhat Script spits out this
line
  + user1@Host2 git-upload-pack /srv/centralrepo
  bash: user1@Host2: command not found
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.

## Check remote path for interactive non-login session
user1@Host1 MINGW64 ~/gitrepository (master)
$ ssh user1@Host2 echo \$PATH
Enter passphrase for key '/c/Users/user1/.ssh/id_rsa':
## >>>Lines from $HOME/.bashrc (See Above, removed here for clarity)
##  PATH looks okay
+ echo
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr
/local/games
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr
/local/games

## List remote Git respository to check permissions
user1@Host1 MINGW64 ~/gitrepository (master)
$ ssh user1@Host2 ls -al /srv/centralrepo.git
Enter passphrase for key '/c/Users/user1/.ssh/id_rsa':
##  >>>Lines from $HOME/.bashrc (See Above, removed here for clarity)
##  CHECK the permissions and owner of the remote git repository
+ ls -al /srv/centralrepo.git
total 44
drwxrwsrwx 7 user1 developer 4096 Feb 11 21:02 .
drwxrwxrwx 4 user1 developer 4096 Feb  2 08:15 ..
drwxrwsrwx 2 user1 developer 4096 Feb  2 08:16 branches
-rwxrwxrwx 1 user1 developer  224 Feb  4 18:09 config
-rwxrwxrwx 1 user1 developer   26 Feb 11 21:02 description
-rwxrwxrwx 1 user1 developer   23 Feb  2 08:16 HEAD
drwxrwsrwx 2 user1 developer 4096 Feb  2 08:16 hooks
drwxrwsrwx 2 user1 developer 4096 Feb  2 08:16 info
drwxrwsrwx 4 user1 developer 4096 Feb  2 08:16 objects
drwxrwsrwx 4 user1 developer 4096 Feb  2 08:16 refs
-rw-rw-r-- 1 user1 developer   52 Feb 11 19:37 sample.txt

## Try cloning with -u option and path to upload-pack
user1@Host1 MINGW64 ~/gitrepository (master)
$ git clone -u /usr/bin/git-upload-pack ssh://user1@Host2/srv/centralrepo
Cloning into 'centralrepo'...
## >>>Lines from $HOME/.bashrc (See Above, removed here for clarity)
## * POSIX directory translation messed up this path
+ user1@Host2 C:/Program Files/Git/usr/bin/git-upload-pack /srv/centralrepo
bash: user1@Host2: command not found
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

## List the remote repository config
user1@Host1 MINGW64 ~/gitrepository (master)
$ ssh user1@Host2 cat /srv/centralrepo.git/config
Enter passphrase for key '/c/Users/user1/.ssh/id_rsa':
## >>>Lines from $HOME/.bashrc (See Above, removed here for clarity)
+ cat /srv/centralrepo.git/config
[core]
repositoryformatversion = 0
filemode = true

[PATCH 2/2] Revert "rev-parse: remove restrictions on some options"

2016-02-26 Thread Jeff King
This reverts commit 68889b416d5b6a5cf7d280a428281d635fe9b292.

That commit bumped some rev-parse options into the main
option-parsing loop, which meant that they no longer had to
come at the very beginning of the option list. However, that
also means that they now came after our call to
setup_git_directory(), and will no longer run outside of a
git repository.

For --local-env-vars, this is semi-questionable. The main
use of that option is to get a list of environment variables
to clear, and if you are not in a repository, there
_probably_ isn't anything to clear. But it places an
unnecessary restriction on callers who may be using it
preemptively.

For --resolve-git-dir, it is almost certainly a regression.
That option is about finding a git dir in the first place,
so it is reasonably likely to be called from outside an
existing repository.

The best solution here would be to have a full parsing loop
that handles all options, but only calls setup_git_directory
as appropriate. Unfortunately, that's a bit complicated to
implement. We _have_ to handle each option in the order it
appears on the command line. If the caller asked for:

  git rev-parse --resolve-git-dir foo/.git --show-toplevel

then it must receive the two lines of output in the correct
to know which is which. But asking for:

  git rev-parse --show-toplevel --resolve-git-dir foo/.git

is weird; we have to setup_git_directory() for the first
option.

So any implementation would probably have to either:

  - make two passes over the options, first figuring out
whether we need a git-dir, and then actually handling
the options. That's possible, but it's probably not
worth the trouble.

  - call setup_git_directory() on the fly when an option
needs it; that requires annotating all of the options,
and there are a considerable number of them.

The original patch was not spurred by an actual bug report,
but by an observation[1] that was essentially "eh, this
looks unnecessarily restrictive". It _is_ restrictive, but
it turns out to be necessarily so. :)

And in practice, it is unlikely anybody was bothered by the
restriction. It's not really sane to use --local-env-vars
with other options, anyway, as it produces unbounded output
(so the caller only know it ends at EOF). It's more
plausible for --resolve-git-dir to be used with other
options, but still unlikely. It's main use is accessing
_other_ repositories (e.g., submodules), so making a query
on the main repository at the same time isn't very useful.

This patch therefore just reverts 68889b416, with a few
caveats:

  1. Since the original change, --resolve-git-dir learned to
 avoid segfaulting on a bogus. We don't know need to
 backport that, because the "restricted" form checks
 argc.

  2. The original patch mentioned that we didn't need to
 clean up any documentation, because the restriction
 wasn't documented. We can at least fix that by
 mentioning the restriction in the manpage.

  3. We can now mark our newly-added tests as passing. :)

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

Signed-off-by: Jeff King 
---
 Documentation/git-rev-parse.txt   | 27 ++-
 builtin/rev-parse.c   | 31 +++
 t/t1515-rev-parse-outside-repo.sh |  4 ++--
 3 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index b6c6326..0f2bb9b 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -28,7 +28,8 @@ OPTIONS
 Operation Modes
 ~~~
 
-Each of these options must appear first on the command line.
+Each of these options must appear first on the command line; they do not
+need to be run in a git repository.
 
 --parseopt::
Use 'git rev-parse' in option parsing mode (see PARSEOPT section below).
@@ -38,6 +39,18 @@ Each of these options must appear first on the command line.
section below). In contrast to the `--sq` option below, this
mode does only quoting. Nothing else is done to command input.
 
+--local-env-vars::
+   List the GIT_* environment variables that are local to the
+   repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
+   Only the names of the variables are listed, not their value,
+   even if they are set.
+
+--resolve-git-dir ::
+   Check if  is a valid repository or a gitfile that
+   points at a valid repository, and print the location of the
+   repository.  If  is a gitfile then the resolved path
+   to the real repository is printed.
+
 Options for --parseopt
 ~~
 
@@ -201,12 +214,6 @@ explicitly.
 Options for Files
 ~
 
---local-env-vars::
-   List the GIT_* environment variables that are local to the
-   repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR).
-   Only the names of the variables are listed, not their 

[PATCH 1/2] t1515: add tests for rev-parse out-of-repo helpers

2016-02-26 Thread Jeff King
The git-rev-parse command is a dumping ground for helpers
that let scripts make various queries of git. Many of these
are conceptually independent of being inside a git
repository.

With the exception of --parseopt, we do not directly test
most of these features in our test suite. Let's give them
some basic sanity checks, which reveals that some of them
have been broken for some time when run from outside a
repository.

Signed-off-by: Jeff King 
---
 t/t1515-rev-parse-outside-repo.sh | 45 +++
 1 file changed, 45 insertions(+)
 create mode 100755 t/t1515-rev-parse-outside-repo.sh

diff --git a/t/t1515-rev-parse-outside-repo.sh 
b/t/t1515-rev-parse-outside-repo.sh
new file mode 100755
index 000..ae33093
--- /dev/null
+++ b/t/t1515-rev-parse-outside-repo.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+test_description='check that certain rev-parse options work outside repo'
+. ./test-lib.sh
+
+test_expect_success 'set up non-repo directory' '
+   GIT_CEILING_DIRECTORIES=$(pwd) &&
+   export GIT_CEILING_DIRECTORIES &&
+   mkdir non-repo &&
+   cd non-repo &&
+   # confirm that git does not find a repo
+   test_must_fail git rev-parse --git-dir
+'
+
+# Rather than directly test the output of sq-quote directly,
+# make sure the shell can read back a tricky case, since
+# that's what we really care about anyway.
+tricky="really tricky with \\ and \" and '"
+dump_args () {
+   for i in "$@"; do
+   echo "arg: $i"
+   done
+}
+test_expect_success 'rev-parse --sq-quote' '
+   dump_args "$tricky" easy >expect &&
+   eval "dump_args $(git rev-parse --sq-quote "$tricky" easy)" >actual &&
+   test_cmp expect actual
+'
+
+test_expect_failure 'rev-parse --local-env-vars' '
+   git rev-parse --local-env-vars >actual &&
+   # we do not want to depend on the complete list here,
+   # so just look for something plausible
+   grep ^GIT_DIR actual
+'
+
+test_expect_failure 'rev-parse --resolve-git-dir' '
+   git init --separate-git-dir repo dir &&
+   test_must_fail git rev-parse --resolve-git-dir . &&
+   echo "$(pwd)/repo" >expect &&
+   git rev-parse --resolve-git-dir dir/.git >actual &&
+   test_cmp expect actual
+'
+
+test_done
-- 
2.7.2.767.g705917e

--
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] credential: let empty credential specs reset helper list

2016-02-26 Thread Junio C Hamano
Jeff King  writes:

> I think there is another reason, which is that the interface we expose
> to config callbacks (and via "config --get-all") is to sequentially pass
> in all values. How does that interact with this "reset"? For example,
> what is the output of:
>
>   git config foo.bar one
>   git -c '!foo.bar' config --get-all foo.bar

The callback API needs to be extended to include this "reset" bit,
not just "var" and "value", obviously.  And then of course the users
of the API need to be updated to act on that "reset" thing.

That is what I meant by "multi-value things need custom code".  The
single-valued ones can do "last one wins", and "reset" can be turned
into "the initial state" assignment for the variable; multi-value
cumulative ones already have custom code to accumulate things into
list, and they need to learn to empty the list upon seeing the
"reset" bit.

But that is not as fundamental as "new syntax breaks old clients".
If we want our new code to do useful things, obviously we would need
to work on making it do so ;-)

> I think you could get away without changing the users of the multi-value
> variables, using the "negative" approach I mentioned above. Basically:
> ...
> But like I said, that does feel somewhat half-implemented to me, since
> it treats the command-line specially.

I agree with you that that is a kludge and not the right way
forward.
--
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/RFC 0/2] fix some rev-parse options in non-repos

2016-02-26 Thread Jeff King
Michael Haggerty noticed recently (off-list) that "git rev-parse
--local-env-vars" doesn't work outside of a git repository. This turns
out to be a regression in v1.8.5, due to a patch by John Keeping that
lifted some other restrictions on how the option could be used.

This fixes it by reverting John's patch, which puts the original
restrictions back in place. I won't repeat the lengthy discussion from
patch 2's commit message here, but the gist of it is that probably
nobody cares about those restrictions, it's more important to fix the
original regression, and it's probably too hard to make both work.

The only thing that gives me pause (and hence the RFC) is that it has
been over 2 years since the original regression. So it's entirely
possible somebody will consider _this_ fix a regression.

  [1/2]: t1515: add tests for rev-parse out-of-repo helpers
  [2/2]: Revert "rev-parse: remove restrictions on some options"

-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: interactive rebase results across shared histories

2016-02-26 Thread Stepan Kasal
Hello Seb,

let me add a few things, perhaps they'll clean some misunderstandings.

On Fri, Feb 26, 2016 at 03:12:46PM -0600, Seb wrote:
> After cleaning up all the mess, I've ended up with a long master branch,
> and a series of earlier commits that are not reachable from master.
> Fortunately, the tags have kept them alive. This is the scenario
> simplified:
> 
> A---C---D(tag2) loose commits (not on any branch)
>  \
>   B(tag1)
> 
> E---F---G---H---*   (master)

I noticed that these are tags.  Actually, tags in git are meant to mark
certain fixed points, and they are not meant to change in the future.

They are used to mark releases in the project, and they can even have
a cryptographic signature attached to it, so that no one can forge them.

I guess that you used them as a temporary mark for yourself when you
reaced a point in development, or to mark a stable point as a base for
future development.  If that was the case, you could have used a branch
as well.

I guess that people subconsciously still think that branch is ecpensive,
based on the experiences from other VCS.  It's not true: branch is
a variable that holds a value: the hex id of the top commit.
As you do not care how many variables you need to declare when writing
code, you should not hesitate to create as many branches as you need
to mark the points in the history.

Perhaps you just delte the tags.  That would be true if the code
in these old branches has already been copied (by rebase) to the new
master.

If you would like to mark the corresponding points in the rewritten
history, you can create these marks again.  (As branches, perhaps.)

Then you say that you want to put everything to one branch master,
to create a linear history of development.  (Well, not true history,
but a made up history, you see.)

For that goal, does master already contain all the code?
If yes, then you have it.  You can perhaps just delete all the old
branches that were used to develop individual parts...

I'm working on a project, where we decided to have linear history
on the main server.
So my own local git clone of my work contains lots of branches named
after features and their combination, like:
counting
counting-3counters
pairs
counting-with-pairs
counting-3c-pairs

I use rebase heavily to move each of the feature (=series of commits)
to another branch ot to master.

For example, when i wanted to enhance branch "counting" with the feature
"pairs," I did it like this:

git branch counting-with-pairs pairs
git rebase -i counting counting-with-pairs

That will take all the commits that are in pairs, but not in counting.
(This is usually all the commits in "pairs", staring from the point
where in branched from master.) And all these get replayed on the tip of
"counting".

Likewise, I can move the topic to the latest master, then move master
(git checkout master; git merge --ff-only some-branch)
and then push.

BTW, another thing:
when you decided to clean up the history -- are there any other
people working with the repository you are working with?

If yes, then each of them has to be prepared to follow your cleanup.
All their work is currently base on the old history; if they push
their work all the old hostory will be back.

They could throw away their current local clones and start anew,
if they had no work there.  But that's probaably not the case.

So they have to fetch your new history of master and then rebase
all of their features --onto your new master.

I hope some of my talking will be useful.

Stepan
--
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] credential: let empty credential specs reset helper list

2016-02-26 Thread Jeff King
On Fri, Feb 26, 2016 at 11:34:12AM -0800, Junio C Hamano wrote:

> >> -  if (!strcmp(key, "helper"))
> >> -  string_list_append(>helpers, value);
> >> -  else if (!strcmp(key, "username")) {
> >> +  if (!strcmp(key, "helper")) {
> >> +  if (*value)
> >> +  string_list_append(>helpers, value);
> >> +  else
> >> +  string_list_clear(>helpers, 0);
> >> +  } else if (!strcmp(key, "username")) {
> >
> > I wondered why neither the existing code nor the updated one has a
> > check for !value, but this callback assumes no credential
> > configuration variable will ever be a boolean and rejects it
> > upfront, so this code before or after the change is safe.
> >
> > Not pointing out anything that needs to be changed; demonstrating
> > that I did read this sufficiently well to say that I have reviewed
> > it ;-)
> 
> This reminds me of one thing.  The only reason why we are hesitant
> to introduce a new syntax like
> 
>   [credential]
>   !helper ;# clear
> helper = ...
> 
> to allow explicit clearing of accumulated values so far IIRC is
> because such a _file_ will not be readable by existing versions of
> Git.  Am I correct?

I think there is another reason, which is that the interface we expose
to config callbacks (and via "config --get-all") is to sequentially pass
in all values. How does that interact with this "reset"? For example,
what is the output of:

  git config foo.bar one
  git -c '!foo.bar' config --get-all foo.bar

?

Do we continue to output the "reset" values, or do we quietly munge the
list on behalf of the caller? If the former, how do we represent that in
the output? I can see arguments both ways.

Implementation-wise (both for git-config and for internal callbacks), it
means we cannot parse the config as a single pass anymore. That's
probably OK; we've already moved partially toward that with the
configset stuff. If we _just_ support this via command-line options, we
could do an initial pass over those, looking for negatives, and then
simply skip all negatives while parsing the config files.

> If that is the case, then that reasoning will still not prevent us
> from adding corresponding support for a command-line overide, i.e.
> either one or both of these:
> 
>   $ git -c credential.!helper cmd
>   $ git -c !credential.helper cmd
> 
> no?

Yes, that would work, though to me it really feels like a
half-implemented feature. You cannot override a bad /etc/gitconfig line
via your ~/.gitconfig or repo-specific .git/config. Those things are
useful.

One other thing that occurred to me is that Apple Git hard-codes the
osxkeychain helper (rather than putting it into the system-wide
gitconfig ). No config-based system can "undo" that, but my patch
does. I admit that's probably not the best argument; hitting Apple with
a clue-stick is a cleaner approach.

> Of course, the code in the configuration subsystem for updated
> version of Git needs to become aware of the new syntax, and those
> that deal with the multi-value variables need custom code, which is
> similar to the way you special cased an empty value in the above
> patch, so I am not sure how much this would help.

I think you could get away without changing the users of the multi-value
variables, using the "negative" approach I mentioned above. Basically:

  1. parse GIT_CONFIG_PARAMETERS looking for negatives; stick them in a
 string-list or whatever.

  2. parse the files; look up each key in the string-list, and if it
 matches, don't even send it to the callback

  3. clear the string-list

  4. parse GIT_CONFIG_PARAMETERS again, ignoring any negatives

But like I said, that does feel somewhat half-implemented to me, since
it treats the command-line specially.

-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 v3 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Jacob Keller
On Fri, Feb 26, 2016 at 11:41 AM, Stefan Beller  wrote:
>
> In the future, would you mind to try interdiffs in a cover letter?
>
> (I do git diff HEAD...$(previousSeries) with previousSerier either
> local branch or rather what Junio picked up already. There is also tbdiff,
> which should be better and easier than this work flow)
>

Yes, I should do that. I could just use the reflog for this actually,
for my workflow.

>
>> +*/
>> +   strbuf_addstr(, var);
>> +   strbuf_addch(, '=');
>> +   strbuf_addstr(, value);
>
> This could be `strbuf_addf("%s=%s", var, value);` (?)
> which then gets quoted below
>

Is there such a thing as sq_quote_buf equivalent of this? If not,
should I add one? I think that might be preferable since we'd drop the
entire extra strbuf variable.

>> +   git_config_from_parameters(sanitize_submodule_config,
>> +  _config);
>> +   argv_array_pushf(out, "%s=%s", *var, 
>> sanitized_config.buf);
>
> like here?
>

Ya, I just wasn't thinking of strbuf_addf. But I think I'd rather have
sq_quote_f or something created instead to drop the need of a separate
strbuf.

>> -   subsha1=$(clear_local_git_env; cd "$sm_path" &&
>> +   subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
>> git rev-parse --verify HEAD) ||
>
> While at it, we could discuss if we want to replace the pattern cd
>  && git-command
> by `git -C  ` eventually (not in this patch) ?

Yes, we should use git -C instead, but probably not worth too much
effort if our plan is to drop the shell code eventually? Might be
worth the cleanup, especially if it lets us avoid a subshell. If we
still need the subshell for other non-git commands I would prefer to
leave it as "(cd  && git command && other commands && ...
&& )

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


Re: What's cooking in git.git (Feb 2016, #07; Thu, 25)

2016-02-26 Thread Torsten Bögershausen
On 2016-02-26 19.29, Junio C Hamano wrote:
> Torsten Bögershausen  writes:
> 
>> CC combine-diff.o
>> combine-diff.c: In function ‘diff_tree_combined’:
>> combine-diff.c:1391: internal compiler error: Segmentation fault
>> Please submit a full bug report,
>> with preprocessed source if appropriate.
>> See  for instructions.
>> make: *** [combine-diff.o] Error 1
>>
>> Revert "use st_add and st_mult for allocation size computation" didn't fix 
>> it.
>> I haven't digged deeper yet.
> 
> Hmph, I am not quite sure what you meant by "I haven't digged
> deeper"; I do not think you should be debugging Apple's compiler
> (unless you have the source to it and that is your job to do so,
> that is).
> 
> In any case, merging the topic to 'master', and reverting that
> commit will leave this only this change between 'master' and the
> result.  I do not immediately spot anything trickier in the
> postimage compared to the preimage that may trickle a compiler bug,
> but what would I know without the source ;-)
> 
Digging means:
run git bisect and report the commit.
And this makes the compiler happy:
  Revert "tree-diff: catch integer overflow in combine_diff_path allocation"

This reverts commit 5b442c4f2723211ce0d862571e88ee206bfd51bf.

Test suite passes,
( except t9115, the 2 new test cases "svn.pathnameencoding=cp932".
  More info about that later)





--
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 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Jacob Keller
On Fri, Feb 26, 2016 at 2:05 PM, Jeff King  wrote:
> On Fri, Feb 26, 2016 at 11:18:48AM -0800, Jacob Keller wrote:
>
>> +test_expect_success 'sanitize-config keeps credential.helper' "
>> + git -c credential.helper=helper submodule--helper sanitize-config 
>> >actual &&
>> + cat >expect <<-EOF &&
>> + 'credential.helper=helper'
>> + EOF
>> + test_cmp expect actual
>> +"
>
> This can (and should) be "<<-\EOF", right?
>

Yes, I actually meant <<-\EOF but forgot while writing it.

> I happened to be writing a test with the exact same problem (embedded
> single-quotes) today, and realized we have another solution which is
> used elsewhere in the test suite:
>
>   sq="'"
>   test_expect_success '...' '
> echo "${sq}credential.helper=helper${sq}" >expect &&
> ...
>   '
>
> that is slightly more verbose, but it does let us keep the main body
> inside single-quotes, without restoring to confusing backslash escaping.
>

I think I prefer the double quotes myself but will use this if people prefer?

> -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] credential: let empty credential specs reset helper list

2016-02-26 Thread Jacob Keller
On Fri, Feb 26, 2016 at 11:34 AM, Junio C Hamano  wrote:
>
> Of course, the code in the configuration subsystem for updated
> version of Git needs to become aware of the new syntax, and those
> that deal with the multi-value variables need custom code, which is
> similar to the way you special cased an empty value in the above
> patch, so I am not sure how much this would help.
>

For most cases, I think the previous approach of setting to empty
string makes sense and is more easilly intuitive, but would only work
for those values which the empty string has no valid meaning.

I would think either approach here is fine, and i think *most* cases
of multivariable configuration don't need to be cleared from within a
configuration file but only on the command line would be acceptable.

If we go this route I would prefer "-c !" vs "-c .!"

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


Re: [PATCH v4 2/3] sumodule--helper: fix submodule--helper clone usage and check argc count

2016-02-26 Thread Jacob Keller
On Fri, Feb 26, 2016 at 11:31 AM, Stefan Beller  wrote:
> On Fri, Feb 26, 2016 at 11:18 AM, Jacob Keller  
> wrote:
>> From: Jacob Keller 
>> -   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
>> "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" 
>> "$reference" "$depth" || exit
>> +   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
>> "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" 
>> ${reference:+"$reference"} ${depth:+"$depth"} || exit
>
> By having this additional fix (i.e. no '--depth', '' is
> passed to the
> submodule helper, we can improve the submodule helper further
> in clone_submodule we can drop the double check for `depth` and `reference`
> (as well as `gitdir`, that double check is unneeded as of now already),
> by just checking for the pointer to be non  NULL and not further checking
> the dereferenced pointer.
>
> That can go in either squashed into this commit or on top of it, either is 
> fine.
>
> That said:
> Reviewed-by: Stefan Beller 
>

To be clear, what this *actually* does is prevent passing

""

when depth or reference are empty. It never passed "--depth" ""
together, or "--reference" "". It *does* pass --prefix "" sometimes,
but not always, from what I could tell when using print debug
statements while running the submodule tests.

I am not sure if it ever passes "--depth" "" in any case, but I don't
believe so.

What this final change is needed for is that without it, after
parse_options, argc is equal 2.

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


Re: [PATCH v4 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Jeff King
On Fri, Feb 26, 2016 at 11:18:48AM -0800, Jacob Keller wrote:

> +test_expect_success 'sanitize-config keeps credential.helper' "
> + git -c credential.helper=helper submodule--helper sanitize-config 
> >actual &&
> + cat >expect <<-EOF &&
> + 'credential.helper=helper'
> + EOF
> + test_cmp expect actual
> +"

This can (and should) be "<<-\EOF", right?

I happened to be writing a test with the exact same problem (embedded
single-quotes) today, and realized we have another solution which is
used elsewhere in the test suite:

  sq="'"
  test_expect_success '...' '
echo "${sq}credential.helper=helper${sq}" >expect &&
...
  '

that is slightly more verbose, but it does let us keep the main body
inside single-quotes, without restoring to confusing backslash escaping.

-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 02/16] bisect: add test for the bisect algorithm

2016-02-26 Thread Stephan Beyer
Hi Christian,

On 02/26/2016 07:53 AM, Christian Couder wrote:
>> +test_expect_success 'bisect algorithm works in linear history with an odd 
>> number of commits' '
>> +   git bisect start A7 &&
>> +   git bisect next &&
>> +   test "$(git rev-parse HEAD)" = "$(git rev-parse A3)" \
>> + -o "$(git rev-parse HEAD)" = "$(git rev-parse A4)"
> 
> I thought that we should not use "-o" and "-a" but instead "|| test"
> and "&& test".

Why is this? I understand the && instead of -a thing (test atomicity),
however, for || this results in an ugly

+   git bisect next &&
+   ( test "$(git rev-parse HEAD)" = "$(git rev-parse A3)" ||
+ test "$(git rev-parse HEAD)" = "$(git rev-parse A4)" )

Right? (Otherwise a failure of e.g. "git bisect start A7" would run
the command after || (which may still be fine in some cases but is wrong
in most of the other cases).

However, what do you think about this?

diff --git a/t/t8010-bisect-algorithm.sh b/t/t8010-bisect-algorithm.sh
index bda59da..ae50e7c 100755
--- a/t/t8010-bisect-algorithm.sh
+++ b/t/t8010-bisect-algorithm.sh
@@ -8,6 +8,16 @@ exec https://github.com/sbeyer/git/commit/2c224093ccee837a7f0f62f6af6a0a804d07c022

(test_compare_rev() could also go into test-lib.sh)

Cheers
Stephan
--
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: interactive rebase results across shared histories

2016-02-26 Thread Seb
On Fri, 26 Feb 2016 23:38:38 +1100,
David  wrote:

> On 24 February 2016 at 10:05, Seb  wrote:
>> On Tue, 23 Feb 2016 23:57:06 +0100,
>> Moritz Neeb  wrote:

>> [...]

 OK, I've followed this advice and looked at the dependency graphs
 in gitk before and after rebasing, I've managed to obtain what I
 was after.  The repository now has two branches: master and topic.
 However, Gitk reveals a problem with a string of commits that are
 not part of any branch:

 A---B---H---I (master) \ C---D---E (loose string of commits) \
 D'---E'---F---G (topic)

 How do I remove these loose commits (C, D, E)?


>>> what you might be after is "git gc". But I never used it, it was not
>>> neccesary for me. I would let the automatic garbage collection drop
>>> my dangling commits. It's safer - who knows when you will still want
>>> to restore your recent "loose string of commits".

>>> How exactly are the loose commits causing trouble?

>> Sure enough, these dangling commits were removed automatically
>> without any intervention.  All is good.

> This discussion could end there without problem. But if you want to
> understand a little more thoroughly, read on ...

Thanks David, I appreciate the insight.  Indeed, I've learnt a lot over
the last few days with help in this thread as I confronted a lurking
problem after many years neglecting it.  Briefly, long ago I was
developing a project in RCS, then on CVS and SVN, until some years ago I
imported it into git via cvs2svn.  I had turned a blind eye to a bit of
mess up to the very early releases, likely due to my inexperience but
also differences between VCS.

After cleaning up all the mess, I've ended up with a long master branch,
and a series of earlier commits that are not reachable from master.
Fortunately, the tags have kept them alive. This is the scenario
simplified:

A---C---D(tag2) loose commits (not on any branch)
 \
  B(tag1)

E---F---G---H---*   (master)

I could put the "loose" (but tagged) commits on a branch at "tag2", but
I hate that "tag1" shows as a twig there...  It would be nice to have
all the history reachable from master.  So two questions I'm working on
right now: 1) how to bring "tag1" into the "tag2" chain of commits, and
then 2) how to tie it all together into master so that it reads
linearly.

-- 
Seb

--
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 14/16] bisect: use a modified breadth-first search to find relevant weights

2016-02-26 Thread Stephan Beyer
Hi,

On 02/26/2016 04:09 AM, Junio C Hamano wrote:
> Interesting.  So you walk from the bottom commits, incrementing the
> weight while walking on a part of the graph that is single strand of
> pearls, or doing the "count the reachable ones the hard way" when
> you hit a merge [*1*], but either way, once you know the commit you
> are looking at is above the mid-way, i.e. reaches more than half of
> the graph, then stop walking because its children will never be
> better than that commit?

Exactly. Maybe that's an even better description for the commit message l-)

> I haven't studied the code carefully, but your mention of BFS makes
> me wonder if you can "narrow" down the search space even more.

I had an idea that aimed at accomplishing this by finding the
highest-distance merge commit using binary search. (The BFS collected
all merge commits, in that order, then you could do binary search.)
So you have O(log(#mergecommits)) "do it the hard way" weight computations.
However, in the worst case (or even in every case, I did not thoroughly
think about the cases that can occur), it could happen that it also had
to do these "do it the hard way" computations for all merge commits with
smaller weight... That's why I dropped this idea in favor of the more
simple approach that I sent to the list.

> In an earlier step of the series, you introduced a work queue to
> replace the recursion.  The recursion forces the algorithm to work
> along the topology of the history, but you have more latitude in
> selecting the commit to dig further with a work queue.
> 
> I wonder if you can sort the elements on the work queue based on
> their distance (i.e. by using a priority queue).  You know the total
> upfront, so you may find a commit whose weight is exactly half of it
> before traversing all the bottom half of the history and it may turn
> out to be even more efficient.  After all, you are only looking for
> just one such commit, not trying to find all the commits with the
> best weight.

For the compute_weight() function (the "doing it the hard way"
function), this would not make sense since all parent commits (of a
merge commit we call compute_weight() on) will have smaller distance.

However, your idea can help:
I just noticed that it's not important that I use a *B*FS because of the
acyclity. So I could also use a DFS that is "more greedy" going towards
high numbers.
Note that the traversal is always on trees because the merge commits are
cut out. So whenever a branching (a commit with more than one child)
occurs, the DFS should follow the branch of maximum length to its leaf.
(These maximum lengths can be saved during build_reversed_dag().)
Then, if there is a halfway commit, we stop. If not, we can just go on
with the remaining DFS...
I think I only rethought and rephrased your idea. :) Sounds good to me.
I'm going to add commits for that.

> [Footnote]
> 
> *1* A merge between a commit that reaches N commits and another that
> reaches M commits may have weight smaller than the sum of N and M,
> and that is why I left the original "truly stupid algorithm" Linus
> wrote as-is when I did the obvious optimization for the linear parts
> of the history.

Yes. In fact, the "truly stupid algorithm" is not truly stupid. I'm not
quite sure, but I think it's still the best algorithm known so far for
that problem. (But maybe the problem is just not very interesting in
science.)

> *2* Whenever I revisited the bisection in my head, I thought about
> ways to improve that "truly stupid" counting, but never thought
> about an approach to simply reduce the number of times the "truly
> stupid" counting has to be done.

Well, I also improved that "truly stupid" counting a little in a former
commit (patch 7). But it's just the implementation that I improved
(time/memory trade-off), not the algorithm. :)

Cheers,
  Stephan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] submodule sync: Test we can pass individual submodules

2016-02-26 Thread Stefan Beller
The parent patch made changes to the way `git submodule--helper list`
is called. From experience this is a sensitive topic and lots subtle things
can go wrong. As all submodule subcommands except `sync` are setup to
run `git submodule--helper list` in the original directory, I suspected
a possible breakage in `sync` not being able to specify an exact submodule
to run in, so let's add a test for that. Instead of adding a complete new
test we can modify an existing test to additionally test the additional
assertion of having just one submodule work fine.

Signed-off-by: Stefan Beller 
---
 t/t7403-submodule-sync.sh | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 79bc135..5dde123 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -28,6 +28,9 @@ test_expect_success setup '
git submodule add ../submodule submodule &&
test_tick &&
git commit -m "submodule"
+   git submodule add ../submodule submodule2 &&
+   test_tick &&
+   git commit -m "second submodule"
) &&
git clone super super-clone &&
(
@@ -149,15 +152,16 @@ test_expect_success 'reset submodule URLs' '
reset_submodule_urls super-clone
 '
 
-test_expect_success '"git submodule sync" should update submodule URLs - 
subdirectory' '
+test_expect_success '"git submodule sync" should update specified submodule 
URLs - subdirectory' '
(
cd super-clone &&
git pull --no-recurse-submodules &&
mkdir -p sub &&
cd sub &&
-   git submodule sync >../../output
+   git submodule sync ../submodule >../../output
) &&
grep "\\.\\./submodule" output &&
+   ! grep submodule2 output &&
test -d "$(
cd super-clone/submodule &&
git config remote.origin.url
@@ -177,7 +181,7 @@ test_expect_success '"git submodule sync" should update 
submodule URLs - subdire
)
 '
 
-test_expect_success '"git submodule sync --recursive" should update all 
submodule URLs - subdirectory' '
+test_expect_success '"git submodule sync --recursive" should update all 
specified submodule URLs - subdirectory' '
(
cd super-clone &&
(
@@ -186,9 +190,10 @@ test_expect_success '"git submodule sync --recursive" 
should update all submodul
) &&
mkdir -p sub &&
cd sub &&
-   git submodule sync --recursive >../../output
+   git submodule sync --recursive ../submodule >../../output
) &&
grep "\\.\\./submodule/sub-submodule" output &&
+   ! grep submodule2 output &&
test -d "$(
cd super-clone/submodule &&
git config remote.origin.url
-- 
2.7.2.368.g934fe14

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


[PATCH 1/2] Check recursive submodule update to have correct path from subdirectory

2016-02-26 Thread Stefan Beller
A similar test exists for `submodule sync` to behave well when being in
an unrelated subdirectory and performing operations on submodules.

Signed-off-by: Stefan Beller 
---
 t/t7406-submodule-update.sh | 12 
 1 file changed, 12 insertions(+)

diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 68ea31d..628da7f 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -774,4 +774,16 @@ test_expect_success 'submodule update --recursive drops 
module name before recur
 test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked 
out" actual
)
 '
+
+test_expect_success 'submodule update --recursive works from subdirectory' '
+   (cd super2 &&
+(cd deeper/submodule/subsubmodule &&
+ git checkout HEAD^
+) &&
+mkdir untracked &&
+cd untracked &&
+git submodule update --recursive >actual &&
+test_i18ngrep "Submodule path .../deeper/submodule/subsubmodule.: 
checked out" actual
+   )
+'
 test_done
-- 
2.7.2.368.g934fe14

--
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/2] recursive submodules: paths are hard

2016-02-26 Thread Stefan Beller
I thought getting rid of the extra `prefix` argument in submodule helper
functions was easy up to the point of all but one test passing in the test
suite.

It turned out the implementation of that prefix patch was wrong, only caught
by tests, so we want to add tests for subtle details with submodule sync and
update which have not been tests yet.

For the record, I thought the 'prefix' patch was as easy as:

-   git submodule--helper list --prefix "$wt_prefix" "$@" | {
+   git -C "$wt_prefix" submodule--helper list "$@" | {

for all occurrences of `submodule--helper list`.

This is not the case as by doing so the recursive functionality of submodules
is broken in some edge cases.

Consider this sequence:

  mkdir untracked &&
  cd untracked &&
  git submodule  --recursive
  
The operation is run from within the work tree, so fro a normal submodule
operation (without --recursive) you expect the pathes to be adapted to be
prefixed by a `../` to make sense relative to the untracked directory.

In the case of recursive submodule operations, currently `git submodule`
usually does

if test -n "$recursive"
then
(
prefix="$prefix$sm_path/"
clear_local_git_env
cd "$sm_path" &&
eval cmd_update
)

By having a change of directory followed by the recursive call to the operation
we need to make sure the displayed path is still correctly referenced to where
the operation started.

By passing the prefix separately to git submodule--helper, this works currently
as the prefix is only used for calculating the displaypath. If it were passed
by the standard Git machinery, there is going on more, which
fails us at some point.

I think we may need to enable Git to pass in 'negative' pathes for the prefix,
i.e. 
  Although operating on this repository, your reference for displaying paths
  should be '../untracked' for the example above, when the submodule is in the
  root directory of the superproject.

This seems currently not possible with the standard way to pass down the prefix.

TL;DR: Most of the test is unrelated to the patch series, the patch series
adds some tests, which I would have found useful to stop me going the wrong
direction.

Thanks,
Stefan

Stefan Beller (2):
  Check recursive submodule update to have correct path from
subdirectory
  submodule sync: Test we can pass individual submodules

 t/t7403-submodule-sync.sh   | 13 +
 t/t7406-submodule-update.sh | 12 
 2 files changed, 21 insertions(+), 4 deletions(-)

-- 
2.7.2.368.g934fe14

--
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 log --no-merges shows grafted merges in shallow clones

2016-02-26 Thread Junio C Hamano
Matthieu Moy  writes:

> Junio C Hamano  writes:
>
>> I do not think this is limited to shallow but for grafts in
>> general.  
>
> Probably yes. I happen to only use grafts in shallow clones ;-).
>
>> cat-file is low-level to show the bare metal, but by using these
>> facility you asked Git to give you an imaginary history where that
>> commit is the root commit--and that is why it is shown, I think.
>>
>> What does it do if you say "git -c log.showRoot=false log -p"?
>
> I get the commit without the patch:
>
> commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)
> Author: Matthieu Moy 
> Date:   Mon Aug 31 16:32:20 2015 +0200
>
> Merge remote-tracking branch 'edward/utf-8-email-support4'
>
> Without "-c log.showRoot=false" I get a big patch (diff of the commit
> against the empty tree).

... which shows that Git is consistently pretending as if that
commit is the root commit, which in turn means that it is correct
for "log --no-merges" to not peek into the information at "cat-file
commit" level.

--
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 log --no-merges shows grafted merges in shallow clones

2016-02-26 Thread Matthieu Moy
Junio C Hamano  writes:

> I do not think this is limited to shallow but for grafts in
> general.  

Probably yes. I happen to only use grafts in shallow clones ;-).

> cat-file is low-level to show the bare metal, but by using these
> facility you asked Git to give you an imaginary history where that
> commit is the root commit--and that is why it is shown, I think.
>
> What does it do if you say "git -c log.showRoot=false log -p"?

I get the commit without the patch:

commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)
Author: Matthieu Moy 
Date:   Mon Aug 31 16:32:20 2015 +0200

Merge remote-tracking branch 'edward/utf-8-email-support4'

Without "-c log.showRoot=false" I get a big patch (diff of the commit
against the empty tree).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
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 log --no-merges shows grafted merges in shallow clones

2016-02-26 Thread Matthieu Moy
Hi,

I don't think that's intended. When running "git log --no-merges" in a
shallow clone, and the last commit in the history is a merge commit,
"git log --no-merges" still shows it.

I've just hit this in a test running on a --depth=50 clone on Travis-CI
on git-multimail:

$ git cat-file -p c3c1cc25b27d448e9ef67b265a11be8735ff2df4
tree c341dd60c4b639eac1d6dcc3caffb5d7201c2245
parent b312e3f90dfef73ba028881694b09affdf6b
parent 842ac6e867885af041499723dc46f2197705204c
author Matthieu Moy  1441031540 +0200
committer Matthieu Moy  1441031540 +0200

Merge remote-tracking branch 'edward/utf-8-email-support4'

$ git log --no-merges c3c1cc25b27d448e9ef67b265a11be8735ff2df4
commit c3c1cc25b27d448e9ef67b265a11be8735ff2df4 (grafted)
Author: Matthieu Moy 
Date:   Mon Aug 31 16:32:20 2015 +0200

Merge remote-tracking branch 'edward/utf-8-email-support4'

I guess Git counts the number of parents that are actually in the
repository, but it could check the number of "parents" field in the
object (cat-file -p was still able to show 2).

Thanks,

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
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] contrib/subtree: add repo url to commit messages

2016-02-26 Thread Eric Sunshine
On Fri, Feb 26, 2016 at 3:28 AM, Mathias Nyman  wrote:
> On 2016-02-25 17:23-0500, Eric Sunshine wrote:
>> On Tue, Feb 23, 2016 at 5:25 AM, Mathias Nyman 
>> wrote:
>>> -   cat <<-EOF
>>> -   $commit_message
>>> -
>>> -   git-subtree-dir: $dir
>>> -   git-subtree-mainline: $latest_old
>>> -   git-subtree-split: $latest_new
>>> -   EOF
>>> +   echo $commit_message
>>> +   echo
>>> +   echo git-subtree-dir: $dir
>>> +   echo git-subtree-mainline: $latest_old
>>> +   echo git-subtree-split: $latest_new
>>
>> It's not clear why this code was changed to use a series of echo's in
>> place of the single cat. Although the net result is the same, this
>> appears to be mere code churn. If your intention was to make it
>> similar to how squash_msg() uses a series of echo's, then that might
>> make sense, however, rejoin_msg() uses the same single 'cat' as
>> add_msg(), so inconsistency remains. Thus, it's not clear what the
>> intention is.
>
> Using a mixutre of heredoc and echo felt messy. But I'll change it
> back to heredoc here, and through out the commit aim for near-zero
> refactoring.

An alternative would be to have a preparatory patch which unifies the
heredoc vs. echo issue across add_msg(), squash_msg(), rejoin_msg(),
but I wouldn't insist upon it (that's just more work for you). Leaving
this bit alone is a reasonable choice.

>>> +   repo="$4" # optional
>>> newsub_short=$(git rev-parse --short "$newsub")
>>> -
>>> +
>>
>>
>> Okay, this change is removing an unnecessary tab. Perhaps the commit
>> message can say that the patch fixes a few whitespace inconsistencies
>> while touching nearby code.
>
> Will undo the whitespace fixing.

Oh, I wasn't insisting that you should undo the whitespace fix.
Typically, you'd make such fixes in a preparatory cleanup patch, but
since there are only two cases here that you've fixed, it probably
wouldn't hurt to retain them (if that's all there are in the file).
The reason I suggested mentioning the whitespace fixes in the commit
message is to let the reviewer know that they weren't cases of you
accidentally making unwanted whitespace changes (like inserting tabs
rather than removing them). As it was, as a reviewer, I had to go
through extra effort to determine whether you had made a fix or had
accidentally botched something.

>>>  cmd_merge()
>>>  {
>>> -   revs=$(git rev-parse $default --revs-only "$@") || exit $?
>>> +   revs=$(git rev-parse $default --revs-only "$1") || exit $?
>>
>> Why is this variable still named 'revs' (plural) since you're only
>> passing in $1 now rather than $@?
>
> Because technically the result can still be more then one rev I guess.
> Consider 'git rev-parse HEAD~1..HEAD', which would return two hashes.

Okay, so I was missing something obvious.
--
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 v3 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Stefan Beller
On Fri, Feb 26, 2016 at 11:17 AM, Jacob Keller  wrote:
> From: Jacob Keller 
>
> Due to the way that the git-submodule code works, it clears all local
> git environment variables before entering submodules. This is normally
> a good thing since we want to clear settings such as GIT_WORKTREE and
> other variables which would affect the operation of submodule commands.
> However, GIT_CONFIG_PARAMETERS is special, and we actually do want to
> preserve these settings. However, we do not want to preserve all
> configuration as many things should be left specific to the parent
> project.
>
> Add a git submodule--helper function, sanitize-config, which shall be
> used to sanitize GIT_CONFIG_PARAMETERS, removing all key/value pairs
> except a small subset that are known to be safe and necessary.
>
> Replace all the calls to clear_local_git_env with a wrapped function
> that filters GIT_CONFIG_PARAMETERS using the new helper and then
> restores it to the filtered subset after clearing the rest of the
> environment.
>
> Signed-off-by: Jacob Keller 
> ---
>
> Notes:
> - v2
> * Clarify which paramaters are left after the sanitization, and don't 
> seem to
>   indicate it is our goal to extend the list.
> * add a comment in the submodule_config_ok function indicating the same
>
> - v3
> * Remove extraneous comments
> * add strbuf_release calls
> * rename sanitize_local_git_env
> * remove use of local
> * add C equivalent of sanitize_config
> * add a test for the credential passing
>
> - v3
> * use argc check instead of empty options check
> * fix brain-melting quotes in t7412-submodule--helper.sh

In the future, would you mind to try interdiffs in a cover letter?

(I do git diff HEAD...$(previousSeries) with previousSerier either
local branch or rather what Junio picked up already. There is also tbdiff,
which should be better and easier than this work flow)


> +*/
> +   strbuf_addstr(, var);
> +   strbuf_addch(, '=');
> +   strbuf_addstr(, value);

This could be `strbuf_addf("%s=%s", var, value);` (?)
which then gets quoted below

> +   git_config_from_parameters(sanitize_submodule_config,
> +  _config);
> +   argv_array_pushf(out, "%s=%s", *var, 
> sanitized_config.buf);

like here?

> -   subsha1=$(clear_local_git_env; cd "$sm_path" &&
> +   subsha1=$(sanitize_submodule_env; cd "$sm_path" &&
> git rev-parse --verify HEAD) ||

While at it, we could discuss if we want to replace the pattern cd
 && git-command
by `git -C  ` eventually (not in this patch) ?
--
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] credential: let empty credential specs reset helper list

2016-02-26 Thread Junio C Hamano
Junio C Hamano  writes:

> Jeff King  writes:
>
>> Sine the credential.helper key is a multi-valued config
>
> s/Sine/Since/;
>
>> diff --git a/credential.c b/credential.c
>> index 7d6501d..aa99666 100644
>> --- a/credential.c
>> +++ b/credential.c
>> @@ -63,9 +63,12 @@ static int credential_config_callback(const char *var, 
>> const char *value,
>>  key = dot + 1;
>>  }
>>  
>> -if (!strcmp(key, "helper"))
>> -string_list_append(>helpers, value);
>> -else if (!strcmp(key, "username")) {
>> +if (!strcmp(key, "helper")) {
>> +if (*value)
>> +string_list_append(>helpers, value);
>> +else
>> +string_list_clear(>helpers, 0);
>> +} else if (!strcmp(key, "username")) {
>
> I wondered why neither the existing code nor the updated one has a
> check for !value, but this callback assumes no credential
> configuration variable will ever be a boolean and rejects it
> upfront, so this code before or after the change is safe.
>
> Not pointing out anything that needs to be changed; demonstrating
> that I did read this sufficiently well to say that I have reviewed
> it ;-)

This reminds me of one thing.  The only reason why we are hesitant
to introduce a new syntax like

[credential]
!helper ;# clear
helper = ...

to allow explicit clearing of accumulated values so far IIRC is
because such a _file_ will not be readable by existing versions of
Git.  Am I correct?

If that is the case, then that reasoning will still not prevent us
from adding corresponding support for a command-line overide, i.e.
either one or both of these:

$ git -c credential.!helper cmd
$ git -c !credential.helper cmd

no?

Of course, the code in the configuration subsystem for updated
version of Git needs to become aware of the new syntax, and those
that deal with the multi-value variables need custom code, which is
similar to the way you special cased an empty value in the above
patch, so I am not sure how much this would help.

--
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 2/3] sumodule--helper: fix submodule--helper clone usage and check argc count

2016-02-26 Thread Stefan Beller
On Fri, Feb 26, 2016 at 11:18 AM, Jacob Keller  wrote:
> From: Jacob Keller 
>
> git submodule--helper clone usage specified that paths come after the --
> as a sequence. However, the actual implementation does not, and requires
> only a single path passed in via --path. In addition, argc was
> unchecked. (allowing arbitrary extra arguments that were silently
> ignored).
>
> Fix the usage description to match implementation. Add an argc check to
> enforce no extra arguments. Fix a bug in the argument passing in
> git-submodule.sh which would pass --reference and --depth as empty
> strings when they were unused, resulting in extra argc after parsing
> options.
>
> Signed-off-by: Jacob Keller 
> ---
>  builtin/submodule--helper.c | 5 -
>  git-submodule.sh| 4 ++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index f4c3eff179b5..072d9bbd12a8 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -187,13 +187,16 @@ static int module_clone(int argc, const char **argv, 
> const char *prefix)
> const char *const git_submodule_helper_usage[] = {
> N_("git submodule--helper clone [--prefix=] [--quiet] "
>"[--reference ] [--name ] [--url ]"
> -  "[--depth ] [--] [...]"),
> +  "[--depth ] [--path ]"),

Right, no extra arguments.

> NULL
> };
>
> argc = parse_options(argc, argv, prefix, module_clone_options,
>  git_submodule_helper_usage, 0);
>
> +   if (argc)
> +   usage(*git_submodule_helper_usage);
> +

This is the fix to check for more arguments.

> strbuf_addf(, "%s/modules/%s", get_git_dir(), name);
> sm_gitdir = strbuf_detach(, NULL);
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 9bc5c5f94d1d..2dd29b3df0e6 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -347,7 +347,7 @@ Use -f if you really want to add it." >&2
> echo "$(eval_gettext "Reactivating local git 
> directory for submodule '\$sm_name'.")"
> fi
> fi
> -   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
> "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" 
> "$reference" "$depth" || exit
> +   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
> "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" 
> ${reference:+"$reference"} ${depth:+"$depth"} || exit

By having this additional fix (i.e. no '--depth', '' is
passed to the
submodule helper, we can improve the submodule helper further
in clone_submodule we can drop the double check for `depth` and `reference`
(as well as `gitdir`, that double check is unneeded as of now already),
by just checking for the pointer to be non  NULL and not further checking
the dereferenced pointer.

That can go in either squashed into this commit or on top of it, either is fine.

That said:
Reviewed-by: Stefan Beller 


> (
> clear_local_git_env
> cd "$sm_path" &&
> @@ -709,7 +709,7 @@ Maybe you want to use 'update --init'?")"
>
> if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
> then
> -   git submodule--helper clone ${GIT_QUIET:+--quiet} 
> --prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" "$reference" 
> "$depth" || exit
> +   git submodule--helper clone ${GIT_QUIET:+--quiet} 
> --prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" 
> ${reference:+"$reference"} ${depth:+"$depth"} || exit
> cloned_modules="$cloned_modules;$name"
> subsha1=
> else
> --
> 2.7.1.429.g45cd78e
>
--
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 v4 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

Due to the way that the git-submodule code works, it clears all local
git environment variables before entering submodules. This is normally
a good thing since we want to clear settings such as GIT_WORKTREE and
other variables which would affect the operation of submodule commands.
However, GIT_CONFIG_PARAMETERS is special, and we actually do want to
preserve these settings. However, we do not want to preserve all
configuration as many things should be left specific to the parent
project.

Add a git submodule--helper function, sanitize-config, which shall be
used to sanitize GIT_CONFIG_PARAMETERS, removing all key/value pairs
except a small subset that are known to be safe and necessary.

Replace all the calls to clear_local_git_env with a wrapped function
that filters GIT_CONFIG_PARAMETERS using the new helper and then
restores it to the filtered subset after clearing the rest of the
environment.

Signed-off-by: Jacob Keller 
---

Notes:
- v2
* Clarify which paramaters are left after the sanitization, and don't seem 
to
  indicate it is our goal to extend the list.
* add a comment in the submodule_config_ok function indicating the same

- v3
* Remove extraneous comments
* add strbuf_release calls
* rename sanitize_local_git_env
* remove use of local
* add C equivalent of sanitize_config
* add a test for the credential passing

- v4
* use argc check instead of empty options check
* fix brain-melting quotes in t7412-submodule--helper.sh

 builtin/submodule--helper.c  | 77 +++-
 git-submodule.sh | 36 +
 t/t5550-http-fetch-dumb.sh   | 17 ++
 t/t7412-submodule--helper.sh | 27 
 4 files changed, 143 insertions(+), 14 deletions(-)
 create mode 100755 t/t7412-submodule--helper.sh

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 072d9bbd12a8..c6c0a3b06e27 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -124,6 +124,64 @@ static int module_name(int argc, const char **argv, const 
char *prefix)
 
return 0;
 }
+
+/*
+ * Rules to sanitize configuration variables that are Ok to be passed into
+ * submodule operations from the parent project using "-c". Should only
+ * include keys which are both (a) safe and (b) necessary for proper
+ * operation.
+ */
+static int submodule_config_ok(const char *var)
+{
+   if (starts_with(var, "credential."))
+   return 1;
+   return 0;
+}
+
+static int sanitize_submodule_config(const char *var, const char *value, void 
*data)
+{
+   struct strbuf quoted = STRBUF_INIT;
+   struct strbuf *out = data;
+
+   if (submodule_config_ok(var)) {
+   if (out->len)
+   strbuf_addch(out, ' ');
+
+   /*
+* The GIT_CONFIG_PARAMETERS parser is a bit picky and
+* requires that each var=value pair be quoted as a single
+* unit.
+*/
+   strbuf_addstr(, var);
+   strbuf_addch(, '=');
+   strbuf_addstr(, value);
+
+   sq_quote_buf(out, quoted.buf);
+   }
+
+   strbuf_release();
+
+   return 0;
+}
+
+static void prepare_submodule_repo_env(struct argv_array *out)
+{
+   const char * const *var;
+
+   for (var = local_repo_env; *var; var++) {
+   if (!strcmp(*var, CONFIG_DATA_ENVIRONMENT)) {
+   struct strbuf sanitized_config = STRBUF_INIT;
+   git_config_from_parameters(sanitize_submodule_config,
+  _config);
+   argv_array_pushf(out, "%s=%s", *var, 
sanitized_config.buf);
+   strbuf_release(_config);
+   } else {
+   argv_array_push(out, *var);
+   }
+   }
+
+}
+
 static int clone_submodule(const char *path, const char *gitdir, const char 
*url,
   const char *depth, const char *reference, int quiet)
 {
@@ -145,7 +203,7 @@ static int clone_submodule(const char *path, const char 
*gitdir, const char *url
argv_array_push(, path);
 
cp.git_cmd = 1;
-   cp.env = local_repo_env;
+   prepare_submodule_repo_env(_array);
cp.no_stdin = 1;
 
return run_command();
@@ -258,6 +316,22 @@ static int module_clone(int argc, const char **argv, const 
char *prefix)
return 0;
 }
 
+static int module_sanitize_config(int argc, const char **argv, const char 
*prefix)
+{
+   struct strbuf sanitized_config = STRBUF_INIT;
+
+   if (argc > 1)
+   usage(_("git submodule--helper sanitize-config"));
+
+   git_config_from_parameters(sanitize_submodule_config, 
_config);
+   if (sanitized_config.len)
+   printf("%s\n", sanitized_config.buf);
+
+

[PATCH v4 2/3] sumodule--helper: fix submodule--helper clone usage and check argc count

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

git submodule--helper clone usage specified that paths come after the --
as a sequence. However, the actual implementation does not, and requires
only a single path passed in via --path. In addition, argc was
unchecked. (allowing arbitrary extra arguments that were silently
ignored).

Fix the usage description to match implementation. Add an argc check to
enforce no extra arguments. Fix a bug in the argument passing in
git-submodule.sh which would pass --reference and --depth as empty
strings when they were unused, resulting in extra argc after parsing
options.

Signed-off-by: Jacob Keller 
---
 builtin/submodule--helper.c | 5 -
 git-submodule.sh| 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index f4c3eff179b5..072d9bbd12a8 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -187,13 +187,16 @@ static int module_clone(int argc, const char **argv, 
const char *prefix)
const char *const git_submodule_helper_usage[] = {
N_("git submodule--helper clone [--prefix=] [--quiet] "
   "[--reference ] [--name ] [--url ]"
-  "[--depth ] [--] [...]"),
+  "[--depth ] [--path ]"),
NULL
};
 
argc = parse_options(argc, argv, prefix, module_clone_options,
 git_submodule_helper_usage, 0);
 
+   if (argc)
+   usage(*git_submodule_helper_usage);
+
strbuf_addf(, "%s/modules/%s", get_git_dir(), name);
sm_gitdir = strbuf_detach(, NULL);
 
diff --git a/git-submodule.sh b/git-submodule.sh
index 9bc5c5f94d1d..2dd29b3df0e6 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -347,7 +347,7 @@ Use -f if you really want to add it." >&2
echo "$(eval_gettext "Reactivating local git 
directory for submodule '\$sm_name'.")"
fi
fi
-   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
"$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" "$reference" 
"$depth" || exit
+   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
"$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" 
${reference:+"$reference"} ${depth:+"$depth"} || exit
(
clear_local_git_env
cd "$sm_path" &&
@@ -709,7 +709,7 @@ Maybe you want to use 'update --init'?")"
 
if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
then
-   git submodule--helper clone ${GIT_QUIET:+--quiet} 
--prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" "$reference" 
"$depth" || exit
+   git submodule--helper clone ${GIT_QUIET:+--quiet} 
--prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" 
${reference:+"$reference"} ${depth:+"$depth"} || exit
cloned_modules="$cloned_modules;$name"
subsha1=
else
-- 
2.7.1.429.g45cd78e

--
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 v4 1/3] t/lib-httpd: load mod_unixd

2016-02-26 Thread Jacob Keller
From: Michael J Gruber 

In contrast to apache 2.2, apache 2.4 does not load mod_unixd in its
default configuration (because there are choices). Thus, with the
current config, apache 2.4.10 will not be started and the httpd tests
will not run on distros with default apache config (RedHat type).

Enable mod_unixd to make the httpd tests run. This does not affect
distros negatively which have that config already in their default
(Debian type). httpd tests will run on these before and after this patch.

Signed-off-by: Michael J Gruber 
Signed-off-by: Junio C Hamano 
---
I am sending this version strictly from PU since I need it to pass the
httpd tests.

 t/lib-httpd/apache.conf | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index 7d15e6d44c83..f667e7ce2f33 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -64,6 +64,9 @@ LockFile accept.lock
 
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
 
+
+   LoadModule unixd_module modules/mod_unixd.so
+
 
 
 PassEnv GIT_VALGRIND
-- 
2.7.1.429.g45cd78e

--
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 v3 2/3] sumodule--helper: fix submodule--helper clone usage and check argc count

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

git submodule--helper clone usage specified that paths come after the --
as a sequence. However, the actual implementation does not, and requires
only a single path passed in via --path. In addition, argc was
unchecked. (allowing arbitrary extra arguments that were silently
ignored).

Fix the usage description to match implementation. Add an argc check to
enforce no extra arguments. Fix a bug in the argument passing in
git-submodule.sh which would pass --reference and --depth as empty
strings when they were unused, resulting in extra argc after parsing
options.

Signed-off-by: Jacob Keller 
---
After adding argc check to my new sanitize-config subcommand, I realized
that submodule--helper clone was the only one without an argc check.
When I went to add it, I realized the usage was incorrect, and the
implementation in git-submodule.sh results in extra arguments being
passed.

I am not sure this is the best way to resolve these, but I wanted to
include it since I think silently accepting extra arguments we don't use
is bad.

 builtin/submodule--helper.c | 5 -
 git-submodule.sh| 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index f4c3eff179b5..072d9bbd12a8 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -187,13 +187,16 @@ static int module_clone(int argc, const char **argv, 
const char *prefix)
const char *const git_submodule_helper_usage[] = {
N_("git submodule--helper clone [--prefix=] [--quiet] "
   "[--reference ] [--name ] [--url ]"
-  "[--depth ] [--] [...]"),
+  "[--depth ] [--path ]"),
NULL
};
 
argc = parse_options(argc, argv, prefix, module_clone_options,
 git_submodule_helper_usage, 0);
 
+   if (argc)
+   usage(*git_submodule_helper_usage);
+
strbuf_addf(, "%s/modules/%s", get_git_dir(), name);
sm_gitdir = strbuf_detach(, NULL);
 
diff --git a/git-submodule.sh b/git-submodule.sh
index 9bc5c5f94d1d..2dd29b3df0e6 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -347,7 +347,7 @@ Use -f if you really want to add it." >&2
echo "$(eval_gettext "Reactivating local git 
directory for submodule '\$sm_name'.")"
fi
fi
-   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
"$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" "$reference" 
"$depth" || exit
+   git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix 
"$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" 
${reference:+"$reference"} ${depth:+"$depth"} || exit
(
clear_local_git_env
cd "$sm_path" &&
@@ -709,7 +709,7 @@ Maybe you want to use 'update --init'?")"
 
if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
then
-   git submodule--helper clone ${GIT_QUIET:+--quiet} 
--prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" "$reference" 
"$depth" || exit
+   git submodule--helper clone ${GIT_QUIET:+--quiet} 
--prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" 
${reference:+"$reference"} ${depth:+"$depth"} || exit
cloned_modules="$cloned_modules;$name"
subsha1=
else
-- 
2.7.1.429.g45cd78e

--
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 v3 3/3] git: submodule honor -c credential.* from command line

2016-02-26 Thread Jacob Keller
From: Jacob Keller 

Due to the way that the git-submodule code works, it clears all local
git environment variables before entering submodules. This is normally
a good thing since we want to clear settings such as GIT_WORKTREE and
other variables which would affect the operation of submodule commands.
However, GIT_CONFIG_PARAMETERS is special, and we actually do want to
preserve these settings. However, we do not want to preserve all
configuration as many things should be left specific to the parent
project.

Add a git submodule--helper function, sanitize-config, which shall be
used to sanitize GIT_CONFIG_PARAMETERS, removing all key/value pairs
except a small subset that are known to be safe and necessary.

Replace all the calls to clear_local_git_env with a wrapped function
that filters GIT_CONFIG_PARAMETERS using the new helper and then
restores it to the filtered subset after clearing the rest of the
environment.

Signed-off-by: Jacob Keller 
---

Notes:
- v2
* Clarify which paramaters are left after the sanitization, and don't seem 
to
  indicate it is our goal to extend the list.
* add a comment in the submodule_config_ok function indicating the same

- v3
* Remove extraneous comments
* add strbuf_release calls
* rename sanitize_local_git_env
* remove use of local
* add C equivalent of sanitize_config
* add a test for the credential passing

- v3
* use argc check instead of empty options check
* fix brain-melting quotes in t7412-submodule--helper.sh

 builtin/submodule--helper.c  | 77 +++-
 git-submodule.sh | 36 +
 t/t5550-http-fetch-dumb.sh   | 17 ++
 t/t7412-submodule--helper.sh | 27 
 4 files changed, 143 insertions(+), 14 deletions(-)
 create mode 100755 t/t7412-submodule--helper.sh

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 072d9bbd12a8..c6c0a3b06e27 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -124,6 +124,64 @@ static int module_name(int argc, const char **argv, const 
char *prefix)
 
return 0;
 }
+
+/*
+ * Rules to sanitize configuration variables that are Ok to be passed into
+ * submodule operations from the parent project using "-c". Should only
+ * include keys which are both (a) safe and (b) necessary for proper
+ * operation.
+ */
+static int submodule_config_ok(const char *var)
+{
+   if (starts_with(var, "credential."))
+   return 1;
+   return 0;
+}
+
+static int sanitize_submodule_config(const char *var, const char *value, void 
*data)
+{
+   struct strbuf quoted = STRBUF_INIT;
+   struct strbuf *out = data;
+
+   if (submodule_config_ok(var)) {
+   if (out->len)
+   strbuf_addch(out, ' ');
+
+   /*
+* The GIT_CONFIG_PARAMETERS parser is a bit picky and
+* requires that each var=value pair be quoted as a single
+* unit.
+*/
+   strbuf_addstr(, var);
+   strbuf_addch(, '=');
+   strbuf_addstr(, value);
+
+   sq_quote_buf(out, quoted.buf);
+   }
+
+   strbuf_release();
+
+   return 0;
+}
+
+static void prepare_submodule_repo_env(struct argv_array *out)
+{
+   const char * const *var;
+
+   for (var = local_repo_env; *var; var++) {
+   if (!strcmp(*var, CONFIG_DATA_ENVIRONMENT)) {
+   struct strbuf sanitized_config = STRBUF_INIT;
+   git_config_from_parameters(sanitize_submodule_config,
+  _config);
+   argv_array_pushf(out, "%s=%s", *var, 
sanitized_config.buf);
+   strbuf_release(_config);
+   } else {
+   argv_array_push(out, *var);
+   }
+   }
+
+}
+
 static int clone_submodule(const char *path, const char *gitdir, const char 
*url,
   const char *depth, const char *reference, int quiet)
 {
@@ -145,7 +203,7 @@ static int clone_submodule(const char *path, const char 
*gitdir, const char *url
argv_array_push(, path);
 
cp.git_cmd = 1;
-   cp.env = local_repo_env;
+   prepare_submodule_repo_env(_array);
cp.no_stdin = 1;
 
return run_command();
@@ -258,6 +316,22 @@ static int module_clone(int argc, const char **argv, const 
char *prefix)
return 0;
 }
 
+static int module_sanitize_config(int argc, const char **argv, const char 
*prefix)
+{
+   struct strbuf sanitized_config = STRBUF_INIT;
+
+   if (argc > 1)
+   usage(_("git submodule--helper sanitize-config"));
+
+   git_config_from_parameters(sanitize_submodule_config, 
_config);
+   if (sanitized_config.len)
+   printf("%s\n", sanitized_config.buf);
+
+   

Re: [GSoC] Microproject :- Teaching git pull --rebase the --no-autostash flag

2016-02-26 Thread Philip Oakley

From: "Matthieu Moy" 

Hi,

Some minor nits in addition to Paul's comments:

Subject: Re: [GSoC] Microproject :- Teaching git pull --rebase 
the --no-autostash flag


The ":-" is typically Indian. Just use ":" here (without a space
before).


I think it was we Brit's who are to blame. While less frequent these days it 
was common here in Briton. I certainly use it sometimes ;-)


http://english.stackexchange.com/questions/31060/is-it-proper-to-use-a-colon-followed-immediately-by-a-hyphen

https://www.quora.com/What-is-this-punctuation-called (originalism would 
also suggest USA..)





Mehul Jain  writes:

With this patch, git pull --rebase will understand --no-autostash command 
line flag.

This flag will override "rebase.autostash" configuration(if set)


Here and elsewhere: space before "(".

--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--


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


Re: [PATCH 01/16] bisect: write about `bisect next` in documentation

2016-02-26 Thread Junio C Hamano
Stephan Beyer  writes:

> +Bisect next
> +~~~
> +
> +Sometimes it can be necessary to check out other branches during a bisect
> +session. If you want to check out the next commit of the bisection again,
> +simply issue the command:
> +
> +
> +$ git bisect next
> +

Hmph, I am not quite sure what you mean by checking out other
branches during a bisect session.

During bisection, you are on a detached HEAD with refs/bisect/*
holding the current state, and "next" indeed is a way to recompute
the commit to be tested based on that state.

But I wonder if it is safe and sane to encourage "checking out other
branches during a bisect session." as you cannot tell what other
crazy things they will do while on "other branches".  I do not think
we even try to (and I do not think we should) handle a case where
the user tries to merge another branch, sees conflicts and says
"bisect next" without cleaning up, for example.

> +Another typical use case of this command is when you have marked a commit
> +as bad but you do not know a good commit. Instead of crawling through the
> +history yourself, let this command check out a commit for you.

I would say this is the only sensible use of "next", but as you
cannot see ;-) in the comment from the pre-context of the patch
below, "have bad but not good. we could bisect althoguh this is less
optimum.", I am not sure if it is a good idea to say "is also helpful"
as if we are encouraging such a usage.

>  OPTIONS
>  ---
>  --no-checkout::
> diff --git a/git-bisect.sh b/git-bisect.sh
> index 5d1cb00..5c93a27 100755
> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -334,16 +334,10 @@ bisect_next_check() {
>   *)
>   bad_syn=$(bisect_voc bad)
>   good_syn=$(bisect_voc good)
> - if test -s "$GIT_DIR/BISECT_START"
> - then
> -
> - eval_gettextln "You need to give me at least one 
> \$bad_syn and one \$good_syn revision.
> -(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for 
> that.)" >&2
> - else
> - eval_gettextln "You need to start by \"git bisect 
> start\".
> -You then need to give me at least one \$good_syn and one \$bad_syn revision.
> -(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for 
> that.)" >&2
> - fi
> + eval_gettextln "You need to give me at least one \$bad_syn 
> revision.
> +Use \"git bisect \$bad_syn\" for that. One \$good_syn revision is also 
> helpful
> +for bisecting (use \"git bisect \$good_syn\"). If you do not know one 
> \$good_syn
> +revision, you can use \"git bisect next\" to find one." >&2
>   exit 1 ;;
>   esac
>  }
> @@ -677,7 +671,6 @@ case "$#" in
>   skip)
>   bisect_skip "$@" ;;
>   next)
> - # Not sure we want "next" at the UI level anymore.
>   bisect_next "$@" ;;
>   visualize|view)
>   bisect_visualize "$@" ;;
--
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: What's cooking in git.git (Feb 2016, #07; Thu, 25)

2016-02-26 Thread Junio C Hamano
Torsten Bögershausen  writes:

> CC combine-diff.o
> combine-diff.c: In function ‘diff_tree_combined’:
> combine-diff.c:1391: internal compiler error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
> make: *** [combine-diff.o] Error 1
>
> Revert "use st_add and st_mult for allocation size computation" didn't fix it.
> I haven't digged deeper yet.

Hmph, I am not quite sure what you meant by "I haven't digged
deeper"; I do not think you should be debugging Apple's compiler
(unless you have the source to it and that is your job to do so,
that is).

In any case, merging the topic to 'master', and reverting that
commit will leave this only this change between 'master' and the
result.  I do not immediately spot anything trickier in the
postimage compared to the preimage that may trickle a compiler bug,
but what would I know without the source ;-)

Thanks for a report, anyway.

diff --git a/combine-diff.c b/combine-diff.c
index 5571304..be09a2b 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -319,7 +319,7 @@ static void append_lost(struct sline *sline, int n, const 
char *line, int len)
if (line[len-1] == '\n')
len--;
 
-   lline = xmalloc(sizeof(*lline) + len + 1);
+   FLEX_ALLOC_MEM(lline, line, line, len);
lline->len = len;
lline->next = NULL;
lline->prev = sline->plost.lost_tail;
@@ -330,8 +330,6 @@ static void append_lost(struct sline *sline, int n, const 
char *line, int len)
sline->plost.lost_tail = lline;
sline->plost.len++;
lline->parent_map = this_mask;
-   memcpy(lline->line, line, len);
-   lline->line[len] = 0;
 }
 
 struct combine_diff_state {
@@ -1043,7 +1041,7 @@ static void show_patch_diff(struct combine_diff_path 
*elem, int num_parent,
elem->mode = canon_mode(S_IFLNK);
 
result_size = len;
-   result = xmalloc(len + 1);
+   result = xmallocz(len);
 
done = read_in_full(fd, result, len);
if (done < 0)
@@ -1051,8 +1049,6 @@ static void show_patch_diff(struct combine_diff_path 
*elem, int num_parent,
else if (done < len)
die("early EOF '%s'", elem->path);
 
-   result[len] = 0;
-
/* If not a fake symlink, apply filters, e.g. autocrlf 
*/
if (is_file) {
struct strbuf buf = STRBUF_INIT;
@@ -1372,7 +1368,7 @@ static struct combine_diff_path *find_paths_multitree(
struct combine_diff_path paths_head;
struct strbuf base;
 
-   parents_sha1 = xmalloc(nparent * sizeof(parents_sha1[0]));
+   ALLOC_ARRAY(parents_sha1, nparent);
for (i = 0; i < nparent; i++)
parents_sha1[i] = parents->sha1[i];
 
@@ -1483,7 +1479,7 @@ void diff_tree_combined(const unsigned char *sha1,
if (opt->orderfile && num_paths) {
struct obj_order *o;
 
-   o = xmalloc(sizeof(*o) * num_paths);
+   ALLOC_ARRAY(o, num_paths);
for (i = 0, p = paths; p; p = p->next, i++)
o[i].obj = p;
order_objects(opt->orderfile, path_path, o, num_paths);
--
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: Rebase performance

2016-02-26 Thread Christian Couder
On Thu, Feb 25, 2016 at 10:42 AM, Duy Nguyen  wrote:
> On Thu, Feb 25, 2016 at 7:50 AM, Duy Nguyen  wrote:
>> On Thu, Feb 25, 2016 at 5:09 AM, Christian Couder
>>  wrote:
>>> Another possibility would be to libify the "git apply" functionality
>>> and then to use the libified "git apply" in run_apply() instead of
>>> launching a separate "git apply" process. One benefit from this is
>>> that we could probably get rid of the read_cache_from() call at the
>>> end of run_apply() and this would likely further speed up things. Also
>>> avoiding to launch separate processes might be a win especially on
>>> Windows.
>>
>> The amount of global variables in apply.c is just scary. Libification
>> will need some cleanup first (i'm not against it though). Out of
>> curiosity, how long does it take to do "git update-index > path>" on this repo? That would cover read_cache_from() and
>> write_cache().

Sure I get:

$ time git update-index > While you're measuring, maybe sprinkle some
>> trace_performance() in apply.c:apply_patch() to get an idea where time
>> is most spent in?

Each call to read_cache() takes around 0.07 seconds and each call to
check_patch_list() takes around 0.045 seconds, the rest of
apply_patch() is not significant.

> I did some experiment.

Thanks for those experiments. They are very interesting!

> The calls from am are basically
>
> for i in $PATCHES; do git apply --cached $i; git commit; done
>
> and we can approximate the libification version of that with
>
> git apply --cached $PATCHES
>
> (I hacked git-apply to do write-tree after each patch, close enough to
> git-commit).
>
> I tried it on my shallow-deepen series, 26 patches. The "for; do
> git-apply;done" command took 0m0.482s (real's time), taskset does not
> affect much for me, while the "libification" took just  0m0.105s.
> That's a very impressive number to aim for, and git.git is a small
> repo.

Yeah, from my tests it also looks like there is a lot that could be
gained from the libification.

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 2/6] t6014: test prune with detached HEADs in separate worktrees

2016-02-26 Thread Junio C Hamano
Michael J Gruber  writes:

> "git prune" relies on "git rev-list --all" to list all reachable,
> non-prunable commits. In the presence of per-worktree refs such as HEAD
> this becomes more complicated.

Not "all", perhaps "majority of".  The index is another anchor point
and rev-list is not involved in it at all.

For those that are anchored by refs and ref-like things, I think the
right thing to do is not to change the semantics of "--all" like
[3/6] does, but to invent a new option to "for-each-ref" that shows
only the refs and ref-like things that are private to the worktree.
That set may include HEAD and refs/bisect/*, perhaps.

With that, the scripted equivalent of "git repack", "git prune" and
"git fsck" can ask "git worktree list" the list of worktrees to
consult, and in each of them run "git for-each-ref --private" and
"git ls-files -s" to grab the objects to be used as the starting
point of reachability traversal.

--
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 1/6] Documentation/git-worktree: spell --detach correctly

2016-02-26 Thread Junio C Hamano
Michael J Gruber  writes:

> Signed-off-by: Michael J Gruber 
> ---
>  Documentation/git-worktree.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> index 62c76c1..51a2ea0 100644
> --- a/Documentation/git-worktree.txt
> +++ b/Documentation/git-worktree.txt
> @@ -50,7 +50,7 @@ Create `` and checkout `` into it. The new 
> working directory
>  is linked to the current repository, sharing everything except working
>  directory specific files such as HEAD, index, etc.
>  +
> -If `` is omitted and neither `-b` nor `-B` nor `--detached` used,
> +If `` is omitted and neither `-b` nor `-B` nor `--detach` used,

That is correct, but I wonder if there is an " is" missing there...?

>  then, as a convenience, a new branch based at HEAD is created automatically,
>  as if `-b $(basename )` was specified.
--
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/WIP 0/6] Detached HEADs in new worktrees considered harmful

2016-02-26 Thread Junio C Hamano
Michael J Gruber  writes:

> Before someone loses their HEAD I should put this series out (again).
>
> 1/6 is a tiny documentation fix.
>
> 2/6 demonstrates that "git prune" in the main worktree loses HEADs in other
> worktrees, and vice versa.

You do need to teach the reachability code to consider points that
are outside refs/ (HEAD and index, at least; I also recall there
were talks about per-worktree hierarchies in refs/?) as anchoring
objects to the non-prunable part of the history.

The prune/fsck reachability code already knows to consider objects
that are reachable only from the index as reachable, and I do not
think "rev-list --all" is used to enumerate them for safekeeping
(even when the worktree feature is not used).  The reachability code
that enumerates objects in the index and cache-tree needs to learn
to peek into sibling worktrees' private objects, I would think, and
I do not think the addition is a good match for rev-list.

--
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/RFC] git-commit: add a commit.verbose config variable

2016-02-26 Thread Matthieu Moy
Junio C Hamano  writes:

> Pranit Bauva  writes:
>
>>> If you know you haven't finished, you may use WIP (work in progress)
>>> instead of RFC in the title.
>>
>> I wasn't familiar with this tag. I will keep it in mind. And this is not
>> included in Documentation/SubmittingPatches , so I will send a patch to
>> include WIP tag.
>
> Please don't.  It is OK to say WIP or RFC or some people even say
> [not a patch] there; we do not need to enumerate all of them, and
> your original RFC was just fine.

In case it was unclear: my "you may" here was really meant to be "you
may", not "you should" ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
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] credential: let empty credential specs reset helper list

2016-02-26 Thread Junio C Hamano
Jeff King  writes:

> Sine the credential.helper key is a multi-valued config

s/Sine/Since/;

> diff --git a/credential.c b/credential.c
> index 7d6501d..aa99666 100644
> --- a/credential.c
> +++ b/credential.c
> @@ -63,9 +63,12 @@ static int credential_config_callback(const char *var, 
> const char *value,
>   key = dot + 1;
>   }
>  
> - if (!strcmp(key, "helper"))
> - string_list_append(>helpers, value);
> - else if (!strcmp(key, "username")) {
> + if (!strcmp(key, "helper")) {
> + if (*value)
> + string_list_append(>helpers, value);
> + else
> + string_list_clear(>helpers, 0);
> + } else if (!strcmp(key, "username")) {

I wondered why neither the existing code nor the updated one has a
check for !value, but this callback assumes no credential
configuration variable will ever be a boolean and rejects it
upfront, so this code before or after the change is safe.

Not pointing out anything that needs to be changed; demonstrating
that I did read this sufficiently well to say that I have reviewed
it ;-)
--
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: Rebase performance

2016-02-26 Thread Stefan Beller
On Fri, Feb 26, 2016 at 7:45 AM, Johannes Schindelin
 wrote:
> Hi Matthieu,
>
> On Thu, 25 Feb 2016, Matthieu Moy wrote:
>
>> Ævar Arnfjörð Bjarmason  writes:
>>
>> > At the risk of derailing this thread, a thing that would make rebase
>> > even faster I think would be to change it so that instead of applying
>> > a patch at a time to the working tree the whole operation takes place
>> > on temporary trees & commits and then we'll eventually move the branch
>> > pointer to that once it's finished.
>> >
>> > I.e. there's no reason for why a sequence of 1000 patches where a
>> > FOO.txt is changed from "hi1", "hi2", "hi3", ... would be noticeably
>> > slower than applying the same changes with git-fast-import.
>>
>> Also, not touching the worktree during rebase would have the advantage
>> that if the final result doesn't change a file, we wouldn't need to
>> touch this file at all, hence the next "make" (or whatever
>> timestamp-using build system the user runs) would consider this file
>> unchanged.
>
> We still have to write all blobs. So I would still expect this to be I/O
> bound.

But if there is an IO bound process, the only way to make it faster
is to reduce its IO, which was the proposal here? I agree that it probably
is not enough to shift it from being IO bound to say CPU bounded.

Thanks,
Stefan

>
> Ciao,
> Dscho
--
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: Restore Question

2016-02-26 Thread Kevin Daudt
On Fri, Feb 26, 2016 at 04:53:35PM +, Gerald  McKinley wrote:
> I have git running on a vm.  One of the repos got messed up.  I restored the
> vm from the previous day.  I gave the vm a different ip address and hostname.
> I did not see all my files in the repo.
> 
> -Original Message-
> From: Kevin Daudt [mailto:m...@ikke.info] 
> Sent: Friday, February 26, 2016 11:44 AM
> To: Gerald McKinley 
> Cc: git@vger.kernel.org
> Subject: Re: Restore Question
> 
> On Fri, Feb 26, 2016 at 02:18:16PM +, Gerald wrote:
> > I have git running on a VMware virtual machine.  I backup the virtual 
> > machine every day.  How do I restore git from a restore of the
> > virtual machine?
> > 
> 
> Can you explain what you mean exactly with restoring git? It's unclear
> what you want to achieve.
> 
> Retrieving a git repository is just a matter of copying the entiry
> repository directory (including .git dir).

Please don't remove the gist mailing list from the CC (use reply all).

Is this VM used to host the repositories, meaning, are they bare
repositories? 

You have to be a little more verbose, it's hard for us to guess what is
going on.

If you have restored the VM, it's just a matter of copying the
repository directory from the backup vm to the current VM..
--
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] Add --no-autostash flag to git pull --rebase

2016-02-26 Thread Mehul Jain
Hi,

Thank you for the suggestions.
On Fri, Feb 26, 2016 at 6:17 PM, Paul Tan  wrote:
> Some grammatical/spelling nits below:

Many apologies for my English.

> I think git-pull's documentation should be updated as well to talk
> about this new command-line switch.

OK.

>> diff --git a/builtin/pull.c b/builtin/pull.c
>> index 10eff03..9d1a3d0 100644
>> --- a/builtin/pull.c
>> +++ b/builtin/pull.c
>> @@ -85,6 +85,7 @@ static char *opt_squash;
>>  static char *opt_commit;
>>  static char *opt_edit;
>>  static char *opt_ff;
>> +static int opt_autostash = -1;
>>  static char *opt_verify_signatures;
>>  static struct argv_array opt_strategies = ARGV_ARRAY_INIT;
>>  static struct argv_array opt_strategy_opts = ARGV_ARRAY_INIT;
>> @@ -146,6 +147,8 @@ static struct option pull_options[] = {
>> OPT_PASSTHRU(0, "ff-only", _ff, NULL,
>> N_("abort if fast-forward is not possible"),
>> PARSE_OPT_NOARG | PARSE_OPT_NONEG),
>> +   OPT_COLOR_FLAG(0,"autostash",_autostash,
>> +   N_("abort if tree is dirty")),
>
> Why OPT_COLOR_FLAG()? And --autostash is not just about aborting if
> the working tree is dirty. Why not just copy the help message from
> git-rebase? Something like:
> "automatically stash/stash pop before and after rebase"

Using OPT_COLOR_FLAG() is wrong, I agree. OPT_BOOL will be a better option.
N_("automatically stash/stash pop before and after rebase") is better.

>> OPT_PASSTHRU(0, "verify-signatures", _verify_signatures, NULL,
>> N_("verify that the named commit has a valid GPG signature"),
>> PARSE_OPT_NOARG),
>> @@ -835,13 +838,14 @@ int cmd_pull(int argc, const char **argv, const char 
>> *prefix)
>> hashclr(orig_head);
>>
>> if (opt_rebase) {
>> -   int autostash = 0;
>> -
>> if (is_null_sha1(orig_head) && !is_cache_unborn())
>> die(_("Updating an unborn branch with changes added 
>> to the index."));
>>
>> -   git_config_get_bool("rebase.autostash", );
>> -   if (!autostash)
>> +   if(opt_autostash < 0)
>> +   
>> if(git_config_get_bool("rebase.autostash",_autostash))
>> +   opt_autostash = 0;
>
> I wonder if this code could be shortened if we simply just called
> git_config_get_bool() just before parse_options(). That way, we don't
> need to check for the "-1" special value.

Definitely. This way opt_autostash can be initialized with 0, thus default
will be false.

>>
>> +   if (!opt_autostash)
>> die_on_unclean_work_tree(prefix);
>
> OK.
>
>>
>> if (get_rebase_fork_point(rebase_fork_point, repo, 
>> *refspecs))
>> diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
>> index c952d5e..512d3bf 100755
>> --- a/t/t5520-pull.sh
>> +++ b/t/t5520-pull.sh
>> @@ -245,6 +245,14 @@ test_expect_success '--rebase fails with multiple 
>> branches' '
>> test modified = "$(git show HEAD:file)"
>>  '
>>
>> +test_expect_success '--rebase --no-autostash fails with dirty working 
>> directory' '
>
> Maybe add ..."and rebase.autostash set" to the test name? Describes
> the test better, and is consistent with the name of the test below.

Can be done. But which one of these will be more appropriate:
 "rebase.autostash set" or "rebase.autostash set true".
I prefer latter, as it will maintain consistence with the test name of
"--rebase --autostash", which will be
'--rebase --autostash succeeds with dirty working directory and
rebase.autostash set false.'


>> +test_expect_success 'git pull -q --rebase --no-autostash' '
>> +   mkdir clonedqrbnas &&
>> +   (cd clonedqrbnas  && git init &&
>> +   git pull -q --rebase --no-autostash "../parent" >out 2>err &&
>> +   test_must_be_empty err &&
>> +   test_must_be_empty out)
>> +'
>> +
>> +test_expect_success 'git pull -v --rebase --no-autostash' '
>> +   mkdir clonedvrbnas &&
>> +   (cd clonedvrbnas && git init &&
>> +   git pull -v --rebase --no-autostash "../parent" >out 2>err &&
>> +   test -s err &&
>> +   test_must_be_empty out)
>> +'
>
> While more tests are always good, I don't think we need to test for
> "-q" and "-v" with --no-autostash, because it's already covered by the
> test for "git pull -q --rebase". Perhaps with --autostash, but even
> then I don't think we need a test for "-v".

OK then. I will only add tests for "git pull --rebase --no-autostash",
"git pull --rebase --autostash" and
"git pull -q --rebase --autostash" in t5521-pull-options.sh

Thanks,
Mehul Jain
--
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] strbuf_write: omit system call when length is zero

2016-02-26 Thread Stefan Beller
On Thu, Feb 25, 2016 at 5:40 PM, Junio C Hamano  wrote:
> Duy Nguyen  writes:
>
>> On Fri, Feb 26, 2016 at 5:34 AM, Stefan Beller  wrote:
>>> In case the length of the buffer is zero, we do not need to call the
>>> fwrite system call as a performance improvement.
>>
>> fwrite is a libc call, not system call. Are you sure it always calls
>> write() (assuming buffering is off)?
>
> I do not think so, but I suspect that the patch misstates its
> rationale (I said I get uncomfortable every time I see a function
> that takes size and nelem separately used by a caller that can
> potentially pass nleme=0, when I wondered it it is OK that no caller
> of this funtion checks its return value).
>

This is exactly what happened. I assumed fwrite would be a system call
eventually.
--
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: Fwd: git clone does not respect command line options

2016-02-26 Thread Junio C Hamano
Jeff King  writes:

> That's behaving as expected. Unfortunately, you cannot currently do what
> you want easily; there is no way to "unset" a multi-valued config
> variable (like credential.helper) with a later one. Git will ask both
> configured helpers for the password, and will store a successful result
> in both.
>
> The simplest way I can think of to work around it is to point your $HOME
> elsewhere[1] during the integration test, so that it does not read your
> regular ~/gitconfig.

Yup, that was the reaction I initially had.  I saw your "setting
helper to an empty string does not mean anything sensible, so let's
use it as a signal to clear the list" patch and I think that is a
reasonable workaround.

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/RFC] git-commit: add a commit.verbose config variable

2016-02-26 Thread Junio C Hamano
Pranit Bauva  writes:

>> If you know you haven't finished, you may use WIP (work in progress)
>> instead of RFC in the title.
>
> I wasn't familiar with this tag. I will keep it in mind. And this is not
> included in Documentation/SubmittingPatches , so I will send a patch to
> include WIP tag.

Please don't.  It is OK to say WIP or RFC or some people even say
[not a patch] there; we do not need to enumerate all of them, and
your original RFC was just fine.
--
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: Restore Question

2016-02-26 Thread Kevin Daudt
On Fri, Feb 26, 2016 at 02:18:16PM +, Gerald wrote:
> I have git running on a VMware virtual machine.  I backup the virtual
> machine every day.  How do I restore git from a restore of the virtual 
> machine?
> 

Can you explain what you mean exactly with restoring git? It's unclear
what you want to achieve.

Retrieving a git repository is just a matter of copying the entiry
repository directory (including .git dir).


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


[PATCH 1/6] Documentation/git-worktree: spell --detach correctly

2016-02-26 Thread Michael J Gruber
Signed-off-by: Michael J Gruber 
---
 Documentation/git-worktree.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 62c76c1..51a2ea0 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -50,7 +50,7 @@ Create `` and checkout `` into it. The new 
working directory
 is linked to the current repository, sharing everything except working
 directory specific files such as HEAD, index, etc.
 +
-If `` is omitted and neither `-b` nor `-B` nor `--detached` used,
+If `` is omitted and neither `-b` nor `-B` nor `--detach` used,
 then, as a convenience, a new branch based at HEAD is created automatically,
 as if `-b $(basename )` was specified.
 
-- 
2.7.2.618.g7a61b68

--
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/WIP 0/6] Detached HEADs in new worktrees considered harmful

2016-02-26 Thread Michael J Gruber
Before someone loses their HEAD I should put this series out (again).

1/6 is a tiny documentation fix.

2/6 demonstrates that "git prune" in the main worktree loses HEADs in other
worktrees, and vice versa.

In fact, one should rethink the meaning of "git rev-list --all" in the context
of per-worktree refs such as HEAD.

3/6 is a possible fix (making "--all" mean "all refs in all worktrees") but may
be too intrusive.

4/6, 5/6, 6/6 are some WIP patches about making 3/6 less intrusive and fixing
some cases where do_head_ref_worktrees() has problems that do_head_ref() doesn't
have.

Michael J Gruber (6):
  Documentation/git-worktree: spell --detach correctly
  t6014: test prune with detached HEADs in separate worktrees
  rev-list: list all heads with --all
  WIP: mess only with mark_reachable
  fix unborn branch case
  revisions: list all worktree HEADs with --all

 Documentation/git-worktree.txt |  2 +-
 Documentation/rev-list-options.txt |  2 +-
 reachable.c|  2 +-
 refs.h |  1 +
 refs/files-backend.c   | 34 +-
 t/t6014-rev-list-all.sh| 25 +
 6 files changed, 62 insertions(+), 4 deletions(-)

-- 
2.7.2.618.g7a61b68

--
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/6] WIP: fix unborn branch case

2016-02-26 Thread Michael J Gruber
Signed-off-by: Michael J Gruber 
---
 refs/files-backend.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index f020c52..1614854 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1780,6 +1780,8 @@ static int do_head_ref_worktrees(const char *submodule, 
each_ref_fn fn, void *cb
worktrees = get_worktrees();
retval = 0;
for (i=0; worktrees[i]; i++) {
+   if (is_null_sha1(worktrees[i]->head_sha1))
+   continue;
hashcpy(oid.hash, worktrees[i]->head_sha1);
retval = retval || fn("HEAD", , worktrees[i]->is_detached ? 
0 : REF_ISSYMREF, cb_data);
}
-- 
2.7.2.618.g7a61b68

--
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/6] t6014: test prune with detached HEADs in separate worktrees

2016-02-26 Thread Michael J Gruber
"git prune" relies on "git rev-list --all" to list all reachable,
non-prunable commits. In the presence of per-worktree refs such as HEAD
this becomes more complicated.

Add a test that makes sure that per-worktree refs from other worktrees
are not omitted.

This is currently broken, possibly resulting in data loss.

Signed-off-by: Michael J Gruber 
---
 t/t6014-rev-list-all.sh | 25 +
 1 file changed, 25 insertions(+)

diff --git a/t/t6014-rev-list-all.sh b/t/t6014-rev-list-all.sh
index c9bedd2..99bf8ae 100755
--- a/t/t6014-rev-list-all.sh
+++ b/t/t6014-rev-list-all.sh
@@ -39,4 +39,29 @@ test_expect_success 'rev-list --graph --no-walk is 
forbidden' '
test_must_fail git rev-list --graph --no-walk HEAD
 '
 
+test_expect_success 'setup worktree tests' '
+   mkdir newtree &&
+   git worktree add --detach newtree master^ &&
+   (
+   cd newtree &&
+   commit detached2
+   )
+'
+
+test_expect_failure 'prune in main worktree does not lose detached HEAD in new 
worktree' '
+   git prune --expire=now &&
+   (
+   cd newtree &&
+   git show HEAD
+   )
+'
+
+test_expect_failure 'prune in new worktree does not lose detached HEAD in main 
worktree' '
+   (
+   cd newtree &&
+   git prune --expire=now
+   ) &&
+   git show HEAD
+'
+
 test_done
-- 
2.7.2.618.g7a61b68

--
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/RFD 3/6] rev-list: list all heads with --all

2016-02-26 Thread Michael J Gruber
HEAD is a worktree specific sysmref, so that a repository with multiple
worktrees can have multiple HEADs, or HEADs in a worktree different from
the current worktree.

So far, "rev-parse --all" adds only the HEAD from the current worktree
to the list of refs (besides branches etc.). So, a detached HEAD from a
different checkout would be missed unless a shared ref (or current HEAD)
points to it (or descents from it). As a consequence, "git prune" can
prune detached HEADs from worktrees and leave the repo in an
inconsistent state.

Make "rev-parse --all" add the HEADs from all worktrees. This results in
a non-worktree-specific ref list and solves the pruning problem.

Signed-off-by: Michael J Gruber 
---

Notes:
This patch solves the pruning problem with worktrees, but I feel quite
uneasy about substituting the ref solving at the very heart of refs.c. So
please consider this a mere poc and a request for discussion/input
about how to do this the right way.

In essence, I feel the worktree interface still has to evolve a bit: I'd
rather for_each_worktree than loop myself, and if many call sites need to
be aware of multiple heads or worktrees than get_worktrees() should be
part of our init stuff, not here. [I may be out of sync of newer progress.]

 refs/files-backend.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/refs/files-backend.c b/refs/files-backend.c
index 81f68f8..5bdb568 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -4,6 +4,7 @@
 #include "../lockfile.h"
 #include "../object.h"
 #include "../dir.h"
+#include "../worktree.h"
 
 struct ref_lock {
char *ref_name;
@@ -1748,7 +1749,8 @@ static int do_for_each_ref(struct ref_cache *refs, const 
char *base,
 static int do_head_ref(const char *submodule, each_ref_fn fn, void *cb_data)
 {
struct object_id oid;
-   int flag;
+   struct worktree **worktrees;
+   int i, retval;
 
if (submodule) {
if (resolve_gitlink_ref(submodule, "HEAD", oid.hash) == 0)
@@ -1757,10 +1759,15 @@ static int do_head_ref(const char *submodule, 
each_ref_fn fn, void *cb_data)
return 0;
}
 
-   if (!read_ref_full("HEAD", RESOLVE_REF_READING, oid.hash, ))
-   return fn("HEAD", , flag, cb_data);
+   worktrees = get_worktrees();
+   retval = 0;
+   for (i=0; worktrees[i]; i++) {
+   hashcpy(oid.hash, worktrees[i]->head_sha1);
+   retval = retval || fn("HEAD", , worktrees[i]->is_detached ? 
0 : REF_ISSYMREF, cb_data);
+   }
 
-   return 0;
+   free_worktrees(worktrees);
+   return retval;
 }
 
 int head_ref(each_ref_fn fn, void *cb_data)
-- 
2.7.2.618.g7a61b68

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


  1   2   >