<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/remote.h, branch v2.32.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.32.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.32.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-02-18T01:21:40Z</updated>
<entry>
<title>Merge branch 'jt/clone-unborn-head'</title>
<updated>2021-02-18T01:21:40Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-02-18T01:21:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=69571dfe219f48614e0e0ae7e28efae0be297764'/>
<id>urn:sha1:69571dfe219f48614e0e0ae7e28efae0be297764</id>
<content type='text'>
"git clone" tries to locally check out the branch pointed at by
HEAD of the remote repository after it is done, but the protocol
did not convey the information necessary to do so when copying an
empty repository.  The protocol v2 learned how to do so.

* jt/clone-unborn-head:
  clone: respect remote unborn HEAD
  connect, transport: encapsulate arg in struct
  ls-refs: report unborn targets of symrefs
</content>
</entry>
<entry>
<title>connect, transport: encapsulate arg in struct</title>
<updated>2021-02-05T21:49:54Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2021-02-05T20:48:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=39835409d10de2402c4b3e10dba20286989627d4'/>
<id>urn:sha1:39835409d10de2402c4b3e10dba20286989627d4</id>
<content type='text'>
In a future patch we plan to return the name of an unborn current branch
from deep in the callchain to a caller via a new pointer parameter that
points at a variable in the caller when the caller calls
get_remote_refs() and transport_get_remote_refs().

In preparation for that, encapsulate the existing ref_prefixes
parameter into a struct. The aforementioned unborn current branch will
go into this new struct in the future patch.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fetch: extract writing to FETCH_HEAD</title>
<updated>2021-01-12T20:06:14Z</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2021-01-12T12:27:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=58a646a3688ea3c15adaf481e440e9ca2d3bce06'/>
<id>urn:sha1:58a646a3688ea3c15adaf481e440e9ca2d3bce06</id>
<content type='text'>
When performing a fetch with the default `--write-fetch-head` option, we
write all updated references to FETCH_HEAD while the updates are
performed. Given that updates are not performed atomically, it means
that we we write to FETCH_HEAD even if some or all of the reference
updates fail.

Given that we simply update FETCH_HEAD ad-hoc with each reference, the
logic is completely contained in `store_update_refs` and thus quite hard
to extend. This can already be seen by the way we skip writing to the
FETCH_HEAD: instead of having a conditional which simply skips writing,
we instead open "/dev/null" and needlessly write all updates there.

We are about to extend git-fetch(1) to accept an `--atomic` flag which
will make the fetch an all-or-nothing operation with regards to the
reference updates. This will also require us to make the updates to
FETCH_HEAD an all-or-nothing operation, but as explained doing so is not
easy with the current layout. This commit thus refactors the wa we write
to FETCH_HEAD and pulls out the logic to open, append to, commit and
close the file. While this may seem rather over-the top at first,
pulling out this logic will make it a lot easier to update the code in a
subsequent commit. It also allows us to easily skip writing completely
in case `--no-write-fetch-head` was passed.

Signed-off-by: Patrick Steinhardt &lt;ps@pks.im&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'sk/force-if-includes'</title>
<updated>2020-10-27T22:09:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-10-27T22:09:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=de0a7effc86aadf6177fdcea52b5ae24c7a85911'/>
<id>urn:sha1:de0a7effc86aadf6177fdcea52b5ae24c7a85911</id>
<content type='text'>
"git push --force-with-lease[=&lt;ref&gt;]" can easily be misused to lose
commits unless the user takes good care of their own "git fetch".
A new option "--force-if-includes" attempts to ensure that what is
being force-pushed was created after examining the commit at the
tip of the remote ref that is about to be force-replaced.

* sk/force-if-includes:
  t, doc: update tests, reference for "--force-if-includes"
  push: parse and set flag for "--force-if-includes"
  push: add reflog check for "--force-if-includes"
</content>
</entry>
<entry>
<title>Merge branch 'jk/refspecs-negative'</title>
<updated>2020-10-05T21:01:54Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-10-05T21:01:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8e3ec76a20d6abf5dd8ceb3f5f2c157000e4c13e'/>
<id>urn:sha1:8e3ec76a20d6abf5dd8ceb3f5f2c157000e4c13e</id>
<content type='text'>
"git fetch" and "git push" support negative refspecs.

* jk/refspecs-negative:
  refspec: add support for negative refspecs
</content>
</entry>
<entry>
<title>push: add reflog check for "--force-if-includes"</title>
<updated>2020-10-03T16:59:18Z</updated>
<author>
<name>Srinidhi Kaushik</name>
<email>shrinidhi.kaushik@gmail.com</email>
</author>
<published>2020-10-03T12:10:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=99a1f9ae10816c2527d7197a5dde714f980b712b'/>
<id>urn:sha1:99a1f9ae10816c2527d7197a5dde714f980b712b</id>
<content type='text'>
Add a check to verify if the remote-tracking ref of the local branch
is reachable from one of its "reflog" entries.

The check iterates through the local ref's reflog to see if there
is an entry for the remote-tracking ref and collecting any commits
that are seen, into a list; the iteration stops if an entry in the
reflog matches the remote ref or if the entry timestamp is older
the latest entry of the remote ref's "reflog". If there wasn't an
entry found for the remote ref, "in_merge_bases_many()" is called
to check if it is reachable from the list of collected commits.

When a local branch that is based on a remote ref, has been rewound
and is to be force pushed on the remote, "--force-if-includes" runs
a check that ensures any updates to the remote-tracking ref that may
have happened (by push from another repository) in-between the time
of the last update to the local branch (via "git-pull", for instance)
and right before the time of push, have been integrated locally
before allowing a forced update.

If the new option is passed without specifying "--force-with-lease",
or specified along with "--force-with-lease=&lt;refname&gt;:&lt;expect&gt;" it
is a "no-op".

Signed-off-by: Srinidhi Kaushik &lt;shrinidhi.kaushik@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refspec: add support for negative refspecs</title>
<updated>2020-09-30T21:52:00Z</updated>
<author>
<name>Jacob Keller</name>
<email>jacob.keller@gmail.com</email>
</author>
<published>2020-09-30T21:25:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c0192df6306d4d9ad77f6015a053925b13155834'/>
<id>urn:sha1:c0192df6306d4d9ad77f6015a053925b13155834</id>
<content type='text'>
Both fetch and push support pattern refspecs which allow fetching or
pushing references that match a specific pattern. Because these patterns
are globs, they have somewhat limited ability to express more complex
situations.

For example, suppose you wish to fetch all branches from a remote except
for a specific one. To allow this, you must setup a set of refspecs
which match only the branches you want. Because refspecs are either
explicit name matches, or simple globs, many patterns cannot be
expressed.

Add support for a new type of refspec, referred to as "negative"
refspecs. These are prefixed with a '^' and mean "exclude any ref
matching this refspec". They can only have one "side" which always
refers to the source. During a fetch, this refers to the name of the ref
on the remote. During a push, this refers to the name of the ref on the
local side.

With negative refspecs, users can express more complex patterns. For
example:

 git fetch origin refs/heads/*:refs/remotes/origin/* ^refs/heads/dontwant

will fetch all branches on origin into remotes/origin, but will exclude
fetching the branch named dontwant.

Refspecs today are commutative, meaning that order doesn't expressly
matter. Rather than forcing an implied order, negative refspecs will
always be applied last. That is, in order to match, a ref must match at
least one positive refspec, and match none of the negative refspecs.
This is similar to how negative pathspecs work.

Signed-off-by: Jacob Keller &lt;jacob.keller@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jx/proc-receive-hook'</title>
<updated>2020-09-25T22:25:39Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-09-25T22:25:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6c430a647cb990fc856d328733fa59e1fafadb97'/>
<id>urn:sha1:6c430a647cb990fc856d328733fa59e1fafadb97</id>
<content type='text'>
"git receive-pack" that accepts requests by "git push" learned to
outsource most of the ref updates to the new "proc-receive" hook.

* jx/proc-receive-hook:
  doc: add documentation for the proc-receive hook
  transport: parse report options for tracking refs
  t5411: test updates of remote-tracking branches
  receive-pack: new config receive.procReceiveRefs
  doc: add document for capability report-status-v2
  New capability "report-status-v2" for git-push
  receive-pack: feed report options to post-receive
  receive-pack: add new proc-receive hook
  t5411: add basic test cases for proc-receive hook
  transport: not report a non-head push as a branch
</content>
</entry>
<entry>
<title>New capability "report-status-v2" for git-push</title>
<updated>2020-08-27T19:47:47Z</updated>
<author>
<name>Jiang Xin</name>
<email>zhiyou.jx@alibaba-inc.com</email>
</author>
<published>2020-08-27T15:45:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=63518a574a3a4b8c6f152b29cb1b6d1f66f6e6c7'/>
<id>urn:sha1:63518a574a3a4b8c6f152b29cb1b6d1f66f6e6c7</id>
<content type='text'>
The new introduced "proc-receive" hook may handle a command for a
pseudo-reference with a zero-old as its old-oid, while the hook may
create or update a reference with different name, different new-oid,
and different old-oid (the reference may exist already with a non-zero
old-oid).  Current "report-status" protocol cannot report the status for
such reference rewrite.

Add new capability "report-status-v2" and new report protocol which is
not backward compatible for report of git-push.

If a user pushes to a pseudo-reference "refs/for/master/topic", and
"receive-pack" creates two new references "refs/changes/23/123/1" and
"refs/changes/24/124/1", for client without the knowledge of
"report-status-v2", "receive-pack" will only send "ok/ng" directives in
the report, such as:

    ok ref/for/master/topic

But for client which has the knowledge of "report-status-v2",
"receive-pack" will use "option" directives to report more attributes
for the reference given by the above "ok/ng" directive.

    ok refs/for/master/topic
    option refname refs/changes/23/123/1
    option new-oid &lt;new-oid&gt;
    ok refs/for/master/topic
    option refname refs/changes/24/124/1
    option new-oid &lt;new-oid&gt;

The client will report two new created references to the end user.

Suggested-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Suggested-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Jiang Xin &lt;zhiyou.jx@alibaba-inc.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>receive-pack: add new proc-receive hook</title>
<updated>2020-08-27T19:47:47Z</updated>
<author>
<name>Jiang Xin</name>
<email>zhiyou.jx@alibaba-inc.com</email>
</author>
<published>2020-08-27T15:45:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=15d3af5e22eceb9cd6cd341703d612a62194451e'/>
<id>urn:sha1:15d3af5e22eceb9cd6cd341703d612a62194451e</id>
<content type='text'>
Git calls an internal `execute_commands` function to handle commands
sent from client to `git-receive-pack`.  Regardless of what references
the user pushes, git creates or updates the corresponding references if
the user has write-permission.  A contributor who has no
write-permission, cannot push to the repository directly.  So, the
contributor has to write commits to an alternate location, and sends
pull request by emails or by other ways.  We call this workflow as a
distributed workflow.

It would be more convenient to work in a centralized workflow like what
Gerrit provided for some cases.  For example, a read-only user who
cannot push to a branch directly can run the following `git push`
command to push commits to a pseudo reference (has a prefix "refs/for/",
not "refs/heads/") to create a code review.

    git push origin \
        HEAD:refs/for/&lt;branch-name&gt;/&lt;session&gt;

The `&lt;branch-name&gt;` in the above example can be as simple as "master",
or a more complicated branch name like "foo/bar".  The `&lt;session&gt;` in
the above example command can be the local branch name of the client
side, such as "my/topic".

We cannot implement a centralized workflow elegantly by using
"pre-receive" + "post-receive", because Git will call the internal
function "execute_commands" to create references (even the special
pseudo reference) between these two hooks.  Even though we can delete
the temporarily created pseudo reference via the "post-receive" hook,
having a temporary reference is not safe for concurrent pushes.

So, add a filter and a new handler to support this kind of workflow.
The filter will check the prefix of the reference name, and if the
command has a special reference name, the filter will turn a specific
field (`run_proc_receive`) on for the command.  Commands with this filed
turned on will be executed by a new handler (a hook named
"proc-receive") instead of the internal `execute_commands` function.
We can use this "proc-receive" command to create pull requests or send
emails for code review.

Suggested by Junio, this "proc-receive" hook reads the commands,
push-options (optional), and send result using a protocol in pkt-line
format.  In the following example, the letter "S" stands for
"receive-pack" and letter "H" stands for the hook.

    # Version and features negotiation.
    S: PKT-LINE(version=1\0push-options atomic...)
    S: flush-pkt
    H: PKT-LINE(version=1\0push-options...)
    H: flush-pkt

    # Send commands from server to the hook.
    S: PKT-LINE(&lt;old-oid&gt; &lt;new-oid&gt; &lt;ref&gt;)
    S: ... ...
    S: flush-pkt
    # Send push-options only if the 'push-options' feature is enabled.
    S: PKT-LINE(push-option)
    S: ... ...
    S: flush-pkt

    # Receive result from the hook.
    # OK, run this command successfully.
    H: PKT-LINE(ok &lt;ref&gt;)
    # NO, I reject it.
    H: PKT-LINE(ng &lt;ref&gt; &lt;reason&gt;)
    # Fall through, let 'receive-pack' to execute it.
    H: PKT-LINE(ok &lt;ref&gt;)
    H: PKT-LINE(option fall-through)
    # OK, but has an alternate reference.  The alternate reference name
    # and other status can be given in options
    H: PKT-LINE(ok &lt;ref&gt;)
    H: PKT-LINE(option refname &lt;refname&gt;)
    H: PKT-LINE(option old-oid &lt;old-oid&gt;)
    H: PKT-LINE(option new-oid &lt;new-oid&gt;)
    H: PKT-LINE(option forced-update)
    H: ... ...
    H: flush-pkt

After receiving a command, the hook will execute the command, and may
create/update different reference.  For example, a command for a pseudo
reference "refs/for/master/topic" may create/update different reference
such as "refs/pull/123/head".  The alternate reference name and other
status are given in option lines.

The list of commands returned from "proc-receive" will replace the
relevant commands that are sent from user to "receive-pack", and
"receive-pack" will continue to run the "execute_commands" function and
other routines.  Finally, the result of the execution of these commands
will be reported to end user.

The reporting function from "receive-pack" to "send-pack" will be
extended in latter commit just like what the "proc-receive" hook reports
to "receive-pack".

Signed-off-by: Jiang Xin &lt;zhiyou.jx@alibaba-inc.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
