[PATCH] git-p4: parse marshal output "p4 -G" in p4 changes

2017-07-03 Thread Miguel Torroja
The option -G of p4 (python marshal output) gives more context about the
data being output. That's useful when using the command "change -o" as
we can distinguish between warning/error line and real change description.

Some p4 triggers in the server side generate some warnings when
executed. Unfortunately those messages are mixed with the output of
"p4 change -o". Those extra warning lines are reported as {'code':'info'}
in python marshal output (-G). The real change output is reported as
{'code':'stat'}

the function p4CmdList accepts a new argument: skip_info. When set to
True it ignores any 'code':'info' entry (skip_info=True by default).

A new test has been created to t9807-git-p4-submit.sh adding a p4 trigger
that outputs extra lines with "p4 change -o" and "p4 changes"

Signed-off-by: Miguel Torroja 
---
 git-p4.py| 90 
 t/t9807-git-p4-submit.sh | 30 
 2 files changed, 91 insertions(+), 29 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index 8d151da91..a262e3253 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -509,7 +509,7 @@ def isModeExec(mode):
 def isModeExecChanged(src_mode, dst_mode):
 return isModeExec(src_mode) != isModeExec(dst_mode)
 
-def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
+def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=True):
 
 if isinstance(cmd,basestring):
 cmd = "-G " + cmd
@@ -545,6 +545,9 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None):
 try:
 while True:
 entry = marshal.load(p4.stdout)
+if skip_info:
+if 'code' in entry and entry['code'] == 'info':
+continue
 if cb is not None:
 cb(entry)
 else:
@@ -879,8 +882,12 @@ def p4ChangesForPaths(depotPaths, changeRange, 
requestedBlockSize):
 cmd += ["%s...@%s" % (p, revisionRange)]
 
 # Insert changes in chronological order
-for line in reversed(p4_read_pipe_lines(cmd)):
-changes.add(int(line.split(" ")[1]))
+for entry in reversed(p4CmdList(cmd)):
+if entry.has_key('p4ExitCode'):
+die('Error retrieving changes descriptions 
({})'.format(entry['p4ExitCode']))
+if not entry.has_key('change'):
+continue
+changes.add(int(entry['change']))
 
 if not block_size:
 break
@@ -1526,37 +1533,62 @@ class P4Submit(Command, P4UserMap):
 
 [upstream, settings] = findUpstreamBranchPoint()
 
-template = ""
+template = """\
+# A Perforce Change Specification.
+#
+#  Change:  The change number. 'new' on a new changelist.
+#  Date:The date this specification was last modified.
+#  Client:  The client on which the changelist was created.  Read-only.
+#  User:The user who created the changelist.
+#  Status:  Either 'pending' or 'submitted'. Read-only.
+#  Type:Either 'public' or 'restricted'. Default is 'public'.
+#  Description: Comments about the changelist.  Required.
+#  Jobs:What opened jobs are to be closed by this changelist.
+#   You may delete jobs from this list.  (New changelists only.)
+#  Files:   What opened files from the default changelist are to be added
+#   to this changelist.  You may delete files from this list.
+#   (New changelists only.)
+"""
+files_list = []
 inFilesSection = False
+change_entry = None
 args = ['change', '-o']
 if changelist:
 args.append(str(changelist))
-
-for line in p4_read_pipe_lines(args):
-if line.endswith("\r\n"):
-line = line[:-2] + "\n"
-if inFilesSection:
-if line.startswith("\t"):
-# path starts and ends with a tab
-path = line[1:]
-lastTab = path.rfind("\t")
-if lastTab != -1:
-path = path[:lastTab]
-if settings.has_key('depot-paths'):
-if not [p for p in settings['depot-paths']
-if p4PathStartsWith(path, p)]:
-continue
-else:
-if not p4PathStartsWith(path, self.depotPath):
-continue
+for entry in p4CmdList(args):
+if not entry.has_key('code'):
+continue
+if entry['code'] == 'stat':
+change_entry = entry
+break
+if not change_entry:
+die('Failed to decode output of p4 change -o')
+for key, value in change_entry.iteritems():
+if key.startswith('File'):
+if settings.has_key('depot-paths'):
+if not [p for p in 

Re: [PATCH] git-p4: parse marshal output "p4 -G" in p4 changes

2017-07-03 Thread Miguel Torroja
I changed the patch a little bit, first change is to ignore by default
any {'code':'info'} in p4CmdList (they are not exposed to the caller)
as those are the verbose messages from triggers (p4 Debug does show
them). the second change is to check the p4 trigger is really set in
the test (Lars suggestion),

On Fri, Jun 30, 2017 at 6:02 PM, Miguel Torroja
 wrote:
> On Fri, Jun 30, 2017 at 12:13 PM, Lars Schneider
>  wrote:
>>
>>> On 30 Jun 2017, at 11:41, Miguel Torroja  wrote:
>>>
>>> On Fri, Jun 30, 2017 at 10:26 AM, Lars Schneider
>>>  wrote:

> On 30 Jun 2017, at 00:46, miguel torroja  wrote:
>
> The option -G of p4 (python marshal output) gives more context about the
> data being output. That's useful when using the command "change -o" as
> we can distinguish between warning/error line and real change description.
>
> Some p4 triggers in the server side generate some warnings when
> executed. Unfortunately those messages are mixed with the output of
> "p4 change -o". Those extra warning lines are reported as {'code':'info'}
> in python marshal output (-G). The real change output is reported as
> {'code':'stat'}
>
> A new test has been created to t9807-git-p4-submit.sh adding a p4 trigger
> that outputs extra lines with "p4 change -o" and "p4 changes"
>
> Signed-off-by: Miguel Torroja 
> Signed-off-by: Junio C Hamano 
> ---
> ...

 I have never worked with p4 triggers and that might be
 the reason why I don't understand your test case.
 Maybe you can help me?

> +test_expect_success 'description with extra lines from verbose p4 
> trigger' '
> + test_when_finished cleanup_git &&
> + git p4 clone --dest="$git" //depot &&
> + (
> + p4 triggers -i <<-EOF
> + Triggers: p4triggertest-command command pre-user-change 
> "echo verbose trigger"
> + EOF
> + ) &&

 You clone the test repo and install a trigger.

> + (
> + cd "$git" &&
> + git config git-p4.skipSubmitEdit true &&
> + echo file20 >file20 &&
> + git add file20 &&
> + git commit -m file20 &&
> + git p4 submit
> + ) &&

 You make a new commit. This should run the "echo verbose trigger", right?
>>>
>>> Yes, that's correct. In this case the trigger is run with p4 change
>>> and p4 changes
>>>

> + (
> + p4 triggers -i <<-EOF
> + Triggers:
> + EOF
> + ) &&

 You delete the trigger.

> + (
> + cd "$cli" &&
> + test_path_is_file file20
> + )

 You check that the file20 is available in P4.


 What would happen if I run this test case without your patch?
 Wouldn't it pass just fine?
>>>
>>> If you run it without the patch for git-p4.py, the test doesn't pass
>>
>> You are right. I did not run "make" properly before running the test :)
>>
>>
 Wouldn't we need to check that no warning/error is in the
 real change description?

>>>
>>> that can also be added, something like this: 'p4 change -o | grep
>>> "verbose trigger"' after setting the trigger?
>>
>> Yeah, maybe. I hope this is no stupid question, but: If you clone the
>> repo with git-p4 *again* ... would you see the "verbose trigger" output
>> in the Git commit message?
>>
>
> The commands that are affected are the ones that don't use the -G
> option, as everything is sent to the standard output without being
> able to filter out what is the real contents or just info messages.
> That's not the case with the python output (-G). Having said that... I
> tried what you just said (just to be sure) and the function
> p4_last_change fails... as it expects the first dictionary returned by
> p4CmdList is the one that contains the change:
> "int(results[0]['change'])" and that's not the case as it's an info
> entry (no 'change' key, that's in the next entry...)  I'll update with
> new patches
>
> I didn't notice that before because the P4 server we have in our
> office only outputs extra info messages with the command "p4 change".
>
>
>> - Lars


Cash Benefit

2017-07-03 Thread Julie Leach



You are a recipient to Mrs Julie Leach Donation of $3 million USD.
Contact ( julieleac...@gmail.com ) for claims.



Re: [PATCH] push: add config option to --force-with-lease by default.

2017-07-03 Thread Ævar Arnfjörð Bjarmason

On Mon, Jul 03 2017, Ævar Arnfjörð Bjarmason jotted:

> On Mon, Jul 03 2017, Francesco Mazzoli jotted:
>
> A couple of things I didn't notice at first:

Oh and also, makes sense to add tests for this, see
t/t5533-push-cas.sh. I.e. just make sure the cases where the option
works work with the config, and that the option overrides the config
etc.

>>  git_config(git_push_config, );
>> +if (push_always_force_with_lease) {
>> +cas.use_tracking_for_rest = 1;
>> +}
>
> This should go in git_push_config.
>
>> +if (!strcmp(var, "push.alwaysforcewithlease")) {
>> +push_always_force_with_lease = git_config_bool(var, value);
>> +return 0;
>> +}
>
> [As you noted on IRC] --force-with-lease takes args, but yours
> doesn't. Arguably this makes no sense whatsoever to have in the config,
> but something worth pointing out in the commit message.
>
> We could make the config accept args, you'd call
> parse_push_cas_option(), but should we? I don't know.
>
> Should this also apply to send-pack's --force-with-lease? Under the same
> option name or send-pack.forceWithLease? I also don't know...


Re: [PATCH] push: add config option to --force-with-lease by default.

2017-07-03 Thread Ævar Arnfjörð Bjarmason

On Mon, Jul 03 2017, Francesco Mazzoli jotted:

A couple of things I didn't notice at first:

>   git_config(git_push_config, );
> + if (push_always_force_with_lease) {
> + cas.use_tracking_for_rest = 1;
> + }

This should go in git_push_config.

> + if (!strcmp(var, "push.alwaysforcewithlease")) {
> + push_always_force_with_lease = git_config_bool(var, value);
> + return 0;
> + }

[As you noted on IRC] --force-with-lease takes args, but yours
doesn't. Arguably this makes no sense whatsoever to have in the config,
but something worth pointing out in the commit message.

We could make the config accept args, you'd call
parse_push_cas_option(), but should we? I don't know.

Should this also apply to send-pack's --force-with-lease? Under the same
option name or send-pack.forceWithLease? I also don't know...


[PATCH] push: add config option to --force-with-lease by default.

2017-07-03 Thread Francesco Mazzoli
The flag can be overridden with `--no-force-with-lease`, or by
passing the config via the command line.

Signed-off-by: Francesco Mazzoli 
---
 Documentation/config.txt   | 5 +
 Documentation/git-push.txt | 4 +++-
 builtin/push.c | 3 +++
 cache.h| 1 +
 config.c   | 4 
 environment.c  | 1 +
 6 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 06898a7..835b34b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2537,6 +2537,11 @@ push.default::
specific workflows; for instance, in a purely central workflow
(i.e. the fetch source is equal to the push destination),
`upstream` is probably what you want.  Possible values are:
+
+push.forceWithLease::
+   When true, `--force-with-lease` is the default behavior when
+   using `push --force`. Explicit invocations of `--force-with-lease`
+   or `--no-force-with-lease` take precedence.
 +
 --
 
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 0a63966..5182656 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -195,7 +195,9 @@ only if the "lease" is still valid.
 `--force-with-lease` alone, without specifying the details, will protect
 all remote refs that are going to be updated by requiring their
 current value to be the same as the remote-tracking branch we have
-for them.
+for them. This behavior can be made default using the `push.forceWithLease`
+configuration option. Consult linkgit:git-config[1]. For more
+information.
 +
 `--force-with-lease=`, without specifying the expected value, will
 protect the named ref (alone), if it is going to be updated, by
diff --git a/builtin/push.c b/builtin/push.c
index 03846e8..d8fa826 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -561,6 +561,9 @@ int cmd_push(int argc, const char **argv, const char 
*prefix)
 
packet_trace_identity("push");
git_config(git_push_config, );
+   if (push_force_with_lease) {
+   cas.use_tracking_for_rest = 1;
+   }
argc = parse_options(argc, argv, prefix, options, push_usage, 0);
set_push_cert_flags(, push_cert);
 
diff --git a/cache.h b/cache.h
index 96055c2..5d29e8e 100644
--- a/cache.h
+++ b/cache.h
@@ -830,6 +830,7 @@ enum push_default_type {
 extern enum branch_track git_branch_track;
 extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
+extern int push_force_with_lease;
 
 enum object_creation_mode {
OBJECT_CREATION_USES_HARDLINKS = 0,
diff --git a/config.c b/config.c
index 1cd40a5..f1b1e28 100644
--- a/config.c
+++ b/config.c
@@ -1317,6 +1317,10 @@ static int git_default_push_config(const char *var, 
const char *value)
}
return 0;
}
+   if (!strcmp(var, "push.forcewithlease")) {
+   push_force_with_lease = git_config_bool(var, value);
+   return 0;
+   }
 
/* Add other config variables here and to Documentation/config.txt. */
return 0;
diff --git a/environment.c b/environment.c
index d40b21f..fb36c1b 100644
--- a/environment.c
+++ b/environment.c
@@ -53,6 +53,7 @@ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
+int push_force_with_lease = 0;
 #ifndef OBJECT_CREATION_MODE
 #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
 #endif
-- 
2.7.4



Should "head" also work for "HEAD" on case-insensitive FS?

2017-07-03 Thread Ævar Arnfjörð Bjarmason
I don't have a OSX box, but was helping a co-worker over Jabber the
other day, and he pasted something like:

$ git merge-base github/master head

Which didn't work for me, and I thought he had a local "head" branch
until realizing that of course we were just resolving HEAD on the FS.

Has this come up before? I think it makes sense to warn/error about
these magic /HEAD/ revisions if they're not upper-case.

This is likely unintentional and purely some emergent effect of how it's
implemented, and leads to unportable git invocations.


Re: [PATCH] push: add config option to --force-with-lease by default.

2017-07-03 Thread Francesco Mazzoli
On 3 July 2017 at 23:47, Ævar Arnfjörð Bjarmason  wrote:
>
> On Mon, Jul 03 2017, Francesco Mazzoli jotted:
>
> > The flag can be overridden with `--no-force-with-lease`, or by
> > passing the config via the command line.
>
> Thanks for hacking on this. A couple of things:
>
> * Most things (but not all) that configure `git whatevs --some-option`
>   are configurable via whatevs.someOption, I think this should follow
>   that convention. I.e. be push.forceWithLease not
>   push.alwaysForceWithLease.
>
>   See my
>   https://public-inbox.org/git/20170324231013.23346-1-ava...@gmail.com/
>   patch series for something that went through many of these cases
>   (although I see I didn't send it all to list). Anyway, something like
>   8/10 of our config variables for switches follow that
>   convention. Let's use it for new config.

OK, my worry was about the fact that if I call it like the option I'd better
support the full range of options available to `--force-with-lease`. Anyway,
I'll change the name.

> * It makes sense to also document this the git-push manpage. See
>   e.g. how we document --follow-tags:
>
>   Push all the refs that [...] This can also be specified with
>   configuration variable push.followTags. For more information, see
>   push.followTags in git-config(1).
>
>You should add something like that to --force-with-lease.

OK, will do.


Re: [PATCH] push: add config option to --force-with-lease by default.

2017-07-03 Thread Ævar Arnfjörð Bjarmason

On Mon, Jul 03 2017, Francesco Mazzoli jotted:

> The flag can be overridden with `--no-force-with-lease`, or by
> passing the config via the command line.

Thanks for hacking on this. A couple of things:

* Most things (but not all) that configure `git whatevs --some-option`
  are configurable via whatevs.someOption, I think this should follow
  that convention. I.e. be push.forceWithLease not
  push.alwaysForceWithLease.

  See my
  https://public-inbox.org/git/20170324231013.23346-1-ava...@gmail.com/
  patch series for something that went through many of these cases
  (although I see I didn't send it all to list). Anyway, something like
  8/10 of our config variables for switches follow that
  convention. Let's use it for new config.

* It makes sense to also document this the git-push manpage. See
  e.g. how we document --follow-tags:

  Push all the refs that [...] This can also be specified with
  configuration variable push.followTags. For more information, see
  push.followTags in git-config(1).

   You should add something like that to --force-with-lease.

> +push.alwaysforcewithlease::
> + When true, `--force-with-lease` is the default behavior when
> + using `push --force`. Explicit invocations of `--force-with-lease`
> + or `--no-force-with-lease` if present, take precedence.

Semantically this makes sense, and is exactly how most of these switch
config variables work (and would be how it worked once refactored with
my CLI arg config patch).


Re: [PATCH v5 3/7] fsmonitor: teach git to optionally utilize a file system monitor to speed up detecting new or changed files.

2017-07-03 Thread Ben Peart



On 6/27/2017 11:43 AM, Christian Couder wrote:

On Sat, Jun 10, 2017 at 3:40 PM, Ben Peart  wrote:


+int read_fsmonitor_extension(struct index_state *istate, const void *data,
+   unsigned long sz)
+{
+   const char *index = data;
+   uint32_t hdr_version;
+   uint32_t ewah_size;
+   int ret;
+
+   if (sz < sizeof(uint32_t) + sizeof(uint64_t) + sizeof(uint32_t))
+   return error("corrupt fsmonitor extension (too short)");
+
+   hdr_version = get_be32(index);


Here we use get_be32(), ...


+   index += sizeof(uint32_t);
+   if (hdr_version != INDEX_EXTENSION_VERSION)
+   return error("bad fsmonitor version %d", hdr_version);
+
+   istate->fsmonitor_last_update = get_be64(index);


...get_be64(), ...


+   index += sizeof(uint64_t);
+
+   ewah_size = get_be32(index);


... and get_be32 again, ...


+   index += sizeof(uint32_t);
+
+   istate->fsmonitor_dirty = ewah_new();
+   ret = ewah_read_mmap(istate->fsmonitor_dirty, index, ewah_size);
+   if (ret != ewah_size) {
+   ewah_free(istate->fsmonitor_dirty);
+   istate->fsmonitor_dirty = NULL;
+   return error("failed to parse ewah bitmap reading fsmonitor index 
extension");
+   }
+
+   return 0;
+}
+
+void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate)
+{
+   uint32_t hdr_version;
+   uint64_t tm;
+   struct ewah_bitmap *bitmap;
+   int i;
+   uint32_t ewah_start;
+   uint32_t ewah_size = 0;
+   int fixup = 0;
+
+   hdr_version = htonl(INDEX_EXTENSION_VERSION);


... but here we use htonl() instead of put_be32(), ...


+   strbuf_add(sb, _version, sizeof(uint32_t));
+
+   tm = htonll((uint64_t)istate->fsmonitor_last_update);


... htonll(), ...


+   strbuf_add(sb, , sizeof(uint64_t));
+   fixup = sb->len;
+   strbuf_add(sb, _size, sizeof(uint32_t)); /* we'll fix this up 
later */
+
+   ewah_start = sb->len;
+   bitmap = ewah_new();
+   for (i = 0; i < istate->cache_nr; i++)
+   if (istate->cache[i]->ce_flags & CE_FSMONITOR_DIRTY)
+   ewah_set(bitmap, i);
+   ewah_serialize_strbuf(bitmap, sb);
+   ewah_free(bitmap);
+
+   /* fix up size field */
+   ewah_size = htonl(sb->len - ewah_start);


... and htonl() again.

It would be more consistent (and perhaps more correct) to use
put_beXX() functions, instead of the htonl() and htonll() functions.


I agree that these are asymmetric.  I followed the pattern used in the 
untracked cache in which write_untracked_extension uses htonl and 
read_untracked_extension uses get_be32. I can change this to be more 
symmetric.





+   memcpy(sb->buf + fixup, _size, sizeof(uint32_t));
+}



+/*
+ * Call the query-fsmonitor hook passing the time of the last saved results.
+ */
+static int query_fsmonitor(int version, uint64_t last_update, struct strbuf 
*query_result)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+   char ver[64];
+   char date[64];
+   const char *argv[4];
+
+   if (!(argv[0] = find_hook("query-fsmonitor")))
+   return -1;
+
+   snprintf(ver, sizeof(version), "%d", version);
+   snprintf(date, sizeof(date), "%" PRIuMAX, (uintmax_t)last_update);
+   argv[1] = ver;
+   argv[2] = date;
+   argv[3] = NULL;
+   cp.argv = argv;


Maybe it would be nicer using the argv_array_pushX() functions.


When the number of arguments is fixed and known, I prefer avoiding the 
dynamic allocations that come along with the argv_array_pushX() functions.





+   cp.out = -1;
+
+   return capture_command(, query_result, 1024);
+}
+
+static void mark_file_dirty(struct index_state *istate, const char *name)
+{
+   struct untracked_cache_dir *dir;
+   int pos;
+
+   /* find it in the index and mark that entry as dirty */
+   pos = index_name_pos(istate, name, strlen(name));
+   if (pos >= 0) {
+   if (!(istate->cache[pos]->ce_flags & CE_FSMONITOR_DIRTY)) {
+   istate->cache[pos]->ce_flags |= CE_FSMONITOR_DIRTY;
+   istate->cache_changed |= FSMONITOR_CHANGED;
+   }
+   }
+
+   /*
+* Find the corresponding directory in the untracked cache
+* and mark it as invalid
+*/
+   if (!istate->untracked || !istate->untracked->root)
+   return;
+
+   dir = find_untracked_cache_dir(istate->untracked, 
istate->untracked->root, name);
+   if (dir) {
+   if (dir->valid) {
+   dir->valid = 0;
+   istate->cache_changed |= FSMONITOR_CHANGED;
+   }
+   }


The code above is quite similar as what is in mark_fsmonitor_dirty(),
so I wonder if a refactoring is possible.


I've felt the same way and looked at how to refactor it better a number 
of times but never came up with a way that 

[PATCH] push: add config option to --force-with-lease by default.

2017-07-03 Thread Francesco Mazzoli
The flag can be overridden with `--no-force-with-lease`, or by
passing the config via the command line.

Signed-off-by: Francesco Mazzoli 
---
 Documentation/config.txt | 5 +
 builtin/push.c   | 3 +++
 cache.h  | 1 +
 config.c | 4 
 environment.c| 1 +
 5 files changed, 14 insertions(+)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 06898a7..36fe882 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2537,6 +2537,11 @@ push.default::
specific workflows; for instance, in a purely central workflow
(i.e. the fetch source is equal to the push destination),
`upstream` is probably what you want.  Possible values are:
+
+push.alwaysforcewithlease::
+   When true, `--force-with-lease` is the default behavior when
+   using `push --force`. Explicit invocations of `--force-with-lease`
+   or `--no-force-with-lease` if present, take precedence.
 +
 --
 
diff --git a/builtin/push.c b/builtin/push.c
index 03846e8..96fc4b2 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -561,6 +561,9 @@ int cmd_push(int argc, const char **argv, const char 
*prefix)
 
packet_trace_identity("push");
git_config(git_push_config, );
+   if (push_always_force_with_lease) {
+   cas.use_tracking_for_rest = 1;
+   }
argc = parse_options(argc, argv, prefix, options, push_usage, 0);
set_push_cert_flags(, push_cert);
 
diff --git a/cache.h b/cache.h
index 96055c2..d31c972 100644
--- a/cache.h
+++ b/cache.h
@@ -830,6 +830,7 @@ enum push_default_type {
 extern enum branch_track git_branch_track;
 extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
+extern int push_always_force_with_lease;
 
 enum object_creation_mode {
OBJECT_CREATION_USES_HARDLINKS = 0,
diff --git a/config.c b/config.c
index 1cd40a5..2a0dbe4 100644
--- a/config.c
+++ b/config.c
@@ -1317,6 +1317,10 @@ static int git_default_push_config(const char *var, 
const char *value)
}
return 0;
}
+   if (!strcmp(var, "push.alwaysforcewithlease")) {
+   push_always_force_with_lease = git_config_bool(var, value);
+   return 0;
+   }
 
/* Add other config variables here and to Documentation/config.txt. */
return 0;
diff --git a/environment.c b/environment.c
index d40b21f..79186c7 100644
--- a/environment.c
+++ b/environment.c
@@ -53,6 +53,7 @@ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
+int push_always_force_with_lease = 0;
 #ifndef OBJECT_CREATION_MODE
 #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
 #endif
-- 
2.7.4



Re: [PATCH 06/12] builtin/update_ref: convert to struct object_id

2017-07-03 Thread Ævar Arnfjörð Bjarmason

On Mon, Jul 03 2017, brian m. carlson jotted:

> Convert the uses of unsigned char * to struct object_id.

I read all of this over (but didn't apply/test it) and it looks good to
me, Just a small nit:

> [...]
>  1 file changed, 34 insertions(+), 35 deletions(-)
> [...]
>   struct strbuf err = STRBUF_INIT;
>   char *refname;
> - unsigned char new_sha1[20];
> - unsigned char old_sha1[20];
> + struct object_id new_oid, old_oid;
> [...]

It's easier to skim these when you leave changes in the number of lines
to separate commits which do more than just rename boilerplate code,
e.g. as in 05/12 where `const char *p` is introduced.

Thanks for working on this.


[GSoC][PATCH 4/5 v4] submodule: port submodule subcommand 'status' from shell to C

2017-07-03 Thread Prathamesh Chavan
This aims to make git-submodule 'status' a built-in. Hence, the function
cmd_status() is ported from shell to C. This is done by introducing
three functions: module_status(), submodule_status() and print_status().

The function module_status() acts as the front-end of the subcommand.
It parses subcommand's options and then calls the function
module_list_compute() for computing the list of submodules. Then
this functions calls for_each_submodule_list() looping through the
list obtained.

Then for_each_submodule_list() calls submodule_status() for each of the
submodule in its list. The function submodule_status() is responsible
for generating the status each submodule it is called for, and
then calls print_status().

Finally, the function print_status() handles the printing of submodule's
status.

Mentored-by: Christian Couder 
Mentored-by: Stefan Beller 
Signed-off-by: Prathamesh Chavan 
---
A NEEDSWORK tag was added at the two places where optimization
for future.

 builtin/submodule--helper.c | 154 
 git-submodule.sh|  49 +-
 2 files changed, 155 insertions(+), 48 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 5884a9725..d67a97062 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -560,6 +560,159 @@ static int module_init(int argc, const char **argv, const 
char *prefix)
return 0;
 }
 
+struct status_cb {
+   const char *prefix;
+   unsigned int quiet: 1;
+   unsigned int recursive: 1;
+   unsigned int cached: 1;
+};
+#define STATUS_CB_INIT { NULL, 0, 0, 0 }
+
+static void print_status(struct status_cb *info, char state, const char *path,
+char *sub_sha1, char *displaypath)
+{
+   if (info->quiet)
+   return;
+
+   printf("%c%s %s", state, sub_sha1, displaypath);
+
+   if (state == ' ' || state == '+') {
+   struct argv_array name_rev_args = ARGV_ARRAY_INIT;
+
+   argv_array_pushl(_rev_args, "print-name-rev",
+path, sub_sha1, NULL);
+   print_name_rev(name_rev_args.argc, name_rev_args.argv,
+  info->prefix);
+   } else {
+   printf("\n");
+   }
+}
+
+static void status_submodule(const struct cache_entry *list_item, void 
*cb_data)
+{
+   struct status_cb *info = cb_data;
+   char *sub_sha1 = xstrdup(oid_to_hex(_item->oid));
+   char *displaypath;
+   struct argv_array diff_files_args = ARGV_ARRAY_INIT;
+
+   if (!submodule_from_path(null_sha1, list_item->name))
+   die(_("no submodule mapping found in .gitmodules for path 
'%s'"),
+ list_item->name);
+
+   displaypath = get_submodule_displaypath(list_item->name, info->prefix);
+
+   if (list_item->ce_flags) {
+   print_status(info, 'U', list_item->name,
+sha1_to_hex(null_sha1), displaypath);
+   goto cleanup;
+   }
+
+   if (!is_submodule_initialized(list_item->name)) {
+   print_status(info, '-', list_item->name, sub_sha1, displaypath);
+   goto cleanup;
+   }
+
+   argv_array_pushl(_files_args, "diff-files",
+"--ignore-submodules=dirty", "--quiet", "--",
+list_item->name, NULL);
+
+   /* NEEDSWORK: future optimization possible */
+   if (!cmd_diff_files(diff_files_args.argc, diff_files_args.argv,
+   info->prefix)) {
+   print_status(info, ' ', list_item->name, sub_sha1, displaypath);
+   } else {
+   if (!info->cached) {
+   struct child_process cp = CHILD_PROCESS_INIT;
+   struct strbuf sb = STRBUF_INIT;
+
+   prepare_submodule_repo_env(_array);
+   cp.git_cmd = 1;
+   cp.dir = list_item->name;
+
+   argv_array_pushl(, "rev-parse",
+"--verify", "HEAD", NULL);
+
+   /* NEEDSWORK: future optimization possible */
+   if (capture_command(, , 0))
+   die(_("could not run 'git rev-parse --verify"
+ "HEAD' in submodule %s"),
+ list_item->name);
+
+   strbuf_strip_suffix(, "\n");
+   print_status(info, '+', list_item->name, sb.buf,
+displaypath);
+   strbuf_release();
+   } else {
+   print_status(info, '+', list_item->name, sub_sha1,
+displaypath);
+   }
+   }
+
+   if (info->recursive) {
+   struct child_process cpr = 

[GSoC][PATCH 1/5 v4] submodule--helper: introduce get_submodule_displaypath()

2017-07-03 Thread Prathamesh Chavan
Introduce function get_submodule_displaypath() to replace the code
occurring in submodule_init() for generating displaypath of the
submodule with a call to it.

This new function will also be used in other parts of the system
in later patches.

Mentored-by: Christian Couder 
Mentored-by: Stefan Beller 
Signed-off-by: Prathamesh Chavan 
---
This series of patches are build over the 'mater' branch.

Complete build report is available at:
https://travis-ci.org/pratham-pc/git/builds
Branch: setnamerev
Build #119

 builtin/submodule--helper.c | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 8517032b3..1bfc91bca 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -220,6 +220,27 @@ static int resolve_relative_url_test(int argc, const char 
**argv, const char *pr
return 0;
 }
 
+static char *get_submodule_displaypath(const char *path, const char *prefix)
+{
+   const char *super_prefix = get_super_prefix();
+
+   if (prefix && super_prefix) {
+   BUG("cannot have prefix '%s' and superprefix '%s'",
+   prefix, super_prefix);
+   } else if (prefix) {
+   struct strbuf sb = STRBUF_INIT;
+   char *displaypath = xstrdup(relative_path(path, prefix, ));
+   strbuf_release();
+   return displaypath;
+   } else if (super_prefix) {
+   int len = strlen(super_prefix);
+   const char *format = is_dir_sep(super_prefix[len - 1]) ? "%s%s" 
: "%s/%s";
+   return xstrfmt(format, super_prefix, path);
+   } else {
+   return xstrdup(path);
+   }
+}
+
 struct module_list {
const struct cache_entry **entries;
int alloc, nr;
@@ -339,16 +360,7 @@ static void init_submodule(const char *path, const char 
*prefix, int quiet)
 
/* Only loads from .gitmodules, no overlay with .git/config */
gitmodules_config();
-
-   if (prefix && get_super_prefix())
-   die("BUG: cannot have prefix and superprefix");
-   else if (prefix)
-   displaypath = xstrdup(relative_path(path, prefix, ));
-   else if (get_super_prefix()) {
-   strbuf_addf(, "%s%s", get_super_prefix(), path);
-   displaypath = strbuf_detach(, NULL);
-   } else
-   displaypath = xstrdup(path);
+   displaypath = get_submodule_displaypath(path, prefix);
 
sub = submodule_from_path(null_sha1, path);
 
@@ -363,7 +375,6 @@ static void init_submodule(const char *path, const char 
*prefix, int quiet)
 * Set active flag for the submodule being initialized
 */
if (!is_submodule_initialized(path)) {
-   strbuf_reset();
strbuf_addf(, "submodule.%s.active", sub->name);
git_config_set_gently(sb.buf, "true");
}
-- 
2.13.0



[GSoC][PATCH 3/5 v4] submodule: port set_name_rev() from shell to C

2017-07-03 Thread Prathamesh Chavan
Function set_name_rev() is ported from git-submodule to the
submodule--helper builtin. The function get_name_rev() generates the
value of the revision name as required, and the function
print_name_rev() handles the formating and printing of the obtained
revision name.

Mentored-by: Christian Couder 
Mentored-by: Stefan Beller 
Signed-off-by: Prathamesh Chavan 
---
As suggested the unnecessary enum present was removed.

 builtin/submodule--helper.c | 63 +
 git-submodule.sh| 16 ++--
 2 files changed, 65 insertions(+), 14 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c4286aac5..5884a9725 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -244,6 +244,68 @@ static char *get_submodule_displaypath(const char *path, 
const char *prefix)
}
 }
 
+static char *get_name_rev(const char *sub_path, const char* object_id)
+{
+   struct strbuf sb = STRBUF_INIT;
+   const char ***d;
+
+   static const char *describe_bare[] = {
+   NULL
+   };
+
+   static const char *describe_tags[] = {
+   "--tags", NULL
+   };
+
+   static const char *describe_contains[] = {
+   "--contains", NULL
+   };
+
+   static const char *describe_all_always[] = {
+   "--all", "--always", NULL
+   };
+
+   static const char **describe_argv[] = {
+   describe_bare, describe_tags, describe_contains,
+   describe_all_always, NULL
+   };
+
+   for (d = describe_argv; *d; d++) {
+   struct child_process cp = CHILD_PROCESS_INIT;
+   prepare_submodule_repo_env(_array);
+   cp.dir = sub_path;
+   cp.git_cmd = 1;
+   cp.no_stderr = 1;
+
+   argv_array_push(, "describe");
+   argv_array_pushv(, *d);
+   argv_array_push(, object_id);
+
+   if (!capture_command(, , 0) && sb.len) {
+   strbuf_strip_suffix(, "\n");
+   return strbuf_detach(, NULL);
+   }
+
+   }
+
+   strbuf_release();
+   return NULL;
+}
+
+static int print_name_rev(int argc, const char **argv, const char *prefix)
+{
+   char *namerev;
+   if (argc != 3)
+   die("print-name-rev only accepts two arguments:  ");
+
+   namerev = get_name_rev(argv[1], argv[2]);
+   if (namerev && namerev[0])
+   printf(" (%s)", namerev);
+   printf("\n");
+
+   return 0;
+}
+
 struct module_list {
const struct cache_entry **entries;
int alloc, nr;
@@ -1242,6 +1304,7 @@ static struct cmd_struct commands[] = {
{"relative-path", resolve_relative_path, 0},
{"resolve-relative-url", resolve_relative_url, 0},
{"resolve-relative-url-test", resolve_relative_url_test, 0},
+   {"print-name-rev", print_name_rev, 0},
{"init", module_init, SUPPORT_SUPER_PREFIX},
{"remote-branch", resolve_remote_submodule_branch, 0},
{"push-check", push_check, 0},
diff --git a/git-submodule.sh b/git-submodule.sh
index e131760ee..e988167e0 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -759,18 +759,6 @@ cmd_update()
}
 }
 
-set_name_rev () {
-   revname=$( (
-   sanitize_submodule_env
-   cd "$1" && {
-   git describe "$2" 2>/dev/null ||
-   git describe --tags "$2" 2>/dev/null ||
-   git describe --contains "$2" 2>/dev/null ||
-   git describe --all --always "$2"
-   }
-   ) )
-   test -z "$revname" || revname=" ($revname)"
-}
 #
 # Show commit summary for submodules in index or working tree
 #
@@ -1042,14 +1030,14 @@ cmd_status()
fi
if git diff-files --ignore-submodules=dirty --quiet -- 
"$sm_path"
then
-   set_name_rev "$sm_path" "$sha1"
+   revname=$(git submodule--helper print-name-rev 
"$sm_path" "$sha1")
say " $sha1 $displaypath$revname"
else
if test -z "$cached"
then
sha1=$(sanitize_submodule_env; cd "$sm_path" && 
git rev-parse --verify HEAD)
fi
-   set_name_rev "$sm_path" "$sha1"
+   revname=$(git submodule--helper print-name-rev 
"$sm_path" "$sha1")
say "+$sha1 $displaypath$revname"
fi
 
-- 
2.13.0



[GSoC][PATCH 5/5 v4] submodule: port submodule subcommand 'sync' from shell to C

2017-07-03 Thread Prathamesh Chavan
Port the submodule subcommand 'sync' from shell to C using the same
mechanism as that used for porting submodule subcommand 'status'.
Hence, here the function cmd_sync() is ported from shell to C.
This is done by introducing three functions: module_sync(),
sync_submodule() and print_default_remote().

The function print_default_remote() is introduced for getting
the default remote as stdout.

Mentored-by: Christian Couder 
Mentored-by: Stefan Beller 
Signed-off-by: Prathamesh Chavan 
---
 builtin/submodule--helper.c | 181 +++-
 git-submodule.sh|  56 +-
 2 files changed, 181 insertions(+), 56 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index d67a97062..f28391634 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -44,6 +44,20 @@ static char *get_default_remote(void)
return ret;
 }
 
+static int print_default_remote(int argc, const char **argv, const char 
*prefix)
+{
+   const char *remote;
+
+   if (argc != 1)
+   die(_("submodule--helper print-default-remote takes no 
arguments"));
+
+   remote = get_default_remote();
+   if (remote)
+   puts(remote);
+
+   return 0;
+}
+
 static int starts_with_dot_slash(const char *str)
 {
return str[0] == '.' && is_dir_sep(str[1]);
@@ -379,6 +393,25 @@ static void module_list_active(struct module_list *list)
*list = active_modules;
 }
 
+static char *get_up_path(const char *path)
+{
+   int i;
+   struct strbuf sb = STRBUF_INIT;
+
+   for (i = count_slashes(path); i; i--)
+   strbuf_addstr(, "../");
+
+   /*
+* Check if 'path' ends with slash or not
+* for having the same output for dir/sub_dir
+* and dir/sub_dir/
+*/
+   if (!is_dir_sep(path[strlen(path) - 1]))
+   strbuf_addstr(, "../");
+
+   return strbuf_detach(, NULL);
+}
+
 static int module_list(int argc, const char **argv, const char *prefix)
 {
int i;
@@ -478,16 +511,18 @@ static void init_submodule(const struct cache_entry 
*list_item, void *cb_data)
char *remote = get_default_remote();
struct strbuf remotesb = STRBUF_INIT;
strbuf_addf(, "remote.%s.url", remote);
-   free(remote);
 
if (git_config_get_string(remotesb.buf, )) {
warning(_("could not lookup configuration '%s'. 
Assuming this repository is its own authoritative upstream."), remotesb.buf);
remoteurl = xgetcwd();
}
relurl = relative_url(remoteurl, url, NULL);
+
+   free(remote);
strbuf_release();
free(remoteurl);
free(url);
+
url = relurl;
}
 
@@ -732,6 +767,148 @@ static int module_name(int argc, const char **argv, const 
char *prefix)
return 0;
 }
 
+struct sync_cb {
+   const char *prefix;
+   unsigned int quiet: 1;
+   unsigned int recursive: 1;
+};
+#define SYNC_CB_INIT { NULL, 0, 0 }
+
+static void sync_submodule(const struct cache_entry *list_item, void *cb_data)
+{
+   struct sync_cb *info = cb_data;
+   const struct submodule *sub;
+   char *sub_key, *remote_key;
+   char *sub_origin_url, *super_config_url, *displaypath;
+   struct strbuf sb = STRBUF_INIT;
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   if (!is_submodule_initialized(list_item->name))
+   return;
+
+   sub = submodule_from_path(null_sha1, list_item->name);
+
+   if (!sub || !sub->url)
+   die(_("no url found for submodule path '%s' in .gitmodules"),
+ list_item->name);
+
+   if (starts_with_dot_dot_slash(sub->url) || 
starts_with_dot_slash(sub->url)) {
+   char *remote_url, *up_path;
+   char *remote = get_default_remote();
+   char *remote_key = xstrfmt("remote.%s.url", remote);
+   free(remote);
+
+   if (git_config_get_string(remote_key, _url))
+   remote_url = xgetcwd();
+   up_path = get_up_path(list_item->name);
+   sub_origin_url = relative_url(remote_url, sub->url, up_path);
+   super_config_url = relative_url(remote_url, sub->url, NULL);
+   free(remote_key);
+   free(up_path);
+   free(remote_url);
+   } else {
+   sub_origin_url = xstrdup(sub->url);
+   super_config_url = xstrdup(sub->url);
+   }
+
+   displaypath = get_submodule_displaypath(list_item->name, info->prefix);
+
+   if (!info->quiet)
+   printf(_("Synchronizing submodule url for '%s'\n"),

[GSoC][PATCH 2/5 v4] submodule--helper: introduce for_each_submodule_list()

2017-07-03 Thread Prathamesh Chavan
Introduce function for_each_submodule_list() and
replace a loop in module_init() with a call to it.

The new function will also be used in other parts of the
system in later patches.

Mentored-by: Christian Couder 
Mentored-by: Stefan Beller 
Signed-off-by: Prathamesh Chavan 
---
 builtin/submodule--helper.c | 39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1bfc91bca..c4286aac5 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -14,6 +14,9 @@
 #include "refs.h"
 #include "connect.h"
 
+typedef void (*submodule_list_func_t)(const struct cache_entry *list_item,
+ void *cb_data);
+
 static char *get_default_remote(void)
 {
char *dest = NULL, *ret;
@@ -352,17 +355,30 @@ static int module_list(int argc, const char **argv, const 
char *prefix)
return 0;
 }
 
-static void init_submodule(const char *path, const char *prefix, int quiet)
+static void for_each_submodule_list(const struct module_list list,
+   submodule_list_func_t fn, void *cb_data)
 {
+   int i;
+   for (i = 0; i < list.nr; i++)
+   fn(list.entries[i], cb_data);
+}
+
+struct init_cb {
+   const char *prefix;
+   unsigned int quiet: 1;
+};
+#define INIT_CB_INIT { NULL, 0 }
+
+static void init_submodule(const struct cache_entry *list_item, void *cb_data)
+{
+   struct init_cb *info = cb_data;
const struct submodule *sub;
struct strbuf sb = STRBUF_INIT;
char *upd = NULL, *url = NULL, *displaypath;
 
-   /* Only loads from .gitmodules, no overlay with .git/config */
-   gitmodules_config();
-   displaypath = get_submodule_displaypath(path, prefix);
+   displaypath = get_submodule_displaypath(list_item->name, info->prefix);
 
-   sub = submodule_from_path(null_sha1, path);
+   sub = submodule_from_path(null_sha1, list_item->name);
 
if (!sub)
die(_("No url found for submodule path '%s' in .gitmodules"),
@@ -374,7 +390,7 @@ static void init_submodule(const char *path, const char 
*prefix, int quiet)
 *
 * Set active flag for the submodule being initialized
 */
-   if (!is_submodule_initialized(path)) {
+   if (!is_submodule_initialized(list_item->name)) {
strbuf_addf(, "submodule.%s.active", sub->name);
git_config_set_gently(sb.buf, "true");
}
@@ -416,7 +432,7 @@ static void init_submodule(const char *path, const char 
*prefix, int quiet)
if (git_config_set_gently(sb.buf, url))
die(_("Failed to register url for submodule path '%s'"),
displaypath);
-   if (!quiet)
+   if (!info->quiet)
fprintf(stderr,
_("Submodule '%s' (%s) registered for path 
'%s'\n"),
sub->name, url, displaypath);
@@ -445,10 +461,10 @@ static void init_submodule(const char *path, const char 
*prefix, int quiet)
 
 static int module_init(int argc, const char **argv, const char *prefix)
 {
+   struct init_cb info = INIT_CB_INIT;
struct pathspec pathspec;
struct module_list list = MODULE_LIST_INIT;
int quiet = 0;
-   int i;
 
struct option module_init_options[] = {
OPT__QUIET(, N_("Suppress output for initializing a 
submodule")),
@@ -473,8 +489,11 @@ static int module_init(int argc, const char **argv, const 
char *prefix)
if (!argc && git_config_get_value_multi("submodule.active"))
module_list_active();
 
-   for (i = 0; i < list.nr; i++)
-   init_submodule(list.entries[i]->name, prefix, quiet);
+   info.prefix = prefix;
+   info.quiet = !!quiet;
+
+   gitmodules_config();
+   for_each_submodule_list(list, init_submodule, );
 
return 0;
 }
-- 
2.13.0



Re: [PATCH v3 2/3] sha1dc: optionally use sha1collisiondetection as a submodule

2017-07-03 Thread Ævar Arnfjörð Bjarmason

On Mon, Jul 03 2017, Junio C. Hamano jotted:

> Ævar Arnfjörð Bjarmason   writes:
>
>> Add an option to use the sha1collisiondetection library from the
>> submodule in sha1collisiondetection/ instead of in the copy in the
>> sha1dc/ directory.
>>
>> This allows us to try out the submodule in sha1collisiondetection
>> without breaking the build for anyone who's not expecting them as we
>> work out any kinks.
>>
>> Signed-off-by: Ævar Arnfjörð Bjarmason 
>> ---
>>  .gitmodules|  4 
>>  Makefile   | 12 
>>  hash.h |  4 
>>  sha1collisiondetection |  1 +
>>  4 files changed, 21 insertions(+)
>>  create mode 100644 .gitmodules
>>  create mode 16 sha1collisiondetection
>>
>> diff --git a/.gitmodules b/.gitmodules
>> new file mode 100644
>> index 00..cbeebdab7a
>> --- /dev/null
>> +++ b/.gitmodules
>> @@ -0,0 +1,4 @@
>> +[submodule "sha1collisiondetection"]
>> +path = sha1collisiondetection
>> +url = https://github.com/cr-marcstevens/sha1collisiondetection.git
>> +branch = master
>
> Do we need to say this "branch" bit?

Yes, it's to make future updates easier, see b928922727 ("submodule add:
If --branch is given, record it in .gitmodules", 2012-12-19).

> Other than that looks good to me.
>
> Thanks.


[GSoC] Update: Week 7

2017-07-03 Thread Prathamesh Chavan
SUMMARY OF MY PROJECT:

Git submodule subcommands are currently implemented by using shell script
'git-submodule.sh'. There are several reasons why we'll prefer not to
use the shell script. My project intends to convert the subcommands into
C code, thus making them builtins. This will increase Git's portability
and hence the efficiency of working with the git-submodule commands.
Link to the complete proposal: [1]

Mentors:
Stefan Beller 
Christian Couder 

UPDATES:

Following are the updates about my ongoing project:

1. sync and status: The patches are updates after the last
   discussion, and will be posted with this update, along
   with the patches of the function get_submodule_displaypath()
   and for_each_submodule_list().

2. deinit: The patch was discussed in the last update, and
   I still have to make the required changes to this patch.

3. summary: I'm still working on debugging this patch as
   the are still some part where the patch isn't working as
   expected.

4. foreach: Most of the time was spent in reading the repo-object
   patch series. Also, currently I'm still confused about the
   approach I have to take for carrying this out.

PLAN FOR WEEK-8 (4 July 2017 to 10 July 2017):

The main focus for this week will be to get the reviewed code merged
by sending new version after their review. Hence, I've attached
the patches which were recently review, after adding the
suggested changes, with this update. Other than that, there is still
lots of work related to porting left as follows:

1. foreach: I'll try to come up with an approach for the present
   problem in the foreach patch, and get this discussed with
   mentors as well as with Brandon Williams so that I can
   get this subcommand ported.

2. summary: Currently, I'm still on debugging the patch. There are
   parts of the patch which aren't running as expected and hence
   it is taking more time to figure it out.

3. deinit: The patch was reviewed in the last update and I'm yet to
   work on the improving the patches as suggested.

Apart from this, there still lie two submodule subcommands: 'add' and
'update' unported.
I'll try to completed as much as work related to porting but will
also, focus on improving the code completed so that it becomes good
for merging.

[1]: 
https://docs.google.com/document/d/1krxVLooWl--75Pot3dazhfygR3wCUUWZWzTXtK1L-xU/

Thanks,
Prathamesh Chavan


Re: What's cooking in git.git (Jun 2017, #09; Fri, 30)

2017-07-03 Thread Junio C Hamano
"Philip Oakley"  writes:

> Am I right that the What's cooking  is prepared by a script?

Because I have to keep track of so many topics, its maintenance is
heavily helped by a script. I do not think it is sensible to expect
me to (or it would be good use of my time) correctly update the list
of commits manually every time a topic is replaced with its new
version.

But I consider the use of the script just like my use of Emacs to
edit the final end result.  Yes, I use tools to prepare it, and the
tools know certain rules that I prefer to apply to the document,
such as "a topic that has not been touched since the previous issue
by default does not need its description updated."

Does that answer your question?



Re: Help needed for solving a few issues with building git

2017-07-03 Thread Junio C Hamano
Junio C Hamano  writes:

>> While trying to build (without the 'gettext' library that's required
>> for localization) I get the following error,
>>
>> Manifying 8 pod documents
>> SUBDIR templates
>> MSGFMT po/build/locale/pt_PT/LC_MESSAGES/git.mo
>> /bin/sh: 1: msgfmt: not found
>> Makefile:2179: recipe for target
>> 'po/build/locale/pt_PT/LC_MESSAGES/git.mo' failed
>> make: *** [po/build/locale/pt_PT/LC_MESSAGES/git.mo] Error 127
>>
>> What could I be missing?
>
> There is
>
> ifndef NO_GETTEXT
> all:: $(MOFILES)
> endif
>
> which attempts to avoid generating *.mo files, but that does not
> seem to be working.

The above comes from one of the Tcl things (probably gitk-git)
For now

$ make NO_GETTEXT=1 NO_MSGFMT=1

may help.

NO_GETTEXT is "My build environment may or may not be capable of
doing the gettext things, but I choose not to use it in my build
result" but NO_MSGFMT is simply "I do not have the msgfmt tool".

Having to specify both is rather unfortunate and we may want to
streamline this.


Re: What's cooking in git.git (Jun 2017, #09; Fri, 30)

2017-07-03 Thread Philip Oakley

From: "Junio C Hamano" 

"Philip Oakley"  writes:


Junio,
Is it possible to include a table of contents that lists the
integration branches, split by your categories, to help find areas of
interest?

[Graduated to "master"]
* topic list
[New Topics]
[Stalled]
[Cooking]
[Discarded]

The TOC wouldn't need the [] or * markings if that's a problem.


I am not sure what you are asking.  Is this the command you are
looking for?

$ grep -e "^[[*]" whats-cooking.txt


Ah, thanks.

It does presume that one has extracted the email to the text file, which is 
easier on some systems and mail clients than others ;-)

Am I right that the What's cooking  is prepared by a script?
--
Philip 



[PATCH 10/12] Convert remaining callers of get_sha1 to get_oid.

2017-07-03 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 builtin/receive-pack.c | 4 ++--
 mailmap.c  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 71c0c768d..1efa48fec 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -919,9 +919,9 @@ static int update_shallow_ref(struct command *cmd, struct 
shallow_info *si)
  */
 static int head_has_history(void)
 {
-   unsigned char sha1[20];
+   struct object_id oid;
 
-   return !get_sha1("HEAD", sha1);
+   return !get_oid("HEAD", );
 }
 
 static const char *push_to_deploy(unsigned char *sha1,
diff --git a/mailmap.c b/mailmap.c
index c1a79c100..cb921b4db 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -214,17 +214,17 @@ static int read_mailmap_blob(struct string_list *map,
 const char *name,
 char **repo_abbrev)
 {
-   unsigned char sha1[20];
+   struct object_id oid;
char *buf;
unsigned long size;
enum object_type type;
 
if (!name)
return 0;
-   if (get_sha1(name, sha1) < 0)
+   if (get_oid(name, ) < 0)
return 0;
 
-   buf = read_sha1_file(sha1, , );
+   buf = read_sha1_file(oid.hash, , );
if (!buf)
return error("unable to read mailmap object at %s", name);
if (type != OBJ_BLOB)


[PATCH 08/12] builtin/unpack-file: convert to struct object_id

2017-07-03 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 builtin/unpack-file.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 73f133419..281ca1db6 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "config.h"
 
-static char *create_temp_file(unsigned char *sha1)
+static char *create_temp_file(struct object_id *oid)
 {
static char path[50];
void *buf;
@@ -9,9 +9,9 @@ static char *create_temp_file(unsigned char *sha1)
unsigned long size;
int fd;
 
-   buf = read_sha1_file(sha1, , );
+   buf = read_sha1_file(oid->hash, , );
if (!buf || type != OBJ_BLOB)
-   die("unable to read blob object %s", sha1_to_hex(sha1));
+   die("unable to read blob object %s", oid_to_hex(oid));
 
xsnprintf(path, sizeof(path), ".merge_file_XX");
fd = xmkstemp(path);
@@ -23,15 +23,15 @@ static char *create_temp_file(unsigned char *sha1)
 
 int cmd_unpack_file(int argc, const char **argv, const char *prefix)
 {
-   unsigned char sha1[20];
+   struct object_id oid;
 
if (argc != 2 || !strcmp(argv[1], "-h"))
usage("git unpack-file ");
-   if (get_sha1(argv[1], sha1))
+   if (get_oid(argv[1], ))
die("Not a valid object name %s", argv[1]);
 
git_config(git_default_config, NULL);
 
-   puts(create_temp_file(sha1));
+   puts(create_temp_file());
return 0;
 }


[PATCH 11/12] sha1_name: convert get_sha1* to get_oid*

2017-07-03 Thread brian m. carlson
Now that all the callers of get_sha1 directly or indirectly use struct
object_id, rename the functions starting with get_sha1 to start with
get_oid.  Convert the internals in sha1_name.c to use struct object_id
as well, and eliminate explicit length checks where possible.

Outside of sha1_name.c and cache.h, this transition was made with the
following semantic patch:

@@
expression E1, E2;
@@
- get_sha1(E1, E2.hash)
+ get_oid(E1, )

@@
expression E1, E2;
@@
- get_sha1(E1, E2->hash)
+ get_oid(E1, E2)

@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2.hash)
+ get_oid_committish(E1, )

@@
expression E1, E2;
@@
- get_sha1_committish(E1, E2->hash)
+ get_oid_committish(E1, E2)

@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2.hash)
+ get_oid_treeish(E1, )

@@
expression E1, E2;
@@
- get_sha1_treeish(E1, E2->hash)
+ get_oid_treeish(E1, E2)

@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2.hash)
+ get_oid_commit(E1, )

@@
expression E1, E2;
@@
- get_sha1_commit(E1, E2->hash)
+ get_oid_commit(E1, E2)

@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2.hash)
+ get_oid_tree(E1, )

@@
expression E1, E2;
@@
- get_sha1_tree(E1, E2->hash)
+ get_oid_tree(E1, E2)

@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2.hash)
+ get_oid_blob(E1, )

@@
expression E1, E2;
@@
- get_sha1_blob(E1, E2->hash)
+ get_oid_blob(E1, E2)

@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3.hash, E4)
+ get_oid_with_context(E1, E2, , E4)

@@
expression E1, E2, E3, E4;
@@
- get_sha1_with_context(E1, E2, E3->hash, E4)
+ get_oid_with_context(E1, E2, E3, E4)

Signed-off-by: brian m. carlson 
---
 apply.c   |   4 +-
 archive.c |   2 +-
 builtin/am.c  |   6 +-
 builtin/cat-file.c|   6 +-
 builtin/commit-tree.c |   4 +-
 builtin/commit.c  |   8 +--
 builtin/grep.c|   4 +-
 builtin/log.c |   4 +-
 builtin/replace.c |   4 +-
 builtin/reset.c   |  10 +--
 builtin/rev-parse.c   |   6 +-
 builtin/show-branch.c |   8 +--
 cache.h   |  17 +++--
 commit.c  |   4 +-
 notes.c   |   2 +-
 remote.c  |   2 +-
 revision.c|  10 +--
 sequencer.c   |   6 +-
 sha1_name.c   | 190 --
 transport-helper.c|   2 +-
 20 files changed, 145 insertions(+), 154 deletions(-)

diff --git a/apply.c b/apply.c
index c442b8932..58d7d5dc5 100644
--- a/apply.c
+++ b/apply.c
@@ -3553,7 +3553,7 @@ static int try_threeway(struct apply_state *state,
/* Preimage the patch was prepared for */
if (patch->is_new)
write_sha1_file("", 0, blob_type, pre_oid.hash);
-   else if (get_sha1(patch->old_sha1_prefix, pre_oid.hash) ||
+   else if (get_oid(patch->old_sha1_prefix, _oid) ||
 read_blob_object(, _oid, patch->old_mode))
return error(_("repository lacks the necessary blob to fall 
back on 3-way merge."));
 
@@ -4077,7 +4077,7 @@ static int build_fake_ancestor(struct apply_state *state, 
struct patch *list)
else
return error(_("sha1 information is lacking or "
   "useless for submodule %s"), 
name);
-   } else if (!get_sha1_blob(patch->old_sha1_prefix, oid.hash)) {
+   } else if (!get_oid_blob(patch->old_sha1_prefix, )) {
; /* ok */
} else if (!patch->lines_added && !patch->lines_deleted) {
/* mode-only change: update the current */
diff --git a/archive.c b/archive.c
index 60b3035a7..557dd2db8 100644
--- a/archive.c
+++ b/archive.c
@@ -358,7 +358,7 @@ static void parse_treeish_arg(const char **argv,
free(ref);
}
 
-   if (get_sha1(name, oid.hash))
+   if (get_oid(name, ))
die("Not a valid object name");
 
commit = lookup_commit_reference_gently(, 1);
diff --git a/builtin/am.c b/builtin/am.c
index c973bd96d..40cc6d6fe 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1131,7 +1131,7 @@ static int index_has_changes(struct strbuf *sb)
struct object_id head;
int i;
 
-   if (!get_sha1_tree("HEAD", head.hash)) {
+   if (!get_oid_tree("HEAD", )) {
struct diff_options opt;
 
diff_setup();
@@ -1432,7 +1432,7 @@ static void write_index_patch(const struct am_state 
*state)
struct rev_info rev_info;
FILE *fp;
 
-   if (!get_sha1_tree("HEAD", head.hash))
+   if (!get_oid_tree("HEAD", ))
tree = lookup_tree();
else
tree = lookup_tree(_tree_oid);
@@ -1661,7 +1661,7 @@ static void do_commit(const struct am_state *state)
if (write_cache_as_tree(tree.hash, 0, NULL))
die(_("git write-tree failed to write a tree"));
 
-   if (!get_sha1_commit("HEAD", parent.hash)) {
+   if (!get_oid_commit("HEAD", )) {
old_oid 

[PATCH 12/12] sha1_name: convert GET_SHA1* flags to GET_OID*

2017-07-03 Thread brian m. carlson
Convert the flags for get_oid_with_context and friends to use "OID"
instead of "SHA1" in their names.

This transform was made by running the following one-liner on the
affected files:

  perl -pi -e 's/GET_SHA1/GET_OID/g'

Signed-off-by: brian m. carlson 
---
 builtin/cat-file.c  |  4 ++--
 builtin/grep.c  |  2 +-
 builtin/log.c   |  2 +-
 builtin/rev-parse.c |  2 +-
 cache.h | 28 +++
 refs.c  |  2 +-
 revision.c  |  6 ++---
 sha1_name.c | 64 ++---
 8 files changed, 55 insertions(+), 55 deletions(-)

diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 695168a98..823608bef 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -63,7 +63,7 @@ static int cat_one_file(int opt, const char *exp_type, const 
char *obj_name,
if (unknown_type)
flags |= LOOKUP_UNKNOWN_OBJECT;
 
-   if (get_oid_with_context(obj_name, GET_SHA1_RECORD_PATH,
+   if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
 , _context))
die("Not a valid object name %s", obj_name);
 
@@ -360,7 +360,7 @@ static void batch_one_object(const char *obj_name, struct 
batch_options *opt,
 struct expand_data *data)
 {
struct object_context ctx;
-   int flags = opt->follow_symlinks ? GET_SHA1_FOLLOW_SYMLINKS : 0;
+   int flags = opt->follow_symlinks ? GET_OID_FOLLOW_SYMLINKS : 0;
enum follow_symlinks_result result;
 
result = get_oid_with_context(obj_name, flags, >oid, );
diff --git a/builtin/grep.c b/builtin/grep.c
index a309ab7c2..48aa39f99 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -1206,7 +1206,7 @@ int cmd_grep(int argc, const char **argv, const char 
*prefix)
break;
}
 
-   if (get_oid_with_context(arg, GET_SHA1_RECORD_PATH,
+   if (get_oid_with_context(arg, GET_OID_RECORD_PATH,
 , )) {
if (seen_dashdash)
die(_("unable to resolve revision: %s"), arg);
diff --git a/builtin/log.c b/builtin/log.c
index 60fac9d4d..3dbdf8cad 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -484,7 +484,7 @@ static int show_blob_object(const struct object_id *oid, 
struct rev_info *rev, c
!DIFF_OPT_TST(>diffopt, ALLOW_TEXTCONV))
return stream_blob_to_fd(1, oid, NULL, 0);
 
-   if (get_oid_with_context(obj_name, GET_SHA1_RECORD_PATH,
+   if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
 , _context))
die(_("Not a valid object name %s"), obj_name);
if (!obj_context.path ||
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 041b7898c..2bd28d3c0 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -702,7 +702,7 @@ int cmd_rev_parse(int argc, const char **argv, const char 
*prefix)
}
if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
quiet = 1;
-   flags |= GET_SHA1_QUIETLY;
+   flags |= GET_OID_QUIETLY;
continue;
}
if (opt_with_value(arg, "--short", )) {
diff --git a/cache.h b/cache.h
index c68f44e10..c14351cba 100644
--- a/cache.h
+++ b/cache.h
@@ -1351,27 +1351,27 @@ struct object_context {
 */
struct strbuf symlink_path;
/*
-* If GET_SHA1_RECORD_PATH is set, this will record path (if any)
+* If GET_OID_RECORD_PATH is set, this will record path (if any)
 * found when resolving the name. The caller is responsible for
 * releasing the memory.
 */
char *path;
 };
 
-#define GET_SHA1_QUIETLY   01
-#define GET_SHA1_COMMIT02
-#define GET_SHA1_COMMITTISH04
-#define GET_SHA1_TREE 010
-#define GET_SHA1_TREEISH  020
-#define GET_SHA1_BLOB 040
-#define GET_SHA1_FOLLOW_SYMLINKS 0100
-#define GET_SHA1_RECORD_PATH 0200
-#define GET_SHA1_ONLY_TO_DIE04000
+#define GET_OID_QUIETLY   01
+#define GET_OID_COMMIT02
+#define GET_OID_COMMITTISH04
+#define GET_OID_TREE 010
+#define GET_OID_TREEISH  020
+#define GET_OID_BLOB 040
+#define GET_OID_FOLLOW_SYMLINKS 0100
+#define GET_OID_RECORD_PATH 0200
+#define GET_OID_ONLY_TO_DIE04000
 
-#define GET_SHA1_DISAMBIGUATORS \
-   (GET_SHA1_COMMIT | GET_SHA1_COMMITTISH | \
-   GET_SHA1_TREE | GET_SHA1_TREEISH | \
-   GET_SHA1_BLOB)
+#define GET_OID_DISAMBIGUATORS \
+   (GET_OID_COMMIT | GET_OID_COMMITTISH | \
+   GET_OID_TREE | GET_OID_TREEISH | \
+   GET_OID_BLOB)
 
 extern int get_oid(const char *str, struct object_id *oid);
 extern 

[PATCH 09/12] builtin/verify-tag: convert to struct object_id

2017-07-03 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 builtin/verify-tag.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index f9a5f7535..30e4c826e 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -56,20 +56,20 @@ int cmd_verify_tag(int argc, const char **argv, const char 
*prefix)
}
 
while (i < argc) {
-   unsigned char sha1[20];
+   struct object_id oid;
const char *name = argv[i++];
-   if (get_sha1(name, sha1)) {
+   if (get_oid(name, )) {
had_error = !!error("tag '%s' not found.", name);
continue;
}
 
-   if (gpg_verify_tag(sha1, name, flags)) {
+   if (gpg_verify_tag(oid.hash, name, flags)) {
had_error = 1;
continue;
}
 
if (fmt_pretty)
-   pretty_print_ref(name, sha1, fmt_pretty);
+   pretty_print_ref(name, oid.hash, fmt_pretty);
}
return had_error;
 }


[PATCH 03/12] submodule: convert submodule config lookup to use object_id

2017-07-03 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 builtin/grep.c   |  4 ++--
 builtin/submodule--helper.c  |  8 
 config.c | 12 ++--
 config.h |  4 ++--
 submodule-config.c   | 36 ++--
 submodule-config.h   | 10 +-
 submodule.c  | 32 
 submodule.h  |  2 +-
 t/helper/test-submodule-config.c | 10 +-
 9 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index f752f642f..397b5f049 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -652,7 +652,7 @@ static int grep_submodule(struct grep_opt *opt, const 
struct object_id *oid,
 */
if (oid) {
const struct submodule *sub =
-   submodule_from_path(null_sha1, path);
+   submodule_from_path(_oid, path);
if (sub)
path = git_path("modules/%s", sub->name);
 
@@ -861,7 +861,7 @@ static int grep_objects(struct grep_opt *opt, const struct 
pathspec *pathspec,
/* load the gitmodules file for this rev */
if (recurse_submodules) {
submodule_free();
-   gitmodules_config_sha1(real_obj->oid.hash);
+   gitmodules_config_oid(_obj->oid);
}
if (grep_object(opt, pathspec, real_obj, list->objects[i].name, 
list->objects[i].path)) {
hit = 1;
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 8517032b3..45cb93287 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -350,7 +350,7 @@ static void init_submodule(const char *path, const char 
*prefix, int quiet)
} else
displaypath = xstrdup(path);
 
-   sub = submodule_from_path(null_sha1, path);
+   sub = submodule_from_path(_oid, path);
 
if (!sub)
die(_("No url found for submodule path '%s' in .gitmodules"),
@@ -476,7 +476,7 @@ static int module_name(int argc, const char **argv, const 
char *prefix)
usage(_("git submodule--helper name "));
 
gitmodules_config();
-   sub = submodule_from_path(null_sha1, argv[1]);
+   sub = submodule_from_path(_oid, argv[1]);
 
if (!sub)
die(_("no submodule mapping found in .gitmodules for path 
'%s'"),
@@ -795,7 +795,7 @@ static int prepare_to_clone_next_submodule(const struct 
cache_entry *ce,
goto cleanup;
}
 
-   sub = submodule_from_path(null_sha1, ce->name);
+   sub = submodule_from_path(_oid, ce->name);
 
if (suc->recursive_prefix)
displaypath = relative_path(suc->recursive_prefix,
@@ -1060,7 +1060,7 @@ static const char *remote_submodule_branch(const char 
*path)
gitmodules_config();
git_config(submodule_config, NULL);
 
-   sub = submodule_from_path(null_sha1, path);
+   sub = submodule_from_path(_oid, path);
if (!sub)
return NULL;
 
diff --git a/config.c b/config.c
index 1cd40a5fe..eb2dae5fb 100644
--- a/config.c
+++ b/config.c
@@ -1466,9 +1466,9 @@ int git_config_from_mem(config_fn_t fn, const enum 
config_origin_type origin_typ
return do_config_from(, fn, data);
 }
 
-int git_config_from_blob_sha1(config_fn_t fn,
+int git_config_from_blob_oid(config_fn_t fn,
  const char *name,
- const unsigned char *sha1,
+ const struct object_id *oid,
  void *data)
 {
enum object_type type;
@@ -1476,7 +1476,7 @@ int git_config_from_blob_sha1(config_fn_t fn,
unsigned long size;
int ret;
 
-   buf = read_sha1_file(sha1, , );
+   buf = read_sha1_file(oid->hash, , );
if (!buf)
return error("unable to load config blob object '%s'", name);
if (type != OBJ_BLOB) {
@@ -1494,11 +1494,11 @@ static int git_config_from_blob_ref(config_fn_t fn,
const char *name,
void *data)
 {
-   unsigned char sha1[20];
+   struct object_id oid;
 
-   if (get_sha1(name, sha1) < 0)
+   if (get_oid(name, ) < 0)
return error("unable to resolve config blob '%s'", name);
-   return git_config_from_blob_sha1(fn, name, sha1, data);
+   return git_config_from_blob_oid(fn, name, , data);
 }
 
 const char *git_etc_gitconfig(void)
diff --git a/config.h b/config.h
index 9e038cce2..033920048 100644
--- a/config.h
+++ b/config.h
@@ -39,8 +39,8 @@ extern int git_default_config(const char *, const char *, 
void *);
 extern int git_config_from_file(config_fn_t fn, const char *, void *);
 

[PATCH 06/12] builtin/update_ref: convert to struct object_id

2017-07-03 Thread brian m. carlson
Convert the uses of unsigned char * to struct object_id.

Signed-off-by: brian m. carlson 
---
 builtin/update-ref.c | 69 ++--
 1 file changed, 34 insertions(+), 35 deletions(-)

diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 40ccfc193..6b90c5dea 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -94,10 +94,10 @@ static char *parse_refname(struct strbuf *input, const char 
**next)
  * provided but cannot be converted to a SHA-1, die.  flags can
  * include PARSE_SHA1_OLD and/or PARSE_SHA1_ALLOW_EMPTY.
  */
-static int parse_next_sha1(struct strbuf *input, const char **next,
-  unsigned char *sha1,
-  const char *command, const char *refname,
-  int flags)
+static int parse_next_oid(struct strbuf *input, const char **next,
+ struct object_id *oid,
+ const char *command, const char *refname,
+ int flags)
 {
struct strbuf arg = STRBUF_INIT;
int ret = 0;
@@ -115,11 +115,11 @@ static int parse_next_sha1(struct strbuf *input, const 
char **next,
(*next)++;
*next = parse_arg(*next, );
if (arg.len) {
-   if (get_sha1(arg.buf, sha1))
+   if (get_oid(arg.buf, oid))
goto invalid;
} else {
/* Without -z, an empty value means all zeros: */
-   hashclr(sha1);
+   oidclr(oid);
}
} else {
/* With -z, read the next NUL-terminated line */
@@ -133,13 +133,13 @@ static int parse_next_sha1(struct strbuf *input, const 
char **next,
*next += arg.len;
 
if (arg.len) {
-   if (get_sha1(arg.buf, sha1))
+   if (get_oid(arg.buf, oid))
goto invalid;
} else if (flags & PARSE_SHA1_ALLOW_EMPTY) {
/* With -z, treat an empty value as all zeros: */
warning("%s %s: missing , treating as zero",
command, refname);
-   hashclr(sha1);
+   oidclr(oid);
} else {
/*
 * With -z, an empty non-required value means
@@ -182,26 +182,25 @@ static const char *parse_cmd_update(struct 
ref_transaction *transaction,
 {
struct strbuf err = STRBUF_INIT;
char *refname;
-   unsigned char new_sha1[20];
-   unsigned char old_sha1[20];
+   struct object_id new_oid, old_oid;
int have_old;
 
refname = parse_refname(input, );
if (!refname)
die("update: missing ");
 
-   if (parse_next_sha1(input, , new_sha1, "update", refname,
-   PARSE_SHA1_ALLOW_EMPTY))
+   if (parse_next_oid(input, , _oid, "update", refname,
+  PARSE_SHA1_ALLOW_EMPTY))
die("update %s: missing ", refname);
 
-   have_old = !parse_next_sha1(input, , old_sha1, "update", refname,
-   PARSE_SHA1_OLD);
+   have_old = !parse_next_oid(input, , _oid, "update", refname,
+  PARSE_SHA1_OLD);
 
if (*next != line_termination)
die("update %s: extra input: %s", refname, next);
 
if (ref_transaction_update(transaction, refname,
-  new_sha1, have_old ? old_sha1 : NULL,
+  new_oid.hash, have_old ? old_oid.hash : NULL,
   update_flags | create_reflog_flag,
   msg, ))
die("%s", err.buf);
@@ -218,22 +217,22 @@ static const char *parse_cmd_create(struct 
ref_transaction *transaction,
 {
struct strbuf err = STRBUF_INIT;
char *refname;
-   unsigned char new_sha1[20];
+   struct object_id new_oid;
 
refname = parse_refname(input, );
if (!refname)
die("create: missing ");
 
-   if (parse_next_sha1(input, , new_sha1, "create", refname, 0))
+   if (parse_next_oid(input, , _oid, "create", refname, 0))
die("create %s: missing ", refname);
 
-   if (is_null_sha1(new_sha1))
+   if (is_null_oid(_oid))
die("create %s: zero ", refname);
 
if (*next != line_termination)
die("create %s: extra input: %s", refname, next);
 
-   if (ref_transaction_create(transaction, refname, new_sha1,
+   if (ref_transaction_create(transaction, refname, new_oid.hash,
   update_flags | create_reflog_flag,
   msg, ))
die("%s", err.buf);
@@ -250,18 +249,18 @@ static 

[PATCH 04/12] remote: convert struct push_cas to struct object_id

2017-07-03 Thread brian m. carlson
This gets rid of one use of get_sha1.

Signed-off-by: brian m. carlson 
---
 remote.c | 6 +++---
 remote.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/remote.c b/remote.c
index d87482573..9da9040bf 100644
--- a/remote.c
+++ b/remote.c
@@ -2294,8 +2294,8 @@ static int parse_push_cas_option(struct push_cas_option 
*cas, const char *arg, i
if (!*colon)
entry->use_tracking = 1;
else if (!colon[1])
-   hashclr(entry->expect);
-   else if (get_sha1(colon + 1, entry->expect))
+   oidclr(>expect);
+   else if (get_oid(colon + 1, >expect))
return error("cannot parse expected object name '%s'", colon + 
1);
return 0;
 }
@@ -2342,7 +2342,7 @@ static void apply_cas(struct push_cas_option *cas,
continue;
ref->expect_old_sha1 = 1;
if (!entry->use_tracking)
-   hashcpy(ref->old_oid_expect.hash, cas->entry[i].expect);
+   oidcpy(>old_oid_expect, >expect);
else if (remote_tracking(remote, ref->name, 
>old_oid_expect))
oidclr(>old_oid_expect);
return;
diff --git a/remote.h b/remote.h
index 6c28cd3e4..2ecf4c8c7 100644
--- a/remote.h
+++ b/remote.h
@@ -282,7 +282,7 @@ struct ref *get_stale_heads(struct refspec *refs, int 
ref_count, struct ref *fet
 struct push_cas_option {
unsigned use_tracking_for_rest:1;
struct push_cas {
-   unsigned char expect[20];
+   struct object_id expect;
unsigned use_tracking:1;
char *refname;
} *entry;


[PATCH 00/12] object_id part 9

2017-07-03 Thread brian m. carlson
This is the ninth in a series of series to convert Git to use struct
object_id.  This series converts the remaining callers of get_sha1 and
friends to take and use struct object_id, and in doing so, renames them
to get_oid and friends.

It is possible there will be some other conflicts with in flight topics,
as get_sha1 is commonly used in the codebase.  This is unavoidable to
some extent, but should be kept in mind.  My experience is that usually
the required changes for conversion are minimal.

This series is much reduced in size thanks to the conversion work done
by Brandon Williams in his earlier series touching the notes code.

brian m. carlson (12):
  builtin/fsck: convert remaining caller of get_sha1 to object_id
  builtin/merge-tree: convert remaining caller of get_sha1 to object_id
  submodule: convert submodule config lookup to use object_id
  remote: convert struct push_cas to struct object_id
  sequencer: convert to struct object_id
  builtin/update_ref: convert to struct object_id
  bisect: convert bisect_checkout to struct object_id
  builtin/unpack-file: convert to struct object_id
  builtin/verify-tag: convert to struct object_id
  Convert remaining callers of get_sha1 to get_oid.
  sha1_name: convert get_sha1* to get_oid*
  sha1_name: convert GET_SHA1* flags to GET_OID*

 apply.c  |   4 +-
 archive.c|   2 +-
 bisect.c |  18 +--
 builtin/am.c |   6 +-
 builtin/cat-file.c   |   8 +-
 builtin/commit-tree.c|   4 +-
 builtin/commit.c |   8 +-
 builtin/fsck.c   |   8 +-
 builtin/grep.c   |   8 +-
 builtin/log.c|   4 +-
 builtin/merge-tree.c |   6 +-
 builtin/receive-pack.c   |   4 +-
 builtin/replace.c|   4 +-
 builtin/reset.c  |  10 +-
 builtin/rev-parse.c  |   8 +-
 builtin/show-branch.c|   8 +-
 builtin/submodule--helper.c  |   8 +-
 builtin/unpack-file.c|  12 +-
 builtin/update-ref.c |  69 ++--
 builtin/verify-tag.c |   8 +-
 cache.h  |  45 
 commit.c |   4 +-
 config.c |  12 +-
 config.h |   4 +-
 mailmap.c|   6 +-
 notes.c  |   2 +-
 refs.c   |   2 +-
 remote.c |   8 +-
 remote.h |   2 +-
 revision.c   |  16 +--
 sequencer.c  |  65 +--
 sha1_name.c  | 234 +++
 submodule-config.c   |  36 +++---
 submodule-config.h   |  10 +-
 submodule.c  |  32 +++---
 submodule.h  |   2 +-
 t/helper/test-submodule-config.c |  10 +-
 transport-helper.c   |   2 +-
 38 files changed, 345 insertions(+), 354 deletions(-)



[PATCH 02/12] builtin/merge-tree: convert remaining caller of get_sha1 to object_id

2017-07-03 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 builtin/merge-tree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index bad6735c7..f12da292c 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -347,12 +347,12 @@ static void merge_trees(struct tree_desc t[3], const char 
*base)
 
 static void *get_tree_descriptor(struct tree_desc *desc, const char *rev)
 {
-   unsigned char sha1[20];
+   struct object_id oid;
void *buf;
 
-   if (get_sha1(rev, sha1))
+   if (get_oid(rev, ))
die("unknown rev %s", rev);
-   buf = fill_tree_descriptor(desc, sha1);
+   buf = fill_tree_descriptor(desc, oid.hash);
if (!buf)
die("%s is not a tree", rev);
return buf;


[PATCH 05/12] sequencer: convert to struct object_id

2017-07-03 Thread brian m. carlson
Convert the remaining instances of unsigned char * to struct object_id.
This removes several calls to get_sha1.

Signed-off-by: brian m. carlson 
---
 sequencer.c | 59 ++-
 1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 3010faf86..16d48a4fb 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -691,7 +691,7 @@ static int run_git_commit(const char *defmsg, struct 
replay_opts *opts,
 
 static int is_original_commit_empty(struct commit *commit)
 {
-   const unsigned char *ptree_sha1;
+   const struct object_id *ptree_oid;
 
if (parse_commit(commit))
return error(_("could not parse commit %s\n"),
@@ -701,12 +701,12 @@ static int is_original_commit_empty(struct commit *commit)
if (parse_commit(parent))
return error(_("could not parse parent commit %s\n"),
oid_to_hex(>object.oid));
-   ptree_sha1 = parent->tree->object.oid.hash;
+   ptree_oid = >tree->object.oid;
} else {
-   ptree_sha1 = EMPTY_TREE_SHA1_BIN; /* commit is root */
+   ptree_oid = _tree_oid; /* commit is root */
}
 
-   return !hashcmp(ptree_sha1, commit->tree->object.oid.hash);
+   return !oidcmp(ptree_oid, >tree->object.oid);
 }
 
 /*
@@ -896,18 +896,18 @@ static int update_squash_messages(enum todo_command 
command,
 
 static void flush_rewritten_pending(void) {
struct strbuf buf = STRBUF_INIT;
-   unsigned char newsha1[20];
+   struct object_id newoid;
FILE *out;
 
-   if (strbuf_read_file(, rebase_path_rewritten_pending(), 82) > 0 &&
-   !get_sha1("HEAD", newsha1) &&
+   if (strbuf_read_file(, rebase_path_rewritten_pending(), 
(GIT_MAX_HEXSZ + 1) * 2) > 0 &&
+   !get_oid("HEAD", ) &&
(out = fopen_or_warn(rebase_path_rewritten_list(), "a"))) {
char *bol = buf.buf, *eol;
 
while (*bol) {
eol = strchrnul(bol, '\n');
fprintf(out, "%.*s %s\n", (int)(eol - bol),
-   bol, sha1_to_hex(newsha1));
+   bol, oid_to_hex());
if (!*eol)
break;
bol = eol + 1;
@@ -1594,36 +1594,37 @@ static int rollback_is_safe(void)
return !oidcmp(_head, _head);
 }
 
-static int reset_for_rollback(const unsigned char *sha1)
+static int reset_for_rollback(const struct object_id *oid)
 {
const char *argv[4];/* reset --merge  + NULL */
 
argv[0] = "reset";
argv[1] = "--merge";
-   argv[2] = sha1_to_hex(sha1);
+   argv[2] = oid_to_hex(oid);
argv[3] = NULL;
return run_command_v_opt(argv, RUN_GIT_CMD);
 }
 
 static int rollback_single_pick(void)
 {
-   unsigned char head_sha1[20];
+   struct object_id head_oid;
 
if (!file_exists(git_path_cherry_pick_head()) &&
!file_exists(git_path_revert_head()))
return error(_("no cherry-pick or revert in progress"));
-   if (read_ref_full("HEAD", 0, head_sha1, NULL))
+   if (read_ref_full("HEAD", 0, head_oid.hash, NULL))
return error(_("cannot resolve HEAD"));
-   if (is_null_sha1(head_sha1))
+   if (is_null_oid(_oid))
return error(_("cannot abort from a branch yet to be born"));
-   return reset_for_rollback(head_sha1);
+   return reset_for_rollback(_oid);
 }
 
 int sequencer_rollback(struct replay_opts *opts)
 {
FILE *f;
-   unsigned char sha1[20];
+   struct object_id oid;
struct strbuf buf = STRBUF_INIT;
+   const char *p;
 
f = fopen(git_path_head_file(), "r");
if (!f && errno == ENOENT) {
@@ -1643,12 +1644,12 @@ int sequencer_rollback(struct replay_opts *opts)
goto fail;
}
fclose(f);
-   if (get_sha1_hex(buf.buf, sha1) || buf.buf[40] != '\0') {
+   if (parse_oid_hex(buf.buf, , ) || *p != '\0') {
error(_("stored pre-cherry-pick HEAD file '%s' is corrupt"),
git_path_head_file());
goto fail;
}
-   if (is_null_sha1(sha1)) {
+   if (is_null_oid()) {
error(_("cannot abort from a branch yet to be born"));
goto fail;
}
@@ -1658,7 +1659,7 @@ int sequencer_rollback(struct replay_opts *opts)
warning(_("You seem to have moved HEAD. "
  "Not rewinding, check your HEAD!"));
} else
-   if (reset_for_rollback(sha1))
+   if (reset_for_rollback())
goto fail;
strbuf_release();
return sequencer_remove_state(opts);
@@ -1788,13 +1789,13 @@ static int make_patch(struct commit *commit, struct 
replay_opts *opts)
 
 static int 

[PATCH 01/12] builtin/fsck: convert remaining caller of get_sha1 to object_id

2017-07-03 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 builtin/fsck.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 87c675689..d601d07fd 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -738,12 +738,12 @@ int cmd_fsck(int argc, const char **argv, const char 
*prefix)
heads = 0;
for (i = 0; i < argc; i++) {
const char *arg = argv[i];
-   unsigned char sha1[20];
-   if (!get_sha1(arg, sha1)) {
-   struct object *obj = lookup_object(sha1);
+   struct object_id oid;
+   if (!get_oid(arg, )) {
+   struct object *obj = lookup_object(oid.hash);
 
if (!obj || !(obj->flags & HAS_OBJ)) {
-   error("%s: object missing", sha1_to_hex(sha1));
+   error("%s: object missing", oid_to_hex());
errors_found |= ERROR_OBJECT;
continue;
}


[PATCH 07/12] bisect: convert bisect_checkout to struct object_id

2017-07-03 Thread brian m. carlson
Signed-off-by: brian m. carlson 
---
 bisect.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/bisect.c b/bisect.c
index a9fd9fbc6..2549eaf7b 100644
--- a/bisect.c
+++ b/bisect.c
@@ -680,16 +680,16 @@ static int is_expected_rev(const struct object_id *oid)
return res;
 }
 
-static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout)
+static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)
 {
char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
 
-   memcpy(bisect_rev_hex, sha1_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);
-   update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, 
UPDATE_REFS_DIE_ON_ERR);
+   memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), GIT_SHA1_HEXSZ + 1);
+   update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev->hash, NULL, 0, 
UPDATE_REFS_DIE_ON_ERR);
 
argv_checkout[2] = bisect_rev_hex;
if (no_checkout) {
-   update_ref(NULL, "BISECT_HEAD", bisect_rev, NULL, 0, 
UPDATE_REFS_DIE_ON_ERR);
+   update_ref(NULL, "BISECT_HEAD", bisect_rev->hash, NULL, 0, 
UPDATE_REFS_DIE_ON_ERR);
} else {
int res;
res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);
@@ -796,7 +796,7 @@ static void check_merge_bases(int no_checkout)
handle_skipped_merge_base(mb);
} else {
printf(_("Bisecting: a merge base must be tested\n"));
-   exit(bisect_checkout(mb->hash, no_checkout));
+   exit(bisect_checkout(mb, no_checkout));
}
}
 
@@ -939,7 +939,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
struct rev_info revs;
struct commit_list *tried;
int reaches = 0, all = 0, nr, steps;
-   const unsigned char *bisect_rev;
+   struct object_id *bisect_rev;
char *steps_msg;
 
read_bisect_terms(_bad, _good);
@@ -977,11 +977,11 @@ int bisect_next_all(const char *prefix, int no_checkout)
exit(4);
}
 
-   bisect_rev = revs.commits->item->object.oid.hash;
+   bisect_rev = >item->object.oid;
 
-   if (!hashcmp(bisect_rev, current_bad_oid->hash)) {
+   if (!oidcmp(bisect_rev, current_bad_oid)) {
exit_if_skipped_commits(tried, current_bad_oid);
-   printf("%s is the first %s commit\n", sha1_to_hex(bisect_rev),
+   printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
term_bad);
show_diff_tree(prefix, revs.commits->item);
/* This means the bisection process succeeded. */


Re: What's cooking in git.git (Jun 2017, #09; Fri, 30)

2017-07-03 Thread Junio C Hamano
"Philip Oakley"  writes:

> Junio,
> Is it possible to include a table of contents that lists the
> integration branches, split by your categories, to help find areas of
> interest?
>
> [Graduated to "master"]
> * topic list
> [New Topics]
> [Stalled]
> [Cooking]
> [Discarded]
>
> The TOC wouldn't need the [] or * markings if that's a problem.

I am not sure what you are asking.  Is this the command you are
looking for?

 $ grep -e "^[[*]" whats-cooking.txt



Re: Help needed for solving a few issues with building git

2017-07-03 Thread Junio C Hamano
Kaartic Sivaraam  writes:

> Hello all,
>
> Building without localization support
> 
> I tried to build git from source without localization support by adding
> the following line to the Makefile,
>
> NO_GETTEXT=1
>
> It doesn't seem to be working for reasons I'm unable to find. I used
> the following commands to build git.
>
> make prefix=$CUSTOM_BUILD_LOCATION
> make install prefix=$CUSTOM_BUILD_LOCATION
>
> While trying to build (without the 'gettext' library that's required
> for localization) I get the following error,
>
> Manifying 8 pod documents
> SUBDIR templates
> MSGFMT po/build/locale/pt_PT/LC_MESSAGES/git.mo
> /bin/sh: 1: msgfmt: not found
> Makefile:2179: recipe for target
> 'po/build/locale/pt_PT/LC_MESSAGES/git.mo' failed
> make: *** [po/build/locale/pt_PT/LC_MESSAGES/git.mo] Error 127
>
> What could I be missing?

There is

ifndef NO_GETTEXT
all:: $(MOFILES)
endif

which attempts to avoid generating *.mo files, but that does not
seem to be working.

>
>
> Adding HTTPS support
> 
> I tried to add HTTP/HTTPS support to the custom built version for which
> AFAIK 'git' depends on 'curl'. I tried providing the location of the
> curl source in the Makefile using the following line after reading the
> instructions in the Makefile.
>
> CURLDIR=/path/to/curl/source

Shouldn't this point at an installed location (iow, we do not build
curl from the source while building Git)?

# Define CURLDIR=/foo/bar if your curl header and library files are in
# /foo/bar/include and /foo/bar/lib directories.


> Even after doing this the custom built git errors with the following
> message when I try to use the 'git fetch' command,
>
> fatal: Unable to find remote helper for 'https'

This is probably because you are trying to run without installing?
Ask the "git" you built what its --exec-path is, and run "ls" on
that directory to see if you have git-remote-https installed?

Trying a freshly built Git binaries without installing is done by
setting GIT_EXEC_PATH to point at bin-wrappers/ directory at the
top-level of your build tree (that is how our tests can run on an
otherwise virgin box with no Git installed).


Re: [PATCH] area: git-merge: add --signoff flag to git-merge

2017-07-03 Thread Junio C Hamano
Łukasz Gryglicki  writes:

> Subject: Re: [PATCH] area: git-merge: add --signoff flag to git-merge

s/area: //; 

> Added --signoff flag to `git-merge` command, added test coverage,
> updated documentation.

That can be seen from the title and the patch text.  While it is not
wrong to list what you did, that shouldn't be the only thing the log
records.  Explain the problem the patch attempts to fix, why it is a
problem, and then give orders to the code to "be like so".

[PATCH] git-merge: honor --signoff flag

The "Signed-off-by:" line is a social convention to certify
that you are legally allowed to do so when you are giving
changes to or recording changes for the project.  

The "git commit" command has a handy option "--signoff" to
add it under your name, because committing is the primary
way for you to record your changes (which may later be sent
to the project in a patch form).

On the other hand, the "git merge" command does not.  [You
make an argument to justify why merge commits also should
have signoffs here].

Teach "git merge" to honor "--signoff" just like "git commit"
does.

or something like that.  It is a norm for a new feature to have
documentation and test, so it is of lessor importance to say "Add
tests and document the new feature" (on the other hand, those who do
not test and document need to justify their omission).

Alternatively, if the problem is so obvious that it does not need to
be explained, the solution often does not need more explanation than
the patch title.

I this case, I think the "problem" is not that obvious; the need for
signing off a merge commit deserves explanation in the log message.


> Signed-off-by: lukaszgryglicki 
> ---

"Signed-off-by: Łukasz Gryglicki ", like you wrote
on your "From:" e-mail header.

>  Documentation/git-merge.txt  |  8 ++
>  builtin/merge.c  |  4 +++
>  t/t9904-git-merge-signoff.sh | 60 
> 
>  3 files changed, 72 insertions(+)
>  create mode 100755 t/t9904-git-merge-signoff.sh
>
> diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
> index 04fdd8cf086db..6b308ab6d0b52 100644
> --- a/Documentation/git-merge.txt
> +++ b/Documentation/git-merge.txt
> @@ -64,6 +64,14 @@ OPTIONS
>  ---
>  include::merge-options.txt[]
>  
> +--signoff::
> + Add Signed-off-by line by the committer at the end of the commit
> + log message.  The meaning of a signoff depends on the project,
> + but it typically certifies that committer has
> + the rights to submit this work under the same license and
> + agrees to a Developer Certificate of Origin
> + (see http://developercertificate.org/ for more information).
> +

Good description.

> diff --git a/builtin/merge.c b/builtin/merge.c
> index 900bafdb45d0b..cb09f4138136b 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -70,6 +70,7 @@ static int continue_current_merge;
>  static int allow_unrelated_histories;
>  static int show_progress = -1;
>  static int default_to_upstream = 1;
> +static int signoff;
>  static const char *sign_commit;
>  
>  static struct strategy all_strategy[] = {
> @@ -233,6 +234,7 @@ static struct option builtin_merge_options[] = {
>   { OPTION_STRING, 'S', "gpg-sign", _commit, N_("key-id"),
> N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
>   OPT_BOOL(0, "overwrite-ignore", _ignore, N_("update ignored 
> files (default)")),
> + OPT_BOOL(0, "signoff", , N_("add Signed-off-by:")),
>   OPT_END()
>  };
>  
> @@ -775,6 +777,8 @@ static void prepare_to_commit(struct commit_list 
> *remoteheads)
>   strbuf_stripspace(, 0 < option_edit);
>   if (!msg.len)
>   abort_commit(remoteheads, _("Empty commit message."));
> + if (signoff)
> + append_signoff(, ignore_non_trailer(msg.buf, msg.len), 0);

I think this is a wrong place to do this, because 

  (1) it is too late to allow "prepare-commit-msg" to futz with it.
  (2) it is too late to allow the end user to further edit it.

A better place probably is before merge_editor_comment is added to
the msg strbuf in the same function, but I didn't think it through.

> diff --git a/t/t9904-git-merge-signoff.sh b/t/t9904-git-merge-signoff.sh
> new file mode 100755
> index 0..eed15b9a85371
> --- /dev/null
> +++ b/t/t9904-git-merge-signoff.sh

Do we need a new script?I think t7608 is about the messages in
the merge commit.

> +# A simple files to commit
> +cat >file1 < +1
> +EOF
> +
> +cat >file2 < +2
> +EOF
> +
> +cat >file3 < +3
> +EOF
>
> +
> +# Expected commit message after merge --signoff
> +cat >expected-signed < +Merge branch 'master' into other-branch
> +
> +Signed-off-by: $(git var GIT_COMMITTER_IDENT | sed -e "s/>.*/>/")
> +EOF
> +
> +# Expected commit message after merge without 

Re: Why doesn't merge fail if message has only sign-off?

2017-07-03 Thread Junio C Hamano
Kaartic Sivaraam  writes:

> While trying to merge a branch using "git merge" if a merge
> message consists only of a "Sign-off" line it doesn't fail.
> To be consistent with the behaviour of "git commit" shouldn't the merge
> fail?

I think that it is not by design that it doesn't fail.  It's not
like we decided to allow s-o-b only merge because we found a reason
why it is a good idea to do so.

So I do not think anybody minds too deeply if somebody came up a
patch to "fix" it.  It's just that nobody tried to create such a
silly merge in real life so far (I do not think you did, either--you
found this out by playing around trying to find corner cases, no?)



Re: [PATCH v3 2/3] sha1dc: optionally use sha1collisiondetection as a submodule

2017-07-03 Thread Junio C Hamano
Ævar Arnfjörð Bjarmason   writes:

> Add an option to use the sha1collisiondetection library from the
> submodule in sha1collisiondetection/ instead of in the copy in the
> sha1dc/ directory.
>
> This allows us to try out the submodule in sha1collisiondetection
> without breaking the build for anyone who's not expecting them as we
> work out any kinks.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason 
> ---
>  .gitmodules|  4 
>  Makefile   | 12 
>  hash.h |  4 
>  sha1collisiondetection |  1 +
>  4 files changed, 21 insertions(+)
>  create mode 100644 .gitmodules
>  create mode 16 sha1collisiondetection
>
> diff --git a/.gitmodules b/.gitmodules
> new file mode 100644
> index 00..cbeebdab7a
> --- /dev/null
> +++ b/.gitmodules
> @@ -0,0 +1,4 @@
> +[submodule "sha1collisiondetection"]
> + path = sha1collisiondetection
> + url = https://github.com/cr-marcstevens/sha1collisiondetection.git
> + branch = master

Do we need to say this "branch" bit?

Other than that looks good to me.

Thanks.


Re: "git intepret-trailers" vs. "sed script" to add the signature

2017-07-03 Thread Junio C Hamano
Kaartic Sivaraam  writes:

> So, it seems that excepting for 'commit' it has quite a nice spacing. I
> guess we could add something like the following to fix that,
>
> # Add new line after SOB in case of "git commit"
> NEW_LINE='\
> '
> if [ -z "$2" ]
> then
>   sed -i "1i$NEW_LINE" "$1"
> fi

Isn't "sed -i" GNUism that is not portable?

> I'll send a typical patch that uses "git interpret-headers" as a
> follow-up.

When you say a "typical" patch, what do you exactly mean?  Does
anybody else send typical patches (or atypical ones for that matter)
to the list?





Re: [RFC/PATCH v4 00/49] Add initial experimental external ODB support

2017-07-03 Thread Junio C Hamano
Christian Couder  writes:

> On Sat, Jul 1, 2017 at 10:33 PM, Junio C Hamano  wrote:
>> Christian Couder  writes:
>>
 I think it would be good to ensure the
 interface is robust and performant enough to actually replace the current
 object store interface (even if we don't actually do that just yet).
>>>
>>> I agree that it should be robust and performant, but I don't think it
>>> needs to be as performant in all cases as the current object store
>>> right now.
>>
>> That sounds like starting from a defeatest position.  Is there a
>> reason why you think using an external interface could never perform
>> well enough to be usable in everyday work?
>
> Perhaps in the future we will be able to make it as performant as, or
> perhaps even more performant, than the current object store, but in
> the current implementation the following issues mean that it will be
> less performant

That might be an answer to a different question; I was hoping to
hear that it should be performant enough for everyday work, but
never thought it would perform as well as local disk.

I haven't used network filesystem quite a while, but a repository on
NFS may still usable, and we know our own access pattern bettern
than NFS which cannot anticipate what paths the next operations by
its client happen, so it is not inconceivable that a well designed
external object database interface would let us outperform "repo on
NFS" scenario.


Greetings!!!.

2017-07-03 Thread Paul Benk
Greetings!

I have a proposal for you, this however is not mandatory nor will I in
any manner compel you to honor against your will. I am Dr.Paul Benk a
former executive director with Arab Tunisian Bank here in Tunis; I
retired 1 year 7 months ago after putting in 28 years of meticulous
service. During my days with Arab Tunisian Bank, I was the personal
account officer and one of the financial advisers to Zine Al-Abidine
Ben Ali the past Tunisian President in self exile at Saudi Arabia.
During his trying period, he instructed me to move all his investment
in my care which consists of US$115M and 767KG of gold out of the Gulf
States for safe keeping; and that I successfully did by moving US$50
Million to Madrid Spain, US$50 Million to Dubai United Arab Emirate,
US$15 Million to Burkina Faso and the 767KG of gold to Burkina Faso in
West Africa as an anonymous deposits, so that the funds will in no way
be traced to him. He has instructed me to find an investor who would
stand as the anonymous depositor of the fund and gold; and claim it
for further investment.

Consequent upon the above, my proposal is that I would like you as a
foreigner to stand in as the anonymous depositor of this fund and gold
that I have successfully moved outside the country and provide an
account overseas where this said fund will be transferred into. It is
a careful network and my voluntary retirement from the Arab Tunisian
Bank is to ensure a hitch-free operation as all modalities for you to
stand as beneficiary and owner of the deposits has been perfected by
me. Mr. Zine al-Abidine Ben Ali will be offering you 20% of the total
investment if you can be the investor and claim this deposits in Spain
and Burkina Faso as the anonymous depositor.

Now my questions are:-

1. Can you handle this transaction?
2. Can I give you this trust?

Consider this and get back to me as soon as possible on my private
email Only here: dr.paulb...@gmail.com, so that I can give you more
details regarding this transaction. Finally, it is my humble request
that the information as contained herein be accorded the necessary
attention, urgency as well as the secrecy it deserves.

I expect your urgent response if you can handle this project.

Respectfully yours,

From:Dr.Paul Benk.
Email: dr.paulb...@gmail.com

--
--


[PATCH v3 1/1] cygwin: Allow pushing to UNC paths

2017-07-03 Thread tboegi
From: Torsten Bögershausen 

 cygwin can use an UNC path like //server/share/repo
 $ cd //server/share/dir
 $ mkdir test
 $ cd test
 $ git init --bare

 However, when we try to push from a local Git repository to this repo,
 there is a problem: Git converts the leading "//" into a single "/".

 As cygwin handles an UNC path so well, Git can support them better:
 - Introduce cygwin_offset_1st_component() which keeps the leading "//",
   similar to what Git for Windows does.
 - Move CYGWIN out of the POSIX in the tests for path normalization in t0060

Signed-off-by: Torsten Bögershausen 
---

I think I skip all the changing in setup.c and cygwin_access() for the
moment:
- It is not clear, what is a regression and what is an improvement
- It may be a problem that could be solved in cygwin itself
- I was able to push a an UNC path on a Windows server
  when the domain controller was reachable.


compat/cygwin.c   | 19 +++
 compat/cygwin.h   |  2 ++
 config.mak.uname  |  1 +
 git-compat-util.h |  3 +++
 t/t0060-path-utils.sh |  2 ++
 5 files changed, 27 insertions(+)
 create mode 100644 compat/cygwin.c
 create mode 100644 compat/cygwin.h

diff --git a/compat/cygwin.c b/compat/cygwin.c
new file mode 100644
index 000..b9862d6
--- /dev/null
+++ b/compat/cygwin.c
@@ -0,0 +1,19 @@
+#include "../git-compat-util.h"
+#include "../cache.h"
+
+int cygwin_offset_1st_component(const char *path)
+{
+   const char *pos = path;
+   /* unc paths */
+   if (is_dir_sep(pos[0]) && is_dir_sep(pos[1])) {
+   /* skip server name */
+   pos = strchr(pos + 2, '/');
+   if (!pos)
+   return 0; /* Error: malformed unc path */
+
+   do {
+   pos++;
+   } while (*pos && pos[0] != '/');
+   }
+   return pos + is_dir_sep(*pos) - path;
+}
diff --git a/compat/cygwin.h b/compat/cygwin.h
new file mode 100644
index 000..8e52de4
--- /dev/null
+++ b/compat/cygwin.h
@@ -0,0 +1,2 @@
+int cygwin_offset_1st_component(const char *path);
+#define offset_1st_component cygwin_offset_1st_component
diff --git a/config.mak.uname b/config.mak.uname
index adfb90b..551e465 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -184,6 +184,7 @@ ifeq ($(uname_O),Cygwin)
UNRELIABLE_FSTAT = UnfortunatelyYes
SPARSE_FLAGS = -isystem /usr/include/w32api -Wno-one-bit-signed-bitfield
OBJECT_CREATION_USES_RENAMES = UnfortunatelyNeedsTo
+   COMPAT_OBJS += compat/cygwin.o
 endif
 ifeq ($(uname_S),FreeBSD)
NEEDS_LIBICONV = YesPlease
diff --git a/git-compat-util.h b/git-compat-util.h
index 047172d..db9c22d 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -189,6 +189,9 @@
 #include 
 #endif
 
+#if defined(__CYGWIN__)
+#include "compat/cygwin.h"
+#endif
 #if defined(__MINGW32__)
 /* pull in Windows compatibility stuff */
 #include "compat/mingw.h"
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 444b5a4..7ea2bb5 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -70,6 +70,8 @@ ancestor() {
 case $(uname -s) in
 *MINGW*)
;;
+*CYGWIN*)
+   ;;
 *)
test_set_prereq POSIX
;;
-- 
2.10.0



Re: Help needed for solving a few issues with building git

2017-07-03 Thread Torsten Bögershausen
On 2017-07-03 15:18, Kaartic Sivaraam wrote:
> Hello all,
> 
> Building without localization support
> 
> I tried to build git from source without localization support by adding
> the following line to the Makefile,
> 
> NO_GETTEXT=1
> 

May be

make NO_GETTEXT=yes


Help needed for solving a few issues with building git

2017-07-03 Thread Kaartic Sivaraam
Hello all,

Building without localization support

I tried to build git from source without localization support by adding
the following line to the Makefile,

NO_GETTEXT=1

It doesn't seem to be working for reasons I'm unable to find. I used
the following commands to build git.

make prefix=$CUSTOM_BUILD_LOCATION
make install prefix=$CUSTOM_BUILD_LOCATION

While trying to build (without the 'gettext' library that's required
for localization) I get the following error,

Manifying 8 pod documents
SUBDIR templates
MSGFMT po/build/locale/pt_PT/LC_MESSAGES/git.mo
/bin/sh: 1: msgfmt: not found
Makefile:2179: recipe for target
'po/build/locale/pt_PT/LC_MESSAGES/git.mo' failed
make: *** [po/build/locale/pt_PT/LC_MESSAGES/git.mo] Error 127

What could I be missing?


Adding HTTPS support

I tried to add HTTP/HTTPS support to the custom built version for which
AFAIK 'git' depends on 'curl'. I tried providing the location of the
curl source in the Makefile using the following line after reading the
instructions in the Makefile.

CURLDIR=/path/to/curl/source

Even after doing this the custom built git errors with the following
message when I try to use the 'git fetch' command,

fatal: Unable to find remote helper for 'https'

Any thing I'm missing?

Note: In case you were wondering, I was able to build 'git' after
installing the dependant package which I find useless as I don't
require any localization messages.

-- 
Kaartic


Re: Continous Integration (was: RE: Git v2.13.1 SHA1 very broken)

2017-07-03 Thread Johannes Schindelin
Hi Adam,

On Sun, 2 Jul 2017, Adam Dinwoodie wrote:

> I do the builds for the Cygwin distribution on my normal PC (so
> reasonably powerful but definitely not devoted to the purpose), and
> doing the build and running the default tests takes in the region of 8
> hours for the 64-bit build and 12 hours for the 32-bit build.

Wow. 8 hours. I take it that you are bitten by the same issue as Git for
Windows, where Git's test suite uses Unix shell scripting rather heavily,
and Unix shell simply requiring tons of expensive emulation to run
decently on Windows.

> At the moment, I'm trying to set up automated regular builds on my PC
> using BuildBot.  I think that, short of someone donating some fairly
> significant resources for Cygwin builds, that's going to be the closest
> I'll be able to find for spotting problems early.  It's a project in my
> currently limited spare time, though, and not something I've done
> before, so it's taking a little while to get going.

How automated is your process? (Including, most importantly, updating
the Cygwin build setup...)

I ask because I could possibly set up something using the existing
infrastructure for Git for Windows' testing, as long as

1) everything is scripted, and

2) you do not need interactive access to any box (I mainly use Docker
   containers to run the builds)

If you are interested, feel free to ping me via private mail.

Ciao,
Johannes


[PATCH] area: git-merge: add --signoff flag to git-merge

2017-07-03 Thread Łukasz Gryglicki
Added --signoff flag to `git-merge` command, added test coverage,
updated documentation.

Signed-off-by: lukaszgryglicki 
---
 Documentation/git-merge.txt  |  8 ++
 builtin/merge.c  |  4 +++
 t/t9904-git-merge-signoff.sh | 60 
 3 files changed, 72 insertions(+)
 create mode 100755 t/t9904-git-merge-signoff.sh

diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 04fdd8cf086db..6b308ab6d0b52 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -64,6 +64,14 @@ OPTIONS
 ---
 include::merge-options.txt[]
 
+--signoff::
+   Add Signed-off-by line by the committer at the end of the commit
+   log message.  The meaning of a signoff depends on the project,
+   but it typically certifies that committer has
+   the rights to submit this work under the same license and
+   agrees to a Developer Certificate of Origin
+   (see http://developercertificate.org/ for more information).
+
 -S[]::
 --gpg-sign[=]::
GPG-sign the resulting merge commit. The `keyid` argument is
diff --git a/builtin/merge.c b/builtin/merge.c
index 900bafdb45d0b..cb09f4138136b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -70,6 +70,7 @@ static int continue_current_merge;
 static int allow_unrelated_histories;
 static int show_progress = -1;
 static int default_to_upstream = 1;
+static int signoff;
 static const char *sign_commit;
 
 static struct strategy all_strategy[] = {
@@ -233,6 +234,7 @@ static struct option builtin_merge_options[] = {
{ OPTION_STRING, 'S', "gpg-sign", _commit, N_("key-id"),
  N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
OPT_BOOL(0, "overwrite-ignore", _ignore, N_("update ignored 
files (default)")),
+   OPT_BOOL(0, "signoff", , N_("add Signed-off-by:")),
OPT_END()
 };
 
@@ -775,6 +777,8 @@ static void prepare_to_commit(struct commit_list 
*remoteheads)
strbuf_stripspace(, 0 < option_edit);
if (!msg.len)
abort_commit(remoteheads, _("Empty commit message."));
+   if (signoff)
+   append_signoff(, ignore_non_trailer(msg.buf, msg.len), 0);
strbuf_release(_msg);
strbuf_addbuf(_msg, );
strbuf_release();
diff --git a/t/t9904-git-merge-signoff.sh b/t/t9904-git-merge-signoff.sh
new file mode 100755
index 0..eed15b9a85371
--- /dev/null
+++ b/t/t9904-git-merge-signoff.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+test_description='git merge --signoff
+
+This test runs git merge --signoff and make sure that it works.
+'
+
+. ./test-lib.sh
+
+# A simple files to commit
+cat >file1 /")
+EOF
+
+# Expected commit message after merge without --signoff (or with --no-signoff)
+cat >expected-unsigned < actual &&
+   test_cmp expected-signed actual
+'
+
+test_expect_success 'master --no-signoff does not add a sign-off line' '
+   git checkout master &&
+  git add file3 && git commit -m master-branch-2 &&
+  git checkout other-branch &&
+   git msob --no-signoff master &&
+   git cat-file commit HEAD | sed -e "1,/^\$/d" > actual &&
+   test_cmp expected-unsigned actual
+'
+
+test_done

--
https://github.com/git/git/pull/381


Re: speeding up git pull from a busy gerrit instance over a slow link?

2017-07-03 Thread Noel Grandin

On 2017/06/30 11:59 PM, Jonathan Tan wrote:


Out of curiosity, what is the timestamp difference between the first and
last GIT_TRACE_PACKET log message containing "refs/changes"?



Cut down log looks like:

08:37:17.734527 pkt-line.c:80   packet:fetch< baeb5486c43d39b063371f91cfaae8efc2c8700b 
refs/changes/00/1000/1

... 3 minutes ..
08:40:10.983005 pkt-line.c:80   packet:fetch< b0dd80238089dfcc0b3bf7bed99564adce649397 
refs/changes/99/6799/2
08:40:10.983054 pkt-line.c:80   packet:fetch< 5c5dd57b54e3107b3069dc8f82df74df63d13555 
refs/heads/distro/collabora/cp-4.0

..
08:40:11.134355 pkt-line.c:80   packet:fetch< 
f8c345808ceafe87be6207e5ae304a9fa6c4cd16 refs/heads/master
08:40:11.134404 pkt-line.c:80   packet:fetch< 3cacadc5c9e6a0780a4c75cd3614eddc8db8e933 
refs/remotes/origin/HEAD

...
08:40:11.173013 pkt-line.c:80   packet:fetch< 6c1b76c38f0fc469a2cbf41ffacde4d76df11ead 
refs/remotes/origin/origin/feature/submodules

08:40:11.173025 pkt-line.c:80   packet:fetch< 
a7d2fe68fd1db70f16a827f828dc541954f9d0f2 refs/tags/COOL_1.0
...
08:40:11.814181 pkt-line.c:80   packet:fetch< 9125509a7c6e65336330b8ac42a293aa77b18ee3 
refs/tags/windows_build_successful_2011_11_08^{}

...
08:40:12.724809 pkt-line.c:80   packet: sideband< 


Disclaimer: http://www.peralex.com/disclaimer.html